ID:133165
 
I've read this post and thought it wasn't a bad idea to make a feature request.

Details:
Basically, a simple proc, GetMouseLoc() (name doesn't matter), that returns a list with the following values:

under_object
icon-x
icon-y
under_location
under_window (would be useful)

This would get the above values without us having to use the mouse at all. This would be very useful for many games, specially shooters, where you would have to hold down the mouse to keep shooting.

Andre-G1 and I have tried to come up with workarounds, but with no luck. Here's a quick example:

client
var
mousepx=0
mousepy=0
mousex=0
mousey=0
mouse_isdown=0
proc
Shoot()
spawn while(mouse_isdown)
world<<"you shoot ([mousex],[mousey])([mousepx],[mousepy])!"
sleep(1)
UpdateMouseLoc(plist,loc)
var/Plist[]=params2list(plist)
src.mousepx=Plist["icon-x"]
src.mousepy=Plist["icon-y"]
src.mousex=loc:x
src.mousey=loc:y
MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params)
src.UpdateMouseLoc(params,src_location)
..()
MouseEntered(object,location,control,params)
src.UpdateMouseLoc(params,location)
..()
MouseExited(object,location,control,params)
src.UpdateMouseLoc(params,location)
..()
MouseDown(object,location,control,params)
mouse_isdown=1
src.UpdateMouseLoc(params,location)
src.Shoot()
..()
MouseUp()
mouse_isdown=0
..()


Unfortunately, MouseDown() is the only proc that calls UpdateMouseLoc(), the other procs are not called while the mouse is down.

Thanks, and hope you consider.

Also if anyone has any tips on how to make this work, feel free to help out!
> client
> var
> mousepx=0
> mousepy=0
> mousex=0
> mousey=0
> mouse_isdown=0
> proc
> Shoot()
> spawn while(mouse_isdown)
> world<<"you shoot ([mousex],[mousey])([mousepx],[mousepy])!"
> sleep(1)
> UpdateMouseLoc(plist,loc)
> var/Plist[]=params2list(plist)
> src.mousepx=Plist["icon-x"]
> src.mousepy=Plist["icon-y"]
> src.mousex=loc:x
> src.mousey=loc:y
> MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params)
> src.UpdateMouseLoc(params,src_location)
> ..()
> MouseEntered(object,location,control,params)
> src.UpdateMouseLoc(params,location)
> ..()
> MouseExited(object,location,control,params)
> src.UpdateMouseLoc(params,location)
> ..()
> MouseDown(object,location,control,params)
> mouse_isdown=1
> src.UpdateMouseLoc(params,location)
> src.Shoot()
> ..()
> MouseUp()
> mouse_isdown=0
> ..()


MouseEntered() is your best chance here. It is the only one you need. However, it will not be updated every pixel and it will not account for when the mouse leaves the map. It can do mouse_x, mouse_y, location, and control very well. The problem lies in the pixel location. While you may get it, it will not update every time the mouse has moved over an object.

[edit]
I also support this idea.
In response to CaptFalcon33035
MouseEnter isn't called when the mouse is down, normally. MouseDrag is called instead.
I'd say the only way to do this at the moment would be to place hundreds of objects on the top of the players screen and use MouseEntered(). However, this would be terrible in terms of resource usage! If your view is 13x13, that would be 169 square tiles. Multiply that by 256 (32x32) and you get the amount of objects you would need in client.screen.

In other words, I concur, this feature would be useful.
I currently have MouseDrag() update the players "clicking" variable to whatever their mouse is now over. The shooting loop takes this into account and adjusts their aim accordingly.
In response to SuperAntx
I've tried that also, didn't work for what I'm trying to do :(