Looking for a bit help to add different variables to my script

Ask gaming related questions
Durete
Posts: 7
Joined: 29 Oct 2018, 18:13

Looking for a bit help to add different variables to my script

29 Oct 2018, 18:38

Hello everyone,

I am looking to add another layer to my warframe script, and possibly to combine 2 scripts in one.

1) Extra layer to the script:

Currently I have a script to do the following:

q= special attack (Press once =one attack, hold=continuous)
e= continuous melee attack
r= rapid fire auto attack

Now what I want to do, is that if I toggle "Home"
That it changes the keybinds from my numpad to add different variables.
(In this game they are for different weapons, as each weapon has a different attack speed)

And that my Q action reads the weapon speed that is selected by Home>Numpadkey and puts that as the delay between attacks.
So that if a weapon has a speed of 1 shot per second, that it would add the delay needed not to repeat the command that second.



This is the code that I have now:
;Pause is on and off toggle for this part of the macro
Pause::

Suspend

Pause,,1

return

;Q is special attack
q::
if(not slideAttackActive) {
slideAttackActive := true
Send, {lshift down}
sleep, 30
Send, {WheelUp}
sleep, 520 ; This is the value that should be dependend on the weapon that is selected by Numpad1-9
Send, {lshift up}
slideAttackActive := false
}
Return


;R is auto fire for rifles
r::

Loop
{
if not GetKeyState("r", "P")
break

Send {LButton}
}
return
;E is automatic quick melee
e::

Loop
{
if not GetKeyState("e", "P")
break

Send {WheelUp}
}
return


Does anyone have an idea how to do this?



I was trying something like this:

;Pause is on and off toggle for this part of the macro
Pause::

Suspend

Pause,,1

return

; Set base attack delay
BaseAttackDelay := 100
AttackDelay := BaseAttackDelay*WeaponSpeed

;Q is special attack
q::
if(not slideAttackActive) {
slideAttackActive := true
Send, {lshift down}
sleep, 30
Send, {WheelUp}
sleep, AttackDelay
Send, {lshift up}
slideAttackActive := false
}
Return


;R is auto fire for rifles
r::

Loop
{
if not GetKeyState("r", "P")
break

Send {LButton}
}
return
;E is automatic quick melee
e::

Loop
{
if not GetKeyState("e", "P")
break

Send {WheelUp}
}
return

;Home is on and off toggle for this part of the macro
Home::

Suspend

Pause,,1

return

Numpad1:: {
Weaponspeed := 450
}
return

Numpad2:: {
Weaponspeed := 375
}
return

================================================================


2) Is it possible to combine these scripts:


I got the above script as one script that I'm running,

Next to that, I have another script running that when toggling "Delete" that it changes the Numpad in different text messages that I send.
;Delete is aan en uit voor chat macros
Delete::

Suspend

Pause,,1

return
;numpad7 is LFG
Numpad7::
Send, Looking For Group to Disney Land
Return


;numpad8 is LFG2
Numpad8::
Send, Looking for Group to Lala Land
return

;numpad9 is WTS
Numpad9::
Send, Hey! I want to Sell my Dirty Socks
return
Is there a way to combine these two scripts?

RIght now I tried combining them, but due to the first script using E R Q as keybinds, those letters will get removed from the messages in the second code.


The combining of the scripts is only an extra of convenience. However, the first question in this post has my highest priority! So any help with that would be much appreciated.

P.s. Using quote tags because the code tags dont seem to work.
Onimuru
Posts: 35
Joined: 08 Sep 2018, 18:35
GitHub: Onimuru

Re: Looking for a bit help to add different variables to my script

29 Oct 2018, 21:43

This is how I would do it:

Code: Select all

#SingleInstance Force
#MaxHotkeysPerInterval 20000
#HotkeyInterval 20
Process, Priority, , High
SetBatchLines, -1
SetKeyDelay, -1, -1

If !A_IsAdmin
{
	Run *RunAs "%A_ScriptFullPath%"
	ExitApp
}

;Create Gui:
Gui, Generic: New, +AlwaysOnTop -Caption +LastFound -SysMenu +ToolWindow +E0x20
Gui, Generic: Color, FFFFFF
Gui, Generic: Font, Bold s8
Gui, Generic: Add, Text, cBlack BackgroundTrans vGeneric
WinSet, TransColor, 150

Exit

;----------; Labels/Functions ;----------;

;----------; Hotkeys ;----------;

#If WinActive(A_ScriptName)	;If script open in editor.
~^s::
	Sleep 200
	Reload
	Return

Esc::ExitApp
#If

Exit

