Checkactivatormotion

From EDukeWiki
Revision as of 17:23, 29 December 2022 by Sangman (talk | contribs) (corrected var name)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

checkactivatormotion <lotag>

Checks to see if the activator with the lotag specified is in motion or not - if it is, than RETURN is set to 1.

Detecting MasterSwitch motion

checkactivatormotion only detects activator motions, but it won't return 1 if it's a delayed masterswitch that goes off. Fortunately, there is a way to check for this. When a MasterSwitch starts moving, the sprite is deleted, meaning that we can catch it in EVENT_KILLIT and act appropriately.

One way to handle this:

var MASTERSWITCH_SUBSCRIPTION 0 2 
var MASTERSWITCH_RETURN 0 2
var temp 0 2
var temp2 0 2

appendevent EVENT_KILLIT
    ifactor MASTERSWITCH
    {
        for temp sprofstat 1
        {
            getav[temp].MASTERSWITCH_SUBSCRIPTION temp2

            ife temp2 sprite[].lotag
                setav[temp].MASTERSWITCH_RETURN 1
        }    
    }
endevent

useractor notenemy MASTERSWITCHHANDLER // this actor has to do something if it detects the masterswitch is moving
    set MASTERSWITCH_SUBSCRIPTION <lotag to check>
    ife MASTERSWITCH_RETURN 1
    {
        // do stuff
        set MASTERSWITCH_RETURN 0 // remember to reset this or whatever code will keep triggering
    }
enda