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

Make EVENT_PLAYER_MOUSE_MOVE Ignore BlzSetMousePos

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
Is it possible to skip the actions of EVENT_PLAYER_MOUSE_MOVE? I've tried disabling the trigger before BlzSetMousePos is called and enabling it after. However, the actions still fire. I tried removing it from trigger queue before and/or after it is called as well. I've tried making it skip it with a real timer and a boolean and it still did not work. I have posted the code below. Alloc is just implemented by the Problem Child Code.
JASS:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~ Alloc ~~ By Sevion ~~ Version 1.09 ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//  What is Alloc?
//         - Alloc implements an intuitive allocation method for array structs
//
//    =Pros=
//         - Efficient.
//         - Simple.
//         - Less overhead than regular structs.
//
//    =Cons=
//         - Must use array structs (hardly a con).
//         - Must manually call OnDestroy.
//         - Must use Delegates for inheritance.
//         - No default values for variables (use onInit instead).
//         - No array members (use another Alloc struct as a linked list or type declaration).
//
//    Methods:
//         - struct.allocate()
//         - struct.deallocate()
//
//           These methods are used just as they should be used in regular structs.
//
//    Modules:
//         - Alloc
//           Implements the most basic form of Alloc. Includes only create and destroy
//           methods.
//
//  Details:
//         - Less overhead than regular structs
//
//         - Use array structs when using Alloc. Put the implement at the top of the struct.
//
//         - Alloc operates almost exactly the same as default structs in debug mode with the exception of onDestroy.
//
//  How to import:
//         - Create a trigger named Alloc.
//         - Convert it to custom text and replace the whole trigger text with this.
//
//  Thanks:
//         - Nestharus for the method of allocation and suggestions on further merging.
//         - Bribe for suggestions like the static if and method names.
//         - PurgeandFire111 for some suggestions like the merging of Alloc and AllocX as well as OnDestroy stuff.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library Alloc    
    module Alloc
        private static integer instanceCount = 0
        private thistype recycle
   
        static method allocate takes nothing returns thistype
            local thistype this
   
            if (thistype(0).recycle == 0) then
                debug if (instanceCount == JASS_MAX_ARRAY_SIZE - 1) then
                    debug call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Alloc ERROR: Attempted to allocate too many instances!")
                    debug return 0
                debug endif
                set instanceCount = instanceCount + 1
                set this = instanceCount
            else
                set this = thistype(0).recycle
                set thistype(0).recycle = thistype(0).recycle.recycle
            endif

            debug set this.recycle = -1
   
            return this
        endmethod
   
        method deallocate takes nothing returns nothing
            debug if (this.recycle != -1) then
                debug call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Alloc ERROR: Attempted to deallocate an invalid instance at [" + I2S(this) + "]!")
                debug return
            debug endif

            set this.recycle = thistype(0).recycle
            set thistype(0).recycle = this
        endmethod
    endmodule
