AutoHotkey Community

It is currently May 26th, 2012, 7:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: May 28th, 2008, 7:26 am 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
Can anyone help me with a script to simulate a dual-joystick control for a game that doesn't actually support it? For instance, the 80s arcade games Robotron and Smash TV had one stick for moving and one for shooting in 8 directions. Some of the home conversions only have a single shoot button and you shoot in the direction you are moving, or there's a lock button to lock your shooting direction so you can strafe.

I want to simulate a shooting joystick for games that only have a single shoot and a lock button. My idea was to use 8 hotkeys or eventually map the second joystick of a dual analog gamepad to move in the direction of the joystick and hold fire and lock, but release the movement so that I can still move with the main directional keys or joystick.


Here's a very simple script that only covers the cardinal directions:

Code:
; cursor keys move
; use WASD for directional shooting
; z is the default shoot key
; c is the default lock key

a::
Send {Left down}{z down}{c down}
Send {Left up}
return

a up::Send {z up}{c up}

w::
Send {Up down}{z down}{c down}
Send {UP up}
return

w up::Send {z up}{c up}

d::
Send {Right down}{z down}{c down}
Send {Right up}
return

d up::Send {z up}{c up}

s::
Send {Down down}{z down}{c down}
Send {Down up}
return

s up::Send {z up}{c up}


I'm using this with Smash TV for Genesis on the Fusion emulator. It usually works as far as firing in the right direction, but sometimes if I am holding A for instance, it will keep moving me Left even if I am holding down Right. And sometimes I can't move at all if I am shooting.

Is there a better way of doing this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2008, 6:24 pm 
Offline

Joined: April 10th, 2008, 10:08 pm
Posts: 111
So you hold down both the shoot button and the lock button while shooting, I guess? Well, I had an idea but you pretty much pasted it in your code...I dunno.
I have Super Smash TV (any difference from Smash TV?) on super nintendo emulator, and it has 8-directional shooting on four buttons. At this point, that's all I can recommend.
Oh yeah, and only download it if you own the actual game :wink: .

_________________
I slit the sheet, the sheet I slit,
and on the slitted sheet I sit. ;~}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2008, 7:20 pm 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
redhatboy wrote:
So you hold down both the shoot button and the lock button while shooting, I guess? Well, I had an idea but you pretty much pasted it in your code...I dunno.
I have Super Smash TV (any difference from Smash TV?) on super nintendo emulator, and it has 8-directional shooting on four buttons. At this point, that's all I can recommend.
Oh yeah, and only download it if you own the actual game :wink: .


Well, I know you can play other versions of Smash TV that have the proper dual joystick-like controls, but there are other games with this kind of "lock firing" and I'd like to use this on those games as well.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2008, 8:05 pm 
Offline

Joined: April 10th, 2008, 10:08 pm
Posts: 111
Hey, I just had an epiphany. If you were to use that script, and hit a shoot button (wsad) while running in a direction, that would interfere with the process of shooting in said direction.
Long story short, the problem is that you can only be moving one direction at any given time (counting diagonals as a single direction). With even the best method, you're going to have some problems running (you have to hit up and fire/lock to shoot up; if you're running down, you'll still have to hit up.)
You could try disabling the arrow keys (if that's what you run with) while changing shooting directions.

Code:
; cursor keys move
; use WASD for directional shooting
; z is the default shoot key
; c is the default lock key

a::
Hotkey, Left, On
Send {Left down}{z down}{c down}
Send {Left up}
Hotkey, Left, Off
return

a up::Send {z up}{c up}

w::
Hotkey, Up, On
Send {Up down}{z down}{c down}
Send {UP up}
Hotkey, Up, Off
return

w up::Send {z up}{c up}

d::
Hotkey, Right, On
Send {Right down}{z down}{c down}
Send {Right up}
Hotkey, Right, Off
return

d up::Send {z up}{c up}

s::
Hotkey, Down, On
Send {Down down}{z down}{c down}
Send {Down up}
Hotkey, Down, Off
return

s up::Send {z up}{c up}

Left::
right::
up::
down::


Can't really test the effectiveness of this script, but you might have to hit each of the shoot buttons to turn the arrow hotkeys off...? I don't know, but if this doesn't work, I don't know what to tell you. Good luck.

_________________
I slit the sheet, the sheet I slit,
and on the slitted sheet I sit. ;~}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2008, 11:22 pm 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
Well, moving and shooting in the same direction is no problem. Moving and shooting in different directions sometimes ends up with me shooting in a direction I don't want to be shooting in.

