• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

MouseAPI

Status
Not open for further replies.

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
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