Detect if human player is mid-cast

Status
Not open for further replies.
Level 45
Joined
Feb 27, 2007
Messages
5,578
I want to be able to detect when a player is in the 'middle' of casting a (non-channeled) point-/object-targeted spell. Specifically after pressing the spell hotkey (or clicking) but before clicking on a target point or object, so while the player is choosing a target for the ability. I don't need an event to fire when this occurs (obviously that's impossible since the unit hasn't been ordered to cast the spell on a target point/object yet), I just want to be able to check at a particular time if Player(N) is in the middle of choosing a target for a spell.

Can any of you think of a way to do this other than:
  • Store each of their currently selected units' current order so they can be restored later
  • Add a no-art/animations, black icon, no-target dummy ability with a unique orderstring to or enable such an ability for their currently selected units
  • Call ForceUIKey() on that spell's hotkey (maybe over time more than once?)
  • If one of the units is ordered to do the dummy ability's unique orderstring within X milliseconds (orders ForceUIKey takes some non-zero to happen) then the player was not casting
    • Restore the order of the unit that attempted to cast
  • If none of the units are ordered to do the orderstring within X milliseconds then the player was casting
  • Remove/disable the dummy ability from/on all selected units
  • All the while check for other orders issued to those units and update their last orders as necessary.
The problem is this is not an instantaneous process.
 
Last edited:
Level 11
Joined
Dec 16, 2018
Messages
365
Change a real from 0 to 1 if the conditions are correct?
Then, simply use an if to verify the value of that real, and thus give the actions.
What I'm not sure is whether or not there is an option to detect "skill button is selected", but that's not the point
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
What I'm not sure is whether or not there is an option to detect "skill button is selected", but that's not the point
What?? The whole point of this thread is that there isn't such a thing.
Change a real from 0 to 1 if the conditions are correct?
There is no way to check "if the conditions are correct"... that's what I'm asking. The only method I know of is the one I posted and it has the problem of not being instant.
What if you create control groups(ingame ctrl + number), then use them to detect your event. Sadly, this means you can only have numbers as hotkeys and they are limited
Good idea but you can't create control groups with triggers, so this would only work if a player read a message to create control groups and then actually did it in-game. In any case that breaks control group functionality which is way, way worse than having to wait a fraction of a second to see if the player was mid-cast. Also selection events are really slow (probably related to framerate/draw times).
 
Status
Not open for further replies.
Top