OK updated, with two sample maps, the icon graphics, shader file and a tutorial in it (detailing both basic and advanced patrol points):
http://theburrow.fragland.net/tutorials/downloads/patrolpoints.zip <- 250k approx
What’s new?
More flexibility in setting up the PP and more callbacks allowing you to react to important PP triggered events.
Here’s the vanilla script - before you run away screaming note it’s only the top few routines (in the ‘user customisable’ section) that you need even remotely concern yourself with:
///////////////////////////////////////////////////////////////////////////////////////////////////////////
<name>
{
/////////////////////////////
// User modifiable scripts //
/////////////////////////////
////////////////////////////////////////////////////////////////
// Things to do when this object spawns. Is called from normal spawn{}
// and already has a delay built in so no need for a wait line
trigger pp_spawn
{
}
////////////////////////////////////////////////////////////////
// How long you must be in the PP to enable it (in seconds)
// Note this is MEANT to use same accum as trigger disabletime
trigger enabletime
{
accum 2 set 15
}
////////////////////////////////////////////////////////////////
// How long the PP must be unattended for to disable (in seconds)
// Note this is MEANT to use same accum as trigger enabletime
trigger disabletime
{
accum 2 set 15
}
////////////////////////////////////////////////////////////////
// Whether 'keep alive' is enabled [0 = disabled, 1 = enabled]
trigger keepalive
{
accum 4 set 1
}
////////////////////////////////////////////////////////////////
// Number of times PP can be used [-1 = infinite, 0 = never, >0 = number of times]
trigger reusable
{
accum 5 set -1
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen when the PP is enabled
trigger enable
{
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen when the PP is disabled
// Usually you'd cancel whatever happened when the PP was enabled
trigger disable
{
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen when the PP is first entered
trigger firstentered
{
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen when there is only
// five seconds until the patrol point is enabled
trigger enablein5
{
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen each second as
// the patrol point is being enabled
trigger tick
{
}
////////////////////////////////////////////////////////////////
// This is where you put anything you want to happen when the PP will disable in 10 seconds
// If your PP is only active for a short period of time (20 seconds or less for example) then
// you'll probably want to leave this section empty
trigger disablein10
{
}
////////////////////////////////////////////////////////////////
// This is called after 'disable' for the last use of the patrol point
// Only relevant if you have given it a limited number of uses
trigger nomoreuses
{
}
////////////////////////////
// Non-modifiable scripts //
////////////////////////////
// Called when object is spawned
spawn
{
accum 1 set 0 // PP state: [0 = disabled, 1 = enabled]
trigger self enabletime // (accum 2) Timer:
// When PP state = 0 then is time remaining until PP is enabled
// When PP state = 1 then is time remaining until PP is disabled
accum 3 set 0 // PP trigger state: [0 = not used, 1 = used]
trigger self keepalive // (accum 4) PP 'keep alive' option: [0 = disabled, 1 = enabled]
trigger self reusable // (accum 5) Reusable option [-1 = infinite, 0 = never, >0 = number of times]
accum 6 set 0 // Previous PP trigger state. Used to determine if countdown has just started:
// [0 = not used, 1 = used]
wait 200 // Pause
trigger self pp_spawn // Calls user defined spawn function
}
// Called when player is inside PP trigger
trigger in
{
accum 3 set 1 // Mark as used this time
}
// Called once a second to see if PP trigger is in use
// Used to control whether PP should be activated, deactivated, or kept alive
trigger check
{
// General PP control
trigger self incheck
trigger self outcheck
// Store state of PP trigger flag
trigger self storestate0
trigger self storestate1
accum 3 set 0 // Reset PP trigger flag
}
trigger storestate0
{
accum 3 abort_if_not_equal 0 // Only continue if flag is appropriate value
accum 6 set 0 // Copy state into accum 6
}
trigger storestate1
{
accum 3 abort_if_not_equal 1 // Only continue if flag is appropriate value
accum 6 set 1 // Copy state into accum 6
}
trigger incheck
{
accum 3 abort_if_not_equal 1 // Only continue if inside trigger
accum 2 inc -1 // Count down time remaining until something happens
// Process depending on whether PP is enabled or not?
trigger self inenabledcheck
trigger self indisabledcheck
}
trigger outcheck
{
accum 3 abort_if_not_equal 0 // Only continue if inside trigger
// Process depending on whether PP is enabled or not?
trigger self outenabledcheck
trigger self outdisabledcheck
}
trigger inenabledcheck
{
accum 1 abort_if_not_equal 1 // Only continue if PP is enabled
trigger self inenabledkeepalive // React if using keep alive
trigger self inenablednokeepalive // React if not using keep alive
}
trigger inenabledkeepalive
{
accum 4 abort_if_not_equal 1 // Only continue if using 'keep alive'
trigger self disabletime // Reset timer
}
trigger inenablednokeepalive
{
accum 4 abort_if_not_equal 0 // Only continue if not using 'keep alive'
trigger self 10remainingcheck // Call '10 seconds remaining' event check
accum 2 abort_if_greater_than 0 // Continue only if PP has been enabled for full time
trigger self disableevent // Sets off the disabling of the PP
}
trigger indisabledcheck
{
accum 1 abort_if_not_equal 0 // Only continue if PP is disabled
accum 5 abort_if_equal 0 // Only continue if PP can be used again
trigger self FirstEnteredCheck // Call 'first entered' check
trigger self EnableIn5Check // Call '5 seconds to enable' check
trigger self tick // Cause a tick event every second as PP is getting enabled
accum 2 abort_if_greater_than 0 // Continue only if PP trigger has been used for long enough
accum 1 set 1 // Mark PP as in use now
trigger self disabletime // Reset counter for time to disable
trigger self enable // Enable whatever effect this PP has
accum 5 abort_if_less_than 1 // Only continue if there is a positive amount of uses left
accum 5 inc -1 // Count down number of times can be used
}
trigger outenabledcheck
{
accum 1 abort_if_not_equal 1 // Only continue if PP is enabled
accum 2 inc -1 // Decrement PP timer
trigger self 10remainingcheck // Call '10 seconds remaining' event check
accum 2 abort_if_greater_than 0 // Stop if timer is greater than 0
trigger self disableevent // Sets off the disabling of the PP
}
trigger outdisabledcheck
{
accum 1 abort_if_not_equal 0 // Only continue if PP is disabled
trigger self enabletime // Reset timer
}
trigger FirstEnteredCheck
{
accum 6 abort_if_not_equal 0 // Only continue if first time entered
trigger self firstentered // Do 'first entered' event
}
trigger EnableIn5Check
{
accum 2 abort_if_not_equal 5 // Only continue if 5 seconds remaining until enable
trigger self enablein5 // Do '5 seconds to enable' event
}
trigger 10remainingcheck
{
accum 2 abort_if_not_equal 10 // Only continue if 10 seconds remaining until disable
trigger self disablein10 // Do '10 seconds remaining' event
}
trigger disableevent
{
accum 1 set 0 // Mark PP as not in use now
trigger self enabletime // Reset counter for time to enable
trigger self disable // Disable whatever effect this PP has
accum 5 abort_if_not_equal 0 // Only continue if PP cannot be used any more times
trigger self nomoreuses // Reacts to no more PP uses
}
}