Jump to content

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

StarCraft 2, Lost Vikings script needed please.


  • Please log in to reply
7 replies to this topic
ParadiseDecay
  • Members
  • 3 posts
  • Last active: Jul 31 2010 07:04 AM
  • Joined: 30 Jul 2010
Hi I recently purchased 'StarCraft 2'. There is a mini arcade game in the cantina called 'Lost Vikings' Its a top down verticle shoot-em-up. I have an Xbox 360 controller for my PC and I've been trying for days to map the games keyboard commands to the 360 pad.

There in game keys are:
Up Arrow Key - Move Ship Up
Down Arrow Key - Move Ship Down
Left Arrow Key - Move Ship Left
Right Arrow Key - Move Ship Right
Spacebar - Fire
Ctrl - Smart Bomb

If anyone can make a small script that allows me to use the pad instead of the keyboard, that would be great thanks.

Cheers!

ParadiseDecay
  • Members
  • 3 posts
  • Last active: Jul 31 2010 07:04 AM
  • Joined: 30 Jul 2010
Bump

This is the sort of script thats been recommended:
---------------------------------------

Joy1::
Send {Spacebar down} ; Hold down the Spacebar.
SetTimer, WaitForButtonUp3, 10
return

WaitForButtonUp3:
if GetKeyState("Joy1") ; The button is still, down, so keep waiting.
return
; Otherwise, the button has been released.
Send {Spacebar up} ; Release the Spacebar.
SetTimer, WaitForButtonUp3, off
return

----------------------------------------------------------------

I've had a play around trying to get 1 button working for now, the fire button (spacebar), but its not working, can anyone tell me what I'm doing wrong? Cheers.

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Xbox 360 controller as mouse + hotkeys
<!-- m -->http://www.autohotke...topic45062.html<!-- m -->

Google for other Xbox 360 controller scripts

And always place code in tags.

ParadiseDecay
  • Members
  • 3 posts
  • Last active: Jul 31 2010 07:04 AM
  • Joined: 30 Jul 2010
Thanks for the link, but Im still struggling to figure it out?

Could someone make me a quick script:

Left Arrow Key > 360 left analog (scroll ship left)
Right Arrow Key > 360 right anaolog (scroll ship right)
Up Arrow Key > 360 up analog (scroll ship up)
Down Arrow Key > 360 down anolog (scroll ship down)
Space Bar > 360 A button (fire)
Ctrl > 360 X button (smart Bomb)

Any help would be greatly appreciated. Cheers.

ilikain
  • Guests
  • Last active:
  • Joined: --
I have no clue how any of this is done, but I would love to be able to use a controller for the Lost Viking game in Starcraft 2. I have never made any form of script, so any help at all would be really helpful.

Gonenuts
  • Members
  • 3 posts
  • Last active: Dec 10 2010 10:19 AM
  • Joined: 08 Dec 2010
Since Blizzard won't code it, I tried it, straight from Help files inside the package, but with some twists.

:
;Jogar Starcraft com joystick
#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchPOV, 5
return

WatchPOV:
GetKeyState, 2POV, 2JoyPOV  ; Get position of the POV control.
KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).

; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if 2POV < 0   ; No angle to report
    KeyToHoldDown =
else if 2POV > 31500                 ; 315 to 360 degrees: Forward
    KeyToHoldDown = Up
else if 2POV between 0 and 4500      ; 0 to 45 degrees: Forward
    KeyToHoldDown = Up
else if 2POV between 4501 and 13500  ; 45 to 135 degrees: Right
    KeyToHoldDown = Right
else if 2POV between 13501 and 22500 ; 135 to 225 degrees: Down
    KeyToHoldDown = Down
else                                ; 225 to 315 degrees: Left
    KeyToHoldDown = Left

if KeyToHoldDown = %KeyToHoldDownPrev%  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyToHoldDown   ; There is a key to press down.
    Send, {%KeyToHoldDown% down}  ; Press it down.
return


;==============================================================================
;section of simple reading the joystick 2 button 1 and launching spacebar.
2Joy1::
Send {Space down}   ; Press the spacebar down.
KeyWait 2Joy1  ; Wait for the user to release the joystick button.
Send {Space up}  ; Release the spacebar.
return

;==============================================================================
;section of simple reading the joystick 2 button 3 and launching ctrl.
2Joy3::
Send {ctrl down}   ; Press the ctrl down.
KeyWait 2Joy3  ; Wait for the user to release the joystick button.
Send {ctrl up}  ; Release the ctrl.
return




