Checkactivatormotion: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Sangman (talk | contribs)
Described how to calculate the same thing for masterswitches
Sangman (talk | contribs)
m formatting
Line 17: Line 17:
     ifactor MASTERSWITCH
     ifactor MASTERSWITCH
     {
     {
for temp sprofstat 1
        for temp sprofstat 1
{
        {
getav[temp].MASTERSWITCH_SUBSCRIBE temp2
            getav[temp].MASTERSWITCH_SUBSCRIBE temp2
 
ife temp2 sprite[].lotag
            ife temp2 sprite[].lotag
        setav[temp].MASTERSWITCH_RETURN 1
        setav[temp].MASTERSWITCH_RETURN 1
}     
        }     
     }
     }
endevent
endevent

Revision as of 12:35, 25 March 2021

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_SUBSCRIBE 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