// =============================================================================== // DESCRIPTION: Abstract class for powerup spawning // CALLED BY: // PARAMS: // TYPE: // =============================================================================== // Init ========================================================================== @INIT if [__debug == 1] goto DEBUG goto SCRIPT // =============================================================================== // Debug ========================================================================= @DEBUG Echo #__debug_prefix#"Calling script _SVR_POWERUP" goto SCRIPT // =============================================================================== // Script ======================================================================== @SCRIPT if [__debug == 1] Echo #__debug_prefix#"Calling method _SVR_POWERUP::"#GetScriptParam(::)# goto #GetScriptParam(::)# goto EOF @GIVE Set _idx #GetScriptParam(idx)# Set _triggeridx #GetScriptParam(triggeridx)# Set _prop #GetNameFromIndex(|#_triggeridx|#)# Set _location #|#_prop|## Set _item #__powerups_location|#_location|## Set __powerups_location#_location#_mtime #GetGameTime()# ExecScript _SVR_POWERUP :: ASSIGN_RANDOM_ITEM location #_location# GiveClientItem #GetClientNumFromIndex(|#_idx|#)# #_item# RemoveEntity #_triggeridx# RemoveEntity Item#_prop# Set #_prop# -1 StartEffectOnObject #_idx# /shared/effects/healed.effect goto EOF @SPAWN Set _location #GetScriptParam(at)# Set _spawn Spawn_Item_#_location# Set _trigger __powerup_spawned_#__powerups_num# CreateVar int #_trigger# #_location# Set _item Item__powerup_spawned_#__powerups_num# SpawnEntityAtEntity #_spawn# Trigger_Proximity name #_trigger# triggeronplayer 1 triggerradius 10 model /ui/models/error.mdf triggerenter "Set _idx #GetScriptParam(index)#; Set _triggeridx #GetScriptParam(triggerindex)#;ExecScript _SVR_POWERUP :: GIVE idx #_idx# triggeridx #_triggeridx#" SpawnEntityAtEntity #_spawn# Prop_Dynamic name #_item# angles "0.0000 0.0000 91.1999" model /shared/models/chest/chest.mdf Set _x #GetPosX(|#_spawn|#)# Set _y #GetPosY(|#_spawn|#)# Set _z #GetPosZ(|#_spawn|#)# Set _z 15 SetPosition #GetIndexFromName(|#_trigger|#)# #_x# #_y# #_z# SetPosition #GetIndexFromName(|#_item|#)# #_x# #_y# #_z# SetToValidPosition #GetIndexFromName(|#_trigger|#)# SetToValidPosition #GetIndexFromName(|#_item|#)# StartEffectOnObject #GetIndexFromName(|#_item|#)# /shared/effects/soul_trail.effect Set __powerups_num [__powerups_num + 1] goto EOF @TICKER_SPAWN Set _time #GetGameTime()# if [! __powerups_assigned] goto EOF // Manual loop this will be too much otherwise.. if [__powerups_location0_mtime == 0 | (__powerups_location0_mtime > 0 & Eval(__powerups_location0_mtime + Eval(__powerups_respawn * 1000)) <= _time)] "Set __powerups_location0_mtime "-1";ExecScript _SVR_POWERUP :: SPAWN at 0" if [__powerups_location1_mtime == 0 | (__powerups_location1_mtime > 0 & Eval(__powerups_location1_mtime + Eval(__powerups_respawn * 1000)) <= _time)] "Set __powerups_location1_mtime "-1";ExecScript _SVR_POWERUP :: SPAWN at 1" if [__powerups_location2_mtime == 0 | (__powerups_location2_mtime > 0 & Eval(__powerups_location2_mtime + Eval(__powerups_respawn * 1000)) <= _time)] "Set __powerups_location2_mtime "-1";ExecScript _SVR_POWERUP :: SPAWN at 2" if [__powerups_location3_mtime == 0 | (__powerups_location3_mtime > 0 & Eval(__powerups_location3_mtime + Eval(__powerups_respawn * 1000)) <= _time)] "Set __powerups_location3_mtime "-1";ExecScript _SVR_POWERUP :: SPAWN at 3" if [__powerups_location4_mtime == 0 | (__powerups_location4_mtime > 0 & Eval(__powerups_location4_mtime + Eval(__powerups_respawn * 1000)) <= _time)] "Set __powerups_location4_mtime "-1";ExecScript _SVR_POWERUP :: SPAWN at 4" goto EOF @ASSIGN_RANDOM_ITEM Set _location #GetScriptParam(location)# Set _rand [floor(rand * __powerups)] Set __powerups_location#_location# #__powerups|#_rand|## Set __powerups_location#_location#_mtime 0 goto EOF @POPULATE Set _idx 0 @POPULATE_ITER if [_idx >= __powerups_locations] goto POPULATE_END ExecScript _SVR_POWERUP :: ASSIGN_RANDOM_ITEM location #_idx# Set _idx [_idx + 1] goto POPULATE_ITER @POPULATE_END Set _idx 0 Set __powerups_assigned True goto EOF @TERMINATE Set __powerups_assigned False Set _idx #__powerups_num_consistancy# @TERMINATE_ITER if [_idx >= __powerups_num] goto TERMINATE_END if [_idx >= 0] ExecScript _SVR_POWERUP :: DESTROY idx #_idx# Set _idx [_idx + 1] goto TERMINATE_ITER @TERMINATE_END Set __powerups_num 0 Set __powerups_consistancy #__powerups_num# goto EOF @DESTROY Set _trigger_name "__powerup_spawned_"#GetScriptParam(idx)# Set _item_name "Item"#_trigger_name# Set _trigger_idx #GetIndexFromName(|#_trigger_name|#)# Set _item_idx #GetIndexFromName(|#_item_name|#)# if #EntityExists(|#_trigger_idx|#)# "RemoveEntity #_trigger_idx#" if #EntityExists(|#_item_idx|#)# "RemoveEntity #_item_idx#" Set __powerup_spawned_#GetScriptParam(idx)# -1 goto EOF @EOF