| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * FILE
- * Toolkit_Triggers.cpp
- *
- * DESCRIPTION
- * Designer Toolkit for Mission Construction - Triggers Subset
- *
- * PROGRAMMER
- * Design Team
- *
- * VERSION INFO
- * $Author: Byon_g $
- * $Revision: 5 $
- * $Modtime: 11/29/01 11:05a $
- * $Archive: /Commando/Code/Scripts/Toolkit_Triggers.cpp $
- *
- ******************************************************************************/
- #include "toolkit.h"
- /*
- Associated Custom Types:
- Trigger Activation/Deactivation Customs - Send 1 for On, 0 for Off:
- M00_CUSTOM_TRIGGER_ACTIVATE_ALL
- M00_CUSTOM_TRIGGER_ACTIVATE_KILLED
- M00_CUSTOM_TRIGGER_ACTIVATE_DESTROYED
- M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED
- M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_EXITED
- M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED_OR_EXITED
- M00_CUSTOM_TRIGGER_ACTIVATE_ENEMY_SEEN
- M00_CUSTOM_TRIGGER_ACTIVATE_DAMAGED
- M00_CUSTOM_TRIGGER_ACTIVATE_WAYPATH_COMPLETE
- M00_CUSTOM_TRIGGER_ACTIVATE_ANIMATION_COMPLETE
- M00_CUSTOM_TRIGGER_TIMER_EXPIRED
- */
- /*
- Function - M00_Controller_Trigger_RMV
- This script handles all operations of triggers.
- Parameters:
- GameObject * obj = The object that is sending the trigger.
- GameObject * target = The target of the trigger.
- float time_lower_bound = A time fluctuator to delay activation.
- float time_upper_bound = A time fluctuator to delay activation.
- int custom_type = The type of the custom to send.
- int custom_param = The parameter of the custom to send.
- */
- void M00_Controller_Trigger_RMV (GameObject * obj, GameObject * target, float time_lower_bound, float time_upper_bound, int custom_type, int custom_param)
- {
- if ((time_lower_bound == 0.0) && (time_upper_bound == 0.0))
- {
- if (target)
- Commands->Send_Custom_Event(obj, target, custom_type, custom_param);
- }
- else if ((time_lower_bound != 0.0) && (time_upper_bound == 0.0))
- {
- if (target)
- Commands->Send_Custom_Event(obj, target, custom_type, custom_param, time_lower_bound);
- }
- else if (time_upper_bound != 0.0)
- {
- float random_time = Commands->Get_Random(time_lower_bound, time_upper_bound);
- if (target)
- Commands->Send_Custom_Event(obj, target, custom_type, custom_param, random_time);
- }
- };
- /*
- Editor Script - M00_Trigger_When_Killed_RMV
- This script triggers when the object it is attached to is killed.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Killed_RMV, "Start_Now=1:int, Receive_Type=1:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
- {
- bool script_enabled;
- bool debug_mode;
- REGISTER_VARIABLES()
- {
- SAVE_VARIABLE(script_enabled, 1);
- SAVE_VARIABLE(debug_mode, 2);
- }
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV DISABLED.\n"));
- }
- }
- void Killed(GameObject * obj, GameObject * killer)
- {
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (script_enabled)
- {
- SCRIPT_DEBUG_MESSAGE (("Unit killed with active M00_Trigger_When_Killed_RMV attached.\n"));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV found its target object.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Killed_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_KILLED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV ENABLED.\n"));
- script_enabled = true;
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Destroyed_RMV
- This script triggers when the object it is attached to is destroyed.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Destroyed_RMV, "Start_Now=1:int, Receive_Type=2:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
- {
- bool script_enabled;
- bool debug_mode;
- REGISTER_VARIABLES()
- {
- SAVE_VARIABLE(script_enabled, 1);
- SAVE_VARIABLE(debug_mode, 2);
- }
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV DISABLED.\n"));
- }
- }
- void Destroyed(GameObject * obj)
- {
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (script_enabled)
- {
- SCRIPT_DEBUG_MESSAGE (("Unit destroyed with active M00_Trigger_When_Destroyed_RMV attached.\n"));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV found its target object.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Destroyed_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_DESTROYED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV ENABLED.\n"));
- script_enabled = true;
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Created_RMV
- This script triggers when the object it is attached to is created.
- NOTE that this script has no ability to be enabled/disabled.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Created_RMV, "Target_ID:int, Send_Type:int, Send_Parameter:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
- {
- bool debug_mode;
- REGISTER_VARIABLES()
- {
- SAVE_VARIABLE(debug_mode, 1);
- }
-
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- SCRIPT_DEBUG_MESSAGE (("Unit created with active M00_Trigger_When_Created_RMV attached.\n"));
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Created_RMV found its target object.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Created_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- };
- /*
- Editor Script - M00_Trigger_Zone_Entered_RMV
- This script triggers when the zone it is attached to is entered.
- Parameters:
- Trigger_Count = How many times this trigger will fire.
- Triggerer = Who can activate this trigger.
- Special Information:
- Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
- Values for Trigger_Count: Enter 0 for infinite triggering.
- */
- DECLARE_SCRIPT(M00_Trigger_Zone_Entered_RMV, "Start_Now=1:int, Receive_Type=3:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- bool debug_mode;
- int trigger_count;
-
- typedef enum
- {
- ANYONE,
- COMMANDO,
- NONCOMMANDO
- } EntererType;
- EntererType allowed;
- REGISTER_VARIABLES()
- {
- SAVE_VARIABLE(script_enabled, 1);
- SAVE_VARIABLE(debug_mode, 2);
- SAVE_VARIABLE(trigger_count, 3);
- SAVE_VARIABLE(allowed, 4);
- }
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV DISABLED.\n"));
- }
- }
- void Entered(GameObject * obj, GameObject * enterer)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Zone entered with active M00_Trigger_Zone_Entered_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV has %d triggers remaining.\n", trigger_count));
- }
-
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- int who = Get_Int_Parameter("Triggerer");
- switch (who)
- {
- case (0):
- {
- allowed = ANYONE;
- break;
- }
- case (1):
- {
- allowed = COMMANDO;
- break;
- }
- case (2):
- {
- allowed = NONCOMMANDO;
- break;
- }
- }
-
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
-
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV found its target object.\n"));
- if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if (allowed == ANYONE)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_RMV did not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_Zone_Exited_RMV
- This script triggers when the zone it is attached to is exited.
- Parameters:
- Trigger_Count = How many times this trigger will fire.
- Triggerer = Who can activate this trigger.
- Special Information:
- Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
- Values for Trigger_Count: Enter 0 for infinite triggering.
- */
- DECLARE_SCRIPT(M00_Trigger_Zone_Exited_RMV, "Start_Now=1:int, Receive_Type=4:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- bool debug_mode;
- int trigger_count;
-
- typedef enum
- {
- ANYONE,
- COMMANDO,
- NONCOMMANDO
- } EntererType;
- EntererType allowed;
- REGISTER_VARIABLES()
- {
- SAVE_VARIABLE(script_enabled, 1);
- SAVE_VARIABLE(debug_mode, 2);
- SAVE_VARIABLE(trigger_count, 3);
- SAVE_VARIABLE(allowed, 4);
- }
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV DISABLED.\n"));
- }
- }
- void Exited(GameObject * obj, GameObject * enterer)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Zone exited with active M00_Trigger_Zone_Exited_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV has %d triggers remaining.\n", trigger_count));
- }
-
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- int who = Get_Int_Parameter("Triggerer");
- switch (who)
- {
- case (0):
- {
- allowed = ANYONE;
- break;
- }
- case (1):
- {
- allowed = COMMANDO;
- break;
- }
- case (2):
- {
- allowed = NONCOMMANDO;
- break;
- }
- }
-
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
-
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV found its target object.\n"));
- if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if (allowed == ANYONE)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Exited_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_Zone_Entered_Or_Exited_RMV
- This script triggers when the zone it is attached to is entered or exited.
- Parameters:
- Trigger_Count = How many times this trigger will fire.
- Triggerer = Who can activate this trigger.
- Special Information:
- Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
- Values for Trigger_Count: Enter 0 for infinite triggering.
- */
- DECLARE_SCRIPT(M00_Trigger_Zone_Entered_Or_Exited_RMV, "Start_Now=1:int, Receive_Type=5:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- bool debug_mode;
- int trigger_count;
- typedef enum
- {
- ANYONE,
- COMMANDO,
- NONCOMMANDO
- } EntererType;
- EntererType allowed;
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV DISABLED.\n"));
- }
- }
- void Exited(GameObject * obj, GameObject * enterer)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Zone exited with active M00_Trigger_Zone_Entered_Or_Exited_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV has %d triggers remaining.\n", trigger_count));
- }
-
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- int who = Get_Int_Parameter("Triggerer");
- switch (who)
- {
- case (0):
- {
- allowed = ANYONE;
- break;
- }
- case (1):
- {
- allowed = COMMANDO;
- break;
- }
- case (2):
- {
- allowed = NONCOMMANDO;
- break;
- }
- }
-
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
-
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV found its target object.\n"));
- if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if (allowed == ANYONE)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_Or_Exited_RMV did not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Entered(GameObject * obj, GameObject * enterer)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Zone entered with active M00_Trigger_Zone_Entered_Or_Exited_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV has %d triggers remaining.\n", trigger_count));
- }
-
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- int who = Get_Int_Parameter("Triggerer");
- switch (who)
- {
- case (0):
- {
- allowed = ANYONE;
- break;
- }
- case (1):
- {
- allowed = COMMANDO;
- break;
- }
- case (2):
- {
- allowed = NONCOMMANDO;
- break;
- }
- }
-
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
-
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV found its target object.\n"));
- if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else if (allowed == ANYONE)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_Or_Exited_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Enemy_Seen_RMV
- This script triggers when an enemy is seen.
- Parameters:
- Trigger_Count = How many times this trigger will fire. Enter 0 for infinite.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Enemy_Seen_RMV, "Start_Now=1:int, Receive_Type=6:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Parameter:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- int trigger_count;
- bool debug_mode;
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV DISABLED.\n"));
- }
- }
- void Enemy_Seen(GameObject * obj, GameObject * enemy)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Enemy seen by unit with active M00_Trigger_When_Enemy_Seen_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV has %d triggers remaining.\n", trigger_count));
- }
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV has found its target object.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Enemy_Seen_RMV could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ENEMY_SEEN) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Damaged_RMV
- This script triggers when the unit is damaged.
- Parameters:
- Trigger_Count = How many times this will trigger.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Damaged_RMV, "Start_Now=1:int, Receive_Type=7:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- int trigger_count;
- bool debug_mode;
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV DISABLED.\n"));
- }
- }
- void Damaged(GameObject * obj, GameObject * damager, float amount)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE (("Unit damaged with active M00_Trigger_When_Damaged_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV has %d triggers remaining.\n", trigger_count));
- }
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV found the target object.\n"));
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Damaged_RMV could not find the target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV received custom type %d,param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_DAMAGED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Action_Complete_RMV
- This script triggers when the unit completes any action. It is designed to respond to
- a particular Action ID.
- Parameters:
- Trigger_Count = How many times this will trigger.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Action_Complete_RMV, "Start_Now=1:int, Receive_Type=8:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Action_ID:int, Trigger_Count=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- int trigger_count;
- bool debug_mode;
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV_ENABLED.\n"));
- }
- else
- {
- script_enabled = false;
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV DISABLED.\n"));
- }
- }
- void Action_Complete(GameObject * obj, int action_id)
- {
- if (script_enabled)
- {
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE(("Action complete by unit with active M00_Trigger_When_Action_Complete_RMV attached.\n"));
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV has %d triggers remaining.\n", trigger_count));
- }
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
-
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV found its target object.\n"));
- if (action_id == Get_Int_Parameter("Action_ID"))
- {
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_When_Action_Complete_RMV cannot find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ACTION_COMPLETE) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- /*
- Editor Script - M00_Trigger_When_Animation_Complete_RMV
- This script triggers when the unit completes an animation.
- Parameters:
- Animation_Name = The name of the animation that is completing.
- Trigger_Count = How many times this will trigger.
- */
- DECLARE_SCRIPT(M00_Trigger_When_Animation_Complete_RMV, "Start_Now=1:int, Receive_Type=9:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Animation_Name:string, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
- {
- bool script_enabled;
- int trigger_count;
- bool debug_mode;
- void Created(GameObject * obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (Get_Int_Parameter("Start_Now"))
- {
- script_enabled = true;
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV ENABLED.\n"));
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- void Animation_Complete(GameObject * obj, const char * name)
- {
- if (script_enabled)
- {
- SCRIPT_DEBUG_MESSAGE(("Animation complete by unit with active M00_Trigger_When_Animation_Complete_RMV attached.\n"));
- if (trigger_count == 1)
- {
- script_enabled = false;
- }
- if (trigger_count > 0)
- {
- trigger_count--;
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV has %d triggers remaining.\n", trigger_count));
- }
- int target_id = Get_Int_Parameter("Target_ID");
- float time_low = Get_Float_Parameter("Min_Delay");
- float time_up = Get_Float_Parameter("Max_Delay");
- int param = Get_Int_Parameter("Send_Param");
- int type = Get_Int_Parameter("Send_Type");
- const char *anim = Get_Parameter("Animation_Name");
- GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
- if (target_id > 0)
- {
- target = Commands->Find_Object(target_id);
- }
- if (target)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV found its target object.\n"));
- if (stricmp(anim, name))
- {
- M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_When_Animation_Complete_RMV cannot find its target object, id = %d!\n", target_id));
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ANIMATION_COMPLETE) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV ENABLED.\n"));
- script_enabled = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV DISABLED.\n"));
- script_enabled = false;
- }
- }
- }
- };
- DECLARE_SCRIPT(M00_Trigger_Timer_Expired_RAD, "Start_Now=0:int, Receive_Type=15:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Timer_Min=0.0:float, Timer_Max=1.0:float, Trigger_Count=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
- {
- bool debug_mode;
- bool script_active;
- int trigger_count;
- void Created(GameObject* obj)
- {
- script_active = false;
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- if (Get_Int_Parameter("Start_Now"))
- {
- Start_Now(obj);
- }
- }
- void Start_Now(GameObject* obj)
- {
- script_active = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- if (trigger_count <= 0)
- {
- trigger_count = -1;
- }
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD ENABLED.\n"));
- Set_Timer(obj);
- }
- void Set_Timer(GameObject* obj)
- {
- float timer_min;
- float timer_max;
- float timer_value;
- timer_min = Get_Float_Parameter("Timer_Min");
- timer_max = Get_Float_Parameter("Timer_Max");
- if (timer_max > timer_min)
- {
- timer_value = Commands->Get_Random(timer_min, timer_max);
- }
- else
- {
- timer_value = timer_min;
- }
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD is starting the timer.\n"));
- Commands->Start_Timer (obj, this, timer_value, M00_TIMER_TRIGGER_EXPIRED);
- }
- void Timer_Expired (GameObject * obj, int timer_id)
- {
- SCRIPT_DEBUG_MESSAGE(("A timer has expired on M00_Trigger_Timer_Expired_RAD.\n"));
- if (script_active)
- {
- if (trigger_count > 0)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD has %d triggers remaining.\n", trigger_count));
- trigger_count--;
- }
- if (trigger_count)
- {
- GameObject* target_obj;
- int target_id;
- int min_delay;
- int max_delay;
- int delay_value;
- target_id = Get_Int_Parameter("Target_ID");
- if (timer_id == M00_TIMER_TRIGGER_EXPIRED)
- {
- target_obj = Commands->Find_Object(target_id);
-
- if (target_obj)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD found its target object.\n"));
- min_delay = Get_Float_Parameter("Min_Delay");
- max_delay = Get_Float_Parameter("Max_Delay");
- if (max_delay > min_delay)
- {
- delay_value = Commands->Get_Random(min_delay, max_delay);
- }
- else
- {
- delay_value = min_delay;
- }
- Commands->Send_Custom_Event (obj, target_obj, Get_Int_Parameter("Send_Type"), Get_Int_Parameter("Send_Param"), delay_value);
- }
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD cannot find its target object, id = %d!\n", target_id));
- }
- Set_Timer(obj);
- }
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD received custom type %d, param %d.\n", type, param));
- if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_TIMER_EXPIRED) || (type == Get_Int_Parameter("Receive_Type")))
- {
- if (param == Get_Int_Parameter("Receive_Param_On"))
- {
- script_active = true;
- trigger_count = Get_Int_Parameter("Trigger_Count");
- Start_Now(obj);
- }
- if (param == Get_Int_Parameter("Receive_Param_Off"))
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD DISABLED.\n"));
- script_active = false;
- }
- }
- }
- };
- /*
- Custom Parameter Settings:
- 0 = Turn this state sequence off.
- -1 = Advance to the next state.
- 1+ = Adjust to this particular numbered state.
- */
- DECLARE_SCRIPT(M00_Trigger_State_Sequence_RAD, "Start_Now=0:int, Receive_Type:int, Num_States=2:int, Loop_States=0:int, Send_Type:int, Target_ID:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
- {
- int state_num;
- bool debug_mode;
- void Created(GameObject* obj)
- {
- debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
- state_num = 1;
- if (Get_Int_Parameter("Start_Now"))
- {
- Send_Custom(obj);
- }
- }
- void Custom(GameObject * obj, int type, int param, GameObject * sender)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD received custom type %d, param %d.\n", type, param));
- if (type == Get_Int_Parameter("Receive_Type"))
- {
- if (param < 0)
- {
- // Advance to the next state.
- state_num++;
- if (state_num > Get_Int_Parameter("Num_States"))
- {
- if (Get_Int_Parameter("Loop_States"))
- {
- state_num = 1;
- }
- else
- {
- state_num = 0;
- }
- }
- Send_Custom(obj);
- }
- if (param > 0)
- {
- // Adjust to this numbered state.
- state_num = param;
- if (state_num > Get_Int_Parameter("Num_States"))
- {
- if (Get_Int_Parameter("Loop_States"))
- {
- state_num = 1;
- }
- else
- {
- state_num = 0;
- }
- }
- Send_Custom(obj);
- }
- if (!param)
- {
- // Turn this state engine off.
- state_num = 0;
- }
- }
- }
- void Send_Custom(GameObject* obj)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD is sending its state custom.\n"));
- GameObject* target_obj;
- int target_id;
- float min_delay;
- float max_delay;
- float delay_value;
- if (state_num)
- {
- target_id = Get_Int_Parameter("Target_ID");
- target_obj = Commands->Find_Object(target_id);
- if (target_obj)
- {
- SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD found its target object.\n"));
- min_delay = Get_Float_Parameter("Min_Delay");
- max_delay = Get_Float_Parameter("Max_Delay");
- if (max_delay > min_delay)
- {
- delay_value = Commands->Get_Random(min_delay, max_delay);
- }
- else
- {
- delay_value = min_delay;
- }
- Commands->Send_Custom_Event (obj, target_obj, Get_Int_Parameter("Send_Type"), state_num, delay_value);
- }
- else
- {
- SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_State_Sequence_RAD could not find its target object, id = %d!\n", target_id));
- }
- }
- }
- };
|