Jump to content

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

warcraft 3 script


  • Please log in to reply
3 replies to this topic
jamestr
  • Members
  • 98 posts
  • Last active: Jul 03 2008 12:30 AM
  • Joined: 05 Apr 2004
this is a generic strategy game script, though the map rotation is specific to warcraft 3.

#MaxThreads	20
#MaxThreadsPerHotkey 4
#HotkeyInterval 1000 ;     default 2000
#MaxHotkeysPerInterval 250 ; default 50
;RWIN::return         ; null rwin

space & lbutton::           ;left click  and move cursor over minimap
	sleep 200  
	MouseClick, left, , , 1, 0,                
	mousemove, 100, 520
return

space & rbutton::           ;right click  and move cursor over toolbar		sleep 200  
	;;send  {SHIFTUP}
	MouseClick, left, , , 1, 0,                
	mousemove, 700, 520
return


!q::suspend          ;;;; Alt-q suspend 

space::Send {space}     ; non-repeating space  
      
;;   		bottow row   zxcvb      
space & z::send, !eu	; equals  alt-e-u (undo)
;space & x::send ^x
;space & c::send ^c
;space & v::send ^v
;space & b::send ^b
 
;; 		 middle row  asdfg               
a::mousemove, 100, 520
space & a::mousemove, 100, 520
;space & s::send  ^a               
;space & d::send  ^a               
;space & f::send  ^a               
space & g::mousemove, 700, 520
g::mousemove, 700, 520

;;  		top row  qwerty
;space & q::send  ^q
;space & w::send  ^w
;space & e::mousemove, 400, 320                  
;space & r::send  ^r
;space & t::send  ^t
;space & y::mousemove, 750, 550
y::mousemove, 350, 350


;;		numerics  123456
1 & space::send, 1     ; non repeating 1

1::			; select hero, 
	send, 1
	sleep 150
	send, t		;  activate spell
return

space & 1::send ^1    ;add units to group 1

space & 2::           ;add units to group 2
	send ^2;
	sleep 200  
	mousemove, 100, 520
return

;;space & 2::send ^2
space & 3::send ^3 
space & 4::send ^4
space & 5::send ^5
space & 6::send ^6 


r::		; logically press L to rotate map  (del key)
   GetKeyState, statew, del, L
   	if statew = u 
		send, {ins up}
	 	Send, {del down}
	if statew = d 
 	 	send, {del up}
 		
return

w::		; logically press w to rotate map (ins key)
   GetKeyState, statew, ins, L
   	if statew = u 
		send, {del up}
	 	Send, {ins down}
	if statew = d 
  		send, {ins up}
return
           
space & p::		;;;;    runs notepad
	Run, Notepad 
	Sleep, 1000 
	Send, {enter}Oh do behave {! 10}
return     



;;space & s::

;;  below moves  cursor to screen edges using esdf (or change to wasd)
s::
;sleep, 100
MouseGetPos, xpos, ypos
MouseMove, 0, 450 
Loop 
{ 
    GetKeyState, state, s, P 
    if state = U 
    { 
;        MouseMove, %xpos%, %ypos% ,1  
	mousemove 400, 350
        break 
    } 
} 
return 


f:: 
MouseGetPos, xpos, ypos
MouseMove, 1100, 500 
Loop 
{ 
    GetKeyState, state, f, P 
    if state = U 
    { 
 ;       MouseMove, %xpos%, %ypos% ,1
        mousemove 400, 350
        break 
    } 
} 
return 
   

e:: 
;sleep, 100
MouseGetPos, xpos, ypos
MouseMove, 400, 00 
Loop 
{ 
    GetKeyState, state, e, P 
    if state = U 
    { 
;       MouseMove, %xpos%, %ypos% ,1
 	 mousemove 400, 250
        break 
    } 
} 
return 
      

d:: 
MouseGetPos, xpos, ypos
MouseMove, 400, 800 
Loop 
{ 
    GetKeyState, state, d, P 
        if state = U 
    { 
;        MouseMove, %xpos%, %ypos% ,1
        mousemove 400, 350
        break 
    } 
} 
return


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Well, you've certainly made great use of the spacebar in that one. I also notice that you've taken advantage of the fact that custom hotkeys can be inverted to form a different hotkey. For example, "space & 1" is different than "1 & space".

If the script doesn't perform exactly the way you want it -- such as MouseGetPos getting messed up when you press two MouseMove keys simultaneously (as you mentioned in your other topic) -- let me know because I think I have some solutions.

jamestr
  • Members
  • 98 posts
  • Last active: Jul 03 2008 12:30 AM
  • Joined: 05 Apr 2004
well, after some strategy game testing I think the script works well, the way it is.

but sure, it would be nice if i knew how to code it so;

"MouseGetPos, xpos, ypos "

retained the mouse location that existed, before i had pressed the 2 mousemove keys.

That might be helpful for a roleplaying or action style game.


by the way,

autohotkey is an AMAZING hotkey program!

Incredibly flexible hotkey configurations!!

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I'm glad you like AHK.

For your script, you could change it so that the MouseGetPos fetches into temporary variables. Then check if those variables contain coordinates that are too close to the coordinates you move to with your other keys. If so, do not update your master variables, let them retain their previous values (which hopefully contain the starting coordinates).