| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
- /*
- ** 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
- *
- * DESCRIPTION
- *
- * PROGRAMMER
- * Patrick Smith
- *
- * VERSION INFO
- * $Author: Byon_g $
- * $Revision: 31 $
- * $Modtime: 11/29/01 11:05a $
- * $Archive: /Commando/Code/Scripts/Test_PDS.cpp $
- *
- ******************************************************************************/
- #include "scripts.h"
- #include "dprint.h"
- DECLARE_SCRIPT(PDS_Generic_Test, "")
- {
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- return ;
- }
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id == 777) {
- GameObject *star = Commands->Get_The_Star ();
- if (star != NULL) {
- Vector3 pos = Commands->Get_Position (star);
- pos.Z = Commands->Get_Safe_Flight_Height (pos.X, pos.Y);
- Commands->Set_Position (game_obj, pos);
- }
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Modify_Attack, "WaypathID=:int")
- {
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- return ;
- }
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id == 777) {
- Commands->Enable_Engine (game_obj, true);
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
- params.WaypathID = Get_Int_Parameter (0);
- params.WaypathSplined = true;
- params.AttackActive = false;
- params.AttackCheckBlocked = false;
- Commands->Action_Attack (game_obj, params);
- //params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
- //params.AttackCheckBlocked = false;
- //Commands->Action_Attack( game_obj, params );
- //Commands->Action_Goto( game_obj, params );
- Commands->Start_Timer(game_obj, this, 4.0F, 888);
- } else if (timer_id == 888) {
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
- params.WaypathID = Get_Int_Parameter (0);
- params.WaypathSplined = true;
- params.AttackActive = true;
- params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
- params.AttackCheckBlocked = false;
-
- Commands->Modify_Action (game_obj, 777, params);
- Commands->Start_Timer(game_obj, this, 4.0F, 999);
- } else if (timer_id == 999) {
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
- params.WaypathID = Get_Int_Parameter (0);
- params.WaypathSplined = true;
- params.AttackActive = false;
- params.AttackCheckBlocked = false;
- //params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
-
- Commands->Modify_Action (game_obj, 777, params);
- Commands->Start_Timer(game_obj, this, 4.0F, 888);
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Dock, "DockDestObjID=:int,DockEntranceObjID=:int")
- {
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer (game_obj, this, 3.0F, 777);
- return ;
- }
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id != 777) {
- return ;
- }
- //
- // Lookup the objects which mark the destination (docked) position
- // and the entrance to the docking bay
- //
- GameObject *dest_obj = Commands->Find_Object (Get_Int_Parameter (0));
- GameObject *entrance_obj = Commands->Find_Object (Get_Int_Parameter (1));
- if (dest_obj != NULL && entrance_obj != NULL) {
- //
- // Start the vehicle's engine
- //
- //Commands->Enable_Engine (game_obj, true);
-
- //
- // Lookup the positions of the two docking markers
- //
- Vector3 dest_pos = Commands->Get_Position (dest_obj);
- Vector3 entrance_pos = Commands->Get_Position (entrance_obj);
- //
- // Dock the vehicle
- //
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Dock_Vehicle (dest_pos, entrance_pos);
- params.MoveSpeed = 1.0F;
- Commands->Action_Dock (game_obj, params);
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Conversation, "Conversation Name=:string,Soldier1_ID=0:int,Soldier2_ID=0:int,Soldier3_ID=0:int")
- {
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
- {
- //
- // Just for kicks, make the unit crouch
- //
- if (action_id == 778) {
- Commands->Set_Animation (game_obj, "S_A_HUMAN.H_A_A0A0_L08", true);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Custom
- ////////////////////////////////////////////////////////////////////
- void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
- {
- if (event == CUSTOM_EVENT_CONVERSATION_BEGAN) {
- int test = 0;
- test ++;
- } else if (event == CUSTOM_EVENT_CONVERSATION_REMARK_STARTED) {
- int test = 0;
- test ++;
- } else if (event == CUSTOM_EVENT_CONVERSATION_REMARK_ENDED) {
- int test = 0;
- test ++;
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id != 777) {
- return ;
- }
- const char *conv_name = Get_Parameter (0);
- //
- // Create the conversation
- //
- int conv_id = Commands->Create_Conversation (conv_name);
- if (conv_id != -1) {
- int soldier1_id = Get_Int_Parameter (1);
- int soldier2_id = Get_Int_Parameter (2);
- int soldier3_id = Get_Int_Parameter (3);
-
- //
- // Have the participants join the conversation
- //
- Commands->Join_Conversation (game_obj, conv_id, true, true);
- if (soldier1_id == -1) {
- GameObject *soldier = Commands->Get_The_Star ();
- if (soldier != NULL) {
- Commands->Join_Conversation (soldier, conv_id, true, true);
- }
- } else if (soldier1_id != 0) {
- GameObject *soldier = Commands->Find_Object (soldier1_id);
- if (soldier != NULL) {
- Commands->Join_Conversation (soldier, conv_id, true, true);
- }
- }
-
- if (soldier2_id != 0) {
- GameObject *soldier = Commands->Find_Object (soldier2_id);
- if (soldier != NULL) {
- Commands->Join_Conversation (soldier, conv_id, true, true);
- }
- }
-
- if (soldier3_id != 0) {
- GameObject *soldier = Commands->Find_Object (soldier3_id);
- if (soldier != NULL) {
- Commands->Join_Conversation (soldier, conv_id, true, true);
- }
- }
- //
- // Begin the conversation
- //
- Commands->Start_Conversation (conv_id, 778);
- Commands->Monitor_Conversation (game_obj, conv_id);
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Get_In_Vehicle_Do_Waypath, "VehicleID=:int,WaypathID=:int,V3Test=1.3 44.543 0:vector3")
- {
- bool m_StartedWaypath;
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject* game_obj)
- {
- //
- // Find the vehicle we want to get into
- //
- m_StartedWaypath = false;
- GameObject *dest_obj = Commands->Find_Object (Get_Int_Parameter (0));
- if (dest_obj != NULL) {
-
- //
- // Instruct our game object to goto the driver's side of the destination vehicle
- //
- Vector3 pos = Commands->Get_Position (dest_obj);
- // Commands->Action_Movement_Goto_Location (game_obj, pos, 1.0F);
- ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( pos, 1, 1 );
- Commands->Action_Goto( game_obj, params );
- } else {
- DebugPrint ("Error! Cannot find destination for PDS_Get_In_Vehicle_Do_Waypath.\n");
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Movement_Complete
- ////////////////////////////////////////////////////////////////////
- // void Movement_Complete (GameObject *game_obj, MovementCompleteReason /*reason*/)
- void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
- {
- //
- // Now tell the object to follow the waypath
- //
- if (m_StartedWaypath == false) {
- // Commands->Action_Movement_Follow_Waypath (game_obj, Get_Int_Parameter(1), 0, 0, true);
- ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( Vector3(0,0,0), 1, 1 );
- params.WaypathID = Get_Int_Parameter(1);
- Commands->Action_Goto( game_obj, params );
- m_StartedWaypath = true;
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Goto_Player, "")
- {
- void Created(GameObject* game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id != 777) {
- return ;
- }
- ActionParamsStruct params;
- //params.ActionID = 777;
- params.Set_Basic( this, 50, 777 );
- params.Set_Movement( Commands->Get_The_Star (), 1, 2 );
- params.MoveFollow = false;
- Commands->Action_Goto( game_obj, params );
- return ;
- }
- void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
- {
- if (action_id == 777) {
- int test = 0;
- test ++;
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Goto_Loc, "ObjDestID=:int")
- {
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject* game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id != 777) {
- return ;
- }
- //
- // Find the destination 'object'
- //
- GameObject* dest_obj = Commands->Find_Object(Get_Int_Parameter(0));
- if (dest_obj != NULL) {
-
- //
- // Instruct our game object to goto the location of the destination object
- //
- Vector3 pos = Commands->Get_Position(dest_obj);
- // Commands->Action_Movement_Goto_Location(game_obj, pos, 3.0F);
- ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( pos, 0.5F, 3 );
- Commands->Action_Goto( game_obj, params );
- } else {
- DebugPrint("Error! Cannot find destination for PDS_Test_Goto_Loc.\n");
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Follow_Player, "")
- {
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer(game_obj, this, 3.0F, 777);
- return ;
- }
- void Poked( GameObject * obj, GameObject * poker )
- {
- Commands->Grant_Key (obj, 1, true);
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- Commands->Innate_Disable (game_obj);
- // Commands->Action_Movement_Follow_Object (game_obj, Commands->Get_The_Star (), 2.0F);
- /*ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( Commands->Get_The_Star (), 1, 15 );
- //params.Set_Attack( Commands->Get_The_Star (), 100, 15, true );
- //params.Set_Movement( Commands->Get_The_Star (), 1, 15 );
- params.MoveFollow = true;
- Commands->Action_Attack( game_obj, params );*/
- ActionParamsStruct params2;
- params2.Set_Basic( this, 50, 0 );
- params2.Set_Movement( Commands->Get_The_Star (), 1, 5 );
- params2.MoveFollow = true;
- Commands->Action_Goto( game_obj, params2 );
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Follow_Waypath, "WaypathID=:int,WaypointStartID=:int,WaypointEndID=:int")
- {
- void Created (GameObject *game_obj)
- {
- Commands->Grant_Key (game_obj, 0);
- Commands->Grant_Key (game_obj, 1);
- Commands->Grant_Key (game_obj, 2);
- Commands->Grant_Key (game_obj, 3);
- Commands->Grant_Key (game_obj, 4);
- Commands->Grant_Key (game_obj, 5);
- Commands->Grant_Key (game_obj, 6);
- Commands->Grant_Key (game_obj, 7);
- Commands->Enable_Engine (game_obj, true);
- ActionParamsStruct params;
- params.Set_Basic( this, 100, 777 );
- params.Set_Movement( Vector3(0,0,0), 1, 5 );
- params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
-
- params.WaypathID = Get_Int_Parameter(0);
- params.WaypathSplined = true;
- params.AttackActive = false;
- params.AttackCheckBlocked = false;
- Commands->Action_Attack( game_obj, params );
- return ;
- }
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- // Commands->Action_Movement_Follow_Waypath (game_obj, Get_Int_Parameter(0), Get_Int_Parameter(1), Get_Int_Parameter(2), true);
- if (timer_id == 777) {
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
- params.WaypathID = Get_Int_Parameter (0);
- params.WaypathSplined = true;
- params.AttackActive = false;
- params.AttackCheckBlocked = false;
- params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
-
- Commands->Modify_Action (game_obj, 777, params);
- //Commands->Action_Goto( game_obj, params );
- return ;
- }
- }
- void Damaged( GameObject * game_obj, GameObject * damager, float amount )
- {
- ActionParamsStruct params;
- params.Set_Basic (this, 100, 777);
- params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
- params.WaypathID = Get_Int_Parameter (0);
- params.WaypathSplined = true;
- params.AttackActive = true;
- params.AttackCheckBlocked = false;
- params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
-
- Commands->Modify_Action (game_obj, 777, params);
- // attack for a while, then go back to following the waypath
- Commands->Start_Timer(game_obj, this, 5.0F, 777);
- }
- };
- DECLARE_SCRIPT(PDS_Test_Harvester, "TiberiumID=:int,DriveToID=:int,EntranceID=:int,DockID=:int")
- {
- int m_State;
- GameObject * m_GameObj;
- ////////////////////////////////////////////////////////////////////
- // State
- ////////////////////////////////////////////////////////////////////
- enum
- {
- DRIVE_TO_TIBERIUM = 0,
- HARVEST_TIBERIUM,
- DRIVE_TO_REFINERY,
- DOCK_HARVESTER_STEP1,
- DOCK_HARVESTER_STEP2,
- UNLOAD_TIBERIUM,
- MAX_STATE
- };
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- //
- // Initialize variables
- //
- m_State = DRIVE_TO_TIBERIUM;
- m_GameObj = game_obj;
- //
- // Process state
- //
- Think ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *obj, int timer_id)
- {
- if (timer_id == 777) {
- Next_State ();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Movement_Complete
- ////////////////////////////////////////////////////////////////////
- // void Movement_Complete (GameObject *obj, MovementCompleteReason reason)
- void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
- {
- Next_State ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Next_State
- ////////////////////////////////////////////////////////////////////
- void Next_State (void)
- {
- //
- // Move on to the next state
- //
- m_State ++;
- if (m_State == MAX_STATE) {
- m_State = DRIVE_TO_TIBERIUM;
- }
- //
- // Process the new state
- //
- Think ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Think
- ////////////////////////////////////////////////////////////////////
- void Think (void)
- {
- switch (m_State)
- {
- case DRIVE_TO_TIBERIUM:
- Drive_To_Obj (Get_Int_Parameter (0), false);
- break;
- case HARVEST_TIBERIUM:
- Commands->Start_Timer (m_GameObj, this, Commands->Get_Random (3.0F, 6.0F), 777);
- break;
- case DRIVE_TO_REFINERY:
- Drive_To_Obj (Get_Int_Parameter (1), false);
- break;
- case DOCK_HARVESTER_STEP1:
- Drive_To_Obj (Get_Int_Parameter (2), true);
- break;
- case DOCK_HARVESTER_STEP2:
- Drive_To_Obj (Get_Int_Parameter (3), true);
- break;
- case UNLOAD_TIBERIUM:
- Commands->Start_Timer (m_GameObj, this, Commands->Get_Random (2.0F, 4.0F), 777);
- break;
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Drive_To_Obj
- ////////////////////////////////////////////////////////////////////
- void Drive_To_Obj (int obj_id, bool force_backup)
- {
- //
- // Find the destination object
- //
- GameObject* dest_obj = Commands->Find_Object (obj_id);
- if (dest_obj != NULL) {
-
- //
- // Instruct our game object to goto the location of the destination object
- //
- Vector3 pos = Commands->Get_Position (dest_obj);
-
- if (force_backup == false) {
- // Commands->Action_Movement_Goto_Location (m_GameObj, pos, 1.0F);
- ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( pos, 1, 1 );
- Commands->Action_Goto( m_GameObj, params );
- } else {
- // Commands->Action_Movement_Backup_Goto_Location (m_GameObj, pos, 1.0F);
- ActionParamsStruct params;
- params.Set_Basic( this, 50, 0 );
- params.Set_Movement( pos, 1, 1 );
- params.MoveBackup = true;
- Commands->Action_Goto( m_GameObj, params );
- }
- } else {
- DebugPrint("Error! Cannot find destination for PDS_Test_Harvester.\n");
- }
- return ;
- }
- };
- ////////////////////////////////////////////////////////////////////
- // Constants
- ////////////////////////////////////////////////////////////////////
- enum
- {
- INVENTORY_EMPTY = 0,
- INVENTORY_MEDKIT,
- };
- enum
- {
- CUSTOM_HAS_MEDKIT = 0,
- CUSTOM_GOT_OBJECT,
- };
- DECLARE_SCRIPT(PDS_Test_Inventory, "")
- {
- ////////////////////////////////////////////////////////////////////
- // Member data
- ////////////////////////////////////////////////////////////////////
- enum
- {
- INVENTORY_MAX = 4
- };
- int Inventory[INVENTORY_MAX];
-
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- //
- // Clear the inventory
- //
- for (int index = 0; index < INVENTORY_MAX; index ++) {
- Inventory[index] = INVENTORY_MEDKIT;
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Custom
- ////////////////////////////////////////////////////////////////////
- void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
- {
- if (event == CUSTOM_HAS_MEDKIT) {
- int *retval = (int *)data;
- if (retval != NULL) {
- (*retval) = 0;
-
- //
- // Check all the inventory slots for the medkit
- //
- for (int index = 0; index < INVENTORY_MAX; index ++) {
- if (Inventory[index] == INVENTORY_MEDKIT) {
- (*retval) = 1;
- break;
- }
- }
- }
- } else if (event == CUSTOM_GOT_OBJECT) {
-
- //
- // Find an empty slot in the inventory and stick this object into it
- //
- for (int index = 0; index < INVENTORY_MAX; index ++) {
- if (Inventory[index] == INVENTORY_EMPTY) {
- Inventory[index] = data;
- break;
- }
- }
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Bubba, "")
- {
- ////////////////////////////////////////////////////////////////////
- // Member data
- ////////////////////////////////////////////////////////////////////
- GameObject * GameObj;
- int State;
- ////////////////////////////////////////////////////////////////////
- // Constants
- ////////////////////////////////////////////////////////////////////
- enum
- {
- TIMER_GROAN = 444,
- };
- enum
- {
- STATE_DYING = 0,
- STATE_FOLLOWING,
- STATE_CRINGING
- };
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- Commands->Clear_Map_Cell_By_Pos (Commands->Get_Position (game_obj));
- Commands->Clear_Map_Cell (0, 0);
- Commands->Clear_Map_Cell (10, 10);
- Commands->Clear_Map_Cell (19, 19);
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Controller, "")
- {
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- Commands->Start_Timer (game_obj, this, 2.0F, 777);
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id == 777) {
- GameObject *the_player = Commands->Get_The_Star ();
- if (the_player != NULL) {
- Commands->Attach_Script (the_player, "PDS_Test_Inventory", "");
- }
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Gunboat, "")
- {
- ////////////////////////////////////////////////////////////////////
- // Member Data
- ////////////////////////////////////////////////////////////////////
- GameObject *GameObj;
- int State;
- ////////////////////////////////////////////////////////////////////
- // Constants
- ////////////////////////////////////////////////////////////////////
- enum
- {
- TIMER_ATTACK = 777,
- };
- enum
- {
- STATE_AT_BEACHHEAD = 0,
- STATE_AT_INLET,
- STATE_FIGHTING_BIG_GUN,
- STATE_IN_TRANSIT
- };
- ////////////////////////////////////////////////////////////////////
- // Created
- ////////////////////////////////////////////////////////////////////
- void Created (GameObject *game_obj)
- {
- GameObj = game_obj;
- State = STATE_AT_BEACHHEAD;
-
- Move_To_Next_Location ();
- //State = STATE_IN_TRANSIT;
-
- Commands->Enable_Engine (GameObj, true);
- Commands->Disable_All_Collisions (GameObj);
- Start_Attack ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Start_Attack
- ////////////////////////////////////////////////////////////////////
- void Start_Attack (void)
- {
- if (State != STATE_IN_TRANSIT) {
- //Commands->Start_Timer (GameObj, this, Commands->Get_Random (10.0F, 12.0F), TIMER_ATTACK);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Move_To_Next_Location
- ////////////////////////////////////////////////////////////////////
- void Move_To_Next_Location (void)
- {
- int waypath_id = 0;
- switch (State)
- {
- case STATE_AT_BEACHHEAD:
- waypath_id = 100050;
- break;
- case STATE_AT_INLET:
- waypath_id = 0;
- break;
- }
- if (waypath_id != 0) {
-
- ActionParamsStruct params;
- params.WaypathID = waypath_id;
- params.WaypointStartID = 0;
- params.WaypointEndID = 0;
- params.WaypathSplined = true;
- Commands->Action_Goto (GameObj, params);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Timer_Expired
- ////////////////////////////////////////////////////////////////////
- void Timer_Expired (GameObject *game_obj, int timer_id)
- {
- if (timer_id == TIMER_ATTACK) {
- GameObject *the_player = Commands->Get_The_Star ();
- if (the_player != NULL) {
-
- Vector3 pos = Commands->Get_Position (the_player);
- //pos.X += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
- //pos.Y += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
- //pos.Z += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
-
- ActionParamsStruct params;
- params.Set_Basic (this, 50, 0);
- params.Set_Attack (pos, 200, 0, true);
- Commands->Action_Attack (GameObj, params);
- Start_Attack ();
- }
- }
- return ;
- }
- };
- DECLARE_SCRIPT(PDS_Test_Sound, "")
- {
- int SoundID;
- bool IsPlaying;
- void Created (GameObject* game_obj)
- {
- IsPlaying = true;
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Poked
- ////////////////////////////////////////////////////////////////////
- void Poked (GameObject * obj, GameObject * poker)
- {
- if (IsPlaying) {
- Commands->Stop_Sound (1700002, false);
- IsPlaying = false;
- } else {
- Commands->Start_Sound (1700002);
- IsPlaying = true;
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- // Custom
- ////////////////////////////////////////////////////////////////////
- void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
- {
- if (event == CUSTOM_EVENT_SOUND_ENDED && data == SoundID) {
- int test = 0;
- test ++;
- }
- return ;
- }
- };
|