AC 1.1.1.0 scripts (currently SVN)
#9
Map triggers:

[cubescript]// $arg1 = map to add a trigger for
// $arg2 = unique trigger name
// $arg3 = trigger zone (a list of 2 points on a grid: "82 84 56 58" for example, 82 = minX, 84 = maxX, 56 = minY 58 = maxY, indicating a trigger zone of 2x2 cubes)
// $arg4 = trigger action (cubescript to execute upon player1 entering the trigger zone)
// $arg5 = action when not in trigger zone
addmaptrigger = [
maptoadd = $arg1
triggername = $arg2
triggerzone = $arg3
triggeraction = $arg4
nottriggeraction = $arg5

check2init (format %1_triggers $maptoadd) ""
if (! (strstr (MDArray_Get_All_Subarray_Names (format %1_triggers $maptoadd)) $triggername)) [
// trigger doesn't exist
MDArray_New_Subarray (format %1_triggers $maptoadd) $triggername (concat (addpunct $triggerzone) (addpunct $triggeraction) (addpunct $nottriggeraction))
]
]

doMapTriggers = [
curmaptriggers = (MDArray_Get_All_Subarray_Names (format %1_triggers (curmap 1)))
if (listlen $curmaptriggers) [
loop cmt (listlen $curmaptriggers) [
curtrigger = (MDArray_Get (format %1_triggers (curmap 1)) (at $curmaptriggers $cmt) -1)
curzone = (at $curtrigger 0)
if (&& (checkrange (player1 x) (at $curzone 0) (at $curzone 1)) (checkrange (player1 y) (at $curzone 2) (at $curzone 3))) [
execute (at $curtrigger 1)
] [ execute (at $curtrigger 2) ]
]
]
sleep 0 doMapTriggers
]

checkinit mapstartalways [ if (checkalias (format %1_triggers (curmap 1))) doMapTriggers ]

// Examples:
inwell = 0
wellinmsg = [ if (<f (player1 z) 3) [ if (! $inwell) [ echo get out of the well!; inwell = 1 ] ] ]
welloutmsg = [ if $inwell [ echo thank you come again!; inwell = 0 ] ]

addmaptrigger ac_desert well "136 141 159 164" wellinmsg welloutmsg
addmaptrigger ac_desert clabase "155 182 164 184" [ echo don't camp the cla base! ] []
addmaptrigger ac_desert rvsfbase "72 102 84 102" [ echo don't camp the rvsf base! ] []

addmaptrigger ac_depot spamzone "192 200 216 226" [ echo watch out for the nade spam! ] []

// you can add as many triggers for as many maps as you want[/cubescript]

Hint: Use /whereami to find the 2 points needed for a "trigger zone"
Thanks given by:


Messages In This Thread
AC 1.1.1.0 scripts (currently SVN) - by Bukz - 10 Jun 12, 04:22AM
RE: AC 1.1.1.0 scripts (currently SVN) - by Bukz - 23 Jun 12, 11:49PM