endlibrary
JASS:
library cameraSystem initializer Init_cameraSystem
    //requires alloc
    //setup begin
    //I am making this in a struct despite it only being used on 12 players.
    globals
        private integer MAX_PLAYERS = 12
        private integer debug_mode = 1
        private real DEFAULT_PANNING_TIME = 0.1
        private real array mouseX
        private real array mouseY
        private real array prevMouseX
        private real array prevMouseY
        private real array skipTimer
        private trigger mouseMove = CreateTrigger()
    endglobals
    
    //setup end
    
    globals
        cameraSys array cs_Index
        integer cs_Max = -1
        private integer cs_Current = 0
        private constant real REPEATED_TIME = 0.03125
    endglobals
    
       function mouseActions takes nothing returns nothing //<=======ACTIONS ON MOUSE MOVE HERE
        local integer i
        set i = GetPlayerId(GetTriggerPlayer())
        //if skipTimer[i] < REPEATED_TIME then
            if GetTriggerPlayer() == GetLocalPlayer() then
                set mouseX[i] = BlzGetTriggerPlayerMouseX()
                set mouseY[i] = BlzGetTriggerPlayerMouseY()
            endif
        //else
            //set skipTimer[i] = skipTimer[i] - REPEATED_TIME
        //endif
    endfunction
    
    struct cameraSys extends array
        implement Alloc
        private integer myPlayer
        private unit u
        private real maxDistance
        private real currentDistance
        private real angle
        private real myX
        private real myY
        private real panningTime //Default should be 0.10 or 0.05
        public integer active
        
        static method create takes unit u, integer myPlayer, real maxDistance returns thistype
            local thistype this = thistype.allocate()
            set this.myPlayer = myPlayer
            set this.active = 1
            set this.u = u
            set this.maxDistance = maxDistance
            set this.panningTime = DEFAULT_PANNING_TIME
            
            set cs_Max = cs_Max + 1
            set cs_Index[cs_Max] = this
            return this
        endmethod
        
        method destroy takes nothing returns nothing
            set this.active = 0
            call this.deallocate()
        endmethod
        
        method getDist takes real x1, real y1, real x2, real y2 returns real
            local real x
            local real y
            local real dist

            set x = x2 - x1
            set x = x * x
            set y = y2 - y1
            set y = y * y
            set dist = SquareRoot(x + y)
            
            return dist
        endmethod
        
        method update takes real delta returns nothing
            local real x
            local real y
            local real angle
            local real distance
            //call DisableTrigger( mouseMove )
            if GetUnitState(this.u, UNIT_STATE_LIFE) < 0.405 then
                call this.destroy()
            else
                set x = GetWidgetX(this.u)
                set y = GetWidgetY(this.u)
                set angle = Atan2(mouseY[this.myPlayer] - y, mouseX[this.myPlayer] - x)
                set distance = getDist(x, y, mouseX[this.myPlayer], mouseY[this.myPlayer])
                if prevMouseX[this.myPlayer] != mouseX[this.myPlayer] and prevMouseY[this.myPlayer] != mouseY[this.myPlayer] then
                    set this.currentDistance = distance
                    set this.angle = angle
                    if this.myTimer <= 0 then
                        set this.myTimer = 0.15
                        if Player(this.myPlayer) == GetLocalPlayer() then
                            //set skipTimer[this.myPlayer] = REPEATED_TIME * 100
                            //call QueuedTriggerRemoveBJ(mouseMove)
                            call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2) //<==========PROBLEM CHILD IS HERE
                            //call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2)
                            //call QueuedTriggerRemoveBJ(mouseMove)
                        endif
                    else
                        set this.myTimer = this.myTimer - 0.03
                    endif
                    //call QueuedTriggerRemoveBJ(mouseMove)
                endif
                if this.currentDistance >= this.maxDistance then
                    set this.myX = x + (this.maxDistance * Cos(this.angle))
                    set this.myY = y + (this.maxDistance * Sin(this.angle))
                else
                    set this.myX = mouseX[this.myPlayer]
                    set this.myY = mouseY[this.myPlayer]
                    set this.myX = x + (this.currentDistance * Cos(this.angle))
                    set this.myY = y + (this.currentDistance * Sin(this.angle))
                        
                endif
                set prevMouseX[this.myPlayer] = mouseX[this.myPlayer]
                set prevMouseY[this.myPlayer] = mouseY[this.myPlayer]
                if debug_mode == 1 then
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " X: " + R2S(this.myX) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Y: " + R2S(this.myY) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " ANGLE: " + R2S(angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT ANGLE: " + R2S(this.angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " DISTANCE: " + R2S(distance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT DISTANCE: " + R2S(this.currentDistance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " PANNING TIME: " + R2S(this.panningTime) )
                    if Player(this.myPlayer) == GetLocalPlayer() then
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height: " + I2S(BlzGetLocalClientHeight()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width: " + I2S(BlzGetLocalClientWidth()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height / 2: " + I2S(BlzGetLocalClientHeight() / 2) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width / 2: " + I2S(BlzGetLocalClientWidth() / 2) )
                    endif
                    
                endif
                if Player(this.myPlayer) == GetLocalPlayer() then
                    call PanCameraToTimed (this.myX, this.myY, this.panningTime)
                endif
            endif
            
            //call EnableTrigger( mouseMove )
        endmethod        
        method setPanningTime takes real time returns nothing
            set this.panningTime = time
        endmethod
        
        method setMaxDistance takes real distance returns nothing
            set this.maxDistance = distance
        endmethod
    endstruct
    
    //indexer
    
    private function Actions takes nothing returns nothing
        if cs_Max > -1 then
            set cs_Current = 0
            loop
                if cs_Index[cs_Current].active == 0 then
                    set cs_Index[cs_Current] = cs_Index[cs_Max]
                    set cs_Max = cs_Max - 1
                    set cs_Current = cs_Current - 1
                else
                    call cs_Index[cs_Current].update(REPEATED_TIME)
                endif
                set cs_Current = cs_Current + 1
                exitwhen cs_Current > cs_Max
            endloop
        endif
    endfunction
    
    
    private function Init_cameraSystem takes nothing returns nothing
        local integer i
        local trigger CSIndex = CreateTrigger()
        
        call TriggerRegisterTimerEvent(CSIndex, REPEATED_TIME, true)
        call TriggerAddAction(CSIndex, function Actions)
        set i = 0
        loop
            exitwhen i >= MAX_PLAYERS
            call TriggerRegisterPlayerEvent(mouseMove, Player(i), EVENT_PLAYER_MOUSE_MOVE)
            set i = i + 1
        endloop
        call TriggerAddAction(mouseMove, function mouseActions)
    endfunction

endlibrary
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
Give the mouseMove trigger a condition that checks the value of some global boolean variable. Set that variable to false before setting mouse position, and back to true after. A little different than just checking a boolean inside the actions block, maybe that'll do the trick. You could even make it into a formal hook to safely use BlzSetMousePos freely in the map.
 
Level 11
Joined
Aug 6, 2009
Messages
697
If you meant something like this then it did not work. There is a boolean before it is called and it's set to true. It is set to false after the call ends and it still does not work properly.

JASS:
library cameraSystem initializer Init_cameraSystem
    //requires alloc
    //setup begin
    //I am making this in a struct despite it only being used on 12 players.
    globals
        private integer MAX_PLAYERS = 12
        private integer debug_mode = 1
        private real DEFAULT_PANNING_TIME = 0.1
        private real array mouseX
        private real array mouseY
        private real array prevMouseX
        private real array prevMouseY
        private real array skipTimer
        private boolean skipMouseMove = false
        private trigger mouseMove = CreateTrigger()
    endglobals
    
    //setup end
    
    globals
        cameraSys array cs_Index
        integer cs_Max = -1
        private integer cs_Current = 0
        private constant real REPEATED_TIME = 0.03125
    endglobals
    
        function mouseActions takes nothing returns nothing
        local integer i
        set i = GetPlayerId(GetTriggerPlayer())
        //if skipTimer[i] < REPEATED_TIME then
            if GetTriggerPlayer() == GetLocalPlayer() then
                set mouseX[i] = BlzGetTriggerPlayerMouseX()
                set mouseY[i] = BlzGetTriggerPlayerMouseY()
            endif
        //else
            //set skipTimer[i] = skipTimer[i] - REPEATED_TIME
        //endif
    endfunction
    
    struct cameraSys extends array
        implement Alloc
        private integer myPlayer
        private unit u
        private real maxDistance
        private real currentDistance
        private real angle
        private real myX
        private real myY
        private real panningTime //Default should be 0.10 or 0.05
        public integer active
        
        static method create takes unit u, integer myPlayer, real maxDistance returns thistype
            local thistype this = thistype.allocate()
            set this.myPlayer = myPlayer
            set this.active = 1
            set this.u = u
            set this.maxDistance = maxDistance
            set this.panningTime = DEFAULT_PANNING_TIME
            
            set cs_Max = cs_Max + 1
            set cs_Index[cs_Max] = this
            return this
        endmethod
        
        method destroy takes nothing returns nothing
            set this.active = 0
            call this.deallocate()
        endmethod
        
        method getDist takes real x1, real y1, real x2, real y2 returns real
            local real x
            local real y
            local real dist

            set x = x2 - x1
            set x = x * x
            set y = y2 - y1
            set y = y * y
            set dist = SquareRoot(x + y)
            
            return dist
        endmethod
        
        method update takes real delta returns nothing
            local real x
            local real y
            local real angle
            local real distance
            //call DisableTrigger( mouseMove )
            if GetUnitState(this.u, UNIT_STATE_LIFE) < 0.405 then
                call this.destroy()
            else
                set x = GetWidgetX(this.u)
                set y = GetWidgetY(this.u)
                set angle = Atan2(mouseY[this.myPlayer] - y, mouseX[this.myPlayer] - x)
                set distance = getDist(x, y, mouseX[this.myPlayer], mouseY[this.myPlayer])
                if prevMouseX[this.myPlayer] != mouseX[this.myPlayer] and prevMouseY[this.myPlayer] != mouseY[this.myPlayer] then
                    set this.currentDistance = distance
                    set this.angle = angle
                    //global skip
                    set skipMouseMove = true
                        if Player(this.myPlayer) == GetLocalPlayer() then
                            //set skipTimer[this.myPlayer] = REPEATED_TIME * 100
                            //call QueuedTriggerRemoveBJ(mouseMove)
                            call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2)
                            //call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2)
                            //call QueuedTriggerRemoveBJ(mouseMove)
                        endif
                    //call QueuedTriggerRemoveBJ(mouseMove)
                    //endglobal skip
                    set skipMouseMove = false
                endif
                if this.currentDistance >= this.maxDistance then
                    set this.myX = x + (this.maxDistance * Cos(this.angle))
                    set this.myY = y + (this.maxDistance * Sin(this.angle))
                else
                    //set this.myX = mouseX[this.myPlayer]
                    //set this.myY = mouseY[this.myPlayer]
                    //test set mousex = x and mousey = y
                    set this.myX = x + (this.currentDistance * Cos(this.angle))
                    set this.myY = y + (this.currentDistance * Sin(this.angle))
                        
                endif
                set prevMouseX[this.myPlayer] = mouseX[this.myPlayer]
                set prevMouseY[this.myPlayer] = mouseY[this.myPlayer]
                if debug_mode == 1 then
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " X: " + R2S(this.myX) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Y: " + R2S(this.myY) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " ANGLE: " + R2S(angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT ANGLE: " + R2S(this.angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " DISTANCE: " + R2S(distance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT DISTANCE: " + R2S(this.currentDistance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " PANNING TIME: " + R2S(this.panningTime) )
                    if Player(this.myPlayer) == GetLocalPlayer() then
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height: " + I2S(BlzGetLocalClientHeight()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width: " + I2S(BlzGetLocalClientWidth()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height / 2: " + I2S(BlzGetLocalClientHeight() / 2) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width / 2: " + I2S(BlzGetLocalClientWidth() / 2) )
                    endif
                    
                endif
                if Player(this.myPlayer) == GetLocalPlayer() then
                    call PanCameraToTimed (this.myX, this.myY, this.panningTime)
                endif
            endif
            
            //call EnableTrigger( mouseMove )
        endmethod        
        method setPanningTime takes real time returns nothing
            set this.panningTime = time
        endmethod
        
        method setMaxDistance takes real distance returns nothing
            set this.maxDistance = distance
        endmethod
    endstruct
    
    //indexer
    
    private function Actions takes nothing returns nothing
        if cs_Max > -1 then
            set cs_Current = 0
            loop
                if cs_Index[cs_Current].active == 0 then
                    set cs_Index[cs_Current] = cs_Index[cs_Max]
                    set cs_Max = cs_Max - 1
                    set cs_Current = cs_Current - 1
                else
                    call cs_Index[cs_Current].update(REPEATED_TIME)
                endif
                set cs_Current = cs_Current + 1
                exitwhen cs_Current > cs_Max
            endloop
        endif
    endfunction
    
    private function mouseCondition takes nothing returns boolean
        if skipMouseMove == false then
            return true
        endif
        return false
    endfunction
    
    
    private function Init_cameraSystem takes nothing returns nothing
        local integer i
        local trigger CSIndex = CreateTrigger()
        
        call TriggerRegisterTimerEvent(CSIndex, REPEATED_TIME, true)
        call TriggerAddAction(CSIndex, function Actions)
        set i = 0
        loop
            exitwhen i >= MAX_PLAYERS
            call TriggerRegisterPlayerEvent(mouseMove, Player(i), EVENT_PLAYER_MOUSE_MOVE)
            set i = i + 1
        endloop
        call TriggerAddAction(mouseMove, function mouseActions)
        call TriggerAddCondition(mouseMove, function mouseCondition)
    endfunction

endlibrary

Below the code has a boolean when mouse is called and it's set to true in order to skip the mouse actions. It is set to false inside the actions with an if/then/else and it still does not work.

JASS:
library cameraSystem initializer Init_cameraSystem
    //requires alloc
    //setup begin
    //I am making this in a struct despite it only being used on 12 players.
    globals
        private integer MAX_PLAYERS = 12
        private integer debug_mode = 1
        private real DEFAULT_PANNING_TIME = 0.1
        private real array mouseX
        private real array mouseY
        private real array prevMouseX
        private real array prevMouseY
        private real array skipTimer
        private boolean skipMouseMove = false
        private trigger mouseMove = CreateTrigger()
    endglobals
    
    //setup end
    
    globals
        cameraSys array cs_Index
        integer cs_Max = -1
        private integer cs_Current = 0
        private constant real REPEATED_TIME = 0.03125
    endglobals
    
        function mouseActions takes nothing returns nothing
        local integer i
        if skipMouseMove == false then
        set i = GetPlayerId(GetTriggerPlayer())
        //if skipTimer[i] < REPEATED_TIME then
            if GetTriggerPlayer() == GetLocalPlayer() then
                set mouseX[i] = BlzGetTriggerPlayerMouseX()
                set mouseY[i] = BlzGetTriggerPlayerMouseY()
            endif
        else
            set skipMouseMove = false
        endif
        //else
            //set skipTimer[i] = skipTimer[i] - REPEATED_TIME
        //endif
    endfunction
    
    struct cameraSys extends array
        implement Alloc
        private integer myPlayer
        private unit u
        private real maxDistance
        private real currentDistance
        private real angle
        private real myX
        private real myY
        private real panningTime //Default should be 0.10 or 0.05
        public integer active
        
        static method create takes unit u, integer myPlayer, real maxDistance returns thistype
            local thistype this = thistype.allocate()
            set this.myPlayer = myPlayer
            set this.active = 1
            set this.u = u
            set this.maxDistance = maxDistance
            set this.panningTime = DEFAULT_PANNING_TIME
            
            set cs_Max = cs_Max + 1
            set cs_Index[cs_Max] = this
            return this
        endmethod
        
        method destroy takes nothing returns nothing
            set this.active = 0
            call this.deallocate()
        endmethod
        
        method getDist takes real x1, real y1, real x2, real y2 returns real
            local real x
            local real y
            local real dist

            set x = x2 - x1
            set x = x * x
            set y = y2 - y1
            set y = y * y
            set dist = SquareRoot(x + y)
            
            return dist
        endmethod
        
        method update takes real delta returns nothing
            local real x
            local real y
            local real angle
            local real distance
            //call DisableTrigger( mouseMove )
            if GetUnitState(this.u, UNIT_STATE_LIFE) < 0.405 then
                call this.destroy()
            else
                set x = GetWidgetX(this.u)
                set y = GetWidgetY(this.u)
                set angle = Atan2(mouseY[this.myPlayer] - y, mouseX[this.myPlayer] - x)
                set distance = getDist(x, y, mouseX[this.myPlayer], mouseY[this.myPlayer])
                if prevMouseX[this.myPlayer] != mouseX[this.myPlayer] and prevMouseY[this.myPlayer] != mouseY[this.myPlayer] then
                    set this.currentDistance = distance
                    set this.angle = angle
                    //global skip
                    set skipMouseMove = true
                        if Player(this.myPlayer) == GetLocalPlayer() then
                            //set skipTimer[this.myPlayer] = REPEATED_TIME * 100
                            //call QueuedTriggerRemoveBJ(mouseMove)
                            call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2)
                            //call BlzSetMousePos(BlzGetLocalClientWidth() / 2, BlzGetLocalClientHeight() / 2)
                            //call QueuedTriggerRemoveBJ(mouseMove)
                        endif
                    //call QueuedTriggerRemoveBJ(mouseMove)
                    //endglobal skip
                    //set skipMouseMove = false
                endif
                if this.currentDistance >= this.maxDistance then
                    set this.myX = x + (this.maxDistance * Cos(this.angle))
                    set this.myY = y + (this.maxDistance * Sin(this.angle))
                else
                    //set this.myX = mouseX[this.myPlayer]
                    //set this.myY = mouseY[this.myPlayer]
                    //test set mousex = x and mousey = y
                    set this.myX = x + (this.currentDistance * Cos(this.angle))
                    set this.myY = y + (this.currentDistance * Sin(this.angle))
                        
                endif
                set prevMouseX[this.myPlayer] = mouseX[this.myPlayer]
                set prevMouseY[this.myPlayer] = mouseY[this.myPlayer]
                if debug_mode == 1 then
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " X: " + R2S(this.myX) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Y: " + R2S(this.myY) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " ANGLE: " + R2S(angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT ANGLE: " + R2S(this.angle) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " DISTANCE: " + R2S(distance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " CURRENT DISTANCE: " + R2S(this.currentDistance) )
                    call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " PANNING TIME: " + R2S(this.panningTime) )
                    if Player(this.myPlayer) == GetLocalPlayer() then
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height: " + I2S(BlzGetLocalClientHeight()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width: " + I2S(BlzGetLocalClientWidth()) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Height / 2: " + I2S(BlzGetLocalClientHeight() / 2) )
                        call DisplayTextToForce( GetPlayersAll(), I2S(this.myPlayer) + " Screen Width / 2: " + I2S(BlzGetLocalClientWidth() / 2) )
                    endif
                    
                endif
                if Player(this.myPlayer) == GetLocalPlayer() then
                    call PanCameraToTimed (this.myX, this.myY, this.panningTime)
                endif
            endif
            
            //call EnableTrigger( mouseMove )
        endmethod        
        method setPanningTime takes real time returns nothing
            set this.panningTime = time
        endmethod
        
        method setMaxDistance takes real distance returns nothing
            set this.maxDistance = distance
        endmethod
    endstruct
    
    //indexer
    
    private function Actions takes nothing returns nothing
        if cs_Max > -1 then
            set cs_Current = 0
            loop
                if cs_Index[cs_Current].active == 0 then
                    set cs_Index[cs_Current] = cs_Index[cs_Max]
                    set cs_Max = cs_Max - 1
                    set cs_Current = cs_Current - 1
                else
                    call cs_Index[cs_Current].update(REPEATED_TIME)
                endif
                set cs_Current = cs_Current + 1
                exitwhen cs_Current > cs_Max
            endloop
        endif
    endfunction
    
    /*private function mouseCondition takes nothing returns boolean
        if skipMouseMove == false then
            return true
        endif
        return false
    endfunction*/
    
    
    private function Init_cameraSystem takes nothing returns nothing
        local integer i
        local trigger CSIndex = CreateTrigger()
        
        call TriggerRegisterTimerEvent(CSIndex, REPEATED_TIME, true)
        call TriggerAddAction(CSIndex, function Actions)
        set i = 0
        loop
            exitwhen i >= MAX_PLAYERS
            call TriggerRegisterPlayerEvent(mouseMove, Player(i), EVENT_PLAYER_MOUSE_MOVE)
            set i = i + 1
        endloop
        call TriggerAddAction(mouseMove, function mouseActions)
        //call TriggerAddCondition(mouseMove, function mouseCondition)
    endfunction

endlibrary
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
You should explore that further. What specifically is "not working" as expected? The conditions actually return false but the trigger still runs? If so that's insane. If that's not the case, then the value of the global isn't being read properly (somehow?) or isn't being read at the time its set to false (how could it be delayed?). Figure out which of those things is happening.
 
Level 11
Joined
Aug 6, 2009
Messages
697
Sorry for the delay, I needed a break. I went ahead and started a timer right after BlzSetMousePos and evaluated the elapsed time when the mouse move event actions occurred. Here are the results:

Results.png


Edit: I did not move my mouse manually during the period it was evaluating the times.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,019
Looks like it takes a frame (or maybe two) to update the position and then fire the event after a mouse move. 1/0.017 = 58.82 fps if one frame is 0.017s. This sort of a thing is very annoying to get around in my experience.
 
Status
Not open for further replies.
Top