Test_BMG.cpp 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  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. *
  22. * DESCRIPTION
  23. *
  24. * PROGRAMMER
  25. * Byon Garrabrant
  26. *
  27. * VERSION INFO
  28. * $Author: Byon_g $
  29. * $Revision: 100 $
  30. * $Modtime: 12/17/01 11:12a $
  31. * $Archive: /Commando/Code/Scripts/Test_BMG.cpp $
  32. *
  33. ******************************************************************************/
  34. #include "scripts.h"
  35. DECLARE_SCRIPT(BMG_Test_Script, "" )
  36. {
  37. void Created(GameObject* obj)
  38. {
  39. Commands->Debug_Message( "BMG Test Script\n" );
  40. // Commands->Start_Timer( obj, this, 5, 0 );
  41. /* ActionParamsStruct params;
  42. params.Set_Basic( this, 80, 0 );
  43. params.Set_Attack( Vector3( 0,0,10 ), 100, 15, 1 );
  44. params.AttackCheckBlocked = false;
  45. Commands->Action_Attack( obj, params );*/
  46. }
  47. void Sound_Heard( GameObject * obj, const CombatSound & sound )
  48. {
  49. Commands->Debug_Message("Heard Sound %d\n", sound.Type );
  50. }
  51. void Timer_Expired( GameObject * obj, int timer_id )
  52. {
  53. Commands->Start_Timer( obj, this, 5, 0 );
  54. GameObject * star = Commands->Get_The_Star();
  55. if ( star ) {
  56. Commands->Clear_Weapons( star );
  57. Commands->Give_PowerUp(star, "POW_LaserRifle_Player");
  58. Commands->Select_Weapon(star, "Weapon_LaserRifle_Player" );
  59. }
  60. }
  61. };
  62. ////////////////////////////////////////////////////////////////////////////////////////////////
  63. ////////////////////////////////////////////////////////////////////////////////////////////////
  64. //////////////////// /////////////////////////////////////////
  65. //////////////////// ALL THE REST ARE COMMENTED OUT /////////////////////////////////////////
  66. //////////////////// /////////////////////////////////////////
  67. ////////////////////////////////////////////////////////////////////////////////////////////////
  68. ////////////////////////////////////////////////////////////////////////////////////////////////
  69. #if 0
  70. DECLARE_SCRIPT(BMG_Toggle_Control, "" )
  71. {
  72. void Created(GameObject* obj)
  73. {
  74. Commands->Debug_Message( "BMG Test Script\n" );
  75. Commands->Start_Timer( obj, this, 3, 0 );
  76. }
  77. void Timer_Expired( GameObject * obj, int timer_id )
  78. {
  79. Commands->Debug_Message( "BMG Test Script\n" );
  80. Commands->Start_Timer( obj, this, 5, timer_id+1 );
  81. GameObject * star = Commands->Get_The_Star();
  82. Commands->Control_Enable( star, ( timer_id & 1 ) );
  83. }
  84. };
  85. DECLARE_SCRIPT(BMG_Test_Enter_Vehicle, "" )
  86. {
  87. void Created(GameObject* obj)
  88. {
  89. Commands->Debug_Message( "BMG Test Script\n" );
  90. Commands->Start_Timer( obj, this, 5, 0 );
  91. }
  92. void Timer_Expired( GameObject * obj, int timer_id )
  93. {
  94. Commands->Debug_Message( "Start Goto\n" );
  95. int priority = 80;
  96. ActionParamsStruct params;
  97. params.Set_Basic( this, priority, 0 );
  98. params.Set_Movement( Vector3( 0.1f, -6.1f, 0 ), 1, 0.2f );
  99. Commands->Action_Goto( obj, params );
  100. }
  101. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  102. {
  103. if ( action_id == 0 ) {
  104. Commands->Debug_Message( "Enter\n" );
  105. int priority = 80;
  106. ActionParamsStruct params;
  107. params.Set_Basic( this, priority, 1 );
  108. params.Set_Movement( Vector3( 2.5f, -6.1f, 0 ), 1, 0.2f );
  109. Commands->Action_Enter_Exit( obj, params );
  110. }
  111. }
  112. };
  113. DECLARE_SCRIPT(BMG_Test_Pogs, "" )
  114. {
  115. void Created(GameObject* obj)
  116. {
  117. Commands->Start_Timer( obj, this, 5, 0 );
  118. }
  119. void Timer_Expired( GameObject * obj, int timer_id )
  120. {
  121. Commands->Debug_Message( "Hello\n" );
  122. Commands->Start_Timer( obj, this, 5, timer_id+1 );
  123. switch( timer_id ) {
  124. case 0:
  125. Commands->Add_Objective( 100, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, IDS_BYON, NULL );
  126. Commands->Set_Objective_Radar_Blip( 100, Vector3( 10, 10, 0 ) );
  127. Commands->Set_Objective_HUD_Info( 100, 100, "HUD_OBJE_ARROW.TGA", IDS_BYON );
  128. break;
  129. case 1:
  130. Commands->Add_Objective( 101, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, IDS_BYON, NULL );
  131. Commands->Set_Objective_Radar_Blip( 101, Vector3( 10, -10, 0 ) );
  132. Commands->Set_Objective_HUD_Info( 101, 101, "HUD_OBJECTIVE.TGA", IDS_BYON );
  133. break;
  134. case 2:
  135. Commands->Set_Objective_Status( 100, OBJECTIVE_STATUS_ACCOMPLISHED );
  136. break;
  137. }
  138. // GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0,0,0));
  139. // Commands->Attach_Script(controller, "Test_Cinematic", "test.txt");
  140. }
  141. };
  142. DECLARE_SCRIPT(BMG_Test_Misc_Script, "" )
  143. {
  144. void Created(GameObject* obj)
  145. {
  146. // GameObject * star = Commands->Get_The_Star();
  147. /* ActionParamsStruct params;
  148. params.Set_Basic( this, 80, 0 );
  149. params.Set_Attack( Vector3( 9.6f,-3.0f,1.9f), 100, 15, 1 );
  150. params.AttackCheckBlocked = false;
  151. Commands->Action_Attack( obj, params );
  152. Commands->Debug_Message( "BMG Test Script %p\n", obj );*/
  153. /*
  154. int priority = 80;
  155. ActionParamsStruct params;
  156. params.Set_Basic( this, priority, 0 );
  157. params.Set_Movement( Vector3( 13,-78,0 ), 1, 1 );
  158. Commands->Action_Goto( obj, params );*/
  159. // Commands->Start_Timer( obj, this, 20, 0 );
  160. // Action_Complete( obj, 1, (ActionCompleteReason)0 );
  161. /* Commands->Debug_Message("Objective Created\n");
  162. Commands->Add_Objective( 300, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, 1000 );
  163. Commands->Set_Objective_Radar_Blip_Object( 300, obj );*/
  164. }
  165. int state;
  166. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  167. {
  168. Commands->Debug_Message( "BMG Complete %p %d\n", obj, complete_reason );
  169. }
  170. void Timer_Expired( GameObject * obj, int timer_id )
  171. {
  172. Commands->Mission_Complete( true );
  173. // Commands->Static_Anim_Phys_Goto_Last_Frame (150047, NULL );
  174. // Commands->Static_Anim_Phys_Goto_Last_Frame (150047, "BASEGATE.BASEGATE" );
  175. // Commands->Static_Anim_Phys_Goto_Frame ( 150047, 31, "BASEGATE.BASEGATE" );
  176. }
  177. void Sound_Heard( GameObject * obj, const CombatSound & sound )
  178. {
  179. Commands->Debug_Message("Heard Sound %d\n", sound.Type );
  180. }
  181. void Damaged( GameObject * obj, GameObject * damager, float amount )
  182. {
  183. GameObject * o = Commands->Create_Object ( "Invisible_Object", Vector3(-90.0f, 50.0f, 0.0f));
  184. Commands->Attach_Script(o, "Test_Cinematic", "X1I_troopdrop02.txt");
  185. }
  186. };
  187. DECLARE_SCRIPT(Start_Script, "" )
  188. {
  189. void Created(GameObject* obj)
  190. {
  191. Commands->Debug_Message( "Start_Script\n" );
  192. }
  193. };
  194. DECLARE_SCRIPT(Respawn_Script, "" )
  195. {
  196. void Created(GameObject* obj)
  197. {
  198. Commands->Debug_Message( "Respawn_Script\n" );
  199. }
  200. };
  201. DECLARE_SCRIPT(BMG_Spray_Shooter, "" )
  202. {
  203. void Created(GameObject* obj)
  204. {
  205. // GameObject * star = Commands->Get_The_Star();
  206. ActionParamsStruct params;
  207. params.Set_Basic( this, 80, 0 );
  208. params.Set_Attack( Vector3( 9.6f,-3.0f,1.9f), 100, 15, 1 );
  209. params.AttackCheckBlocked = false;
  210. Commands->Action_Attack( obj, params );
  211. Commands->Debug_Message( "BMG Test Script %p\n", obj );
  212. /*
  213. int priority = 80;
  214. ActionParamsStruct params;
  215. params.Set_Basic( this, priority, 0 );
  216. params.Set_Movement( Vector3( 13,-78,0 ), 1, 1 );
  217. Commands->Action_Goto( obj, params );*/
  218. // Commands->Start_Timer( obj, this, 20, 0 );
  219. // Action_Complete( obj, 1, (ActionCompleteReason)0 );
  220. /* Commands->Debug_Message("Objective Created\n");
  221. Commands->Add_Objective( 300, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, 1000 );
  222. Commands->Set_Objective_Radar_Blip_Object( 300, obj );*/
  223. }
  224. int state;
  225. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  226. {
  227. Commands->Debug_Message( "BMG Complete %p %d\n", obj, complete_reason );
  228. }
  229. void Timer_Expired( GameObject * obj, int timer_id )
  230. {
  231. Commands->Mission_Complete( true );
  232. // Commands->Static_Anim_Phys_Goto_Last_Frame (150047, NULL );
  233. // Commands->Static_Anim_Phys_Goto_Last_Frame (150047, "BASEGATE.BASEGATE" );
  234. // Commands->Static_Anim_Phys_Goto_Frame ( 150047, 31, "BASEGATE.BASEGATE" );
  235. }
  236. };
  237. DECLARE_SCRIPT(BMG_Monitor_Events, "" )
  238. {
  239. void Created(GameObject* obj)
  240. {
  241. Commands->Debug_Message( "BMG Monitor Events Created\n" );
  242. Commands->Enable_Enemy_Seen( obj, true );
  243. }
  244. virtual void Custom( GameObject * obj, int type, int param, GameObject * sender )
  245. {
  246. switch( type ) {
  247. case CUSTOM_EVENT_VEHICLE_ENTERED:
  248. Commands->Debug_Message("BMG CUSTOM VEHICLE ENTERED %d %d\n", param, Commands->Get_ID( sender ) );
  249. break;
  250. case CUSTOM_EVENT_VEHICLE_EXITED:
  251. Commands->Debug_Message("BMG CUSTOM VEHICLE EXITED %d %d\n", param, Commands->Get_ID( sender ) );
  252. break;
  253. default:
  254. Commands->Debug_Message("BMG CUSTOM %d %d\n", type, param );
  255. break;
  256. }
  257. }
  258. void Enemy_Seen( GameObject * obj, GameObject * enemy )
  259. {
  260. Commands->Debug_Message("BMG ENEMY_SEEN %d\n", Commands->Get_ID( enemy ) );
  261. }
  262. };
  263. DECLARE_SCRIPT(BMG_Test_Powerup, "" )
  264. {
  265. virtual void Custom( GameObject * obj, int type, int param, GameObject * sender )
  266. {
  267. if ( type == CUSTOM_EVENT_POWERUP_GRANTED ) {
  268. Commands->Debug_Message( "POWERUP for %d\n", Commands->Get_ID( sender ) );
  269. }
  270. }
  271. };
  272. DECLARE_SCRIPT(BMG_Test_Walking, "" )
  273. {
  274. int state;
  275. void Created(GameObject* obj)
  276. {
  277. Commands->Debug_Message("BMG Walking\n");
  278. Action_Complete( obj, 1, (ActionCompleteReason)0 );
  279. }
  280. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  281. {
  282. state = !state;
  283. int priority = 80;
  284. ActionParamsStruct params;
  285. params.Set_Basic( this, priority, action_id+1 );
  286. if ( state ) {
  287. params.Set_Movement( Vector3( 7,-3,0 ), 1, 1 );
  288. } else {
  289. params.Set_Movement( Vector3( 10,0,0 ), 1, 1 );
  290. }
  291. params.Set_Attack( Vector3( 20,20,0 ), 100, 1, true );
  292. Commands->Action_Attack( obj, params );
  293. }
  294. };
  295. DECLARE_SCRIPT(BMG_Vehicle_Awareness, "" )
  296. {
  297. void Created(GameObject* obj)
  298. {
  299. Commands->Enable_Enemy_Seen( obj, true );
  300. }
  301. void Sound_Heard( GameObject * obj, const CombatSound & sound )
  302. {
  303. Commands->Debug_Message("Heard\n");
  304. }
  305. void Enemy_Seen( GameObject * obj, GameObject * enemy )
  306. {
  307. Commands->Debug_Message("Seen\n");
  308. }
  309. };
  310. DECLARE_SCRIPT(BMG_Test_Score, "" )
  311. {
  312. void Created(GameObject* obj)
  313. {
  314. Commands->Start_Timer( obj, this, 1, 0 );
  315. }
  316. void Timer_Expired( GameObject * obj, int timer_id )
  317. {
  318. GameObject * star = Commands->Get_A_Star( Vector3(0,0,0) );
  319. if (star) {
  320. Commands->Give_Points( star, 100, 0 );
  321. Commands->Debug_Message("Add Score\n");
  322. }
  323. }
  324. };
  325. DECLARE_SCRIPT(BMG_Test_Flash, "" )
  326. {
  327. void Created(GameObject* obj)
  328. {
  329. Timer_Expired( obj, 0 );
  330. }
  331. void Timer_Expired( GameObject * obj, int timer_id )
  332. {
  333. Commands->Start_Timer( obj, this, 1, timer_id + 1 );
  334. Commands->Set_Is_Rendered( obj, (timer_id & 1) == 0 );
  335. }
  336. };
  337. DECLARE_SCRIPT(BMG_Test_Objective, "" )
  338. {
  339. void Created(GameObject* obj)
  340. {
  341. Commands->Debug_Message("Objective Created\n");
  342. Commands->Add_Objective( 300, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, 1000 );
  343. Commands->Set_Objective_Radar_Blip_Object( 300, obj );
  344. Commands->Start_Timer( obj, this, 6, 0);
  345. }
  346. void Timer_Expired( GameObject * obj, int timer_id )
  347. {
  348. Commands->Debug_Message("Objective Removed\n");
  349. Commands->Remove_Objective( 300 );
  350. }
  351. };
  352. DECLARE_SCRIPT(BMG_Test_Messages, "speed=1.0:float")
  353. {
  354. void Created(GameObject* obj)
  355. {
  356. Commands->Debug_Message("BMG CREATED\n");
  357. }
  358. void Killed( GameObject * obj, GameObject * killer )
  359. {
  360. Commands->Debug_Message("BMG KILLED\n");
  361. }
  362. virtual void Damaged( GameObject * obj, GameObject * damager, float amount )
  363. {
  364. Commands->Debug_Message("BMG DAMAGED\n");
  365. }
  366. virtual void Custom( GameObject * obj, int type, int param, GameObject * sender )
  367. {
  368. Commands->Debug_Message("BMG CUSTOM %d %d\n", type, param );
  369. }
  370. };
  371. DECLARE_SCRIPT(BMG_Test_Anim_Speed, "speed=1.0:float")
  372. {
  373. void Created(GameObject* obj)
  374. {
  375. Timer_Expired( obj, -1 );
  376. }
  377. void Timer_Expired( GameObject * obj, int timer_id )
  378. {
  379. Commands->Start_Timer( obj, this, 3.5, (timer_id+1)&3 );
  380. Vector3 position = Commands->Get_Position( obj );
  381. float speed = Get_Float_Parameter( "speed" );
  382. switch( timer_id ) {
  383. case 0: position += Vector3( speed * 100, 0, 0 ); break;
  384. case 1: position += Vector3( -speed * 100, 0, 0 ); break;
  385. case 2: position += Vector3( 0, speed * 100, 0 ); break;
  386. case 3: position += Vector3( 0, -speed * 100, 0 ); break;
  387. }
  388. ActionParamsStruct params;
  389. params.Set_Basic( this, 80, 0 );
  390. params.Set_Movement( position, speed, 0.5f );
  391. GameObject * star = Commands->Get_A_Star( position );
  392. params.Set_Attack( star, 0.1f, 0, 1 );
  393. Commands->Action_Attack( obj, params );
  394. }
  395. };
  396. DECLARE_SCRIPT( BMG_Test_Radar, "" )
  397. {
  398. void Created( GameObject * obj )
  399. {
  400. Commands->Debug_Message("BMG Test Radar\n");
  401. // Commands->Start_Timer( obj, this, 5, 1 );
  402. // Commands->Start_Timer( obj, this, 10, 2 );
  403. // Commands->Start_Timer( obj, this, 5, 3 );
  404. // Commands->Start_Timer( obj, this, 10, 4 );
  405. // Commands->Start_Timer( obj, this, 15, 5 );
  406. // Commands->Start_Timer( obj, this, 20, 6 );
  407. Commands->Start_Timer( obj, this, 5, 7 );
  408. Commands->Start_Timer( obj, this, 10, 8 );
  409. }
  410. void Timer_Expired( GameObject * obj, int timer_id )
  411. {
  412. switch( timer_id ) {
  413. case 1:
  414. Commands->Debug_Message("BMG Test Radar : Change Color\n");
  415. Commands->Set_Obj_Radar_Blip_Color( obj, RADAR_BLIP_COLOR_GDI );
  416. break;
  417. case 2:
  418. Commands->Debug_Message("BMG Test Radar : Change Shape\n");
  419. Commands->Set_Obj_Radar_Blip_Shape( obj, RADAR_BLIP_SHAPE_VEHICLE );
  420. break;
  421. case 3:
  422. Commands->Debug_Message("BMG Test Radar : Create Objective\n");
  423. Commands->Add_Objective( 6, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, IDS_M04_RescuePrisoners );
  424. break;
  425. case 4:
  426. Commands->Debug_Message("BMG Test Radar : Make Objective Blip\n");
  427. Commands->Set_Objective_Radar_Blip( 6, Vector3( -5, -15, 0 ) );
  428. break;
  429. case 5:
  430. Commands->Debug_Message("BMG Test Radar : Change Objective Priority\n");
  431. Commands->Change_Objective_Type( 6, OBJECTIVE_TYPE_SECONDARY );
  432. break;
  433. case 6:
  434. Commands->Debug_Message("BMG Test Radar : Change Objective Status\n");
  435. Commands->Set_Objective_Status( 6, OBJECTIVE_STATUS_ACCOMPLISHED );
  436. break;
  437. case 7:
  438. Commands->Debug_Message("BMG Test Radar : Create Marker\n");
  439. Commands->Add_Radar_Marker( 9, Vector3( -5, -15, 0 ), RADAR_BLIP_SHAPE_VEHICLE, RADAR_BLIP_COLOR_GDI );
  440. break;
  441. case 8:
  442. Commands->Debug_Message("BMG Test Radar : Delete Marker\n");
  443. Commands->Clear_Radar_Marker( 9 );
  444. break;
  445. }
  446. }
  447. };
  448. DECLARE_SCRIPT( BMG_Test_Animation, "" )
  449. {
  450. void Created( GameObject * obj )
  451. {
  452. Commands->Debug_Message("BMG Test Animation\n");
  453. Timer_Expired( obj, 1 );
  454. }
  455. void Timer_Expired( GameObject * obj, int timer_id )
  456. {
  457. Commands->Start_Timer( obj, this, 1, 1 );
  458. ActionParamsStruct params;
  459. params.Set_Basic( this, 190, 0 );
  460. params.Set_Animation( "S_A_HUMAN.H_A_611A", false );
  461. // Commands->Action_Play_Animation( obj, params );
  462. Commands->Set_Animation( obj, "S_A_HUMAN.H_A_611A", true );
  463. }
  464. };
  465. DECLARE_SCRIPT( BMG_Test_Attack, "" )
  466. {
  467. void Created(GameObject* obj)
  468. {
  469. ActionParamsStruct params;
  470. params.Set_Basic( this, 1000, 1 );
  471. params.Set_Movement( Vector3( 5,5,5 ), 1, 1000 );
  472. params.Set_Attack( Vector3( 5,5,5 ), 1000, 0, 1 );
  473. params.AttackCheckBlocked = false;
  474. Commands->Action_Attack( obj, params );
  475. }
  476. };
  477. DECLARE_SCRIPT( BMG_Test_Damage, "" )
  478. {
  479. void Created(GameObject* obj)
  480. {
  481. Commands->Start_Timer( obj, this, 3, 0 );
  482. }
  483. void Timer_Expired (GameObject* obj, int Timer_ID)
  484. {
  485. Commands->Start_Timer( obj, this, 3, 0 );
  486. Commands->Debug_Message( "BMG_Test_Damage\n" );
  487. Commands->Apply_Damage( obj, 2, "STEEL" );
  488. }
  489. };
  490. DECLARE_SCRIPT( BMG_Test_Save_Load, "" )
  491. {
  492. int Value1;
  493. float Value2;
  494. // Register variables to be Auto-Saved
  495. // All variables must have a unique ID, less than 256, that never changes
  496. REGISTER_VARIABLES()
  497. {
  498. SAVE_VARIABLE( Value1, 1 );
  499. SAVE_VARIABLE( Value2, 2 );
  500. }
  501. void Created( GameObject* obj )
  502. {
  503. Timer_Expired( obj, 1 );
  504. Timer_Expired( obj, 2 );
  505. Value1 = 0;
  506. Value2 = 0.0f;
  507. }
  508. void Timer_Expired( GameObject* obj, int Timer_ID )
  509. {
  510. if ( Timer_ID == 1 ) {
  511. Commands->Debug_Message("BMG_Test_Save_Load: Value1: %d\n", Value1++ );
  512. Commands->Start_Timer( obj, this, 1, Timer_ID );
  513. } else {
  514. Value2 += 0.3333f;
  515. Commands->Debug_Message("BMG_Test_Save_Load: Value2: %f\n", Value2 );
  516. Commands->Start_Timer( obj, this, 1.5f, Timer_ID );
  517. }
  518. }
  519. //*****************************************************************************
  520. #if 0
  521. typedef enum
  522. {
  523. DATA_ID_VALUE1,
  524. DATA_ID_VALUE2,
  525. };
  526. void Save_Data( ScriptSaver & saver )
  527. {
  528. SAVE_BEGIN();
  529. SAVE_DATA( DATA_ID_VALUE1, Value1 );
  530. SAVE_DATA( DATA_ID_VALUE2, Value2 );
  531. SAVE_END();
  532. }
  533. void Load_Data( ScriptLoader & loader )
  534. {
  535. LOAD_BEGIN();
  536. LOAD_DATA( DATA_ID_VALUE1, Value1 );
  537. LOAD_DATA( DATA_ID_VALUE2, Value2 );
  538. LOAD_END();
  539. }
  540. #endif
  541. };
  542. DECLARE_SCRIPT( BMG_Test_Attach, "" )
  543. {
  544. void Created(GameObject* obj)
  545. {
  546. Commands->Start_Timer( obj, this, 3, 0 );
  547. }
  548. void Timer_Expired (GameObject* obj, int Timer_ID)
  549. {
  550. Commands->Debug_Message("BMG_Test_Attach to Commando's HEAD!!!\n" );
  551. GameObject * star = Commands->Get_A_Star( Commands->Get_Position( obj ) );
  552. if ( star != NULL ) {
  553. Commands->Attach_To_Object_Bone( obj, star, "C HEAD" );
  554. }
  555. }
  556. };
  557. DECLARE_SCRIPT( BMG_Test_Spawn, "" )
  558. {
  559. void Created(GameObject* obj)
  560. {
  561. Commands->Start_Timer( obj, this, 5, 0 );
  562. }
  563. void Timer_Expired (GameObject* obj, int Timer_ID)
  564. {
  565. Commands->Start_Timer( obj, this, 5, 0 );
  566. GameObject * spawn = Commands->Trigger_Spawner( 100026, true );
  567. Commands->Debug_Message("BMG_Test_Spawn %p\n", spawn);
  568. }
  569. };
  570. DECLARE_SCRIPT( BMG_Test_Custom, "" )
  571. {
  572. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  573. {
  574. Commands->Debug_Message("BMG Test Custom %d %d\n", type, param );
  575. }
  576. };
  577. DECLARE_SCRIPT(BMG_Test_Running, "" )
  578. {
  579. int state;
  580. void Created(GameObject* obj)
  581. {
  582. Commands->Debug_Message("BMG Running\n");
  583. Action_Complete( obj, 1, (ActionCompleteReason)0 );
  584. }
  585. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  586. {
  587. state = !state;
  588. int priority = 80;
  589. ActionParamsStruct params;
  590. params.Set_Basic( this, priority, action_id+1 );
  591. if ( state ) {
  592. params.Set_Movement( Vector3( 13,-78,0 ), 1, 1 );
  593. } else {
  594. params.Set_Movement( Vector3( 69,-21,0 ), 1, 1 );
  595. }
  596. Commands->Action_Goto( obj, params );
  597. }
  598. };
  599. DECLARE_SCRIPT(BMG_Set_Home, "")
  600. {
  601. void Created(GameObject* obj)
  602. {
  603. Commands->Start_Timer( obj, this, 5, 0 );
  604. }
  605. void Timer_Expired (GameObject* obj, int Timer_ID)
  606. {
  607. Commands->Debug_Message("BMG_Set_Home\n");
  608. Commands->Set_Innate_Soldier_Home_Location( obj, Vector3(0,0,0), 0.5 );
  609. }
  610. };
  611. DECLARE_SCRIPT(BMG_Look_Test, "")
  612. {
  613. void Created(GameObject* obj)
  614. {
  615. Commands->Start_Timer( obj, this, 1, -10 );
  616. }
  617. void Timer_Expired (GameObject* obj, int Timer_ID)
  618. {
  619. Commands->Debug_Message("BMG_Look_Test %d\n", Timer_ID);
  620. ActionParamsStruct params;
  621. params.Set_Basic(this, 100, 100);
  622. if ( Timer_ID >= 12 ) {
  623. Timer_ID = -10;
  624. } else {
  625. Timer_ID += 20;
  626. }
  627. params.Set_Look( Vector3( 0,2,Timer_ID ), 5 );
  628. params.Set_Look( Commands->Get_The_Star(), 5 );
  629. Commands->Start_Timer( obj, this, 10, Timer_ID );
  630. params.Set_Movement( Vector3( Timer_ID,Timer_ID,0 ), 0, 1 );
  631. // params.Set_Movement(p_leader, 1.0f, 1.0f);
  632. Commands->Action_Goto(obj, params);
  633. }
  634. };
  635. DECLARE_SCRIPT(BMG_Timer_Test, "")
  636. {
  637. void Created(GameObject* obj)
  638. {
  639. Commands->Debug_Message("BMG Timer Test Start\n");
  640. Commands->Start_Timer( obj, this, 5, 0 );
  641. }
  642. void Timer_Expired (GameObject* obj, int Timer_ID)
  643. {
  644. Commands->Debug_Message("Difficulty Level is %d\n", Commands->Get_Difficulty_Level() );
  645. Commands->Start_Timer( obj, this, 5, 0 );
  646. }
  647. };
  648. DECLARE_SCRIPT(BMG_Shooter, "")
  649. {
  650. void Created(GameObject* obj)
  651. {
  652. GameObject * target = Commands->Find_Object( 100004 );
  653. if ( target ) {
  654. Commands->Debug_Message("Shooting\n" );
  655. ActionParamsStruct params;
  656. params.Set_Basic( this, 1000, 1 );
  657. params.Set_Movement( target, 1, 1000 );
  658. params.Set_Attack( target, 1000, 0, 1 );
  659. Commands->Action_Attack( obj, params );
  660. }
  661. }
  662. };
  663. DECLARE_SCRIPT(BMG_Test_Display_Text, "" )
  664. {
  665. void Created(GameObject* obj)
  666. {
  667. Commands->Debug_Message( "BMG_Test_Display_Text %s %d %f\n", "Hi", 5, 1.5f );
  668. Commands->Set_Display_Color( 0,0,255 );
  669. Commands->Display_Text( IDS_BYON );
  670. Commands->Display_Float( 1.5f );
  671. Commands->Display_Int( 5 );
  672. Commands->Set_Display_Color();
  673. Commands->Display_Text( IDS_BYON );
  674. Action_Complete( obj, 1, (ActionCompleteReason)0 );
  675. }
  676. };
  677. DECLARE_SCRIPT(BMG_Test_Poked, "" )
  678. {
  679. void Poked( GameObject * obj, GameObject * poker )
  680. {
  681. Commands->Debug_Message_2("BMG_TEST_POKED %p Poked\n", (int)obj);
  682. }
  683. };
  684. DECLARE_SCRIPT(BMG_Test_Running, "" )
  685. {
  686. int state;
  687. void Created(GameObject* obj)
  688. {
  689. Commands->Debug_Message("BMG Running\n");
  690. Action_Complete( obj, 1, (ActionCompleteReason)0 );
  691. }
  692. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  693. {
  694. state = !state;
  695. int priority = 80;
  696. ActionParamsStruct params;
  697. params.Set_Basic( this, priority, action_id+1 );
  698. if ( state ) {
  699. params.Set_Movement( Vector3( 13,-78,0 ), 1, 1 );
  700. } else {
  701. params.Set_Movement( Vector3( 69,-21,0 ), 1, 1 );
  702. }
  703. Commands->Action_Goto( obj, params );
  704. }
  705. };
  706. DECLARE_SCRIPT(BMG_Test_Objectives, "")
  707. {
  708. void Created(GameObject* obj)
  709. {
  710. Commands->Debug_Message("BMG Objectives\n");
  711. Commands->Start_Timer( obj, this, 5, 0 );
  712. Commands->Start_Timer( obj, this, 10, 1 );
  713. Commands->Start_Timer( obj, this, 15, 2 );
  714. Commands->Start_Timer( obj, this, 20, 3 );
  715. Commands->Start_Timer( obj, this, 25, 4 );
  716. Commands->Start_Timer( obj, this, 30, 5 );
  717. }
  718. void Timer_Expired (GameObject* obj, int Timer_ID)
  719. {
  720. switch ( Timer_ID ) {
  721. case 0: Commands->Add_Objective( 100, OBJECTIVE_TYPE_PRIMARY, "Eat Your Vegetables" );
  722. break;
  723. case 1: Commands->Set_Objective_Radar_Blip( 100, Vector3( 10,10,10 ) );
  724. break;
  725. case 2: Commands->Change_Objective_Type( 100, OBJECTIVE_TYPE_SECONDARY );
  726. break;
  727. case 3: Commands->Set_Objective_Status( 100, OBJECTIVE_STATUS_FAILED );
  728. break;
  729. case 4: Commands->Remove_Objective( 100 );
  730. break;
  731. case 5: Commands->Set_Objective_Radar_Blip_Object( 100, obj );
  732. break;
  733. }
  734. }
  735. };
  736. DECLARE_SCRIPT( BMG_Test_Priority_1, "" )
  737. {
  738. void Created( GameObject * obj )
  739. {
  740. Commands->Debug_Message("BMG Test Priority 1\n");
  741. Commands->Start_Timer( obj, this, 2, 100 );
  742. }
  743. void Timer_Expired( GameObject * obj, int timer_id )
  744. {
  745. Commands->Debug_Message_2("BMG Test Priority 1 %d\n", timer_id);
  746. Commands->Send_Custom_Event( obj, obj, 500, 600, 8 );
  747. // Commands->Start_Timer( obj, this, 6, timer_id + 1 );
  748. // Commands->Action_Goto_Location( obj, this, 90, Vector3( 18,5,0 ), 0.3f, 1, 0 );
  749. ActionParamsStruct params;
  750. params.Set_Basic( this, 90, 0 );
  751. params.Set_Animation( "S_A_HUMAN.H_A_611A", false );
  752. Commands->Action_Play_Animation( obj, params );
  753. // Commands->Action_Play_Animation( obj, this, 90, "S_A_HUMAN.H_A_611A", false, 0 );
  754. // Vector3 pos = Commands->Get_Position( Commands->Get_The_Star() );
  755. // Commands->Action_Goto_Location( obj, this, 70, pos, 0.2f, 0.5f, 0 );
  756. }
  757. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  758. {
  759. Commands->Debug_Message_2("BMG Test Priority 1 Complete %d\n", complete_reason );
  760. }
  761. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  762. {
  763. Commands->Debug_Message_2("BMG Test Priority 1 Custom from %p\n", (int)sender );
  764. }
  765. };
  766. DECLARE_SCRIPT( BMG_Test_Priority_2, "" )
  767. {
  768. void Created( GameObject * obj )
  769. {
  770. Commands->Debug_Message("BMG Test Priority 2\n");
  771. Commands->Start_Timer( obj, this, 3, 200 );
  772. }
  773. void Timer_Expired( GameObject * obj, int timer_id )
  774. {
  775. Commands->Debug_Message_2("BMG Test Priority 2 %d\n", timer_id);
  776. Commands->Send_Custom_Event( obj, obj, 700, 800 );
  777. // Commands->Start_Timer( obj, this, 3, timer_id + 1 );
  778. ActionParamsStruct params;
  779. params.Set_Basic( this, 80, 0 );
  780. params.Set_Movement( Vector3( -2,25,0 ), 0.3f, 1 );
  781. Commands->Action_Goto( obj, params );
  782. }
  783. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  784. {
  785. Commands->Debug_Message_2("BMG Test Priority 2 Complete %d\n", complete_reason );
  786. }
  787. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  788. {
  789. Commands->Debug_Message_2("BMG Test Priority 2 Custom from %p\n", (int)sender );
  790. }
  791. };
  792. DECLARE_SCRIPT(BMG_Test_Zone, "")
  793. {
  794. void Entered( GameObject * obj, GameObject * enterer )
  795. {
  796. Commands->Debug_Message("Test Zone Entered\n");
  797. }
  798. void Exited( GameObject * obj, GameObject * exiter )
  799. {
  800. Commands->Debug_Message("Test Zone Exited\n");
  801. }
  802. };
  803. DECLARE_SCRIPT(BMG_Test_Cinematic, "ScriptName=:string")
  804. {
  805. void Created(GameObject* obj)
  806. {
  807. Commands->Debug_Message("BMG Cinematic\n");
  808. Commands->Set_Animation (obj, Get_Parameter("ScriptName"), 1);
  809. Commands->Start_Timer( obj, 5, 0 );
  810. }
  811. void Timer_Expired (GameObject* obj, int Timer_ID)
  812. {
  813. Commands->Debug_Message("BMG Timer\n");
  814. Commands->Start_Timer( obj, 5, 0 );
  815. Vector3 pos = Commands->Get_Position( obj );
  816. Commands->Create_Object_At_Bone( obj, "health 100 standard", "V_LANDGEAR1" );
  817. Commands->Create_Object_At_Bone( obj, "health 100 standard", "SEAT0" );
  818. }
  819. };
  820. DECLARE_SCRIPT(BMG_Test_C130_DropOff_Cinematic, "ObjToCreate=:string")
  821. {
  822. void Created(GameObject* obj)
  823. {
  824. Commands->Debug_Message("BMG_Test_C130_DropOff_Cinematic\n");
  825. Commands->Set_Animation (obj, "v_nod_c-130e3.m_cargo-drop", 0);
  826. float drop_frame = 446;
  827. float drop_time = drop_frame / 30; // find the time assumeing 30fps
  828. Commands->Start_Timer( obj, drop_time, 0 );
  829. }
  830. void Timer_Expired (GameObject* obj, int Timer_ID)
  831. {
  832. Commands->Create_Object_At_Bone( obj, Get_Parameter("ObjToCreate"), "CARGO" );
  833. }
  834. void Animation_Complete(GameObject* obj, const char* name)
  835. {
  836. Commands->Debug_Message("Destroy the C130\n");
  837. Commands->Destroy_Object( obj );
  838. }
  839. void Killed(GameObject* obj, GameObject* killer)
  840. {
  841. Vector3 pos = Commands->Get_Bone_Position( obj, "CARGO" );
  842. Commands->Create_Explosion( "Rocket Explosion", pos, killer );
  843. }
  844. };
  845. DECLARE_SCRIPT(BMG_Test_Orca_Attack_Cinematic, "")
  846. {
  847. enum {
  848. SHOOT,
  849. STOP
  850. };
  851. void Created(GameObject* obj)
  852. {
  853. float shoot_frame = 100;
  854. float shoot_time = shoot_frame / 30; // find the time assumeing 30fps
  855. float stop_frame = 200;
  856. float stop_time = stop_frame / 30; // find the time assumeing 30fps
  857. Commands->Start_Timer( obj, shoot_time, SHOOT );
  858. Commands->Start_Timer( obj, stop_time, STOP );
  859. }
  860. void Timer_Expired (GameObject* obj, int timer_id)
  861. {
  862. if ( timer_id == SHOOT ) {
  863. Commands->Trigger_Weapon( obj, true, Vector3(0,0,0) );
  864. }
  865. if ( timer_id == STOP ) {
  866. Commands->Trigger_Weapon( obj, false, Vector3(0,0,0) );
  867. }
  868. }
  869. };
  870. DECLARE_SCRIPT(BMG_Test_SAPO, "")
  871. {
  872. enum {
  873. OPEN,
  874. CLOSE
  875. };
  876. void Created(GameObject* obj)
  877. {
  878. Commands->Debug_Message("BMG_Test_SAPO\n");
  879. Commands->Start_Timer( obj, 1, OPEN );
  880. }
  881. void Timer_Expired (GameObject* obj, int timer_id)
  882. {
  883. if ( timer_id == OPEN ) {
  884. Commands->Debug_Message("BMG_Test_SAPO OPEN\n");
  885. Commands->Static_Anim_Phys_Goto_Frame( 1051, 0 );
  886. Commands->Start_Timer( obj, 6, CLOSE );
  887. }
  888. if ( timer_id == CLOSE ) {
  889. Commands->Debug_Message("BMG_Test_SAPO CLOSE\n");
  890. Commands->Static_Anim_Phys_Goto_Last_Frame( 1051 );
  891. Commands->Start_Timer( obj, 6, OPEN );
  892. }
  893. }
  894. };
  895. DECLARE_SCRIPT(BMG_Test_Follow, "TargetID=:int")
  896. {
  897. void Created(GameObject* obj)
  898. {
  899. Movement_Complete( obj, (MovementCompleteReason)0 );
  900. }
  901. void Movement_Complete(GameObject* obj, MovementCompleteReason reason)
  902. {
  903. Commands->Debug_Message("BMG Follow\n");
  904. GameObject * target = Commands->Find_Object( Get_Int_Parameter( "TargetID" ) );
  905. if ( target != NULL ) {
  906. Commands->Action_Movement_Follow_Object( obj, target, 1 );
  907. }
  908. }
  909. };
  910. DECLARE_SCRIPT(BMG_Test_Complete, "")
  911. {
  912. void Created(GameObject* obj)
  913. {
  914. Commands->Start_Timer( obj, 3, 0 );
  915. }
  916. void Timer_Expired (GameObject* obj, int timer_id)
  917. {
  918. Commands->Mission_Complete( true );
  919. }
  920. };
  921. DECLARE_SCRIPT(BMG_Test_Debug, "position=3.1 4.2 5.3:vector3")
  922. {
  923. void Created(GameObject* obj)
  924. {
  925. Vector3 pos1 = Get_Vector3_Parameter( 0 );
  926. Vector3 pos2 = Get_Vector3_Parameter( "position" );
  927. Commands->Display_Text("Got1 %f %f %f\n", pos1.X, pos1.Y, pos1.Z );
  928. Commands->Display_Text("Got2 %f %f %f\n", pos2.X, pos2.Y, pos2.Z );
  929. // Commands->Debug_Message("Debug Test 1\n");
  930. // Commands->Display_Text( "Debug Test 2\n" );
  931. // Commands->Display_Text_Colored( Vector3( 0,0,1 ), "Debug Test 3\n" );
  932. // Commands->Start_Timer( obj, 1, 0 );
  933. }
  934. void Timer_Expired (GameObject* obj, int timer_id)
  935. {
  936. }
  937. };
  938. DECLARE_SCRIPT(BMG_Test_Anim, "")
  939. {
  940. void Created(GameObject* obj)
  941. {
  942. Commands->Start_Timer( obj, 0.001f, 0 );
  943. }
  944. void Timer_Expired (GameObject* obj, int timer_id)
  945. {
  946. Commands->Start_Timer( obj, 0.001f, 0 );
  947. Commands->Set_Animation( obj, "S_A_HUMAN.H_A_J99C", true );
  948. }
  949. };
  950. #endif