• 🏆 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!

Programatically changing mouse cursor?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
I want to create a fake target ability and to this end I'd need to override the mouse cursor, is it possible to change it to the generic select target cursor?


What I want to achieve is something with the following syntax:

JASS:
struct PlayerCursor extends array
  
    private static thistype first
    private static thistype last
    private static thistype cur
    private static timer t
  
    private thistype prev
    private thistype next
    private boolean inList
  
    private real aoe//0 == single target
    private trigger trgOnPressed
    private effect cursor // dummy visual effect
  

    boolean targetUnit
    boolean targetItem
    boolean targetDestructable
  
    private static method onMouseMove takes nothing returns nothing
        set cur = first
        loop
            exitwhen cur == 0
            // move effect to moseXY
            set cur = cur.next
        endloop
    endmethod
  
    method getSingleTarget takes real x, real y returns handle
      
    endmethod
  
    method operator aoe= takes real r returns nothing
         // update effect if need be, if 0 than single target cursor
    endmethod
  
    method start takes nothing returns nothing
        if inList then
            return
        endif
        if first == 0 then
            set first = this
            set last = this
            set this.prev = 0
            if t == null then
                set t = CreateTimer()
            endif
            call TimerStart(t, 0.03125, true, function thistype.onMouseMove)
        else
            set last.next = this
            set this.prev = last
            set last = this
        endif
        set this.next = 0
        set this.inList = true
    endmethod

    method stop takes nothing returns nothing
        if not inList then
            return
        endif
        if first == this then
            set first = first.next
            if first != 0 then
                set first.prev = 0
            else
                call PauseTimer(t)
            endif
        elseif last == this then
            set last = last.prev
            set last.next = 0
        else
            set this.prev.next = this.next
            set this.next.prev = this.prev
        endif
        set this.inList = false
    endmethod

endstruct

An alternative is using:

  • Selection - Select (Triggering unit) for Player 1 (Red)
  • Game - Force Player 1 (Red) to press the key A
  • Game - Force Player 1 (Red) to press the key B
But I don't think there is any way to detect when the cancel button was issued.
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
I'm experimenting with the simpler solution but I'm running into a problem. It only works the first time. What is supposed to happen is that when Ability "Extra Option" is cast the unit will be given a new dummy ability and instantly be forced to use it. When the dummy ability is cast it is removed, it's also removed with a delay after mouse down is triggered or when esc is pressed.

It works in the first cycle, but the second time no dummy ability is added, in fact the "Add" trigger is never fierd again?

  • Add
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Extra Option
    • Actions
      • Game - Display to (All players) the text: Added
      • Unit - Add Single Target Ground to (Triggering unit)
      • Set HAS_SPELL = True
      • Wait 0.05 seconds
      • Game - Force Player 1 (Red) to press the key T
  • Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Single Target Ground
    • Actions
      • Unit - Remove Single Target Ground from (Triggering unit)
      • Game - Display to (All players) the text: removed
      • Set HAS_SPELL = False
  • Remove
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 1 (Red) issues Mouse Down event
    • Conditions
      • HAS_SPELL Equal to True
    • Actions
      • Game - Display to (All players) the text: Mouse
      • Wait 0.10 seconds
      • Set HAS_SPELL = False
      • Unit - Remove Single Target Ground from Footman 0058 <gen>
Its as if the unit has bugged because it can't move or anything, any ideas of what could be causing this?

Edit: Apperently pausing/unpausing the unit fixed the issue.
 
Last edited:
Status
Not open for further replies.
Top