• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

MouseAPI

Status
Not open for further replies.
Level 21
Joined
Aug 3, 2004
Messages
710
MouseAPI allows getting and setting mouse coordinates. These aren't relative to the game, but just the screen coordinates.
JASS:
native GetMouseX            takes nothing                   returns integer
native GetMouseY            takes nothing                   returns integer
native GetMouseXRelative    takes nothing                   returns integer
native GetMouseYRelative    takes nothing                   returns integer
native SetMouseX            takes integer x                 returns nothing
native SetMouseY            takes integer y                 returns nothing
native SetMousePos          takes integer x, integer y      returns nothing
//
//===================================================
// Mouse API constants
//===================================================
constant integer EVENT_LMOUSEUP 	= 0
constant integer EVENT_LMOUSEDOWN 	= 1
constant integer EVENT_RMOUSEUP 	= 2
constant integer EVENT_RMOUSEDOWN 	= 3
constant integer EVENT_MMOUSEUP 	= 4
constant integer EVENT_MMOUSEDOWN 	= 5
constant integer EVENT_MOUSEWHEEL 	= 6
// New Functions
native TriggerRegisterMouseEvent takes trigger whichTrigger, integer eventtype returns nothing
native GetTriggerWheelDelta takes nothing                   returns integer

Download: N/A Part of official Release
Native Set Type: Single Player or WarSoc
Release: 0.02alpha, updated in 0.10

GetMouseX Gets the X component of the mouse position.
GetMouseY Gets the Y component of the mouse position.
GetMouseXRelative Gets the X component of the mouse position relative to the window.
GetMouseYRelative Gets the Y component of the mouse position relative to the window.
SetMouseX Sets the X component of the mouse position.
SetMouseY Sets the Y component of the mouse position.
SetMousePos Sets the X and Y component of the mouse position, faster if you need to move both at once.

Example usage:
JASS:
 local integer mx = GetMouseX()
 local integer my = GetMouseY()
 local integer vx = GetWindowWidth()/2 //GetWindowWidth is part of WindowAPI
 local integer vy = GetWindowHeight()/2 //GetWindowHeight is part of WindowAPI

    set vx = vx-mx
    set vy = vy-my
        //now you can use vx and vy as offset variables to move things. Like a unit.
    call SetMouseX(GetWindowWidth()/2) //GetWindowWidth is part of WindowAPI
    call SetMouseY(GetWindowHeight()/2) //GetWindowHeight is part of WindowAPI
 
Last edited:
Level 5
Joined
Aug 16, 2007
Messages
149
how do I get the mouse x and y for each individual player? Using GetLocalPlayer()?

EDIT:
Didn't read the 'single player or WarSoc' part, sorry.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
I think its impossible to play the maps made with it in Bnet
because its impossible to change mause position in default Wc3
so all players will have to have RtC
Wc3 doesnt sync the mause because it would delay AFAIK
 
Status
Not open for further replies.
Top