I notice that when I am shooting in a direction with the script, I end up moving in that direction a little bit also. When I use your script that turns off the arrow keys, I end up not being able to move in certain directions until I totally release the shooting buttons.

Does it make sense that the WASD hotkeys keep repeating the "up down left right" keys if I hold them down?

Should I be using SendInput or SendPlay?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2008, 6:00 am 
Well...sadly, I am very inexperienced. Instead of a:: you could try a down:: maybe? I don't know. My own scripts usually take many tries. Maybe some more experienced user can help you. Good luck. :?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2008, 6:23 am 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
How does the disabling the arrow keys work? I tried using that part but sometimes the arrow keys stay disabled.

Also, it seems like my WASD are repeating when I hold them down because I keep moving in that direction. How do I stop that?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2008, 9:50 pm 
Offline

Joined: April 10th, 2008, 10:08 pm
Posts: 111
Using left for an example:
Code:
; To assign/activate a hotkey (assign it to nothing, so it does nothing)
Left::

; to disable the hotkey so it regains normal function
Hotkey, Left, Off

; to reacivate hotkey assign
Hotkey, Left, On



I stole that from somebody else's script, actually, but I'm pretty sure that's how it works.

_________________
I slit the sheet, the sheet I slit,
and on the slitted sheet I sit. ;~}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2008, 5:00 am 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
Ok, so maybe I need to turn off all of the directional keys right when the shooting direction is triggering.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 4:43 am 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
This version tries to turn off all the directional keys before changing where I aim to fire, but I think the emulator app is still picking up the directional keys. I'm also using the number pad to do the firing, and I'm leaving the shoot button down when i trigger the directional shooting, and using the 5 key to turn off shooting.

Code:
;send Left, then hold shoot and lock

Delay := 100 ;milliseconds

NumPad4::
Hotkey, Left, On
Hotkey, Up, On
Hotkey, Right, On
Hotkey, Down, On
Send {x up}
Sleep %Delay%
Send {Left down}{x down}
Send {Left up}
Hotkey, Left, Off
Hotkey, Up, Off
Hotkey, Right, Off
Hotkey, Down, Off
return

NumPad8::
Hotkey, Left, On
Hotkey, Up, On
Hotkey, Right, On
Hotkey, Down, On
Send {x up}
Sleep %Delay%
Send {Up down}{x down}
Send {UP up}
Hotkey, Left, Off
Hotkey, Up, Off
Hotkey, Right, Off
Hotkey, Down, Off
return

NumPad6::
Hotkey, Left, On
Hotkey, Up, On
Hotkey, Right, On
Hotkey, Down, On
Send {x up}
Sleep %Delay%
Send {Right down}{x down}
Send {Right up}
Hotkey, Left, Off
Hotkey, Up, Off
Hotkey, Right, Off
Hotkey, Down, Off
return

NumPad2::
Hotkey, Left, On
Hotkey, Up, On
Hotkey, Right, On
Hotkey, Down, On
Send {x up}
Sleep %Delay%
Send {Down down}{x down}
Send {Down up}
Hotkey, Left, Off
Hotkey, Up, Off
Hotkey, Right, Off
Hotkey, Down, Off
return

NumPad5::Send {x up}

Left::
right::
Up::
Down::


what am I doing wrong?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Tilter_of_Windmills, tomL and 70 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group