;==============================================================================
;turning button 1 in the spacebar, joystick 2. with turbo embedded.
;2Joy1::
;Send {Space down}   ; Press the spacebar down.
;SetTimer, WaitFor2Joy1, 30  ; Reduce the number 30 to 20 or 10 to send keys faster. ;Increase it to send slower.
;return

;WaitFor2Joy1:
;if not GetKeyState("2Joy1")  ; The button has been released.
;{
;    Send {Space up}  ; Release the spacebar.
;    SetTimer, WaitFor2Joy1, off  ; Stop monitoring the button.
;    return
;}
; Since above didn't "return", the button is still being held down.
;Send {Space down}  ; Send another Spacebar keystroke.
;return
;end of spacebar remapped for 2joy1.

Yeah, all the comented sections at the bottom were coding failures, feel free to cut them off. The first section came straight from the help files, but it reads the POV instead of the Axis.
And my system reads my pad as #2, so all the input readings are marked 2joy instead of joy.
What bugs me, I can't fly the ship in diagonal, since this method of reading the axis won't allow it. Apparently, my POV emits a single number for each of 8 positions of the axis, and can be swapped to the axis by a button on the HW. So, in theory, I can read the diagonal positions, but I have no clue on how to push it through (and I've been coding for, like... only 2 hours using this tools:)) It also has a "turbo" function embedded on the gaming pad, so I didn't need to use the Hotkey code.

Gonenuts
  • Members
  • 3 posts
  • Last active: Dec 10 2010 10:19 AM
  • Joined: 08 Dec 2010
Here. ENJOY. Just a couple of caveats:

You must run the script that tells you which joystick number you have on the system. Mine is mapped to number 2, who knows why. So, when reading joystick inputs, all variables read for instance 2joy1, which would read if the first button on joy 2 is being pressed. You must adapt the code to the right input for you.

The axis were a pain, but they work. Don't try POV, this version is not good yet. I left all the garbage commented, to give people ideas. You can fly diagonal.

I left a pretty narrow deadzone (10% on both axis). I believe my gamepad got increased responsiveness for some reason. You can change it to your liking. (You will find some 55 and 45 on the code, those are it.)
Also, if you want to reverse the axis, fool around with the IF ELSE statements <> signs (smaller or greater then) and it gets easy. The real genius was a man that figured out how to separate the axis in different variables, because the default example that comes in the help is... weak.
The help example won't assume you can use diagonal.

The POV has that problem too, because in this case the axis are really "joined by the hip". It can be done, but you must figure it out for yourself. I commented the R axis, you don't need it. You can expand to the z axis too. Some comments are portuguese, but you can hack it, and there is alwasy google translate too. hehehe...

The turbo function can be used for the buttons, but there it is also on the forum pages with those. My gamepad had the turbo button already, so...

Well, here it is:
;Script of vanattab (http://www.curse.com/forums/p/47783/259487.aspx) to play WoW.
;Modified to play Lost Vikings on Starcraft 2.
;Watch out for joypad numbering: JoyX is reading the axis X on joystick 1. 2JoyX would be the joystick X axis on joy 2.
#Persistent ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5 ;polling axis 5ms
SetTimer, WatchPOV, 5  ;polling pov 5ms
return



WatchAxis:
GetKeyState, 2JoyX, 2JoyX ; Get position of X axis.
GetKeyState, 2JoyY, 2JoyY ; Get position of Y axis.
;GetKeyState, 2JoyR, 2JoyR ; Get position of R axis. (r disabled)



KeyToHoldDownPrevX = %KeyToHoldDownX% ;variável declarada KeyToHoldDownPrevX
KeyToHoldDownPrevY = %KeyToHoldDownY% ;keytoholdownY também?
;KeyToHoldDownPrevR = %KeyToHoldDownR% ;(r disabled)


;assuming the x axis goes from 0 to 100, left to right. same for Y axis. His "deadzone" is 30 steps wide, then.
;it looks like the char would be always going left until you told otherwise ;(where is the 45?) 
;but when he uses else if JoyX the script tool assumed all the rest. Or so it seems.
;update: it would keep going any direction pressed, except he kills the loops at the end when the buttons are released.
;if the script crashed mid term it would make the guy spin left or keep going left... hehe... kludgy...
;it does keep going one direction if you mess with the deadzones and limits.
;update 2: he copied it from the help file, so who cares.


;===============================================
;=leitura de posição eixo x, considerando zonas mortas (65) e pontos de mudança. (0..25 e 75..100) usar between nnn e nnnn ajuda.
;===============================================
if 2JoyX > 55 	        
KeyToHoldDownX = Right
else if 2JoyX < 45
KeyToHoldDownX = Left
else
KeyToHoldDownX =

;a unica saída da função acima é keytoholdownx, que determina qual o 
;botão a apertar pro eixo x, esquerda ou direita.
;===============================================
;leitura do eixo y
;===============================================

if 2JoyY > 55
KeyToHoldDownY = Down
else if 2JoyY < 45
KeyToHoldDownY = Up
else
KeyToHoldDownY =
;===============================================
;leitura do eixo r
;===============================================

;if JoyR > 60
;KeyToHoldDownR = d
;else if JoyR 
;KeyToHoldDownR = a
;else
;KeyToHoldDownR =

;===============================================
;control axis x changes
;===============================================
if KeyToHoldDownX = %KeyToHoldDownPrevX%   ;a variável heytoholdownx foi mexida pela leitura? compara com a anterior.
{
}
else
{
SetKeyDelay -1 ; Avoid delays between keystrokes.



if KeyToHoldDownPrevX ; There is a previous key to release.
Send, {%KeyToHoldDownPrevX% up} ; Release it.
if KeyToHoldDownX ; There is a key to press down.
Send, {%KeyToHoldDownX% down} ; Press it down.
}
;===============================================
;control axis y changes
;===============================================

if KeyToHoldDownY = %KeyToHoldDownPrevY% ; The correct key is already down (or no key is needed).
{
}
else
{
SetKeyDelay -1 ; Avoid delays between keystrokes.



if KeyToHoldDownPrevY ; There is a previous key to release.
Send, {%KeyToHoldDownPrevY% up} ; Release it.
if KeyToHoldDownY ; There is a key to press down.
Send, {%KeyToHoldDownY% down} ; Press it down.
}

;===============================================
;control axis r changes
;===============================================

;if KeyToHoldDownR = %KeyToHoldDownPrevR% ; The correct key is already down (or no key is needed).
;{
;}
;else
;{
;SetKeyDelay -1 ; Avoid delays between keystrokes.



;if KeyToHoldDownPrevR ; There is a previous key to release.
;Send, {%KeyToHoldDownPrevR% up} ; Release it.
;if KeyToHoldDownR ; There is a key to press down.
;Send, {%KeyToHoldDownR% down} ; Press it down.
;}



return



;;;;;;;;;;;;;;;;;;;;;;;;;THIS IS THE END OF AXIS MOVMENT



;;;;;;;;;;;;;;;;;;;;;;;;;THIS IS THE START OF DIRECTION MAPING



WatchPOV:
GetKeyState, 2POV, 2JoyPOV ; Get position of the POV control.
KeyToHoldDownPOVPrev = %KeyToHoldDownPOV% ; Prev now holds the key that was down before (if any).

;double warning: POV is broken. You should comment or fix this entire 
;section.
;warning: keytoholdown is now reading POV. should change to keytoholdownPOV.
;he can map diagonals directly to buttons, but some games won't allow. This section needs rewriting so diagonals can be combination of the pov axis.

; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if 2POV = -1 ; No angle to report

KeyToHoldDownPOV =

else If 2JoyPov = 9000
   Send {Right}
else if 2JoyPov = 4500
   Send {Up}{Right}
else if 2JoyPov = 0
   Send {UP}
else if 2JoyPov = 13500
   Send {Down}{Right}
else if 2JoyPov = 18000
   Send {Down}
else if 2JoyPov = 22500
   Send {Down}{Left}
else if 2JoyPov = 27000
   Send {Left}
else if 2JoyPov = 31500
   Send {Up}{Left}
return


if KeyToHoldDownPOV = %KeyToHoldDownPOVPrev% ; The correct key is already down (or no key is needed).
return ; Do nothing.



; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPOVPrev% up} ; Release it.
if KeyToHoldDownPOV ; There is a key to press down.
Send, {%KeyToHoldDownPOV% down} ; Press it down.
return
;;;;;;;;;;;;;;;;;;;;;;;;;THIS IS THE END OF DIR MAPING

;key mapping

;==============================================================================
;section of simple reading the joystick 2 button 1 and launching spacebar.
2Joy1::
Send {Space down}   ; Press the spacebar down.
KeyWait 2Joy1  ; Wait for the user to release the joystick button.
Send {Space up}  ; Release the spacebar.
return

;==============================================================================
;section of simple reading the joystick 2 button 3 and launching ctrl.
2Joy3::
Send {ctrl down}   ; Press the ctrl down.
KeyWait 2Joy3  ; Wait for the user to release the joystick button.
Send {ctrl up}  ; Release the ctrl.
return




Jason Bourne
  • Guests
  • Last active:
  • Joined: --
Thanks A LOT!!!!

maybe now I can get ALL campaign achievements :D