$Numpad1::
	KeyWait, Numpad1, T1	;Press and hold for 1 second.
	If ErrorLevel
	{
		If !(c_V = 1)
		{
			Weaponspeed := 450
			GuiControl, Generic:, Generic, Weapon 1
			GuiControl, Generic: Move, Generic, w150 x52
			Gui, Generic: Show, w150 Center NA, Generic
			KeyWait, Numpad1
			Gui, Generic: Hide
			c_V := 1
		}
	}
	Else
		Send {Numpad1}
	Return

$Numpad2::
	KeyWait, Numpad2, T1
	If ErrorLevel
	{
		If !(c_V = 2)
		{
			Weaponspeed := 375
			GuiControl, Generic:, Generic, Weapon 2
			GuiControl, Generic: Move, Generic, w150 x52
			Gui, Generic: Show, w150 Center NA, Generic
			KeyWait, Numpad2
			Gui, Generic: Hide
			c_V := 2
		}
	}
	Else
		Send {Numpad2}
	Return

*$q::		;Q is special attack
	If !slideAttackActive
	{
		slideAttackActive := True
		Send, {Shift Down}
		Sleep, 30
		Send, {WheelUp}
		Sleep, Weaponspeed
		Send, {Shift Up}
		slideAttackActive := False
	}
	Return

~*$r::		;R is auto fire for rifles
	While GetKeyState("r", "P")
		Send {LButton}
	Return

~*$e::		;E is automatic quick melee
	While GetKeyState("e", "P")
		Send {WheelUp}
	Return

;----------; Hotstrings ;----------;

:*:lfg1::Looking For Group to Disney Land
:*:lfg2::Looking for Group to Lala Land
:*:wts::Hey! I want to Sell my Dirty Socks
Hmmm RIP formatting...
Last edited by Onimuru on 30 Oct 2018, 09:12, edited 1 time in total.
User avatar
Coderooney
Posts: 42
Joined: 23 Mar 2017, 22:41

Re: Looking for a bit help to add different variables to my script

29 Oct 2018, 22:27

Regarding your second question about combining the two scripts, does adding $ before the hotkeys work? e.g. $q:: and $r::

Edit: Whoops, hadn't refreshed the page and didn't see Onimuru's post.
Durete
Posts: 7
Joined: 29 Oct 2018, 18:13

Re: Looking for a bit help to add different variables to my script

30 Oct 2018, 02:50

Wow, thanks a lot!

This is more help than I could've dreamed off :)

Also a nice opportunity to learn this better:


I can't really figure out what this part of the script does:
If !A_IsAdmin

{

Run *RunAs "%A_ScriptFullPath%"

ExitApp

}
As in, what does this code run/load?

Second part of the code I don't fully understand is:
#If WinActive(A_ScriptName) ;If script open in editor.

~^s::

Sleep 200

Reload

Return



Esc::ExitApp

#If



Exit
This is if the script is open in the editor and you save it by pressing ctrl+s it automatically reloads after 200 miliseconds and if you press Escape it closes AHK?
or am I wrong there?

Hope you don't mind me asking. I like to understand every part of it :) Most of the code I can read and understand although writing it is a total different story :) (You saw how basic my script was.)
Onimuru
Posts: 35
Joined: 08 Sep 2018, 18:35
GitHub: Onimuru

Re: Looking for a bit help to add different variables to my script

30 Oct 2018, 09:06

Durete wrote:
30 Oct 2018, 02:50
Wow, thanks a lot!

This is more help than I could've dreamed off :)

Also a nice opportunity to learn this better:


I can't really figure out what this part of the script does:
If !A_IsAdmin

{

Run *RunAs "%A_ScriptFullPath%"

ExitApp

}
As in, what does this code run/load?

Second part of the code I don't fully understand is:
#If WinActive(A_ScriptName) ;If script open in editor.

~^s::

Sleep 200

Reload

Return



Esc::ExitApp

#If



Exit
This is if the script is open in the editor and you save it by pressing ctrl+s it automatically reloads after 200 miliseconds and if you press Escape it closes AHK?
or am I wrong there?

Hope you don't mind me asking. I like to understand every part of it :) Most of the code I can read and understand although writing it is a total different story :) (You saw how basic my script was.)
Sure np, I just include that in all my scripts. No particular need for it..

Code: Select all

#If WinActive(A_ScriptName)
;If the editor is open and tabbed to this script; action.

If !A_IsAdmin
;If script is not loaded as admin; action (in this case, run script as admin(necessary for most games)). If !A_IsAdmin is the same as If NOT A_IsAdmin i.e. A_IsAdmin = False

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 11 guests