Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

DayZ Autowalk



  • Please log in to reply
10 replies to this topic
arough
  • Members
  • 8 posts
  • Last active: Aug 14 2013 06:14 PM
  • Joined: 11 Aug 2013

Hey guys,

 

I've read some threads regarding autowalk but none suits my needs =)

 

I've experminented a bit but it won't work like it should. I've also searched the documentation.

 

I want the script to hold down "w" if i press F1. But it should pause it on F1 too. And activate it again if i press F1 once more.

 

Any suggestions?



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

There are a couple of ways it could be done depending on your game and if you have or need to have other hotkeys active at the same time in your script. The most straightforward way would probably be...

f!::
Keywait, f1 ;<-- wait for the f1 key to be released before continuing
moveflag := !moveflag ;<-- toggle for move/notmove
if (moveflag) ;<-- if the move toggle is on
{   loop
    {   Send, {w down} ;<-- keep sending w's until the toggle changes
        Sleep, 100
    }
}
Else ;<-- and if the move toggle is off
{   Send, {w, up} ;<-- release the w key
    Sleep, 100
}
Return ;<-- and end the routine


It's important to recognize that the w key is by nature for many games and apps an autorepeat key and may not require the loop for the games that autorepeat it automatically. It's also important to recognize that sometimes a running loop like this can interfere with the responsiveness of other hotkeys that you may want to fire while trying to move and may require you to turn off the move before using those other hotkeys.


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


arough
  • Members
  • 8 posts
  • Last active: Aug 14 2013 06:14 PM
  • Joined: 11 Aug 2013

I tested in notepad and if i press f1 again it wont stop.

 

I just want to use it for long walks grin.png If it will get serious I will push f1 too diable it again =)

 

It would also be acceptable if i use 2 keys. f1 to start and f2 to stop if it is more easy =)



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

K, then try this without the loop command...

f!::
    Keywait, f1 ;<-- wait for the f1 key to be released before continuing
    moveflag := !moveflag ;<-- toggle for move/notmove
    If (!moveflag)
        Return
    While (moveflag)
    {   Send, {w down} ;<-- keep sending w's until the toggle changes
        Sleep, 100
    }
    ;<-- once the toggle is off
    Send, {w, up} ;<-- release the w key
    Sleep, 100
    Return ;<-- and end the routine

This is another way it might be done...


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


arough
  • Members
  • 8 posts
  • Last active: Aug 14 2013 06:14 PM
  • Joined: 11 Aug 2013

This doesnt work either xD

And the second character must be a 1 right?

Does it work for you?

 

I appriciate the help though.



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

Yes that hotkey should be f1 not f!. I guess i may have hit the shift key when writing that one. Now you have me really puzzled though. I used a similiar method in the game Age of Conan but there i had to work a bit differently. Because I wanted to use the movement keys for climbing as well as breaking off combat I had to construct the routine a bit differently. This routine doesn't use a loop at all because Age of Conan sees the w and s keys as repeatable when held down. Not knowing your particular game's handlers makes it a bit less obvious what can be done.

;--------------------------------------------------------------------
; Auto Move/climb conttrols for Age of Conan Move to AoCSpecialized
; module when debugged
;--------------------------------------------------------------------
$NumpadSub:: ;<-- stop fighting and back up or stop
	Suspend Permit
	ltr = s
	goto forwardback

$XButton1:: ;<-- run away from fight
	Suspend Permit
$NumpadAdd:: ;<-- Stop fighting andmove forward
	Suspend Permit
	ltr = w
	goto forwardback
	
forwardback:
	SendingFlag := 0 ;This turns off my infight flag
	AutoTarget := 0 ;This turns off my autotargeting of mobs
	AutoLoot := 0 ;And this turns off my autolooting
	AutoRest := 0 ;Turns off auto resting when health or mana is low
	hk := A_ThisHotkey
	Moveflag := !MoveFlag
	If (!MoveFlag)
		goto CancelMove

	; a small tooltip status indicator
	Tooltip, AutoMove (%ltr%) use %hk% or NumpadDel to stop,100,40,2
	;WinActivate, %vWinID% ;This makes sure my game window is active
	Send, {%ltr% Down}
	return
	
