Test_RMV.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * FILE
  21. * Test_RMV.cpp
  22. *
  23. * DESCRIPTION
  24. * Test code location
  25. *
  26. * PROGRAMMER
  27. * Ryan Vervack
  28. *
  29. * VERSION INFO
  30. * $Author: Byon_g $
  31. * $Revision: 154 $
  32. * $Modtime: 11/29/01 11:05a $
  33. * $Archive: /Commando/Code/Scripts/Test_RMV.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "scripts.h"
  37. #include "toolkit.h"
  38. #include "wwmath.h"
  39. #include <string.h>
  40. #include <stdio.h>
  41. #include "mission3.h"
  42. DECLARE_SCRIPT(RMV_Test_Script, "")
  43. {
  44. void Sound_Heard(GameObject * obj, const CombatSound & sound)
  45. {
  46. Commands->Debug_Message("Sound heard.\n");
  47. }
  48. };
  49. DECLARE_SCRIPT(M00_C130_Dropoff_RMV, "ObjToCreate=:string")
  50. {
  51. enum {M00_TIMER_DROP_OBJECT_RMV};
  52. void Created( GameObject * obj )
  53. {
  54. Commands->Set_Animation ( obj, "V_NOD_C-130E3.M_cargo-drop", 0 );
  55. int drop_frame;
  56. drop_frame = 460;
  57. float drop_time;
  58. drop_time= ( float )drop_frame / 30.0;
  59. Commands->Start_Timer( obj, this, drop_time, M00_TIMER_DROP_OBJECT_RMV );
  60. }
  61. void Killed(GameObject * obj, GameObject * killer)
  62. {
  63. Commands->Create_Explosion_At_Bone("C-130 Explosion 01", obj, "BODYMAIN", killer);
  64. }
  65. void Timer_Expired ( GameObject* obj, int Timer_ID )
  66. {
  67. if ( Timer_ID == M00_TIMER_DROP_OBJECT_RMV )
  68. {
  69. GameObject *object;
  70. object = Commands->Create_Object_At_Bone( obj, Get_Parameter( "ObjToCreate" ), "CARGO" );
  71. if (object)
  72. {
  73. //This is where you can manipulate the object, attach scripts, etc.
  74. }
  75. }
  76. }
  77. void Animation_Complete(GameObject * obj, const char *anim)
  78. {
  79. Commands->Destroy_Object(obj);
  80. }
  81. };
  82. DECLARE_SCRIPT(M00_Commando_Death_Taunt, "")
  83. {
  84. void Killed(GameObject * obj, GameObject * killer)
  85. {
  86. if (Commands->Is_A_Star(killer))
  87. {
  88. float random = Commands->Get_Random(1, 20);
  89. switch (int(random))
  90. {
  91. case 1: Commands->Create_Sound("tuffguy1", Vector3(0,0,0), killer);
  92. break;
  93. case 5: Commands->Create_Sound("laugh1", Vector3(0,0,0), killer);
  94. break;
  95. case 10: Commands->Create_Sound("keepem1", Vector3(0,0,0), killer);
  96. break;
  97. case 15: Commands->Create_Sound("lefty1", Vector3(0,0,0), killer);
  98. break;
  99. }
  100. }
  101. }
  102. };
  103. DECLARE_SCRIPT(M00_Damaged_Warning, "")
  104. {
  105. bool just_sent;
  106. REGISTER_VARIABLES()
  107. {
  108. SAVE_VARIABLE( just_sent, 1 );
  109. }
  110. void Created(GameObject * obj)
  111. {
  112. just_sent = false;
  113. }
  114. void Damaged(GameObject * obj, GameObject * damager, float amount)
  115. {
  116. if ((Commands->Get_Health(obj) <= 25.0f) && (!just_sent))
  117. {
  118. Commands->Create_Sound("00-N112E", Vector3(0,0,0), obj);
  119. /* Commands->Set_Display_Color(255,0,0);
  120. Commands->Display_Text(IDS_M00_HEALTH_WARNING);
  121. Commands->Set_Display_Color(); */
  122. just_sent = true;
  123. Commands->Start_Timer(obj, this, 30.0f, 0);
  124. }
  125. }
  126. void Timer_Expired(GameObject * obj, int timer_id)
  127. {
  128. just_sent = false;
  129. }
  130. };
  131. DECLARE_SCRIPT(M00_Put_Script_On_Commando, "")
  132. {
  133. enum {SCRIPT_ON_COMMANDO_TIMER};
  134. void Created(GameObject * obj)
  135. {
  136. Commands->Start_Timer(obj, this, 0.2f, SCRIPT_ON_COMMANDO_TIMER);
  137. }
  138. void Timer_Expired(GameObject * obj, int timer_id)
  139. {
  140. if (timer_id == SCRIPT_ON_COMMANDO_TIMER)
  141. {
  142. GameObject *star;
  143. star = Commands->Get_A_Star(Commands->Get_Position(obj));
  144. if (star)
  145. {
  146. Commands->Attach_Script(star, "M00_Damaged_Warning", "");
  147. }
  148. else
  149. {
  150. Commands->Start_Timer(obj, this, 1.0f, SCRIPT_ON_COMMANDO_TIMER);
  151. }
  152. }
  153. }
  154. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  155. {
  156. if ((type == 12176) && (param == 12176))
  157. {
  158. Commands->Start_Timer(obj, this, 2.0f, SCRIPT_ON_COMMANDO_TIMER);
  159. }
  160. }
  161. };
  162. DECLARE_SCRIPT(RMV_Hostage_Rescue_Point, "")
  163. {
  164. void Entered(GameObject * obj, GameObject * enterer)
  165. {
  166. if (!Commands->Is_A_Star(enterer))
  167. {
  168. Commands->Send_Custom_Event(obj, enterer, 999, 999);
  169. }
  170. }
  171. };
  172. DECLARE_SCRIPT(RMV_Trigger_Killed, "ID:int, Type:int, Param:int")
  173. {
  174. void Killed(GameObject * obj, GameObject * killer)
  175. {
  176. // if (Commands->Is_A_Star(killer))
  177. {
  178. GameObject * target = Commands->Find_Object(Get_Int_Parameter("ID"));
  179. int type = Get_Int_Parameter("Type");
  180. int param = Get_Int_Parameter("Param");
  181. Commands->Send_Custom_Event(obj, target, type, param);
  182. }
  183. }
  184. };
  185. DECLARE_SCRIPT(RMV_Home_Point, "Radius:float")
  186. {
  187. void Created(GameObject * obj)
  188. {
  189. Commands->Set_Innate_Soldier_Home_Location(obj, Commands->Get_Position(obj), Get_Float_Parameter("Radius"));
  190. }
  191. };
  192. DECLARE_SCRIPT(RMV_Test_Facing, "")
  193. {
  194. void Damaged(GameObject * obj, GameObject * damager, float amount)
  195. {
  196. Vector3 my_pos = Commands->Get_Position(obj);
  197. Vector3 target_pos = Commands->Get_Position(damager);
  198. float angle = WWMath::Atan2((my_pos.X - target_pos.X), (my_pos.Y - target_pos.Y));
  199. Commands->Set_Facing(obj, -90.0f - RAD_TO_DEGF(angle));
  200. }
  201. };
  202. DECLARE_SCRIPT(RMV_Camera_Behavior, "Angle:float, Alarm_ID=0:int, Is_Gun=0:int, Delay=0.0:float")
  203. {
  204. int switcher, enemy_id, sound_id;
  205. bool enemy_seen, timer_expired, alert, is_gun, attacking;
  206. REGISTER_VARIABLES()
  207. {
  208. SAVE_VARIABLE(switcher, 1);
  209. SAVE_VARIABLE(enemy_seen, 2);
  210. SAVE_VARIABLE(enemy_id, 3);
  211. SAVE_VARIABLE(timer_expired, 4);
  212. SAVE_VARIABLE(alert, 5);
  213. SAVE_VARIABLE(sound_id, 6);
  214. SAVE_VARIABLE(is_gun, 7);
  215. SAVE_VARIABLE(attacking, 8);
  216. }
  217. Vector3 Get_Target(void)
  218. {
  219. float facing = Commands->Get_Facing(Owner());
  220. Vector3 target = Commands->Get_Position(Owner());
  221. target.X += cos(DEG_TO_RADF(facing)) * 10.0f;
  222. target.Y += sin(DEG_TO_RADF(facing)) * 10.0f;
  223. target.Z -= 0.9f;
  224. float angle = Get_Float_Parameter(0);
  225. angle = WWMath::Clamp(angle, 0.0f, 360.0f);
  226. switch (switcher)
  227. {
  228. case 0: angle /= 2.0f;
  229. break;
  230. case 1: angle /= 4.0f;
  231. break;
  232. case 2: angle = 0.0f;
  233. break;
  234. case 3: angle /= -4.0f;
  235. break;
  236. case 4: angle /= -2.0f;
  237. break;
  238. case 5: angle /= -4.0f;
  239. break;
  240. case 6: angle = 0.0f;
  241. break;
  242. case 7: angle /= 4.0f;
  243. break;
  244. }
  245. target -= Commands->Get_Position(Owner());
  246. target.Rotate_Z(DEG_TO_RADF(angle));
  247. target += Commands->Get_Position(Owner());
  248. return target;
  249. }
  250. Vector3 Get_First_Target(void)
  251. {
  252. float angle = Get_Float_Parameter(0);
  253. float facing = Commands->Get_Facing(Owner());
  254. angle = angle / 2;
  255. Vector3 target = Commands->Get_Position(Owner());
  256. target.X += cos(DEG_TO_RADF(facing)) * 10.0f;
  257. target.Y += sin(DEG_TO_RADF(facing)) * 10.0f;
  258. target.Z -= 1.0f;
  259. target -= Commands->Get_Position(Owner());
  260. target.Rotate_Z(DEG_TO_RADF(angle));
  261. target += Commands->Get_Position(Owner());
  262. return target;
  263. }
  264. void Created(GameObject * obj)
  265. {
  266. switcher = enemy_id = sound_id = 0;
  267. is_gun = (Get_Int_Parameter("Is_Gun") == 1) ? true : false;
  268. enemy_seen = timer_expired = alert = attacking = false;
  269. Commands->Enable_Enemy_Seen(obj);
  270. ActionParamsStruct params;
  271. params.Set_Basic(this, 90, 0);
  272. params.Set_Attack(Get_First_Target(), 0.0f, 0.0f, true);
  273. Commands->Action_Attack(obj, params);
  274. Commands->Start_Timer(obj, this, Get_Int_Parameter(0) / 60.0f, 0);
  275. }
  276. void Resume(void)
  277. {
  278. enemy_id = 0;
  279. enemy_seen = timer_expired = alert = attacking = false;
  280. Commands->Action_Reset(Owner(), 100);
  281. switcher = 0;
  282. }
  283. void Alarm(void)
  284. {
  285. Commands->Stop_Sound(sound_id, true);
  286. if (Get_Int_Parameter("Alarm_ID") != 0)
  287. {
  288. GameObject * alarm = Commands->Find_Object(Get_Int_Parameter("Alarm_ID"));
  289. if (alarm)
  290. {
  291. Commands->Send_Custom_Event(Owner(), alarm, M00_CUSTOM_CAMERA_ALARM, enemy_id);
  292. }
  293. }
  294. enemy_id = 0;
  295. enemy_seen = timer_expired = alert = false;
  296. switcher = 0;
  297. Commands->Action_Reset(Owner(), 100);
  298. }
  299. void Fire(void)
  300. {
  301. Commands->Action_Reset(Owner(), 100);
  302. Commands->Stop_Sound(sound_id, true);
  303. attacking = true;
  304. ActionParamsStruct params;
  305. params.Set_Basic(this, 99, 3);
  306. params.Set_Attack(Commands->Find_Object(enemy_id), 200.0f, 0.0f, true);
  307. Commands->Action_Attack(Owner(), params);
  308. Commands->Start_Timer(Owner(), this, 3.0f, 10);
  309. }
  310. void Timer_Expired(GameObject * obj, int timer_id)
  311. {
  312. if (timer_id == 10)
  313. {
  314. GameObject * enemy = Commands->Find_Object(enemy_id);
  315. if (!Commands->Is_Object_Visible(obj, enemy))
  316. {
  317. enemy_id = 0;
  318. enemy_seen = timer_expired = alert = attacking = false;
  319. switcher = 0;
  320. Commands->Action_Reset(obj, 100);
  321. }
  322. else
  323. {
  324. Commands->Start_Timer(obj, this, 3.0f, 10);
  325. }
  326. }
  327. else if (timer_id == 1)
  328. {
  329. timer_expired = true;
  330. Commands->Start_Timer(obj, this, 2.0f, 2);
  331. }
  332. else if (timer_id == 2)
  333. {
  334. if (!alert)
  335. {
  336. Resume();
  337. }
  338. else
  339. {
  340. is_gun ? Fire() : Alarm();
  341. }
  342. }
  343. else
  344. {
  345. ++switcher %= 8;
  346. ActionParamsStruct params;
  347. params.Set_Basic(this, 90, 0);
  348. params.Set_Attack(Get_Target(), 0.0f, 0.0f, true);
  349. Commands->Action_Attack(obj, params);
  350. Commands->Start_Timer(obj, this, Get_Float_Parameter(0) / 120.0f, 0);
  351. }
  352. }
  353. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  354. {
  355. if (reason != ACTION_COMPLETE_NORMAL)
  356. {
  357. return;
  358. }
  359. if (action_id == 3)
  360. {
  361. enemy_id = 0;
  362. enemy_seen = timer_expired = alert = attacking = false;
  363. switcher = 0;
  364. Commands->Action_Reset(obj, 100);
  365. }
  366. }
  367. void Enemy_Seen(GameObject * obj, GameObject * enemy)
  368. {
  369. if (!enemy_seen && !attacking)
  370. {
  371. Vector3 pos = Commands->Get_Position(obj);
  372. sound_id = Commands->Create_Sound("Beep", pos, obj);
  373. ActionParamsStruct params;
  374. params.Set_Basic(this, 99, 1);
  375. params.Set_Attack(enemy, 0.0f, 0.0f, true);
  376. Commands->Action_Attack(obj, params);
  377. enemy_id = Commands->Get_ID(enemy);
  378. enemy_seen = true;
  379. Commands->Start_Timer(obj, this, Get_Float_Parameter("Delay"), 1);
  380. }
  381. if (enemy_seen && timer_expired && (enemy_id == Commands->Get_ID(enemy)))
  382. {
  383. alert = true;
  384. }
  385. }
  386. void Killed(GameObject * obj, GameObject * killer)
  387. {
  388. Commands->Stop_Sound(sound_id, true);
  389. }
  390. };
  391. DECLARE_SCRIPT(RMV_Cinematic_Position, "Bone:string")
  392. {
  393. void Created(GameObject * obj)
  394. {
  395. Commands->Start_Timer(obj, this, 1.0f, 0);
  396. }
  397. void Timer_Expired(GameObject * obj, int timer_id)
  398. {
  399. const char * bone = Get_Parameter("Bone");
  400. if (bone)
  401. {
  402. Vector3 pos = Commands->Get_Bone_Position(obj, bone);
  403. Commands->Debug_Message("Position of %s bone is (%3.2f, %3.2f, %3.2f).\n", bone, pos.X, pos.Y, pos.Z);
  404. Commands->Start_Timer(obj, this, 1.0f, 0);
  405. }
  406. }
  407. };
  408. DECLARE_SCRIPT(M00_Destroyed_Turret, "")
  409. {
  410. void Killed(GameObject * obj, GameObject * killer)
  411. {
  412. Vector3 my_pos = Commands->Get_Position(obj);
  413. float facing = Commands->Get_Facing(obj);
  414. GameObject * destroyed_turret = Commands->Create_Object("Nod_Turret_Destroyed", my_pos);
  415. Commands->Set_Facing(destroyed_turret, facing);
  416. }
  417. };
  418. DECLARE_SCRIPT(RMV_Engine_Sound, "Preset:string, Bone:string")
  419. {
  420. int sound_id;
  421. REGISTER_VARIABLES()
  422. {
  423. SAVE_VARIABLE(sound_id, 1);
  424. }
  425. void Created(GameObject * obj)
  426. {
  427. const char * sound = Get_Parameter("Preset");
  428. const char * bone = Get_Parameter("Bone");
  429. sound_id = Commands->Create_3D_Sound_At_Bone(sound, obj, bone);
  430. }
  431. void Destroyed(GameObject * obj)
  432. {
  433. Commands->Stop_Sound(sound_id, true);
  434. }
  435. };
  436. DECLARE_SCRIPT(RMV_Transport_Evac, "Number:int, Nod=0:int")
  437. {
  438. int number;
  439. bool loading_complete;
  440. int traj_id, trans_id;
  441. REGISTER_VARIABLES()
  442. {
  443. SAVE_VARIABLE(number, 1);
  444. SAVE_VARIABLE(loading_complete, 2);
  445. SAVE_VARIABLE(traj_id, 3);
  446. SAVE_VARIABLE(trans_id, 4);
  447. }
  448. void Created(GameObject * obj)
  449. {
  450. number = Get_Int_Parameter("Number");
  451. int nod = Get_Int_Parameter("Nod");
  452. loading_complete = false;
  453. GameObject * traj = Commands->Create_Object("Invisible_Object", Commands->Get_Position(obj));
  454. Commands->Set_Model(traj, "XG_TransprtBone");
  455. Commands->Set_Facing(traj, Commands->Get_Facing(obj));
  456. GameObject * transport = Commands->Create_Object("Invisible_Object", Commands->Get_Position(obj));
  457. Commands->Set_Model(transport, (nod == 1) ? "v_NOD_trnspt" : "v_GDI_trnspt");
  458. Commands->Set_Facing(transport, Commands->Get_Facing(obj));
  459. char traj_anim[40];
  460. sprintf(traj_anim, "XG_TransprtBone.XG_EV%d_PathA", number);
  461. char trans_anim[40];
  462. sprintf(trans_anim, "v_%s_trnspt.XG_EV%d_trnsA", (nod == 1) ? "NOD" : "GDI", number);
  463. Commands->Set_Animation(traj, traj_anim, false);
  464. Commands->Set_Animation(transport, trans_anim, false);
  465. Commands->Attach_To_Object_Bone(transport, traj, "BN_Trajectory");
  466. Commands->Start_Timer(obj, this, 280.0f / 30.0f, 0);
  467. traj_id = Commands->Get_ID(traj);
  468. trans_id = Commands->Get_ID(transport);
  469. }
  470. void Timer_Expired(GameObject * obj, int timer_id)
  471. {
  472. GameObject * traj = Commands->Find_Object(traj_id);
  473. GameObject * transport = Commands->Find_Object(trans_id);
  474. int nod = Get_Int_Parameter("Nod");
  475. if (timer_id == 0)
  476. {
  477. char traj_anim[40];
  478. sprintf(traj_anim, "XG_TransprtBone.XG_EV%d_Pathloop", number);
  479. char trans_anim[40];
  480. sprintf(trans_anim, "v_%s_trnspt.XG_EV%d_trnsloop",(nod == 1) ? "NOD" : "GDI", number);
  481. Commands->Set_Animation(traj, traj_anim, false);
  482. Commands->Set_Animation(transport, trans_anim, false);
  483. Commands->Start_Timer(obj, this, 94.0f / 30.0f, 1);
  484. }
  485. else if (timer_id == 1)
  486. {
  487. if (loading_complete)
  488. {
  489. char traj_anim[40];
  490. sprintf(traj_anim, "XG_TransprtBone.XG_EV%d_PathZ", number);
  491. char trans_anim[40];
  492. sprintf(trans_anim, "v_%s_trnspt.XG_EV%d_trnsz", (nod == 1) ? "NOD" : "GDI", number);
  493. Commands->Set_Animation(traj, traj_anim, false);
  494. Commands->Set_Animation(transport, trans_anim, false);
  495. Commands->Start_Timer(obj, this, 231.0f / 30.0f, 2);
  496. }
  497. else
  498. {
  499. char traj_anim[40];
  500. sprintf(traj_anim, "XG_TransprtBone.XG_EV%d_Pathloop", number);
  501. char trans_anim[40];
  502. sprintf(trans_anim, "v_%s_trnspt.XG_EV%d_trnsloop", (nod == 1) ? "NOD" : "GDI", number);
  503. Commands->Set_Animation(traj, traj_anim, false);
  504. Commands->Set_Animation(transport, trans_anim, false);
  505. Commands->Start_Timer(obj, this, 94.0f / 30.0f, 1);
  506. }
  507. }
  508. else if (timer_id == 2)
  509. {
  510. Commands->Destroy_Object(traj);
  511. Commands->Destroy_Object(transport);
  512. Commands->Destroy_Object(obj);
  513. }
  514. }
  515. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  516. {
  517. loading_complete = true;
  518. }
  519. };
  520. DECLARE_SCRIPT(Poke_And_Play_Cinematic, "Text_File:string, Location=0 0 0:vector3")
  521. {
  522. void Poked(GameObject * obj, GameObject * poker)
  523. {
  524. Vector3 pos = Get_Vector3_Parameter("Location");
  525. const char * file = Get_Parameter("Text_File");
  526. GameObject * arrow = Commands->Create_Object("Invisible_Object", pos);
  527. Commands->Attach_Script(arrow, "Test_Cinematic", file);
  528. }
  529. };
  530. DECLARE_SCRIPT(M00_Ion_Cannon_Sound, "Number=0:int")
  531. {
  532. void Created(GameObject * obj)
  533. {
  534. int num = Get_Int_Parameter(0);
  535. Vector3 pos = Commands->Get_Position(obj);
  536. Commands->Create_Sound((num == 0) ? "Ion_Cannon_Buildup" : "Ion_Cannon_Fire", pos, obj);
  537. }
  538. };
  539. DECLARE_SCRIPT(RMV_Trigger_Poked_2, "Target:int, Type:int, Param:int")
  540. {
  541. void Poked(GameObject * obj, GameObject * poker)
  542. {
  543. GameObject * target = Commands->Find_Object(Get_Int_Parameter("Target"));
  544. if (target)
  545. {
  546. Commands->Send_Custom_Event(obj, target, Get_Int_Parameter("Type"), Get_Int_Parameter("Param"));
  547. }
  548. Commands->Destroy_Object(obj);
  549. }
  550. };
  551. DECLARE_SCRIPT(RMV_Test_Damage, "")
  552. {
  553. float total_damage;
  554. float max_shield;
  555. int count;
  556. void Created(GameObject * obj)
  557. {
  558. total_damage = 0.0f;
  559. count = 0;
  560. max_shield = Commands->Get_Shield_Strength(obj);
  561. }
  562. void Damaged(GameObject * obj, GameObject * damager, float amount)
  563. {
  564. count++;
  565. float damage = Commands->Get_Max_Health(obj) - Commands->Get_Health(obj);
  566. Commands->Set_Health(obj, Commands->Get_Max_Health(obj));
  567. total_damage += damage;
  568. bool maxed;
  569. if (damage >= Commands->Get_Max_Health(obj))
  570. {
  571. maxed = true;
  572. }
  573. else
  574. {
  575. maxed = false;
  576. }
  577. Commands->Debug_Message("Object took %3.2f points of damage%s.\n", damage, maxed ? " or more" : "");
  578. }
  579. void Poked(GameObject * obj, GameObject * poker)
  580. {
  581. Commands->Debug_Message("Cumulative damage was %3.2f from %d sources.\n", total_damage, count);
  582. total_damage = 0.0f;
  583. count = 0;
  584. Commands->Set_Shield_Strength(obj, max_shield);
  585. }
  586. };
  587. DECLARE_SCRIPT(RMV_Test_Stealth, "")
  588. {
  589. void Created(GameObject * obj)
  590. {
  591. Commands->Enable_Stealth(obj, true);
  592. }
  593. };