Checkactivatormotion: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Sangman (talk | contribs)
m formatting
Sangman (talk | contribs)
corrected var name
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:
         for temp sprofstat 1
         for temp sprofstat 1
         {
         {
             getav[temp].MASTERSWITCH_SUBSCRIBE temp2
             getav[temp].MASTERSWITCH_SUBSCRIPTION temp2


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

Latest revision as of 17:23, 29 December 2022

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