$NumPadDel:: ;<-- cancel run/climb
	Suspend Permit
CancelMove:
	tooltip,,,,2
	MoveFlag = 0
	;WinActivate, %vWinID%
	Send, {w up}
	Send, {s up}
	Return
	

This as you can see, also uses the numpad keys and the mouse button 4 (XButton1) to control the movements. This routine works flawlessly in AOC. Perhaps you can figure a way to modify it to work in your own game. This is a straight cut out of my own game controller code for the MMORPG game "Age of Conan". The %vWinID% thing is the ahk_id of the game window which i set up when the game first loads so i can control where keys and clicks are sent and when. I commented those lines out because I didn't provide the code to set the vWinID up.


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


arough
  • Members
  • 8 posts
  • Last active: Aug 14 2013 06:14 PM
  • Joined: 11 Aug 2013

I think it doesn't have to do with the game.

It won't work in notepad either.

It won't stop if I press F1 again.

 

Does the first two scripts run fine in your notepad?



apophis
  • Members
  • 23 posts
  • Last active: Jul 10 2015 02:07 PM
  • Joined: 19 Sep 2010

script works if you add this

 

#MaxThreadsPerHotkey 2

 

only tested first 1

#MaxThreadsPerHotkey 2
f1::
    Keywait, f1 ;<-- wait for the f1 key to be released before continuing
    moveflag := !moveflag ;<-- toggle for move/notmove
    If (!moveflag)
        Return
    While (moveflag)
    {   Send, {w down} ;<-- keep sending w's until the toggle changes
        Sleep, 100
    }
    ;<-- once the toggle is off
    Send, {w, up} ;<-- release the w key
    Sleep, 100
    Return ;<-- and end the routine

i also think if the movement is not constant

you should remove or lower the sleep command



arough
  • Members
  • 8 posts
  • Last active: Aug 14 2013 06:14 PM
  • Joined: 11 Aug 2013
✓  Best Answer

Your script didn't work either, but there was a thread about the same topic (shame on me) and some dude posted this:

Toggle := FALSE

;

$NumPad4::

  if Toggle

  {

    Toggle := FALSE

    Send. {w down]

  }

  else

  {

    Toggle := TRUE

    Send {w up}

  }

return

Works like a charm =)

Thank you guys.



surf
  • Members
  • 4 posts
  • Last active: May 28 2014 11:51 PM
  • Joined: 19 May 2014

Yeah none of this works any more. I'll have a tinker tonight and see what I can see...



surf
  • Members
  • 4 posts
  • Last active: May 28 2014 11:51 PM
  • Joined: 19 May 2014

OK I fixed the typos and got the last script working... Then I decided to rewrite the whole thing to provide generic key-holds in DayZ.

 

Numeric keypad roles....

9 Autolean right (similar to double-tapping e)

8 Autorun toggle

7 Autolean left (similar to double-tapping q)

6 Auto-strafe right

5 Autowalk toggle

4 Auto-strafe left

 

DayZ.ahk...

; DayZ AutoHotKey script v1.0

; Auto-execute section.
gWalking := ""
gLeaning := ""
gStrafing := ""

; Hotkey bindings.
$NumPad9::KeyToggle(gLeaning, "e")
$NumPad8::KeyToggle(gWalking, "w", TRUE)
$NumPad7::KeyToggle(gLeaning, "q")
$NumPad6::KeyToggle(gStrafing, "d")
$NumPad5::KeyToggle(gWalking, "w")
$NumPad4::KeyToggle(gStrafing, "a")

; Functions.
KeyToggle(ByRef toggleVar, keyVal, doubleTap=FALSE)
{
    if(toggleVar <> "")
    {
        Send {%toggleVar% up}
    }
    
    if(toggleVar = keyVal)
    {
        toggleVar := ""
    }
    else
    {
        if(doubleTap)
        {
            Send {%keyVal%}
        }
        
        Send {%keyVal% down}
        toggleVar := keyVal
    }
}


; EOF