Test_DLS.cpp 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296
  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. #include "scripts.h"
  19. #include "toolkit.h"
  20. #include "Mission7.h"
  21. #include "Mission5.h"
  22. #include <stdio.h>
  23. #include <time.h>
  24. DECLARE_SCRIPT (DLS_SpawnTest, "")
  25. {
  26. bool already_entered;
  27. // Register variables to be Auto-Saved
  28. // All variables must have a unique ID, less than 256, that never changes
  29. REGISTER_VARIABLES()
  30. {
  31. SAVE_VARIABLE( already_entered, 1 );
  32. }
  33. void Created (GameObject * obj)
  34. {
  35. Commands->Enable_Spawner(100002, false);
  36. already_entered = false;
  37. }
  38. void Entered (GameObject * obj, GameObject * enterer)
  39. {
  40. if ((Commands->Is_A_Star(enterer)) && (!already_entered))
  41. {
  42. already_entered = true;
  43. // Commands->Trigger_Spawner(100002);
  44. Commands->Enable_Spawner(100002, true);
  45. }
  46. }
  47. };
  48. DECLARE_SCRIPT (DLS_Spawner, "")
  49. {
  50. // Register variables to be Auto-Saved
  51. // All variables must have a unique ID, less than 256, that never changes
  52. REGISTER_VARIABLES()
  53. {
  54. }
  55. void Created (GameObject * obj)
  56. {
  57. Commands->Enable_Spawner(Commands->Get_ID(obj), false);
  58. }
  59. };
  60. DECLARE_SCRIPT (DLS_Two_Way, "")
  61. {
  62. // Register variables to be Auto-Saved
  63. // All variables must have a unique ID, less than 256, that never changes
  64. REGISTER_VARIABLES()
  65. {
  66. }
  67. void Created (GameObject * obj)
  68. {
  69. ActionParamsStruct params;
  70. params.Set_Basic( this, INNATE_PRIORITY_FOOTSTEPS_HEARD + 5, 10 );
  71. params.Set_Movement( Commands->Find_Object(100001), WALK, 1.5f );
  72. Commands->Action_Goto( obj, params );
  73. }
  74. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  75. {
  76. ActionParamsStruct params;
  77. if((action_id == 10) && (reason == ACTION_COMPLETE_NORMAL))
  78. {
  79. int id = 100000;
  80. params.Set_Basic( this, INNATE_PRIORITY_FOOTSTEPS_HEARD + 5, 11 );
  81. params.Set_Movement( Commands->Find_Object(id), WALK, 1.5f );
  82. Commands->Action_Goto( obj, params );
  83. }
  84. if((action_id == 11) && (reason == ACTION_COMPLETE_NORMAL))
  85. {
  86. int id = 100001;
  87. params.Set_Basic( this, INNATE_PRIORITY_FOOTSTEPS_HEARD + 5, 10 );
  88. params.Set_Movement( Commands->Find_Object(id), WALK, 1.5f );
  89. Commands->Action_Goto( obj, params );
  90. }
  91. }
  92. };
  93. DECLARE_SCRIPT(DLS_Invulnerable_Test, "")
  94. {
  95. bool debug_mode;
  96. int poke_id;
  97. // Register variables to be Auto-Saved
  98. // All variables must have a unique ID, less than 256, that never changes
  99. REGISTER_VARIABLES()
  100. {
  101. SAVE_VARIABLE( debug_mode, 2 );
  102. }
  103. void Created (GameObject * obj)
  104. {
  105. Commands->Set_Health( obj, 2);
  106. Commands->Apply_Damage( obj, 50000.0f, "STEEL");
  107. }
  108. };
  109. DECLARE_SCRIPT(DLS_InnateIsStationary_Test, "")
  110. {
  111. bool debug_mode;
  112. int poke_id;
  113. // Register variables to be Auto-Saved
  114. // All variables must have a unique ID, less than 256, that never changes
  115. REGISTER_VARIABLES()
  116. {
  117. SAVE_VARIABLE( debug_mode, 2 );
  118. }
  119. void Created (GameObject * obj)
  120. {
  121. Commands->Set_Innate_Is_Stationary(obj, true);
  122. }
  123. void Poked(GameObject * obj, GameObject * poker)
  124. {
  125. ActionParamsStruct params;
  126. params.Set_Basic (this, (INNATE_PRIORITY_ENEMY_SEEN + 5), 100755);
  127. params.Set_Movement (STAR, RUN, 2.0f);
  128. params.MoveFollow = true;
  129. Commands->Action_Goto (obj, params);
  130. }
  131. };
  132. DECLARE_SCRIPT(DLS_Camera_Test, "Pan_Loc1_ID=0:int, Pan_Loc2_ID=0:int, Debug_Mode=0:int")
  133. {
  134. bool debug_mode;
  135. int pan_loc1_id;
  136. int pan_loc2_id;
  137. int enemy_id;
  138. int seen_cnt;
  139. int time;
  140. enum {CAMERA_LOC1 = 15, CAMERA_LOC2 = 16, STAR_VISIBLE = 17};
  141. // Register variables to be Auto-Saved
  142. // All variables must have a unique ID, less than 256, that never changes
  143. REGISTER_VARIABLES()
  144. {
  145. SAVE_VARIABLE( debug_mode, 2 );
  146. }
  147. void Created (GameObject * obj)
  148. {
  149. ActionParamsStruct params;
  150. Commands->Enable_Enemy_Seen( obj, true );
  151. pan_loc1_id = Get_Int_Parameter("Pan_Loc1_ID");
  152. pan_loc2_id = Get_Int_Parameter("Pan_Loc2_ID");
  153. enemy_id = 0;
  154. seen_cnt = 0;
  155. time = 0;
  156. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 5, CAMERA_LOC1 );
  157. params.Set_Attack (Commands->Find_Object(pan_loc1_id), 0.0f, 0.0f, 1);
  158. params.AttackCheckBlocked = false;
  159. Commands->Action_Attack( obj, params );
  160. }
  161. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  162. {
  163. ActionParamsStruct params;
  164. if((action_id == CAMERA_LOC1) && (reason == ACTION_COMPLETE_NORMAL))
  165. {
  166. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 5, CAMERA_LOC2 );
  167. params.Set_Attack (Commands->Find_Object(pan_loc2_id), 0.0f, 0.0f, 1);
  168. params.AttackCheckBlocked = false;
  169. Commands->Action_Attack( obj, params );
  170. }
  171. if((action_id == CAMERA_LOC1) && (reason == ACTION_COMPLETE_LOW_PRIORITY))
  172. {
  173. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 5, CAMERA_LOC2 );
  174. params.Set_Attack (Commands->Find_Object(pan_loc2_id), 0.0f, 0.0f, 1);
  175. params.AttackCheckBlocked = false;
  176. Commands->Action_Attack( obj, params );
  177. Commands->Start_Timer (obj, this, 2.0f, STAR_VISIBLE);
  178. }
  179. if((action_id == CAMERA_LOC2) && (reason == ACTION_COMPLETE_NORMAL))
  180. {
  181. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 5, CAMERA_LOC1 );
  182. params.Set_Attack (Commands->Find_Object(pan_loc2_id), 0.0f, 0.0f, 1);
  183. params.AttackCheckBlocked = false;
  184. Commands->Action_Attack( obj, params );
  185. }
  186. }
  187. void Timer_Expired(GameObject * obj, int timer_id )
  188. {
  189. ActionParamsStruct params;
  190. if(timer_id == STAR_VISIBLE)
  191. {
  192. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 5, CAMERA_LOC1 );
  193. params.Set_Attack (Commands->Find_Object(pan_loc2_id), 0.0f, 0.0f, 1);
  194. params.AttackCheckBlocked = false;
  195. Commands->Action_Attack( obj, params );
  196. }
  197. }
  198. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  199. {
  200. ActionParamsStruct params;
  201. enemy_id = Commands->Get_ID(enemy);
  202. SCRIPT_DEBUG_MESSAGE (("Enemy Seen: %d Seen Time: %d.\n", Commands->Get_ID(enemy), time));
  203. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN, 1 );
  204. params.Set_Attack (enemy, 0.0f, 0.0f, 1);
  205. params.AttackCheckBlocked = false;
  206. Commands->Action_Attack( obj, params );
  207. if(seen_cnt < 5)
  208. {
  209. seen_cnt++;
  210. Commands->Create_Sound ("Klaxon Warning", Commands->Get_Position (obj), obj);
  211. Commands->Start_Timer (obj, this, 2.0f, STAR_VISIBLE);
  212. }
  213. else
  214. {
  215. Commands->Create_Sound ("Klaxon", Commands->Get_Position (obj), obj);
  216. }
  217. }
  218. };
  219. DECLARE_SCRIPT(DLS_Gun_Test, "Debug_Mode=0:int")
  220. {
  221. bool debug_mode;
  222. enum {GUN_LOC1, GUN_LOC2};
  223. // Register variables to be Auto-Saved
  224. // All variables must have a unique ID, less than 256, that never changes
  225. REGISTER_VARIABLES()
  226. {
  227. SAVE_VARIABLE( debug_mode, 2 );
  228. }
  229. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  230. {
  231. ActionParamsStruct params;
  232. if(action_id == 666)
  233. {
  234. SCRIPT_DEBUG_MESSAGE (("Action ID: %d ActionCompleteReason: %d.\n", action_id, reason));
  235. }
  236. }
  237. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  238. {
  239. ActionParamsStruct params;
  240. if (type == 666 && param == 666)
  241. {
  242. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1 );
  243. params.Set_Attack (STAR, 250.0f, 0.0f, 1);
  244. params.AttackCheckBlocked = false;
  245. Commands->Action_Attack( obj, params );
  246. }
  247. }
  248. };
  249. DECLARE_SCRIPT(DLS_Test_NULL, "Debug_Mode=0:int")
  250. {
  251. bool debug_mode;
  252. // Register variables to be Auto-Saved
  253. // All variables must have a unique ID, less than 256, that never changes
  254. REGISTER_VARIABLES()
  255. {
  256. SAVE_VARIABLE( debug_mode, 2 );
  257. }
  258. void Created(GameObject * obj)
  259. {
  260. }
  261. void Poked(GameObject * obj, GameObject * poker)
  262. {
  263. const char *conv_name = ("IDS_M06_D05");
  264. int conv_id = Commands->Create_Conversation (conv_name);
  265. Commands->Join_Conversation(NULL, conv_id, false, true);
  266. Commands->Start_Conversation (conv_id, 1);
  267. Commands->Monitor_Conversation (obj, conv_id);
  268. }
  269. };
  270. DECLARE_SCRIPT(DLS_Rappelling_Activate, "Debug_Mode=0:int")
  271. {
  272. bool debug_mode;
  273. bool already_entered;
  274. // Register variables to be Auto-Saved
  275. // All variables must have a unique ID, less than 256, that never changes
  276. REGISTER_VARIABLES()
  277. {
  278. SAVE_VARIABLE( debug_mode, 1 );
  279. SAVE_VARIABLE( already_entered, 2 );
  280. }
  281. void Damaged (GameObject * obj, GameObject * damager, float amount)
  282. {
  283. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  284. Commands->Set_Facing(controller, 0.000f);
  285. Commands->Attach_Script(controller, "Test_Cinematic", "X5C_Wintroops3.txt");
  286. }
  287. };
  288. DECLARE_SCRIPT(DLS_Tank_Path_Test, "Debug_Mode=0:int")
  289. {
  290. bool debug_mode;
  291. enum {STAR_VISIBLE};
  292. // Register variables to be Auto-Saved
  293. // All variables must have a unique ID, less than 256, that never changes
  294. REGISTER_VARIABLES()
  295. {
  296. SAVE_VARIABLE( debug_mode, 1 );
  297. }
  298. void Created (GameObject * obj)
  299. {
  300. Commands->Start_Timer (obj, this, 2.0f, STAR_VISIBLE);
  301. }
  302. void Damaged( GameObject * obj, GameObject * damager, float amount )
  303. {
  304. ActionParamsStruct params;
  305. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1 );
  306. params.Set_Attack (STAR, 200.0f, 5.0f, 0);
  307. params.AttackCheckBlocked = false;
  308. Commands->Action_Attack (obj, params);
  309. }
  310. void Timer_Expired(GameObject * obj, int timer_id )
  311. {
  312. ActionParamsStruct params;
  313. if(timer_id == STAR_VISIBLE)
  314. {
  315. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1 );
  316. params.Set_Attack (STAR, 200.0f, 5.0f, 1);
  317. params.AttackCheckBlocked = false;
  318. Commands->Action_Attack (obj, params);
  319. }
  320. }
  321. };
  322. DECLARE_SCRIPT(DLS_Vehicle_Follow, "Debug_Mode=0:int")
  323. {
  324. bool debug_mode;
  325. enum {STAR_VISIBLE};
  326. // Register variables to be Auto-Saved
  327. // All variables must have a unique ID, less than 256, that never changes
  328. REGISTER_VARIABLES()
  329. {
  330. SAVE_VARIABLE( debug_mode, 1 );
  331. }
  332. void Created (GameObject * obj)
  333. {
  334. Commands->Start_Timer (obj, this, 2.0f, STAR_VISIBLE);
  335. }
  336. void Timer_Expired(GameObject * obj, int timer_id )
  337. {
  338. ActionParamsStruct params;
  339. if(timer_id == STAR_VISIBLE)
  340. {
  341. Commands->Apply_Damage( obj, 100000, "STEEL", NULL );
  342. }
  343. }
  344. };
  345. DECLARE_SCRIPT(DLS_Filing_Cabinet, "Debug_Mode=0:int")
  346. {
  347. bool debug_mode;
  348. bool destroyed_state;
  349. enum {FRAME0, FRAME1, FRAME2, FRAME3, FRAME5, FRAME6, FRAME7, FRAME8, FRAME9};
  350. // Register variables to be Auto-Saved
  351. // All variables must have a unique ID, less than 256, that never changes
  352. REGISTER_VARIABLES()
  353. {
  354. SAVE_VARIABLE( debug_mode, 1 );
  355. }
  356. void Created (GameObject * obj)
  357. {
  358. destroyed_state = false;
  359. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 0);
  360. }
  361. void Damaged (GameObject * obj, GameObject * damager, float amount)
  362. {
  363. if(!destroyed_state)
  364. {
  365. if(Commands->Get_Health(obj) < (Commands->Get_Max_Health(obj) * 3.0f))
  366. {
  367. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 4);
  368. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME5);
  369. destroyed_state = true;
  370. }
  371. else
  372. {
  373. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 1);
  374. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME2);
  375. }
  376. }
  377. }
  378. void Timer_Expired(GameObject * obj, int timer_id )
  379. {
  380. ActionParamsStruct params;
  381. if(timer_id == FRAME0)
  382. {
  383. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 0);
  384. }
  385. if(timer_id == FRAME2)
  386. {
  387. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 2);
  388. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME3);
  389. }
  390. if(timer_id == FRAME3)
  391. {
  392. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 3);
  393. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME0);
  394. }
  395. if(timer_id == FRAME5)
  396. {
  397. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 5);
  398. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME6);
  399. }
  400. if(timer_id == FRAME6)
  401. {
  402. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 6);
  403. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME7);
  404. }
  405. if(timer_id == FRAME7)
  406. {
  407. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 7);
  408. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME8);
  409. }
  410. if(timer_id == FRAME8)
  411. {
  412. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 8);
  413. Commands->Start_Timer (obj, this, (1.0f / 30.0f), FRAME9);
  414. }
  415. if(timer_id == FRAME9)
  416. {
  417. Commands->Set_Animation_Frame(obj, "dsp_lockers.dsp_lockers", 9);
  418. }
  419. }
  420. void Killed (GameObject * obj, GameObject * killer)
  421. {
  422. Commands->Create_Explosion("Small Crate Explosion", Commands->Get_Position(obj), obj);
  423. }
  424. };
  425. DECLARE_SCRIPT(DLS_Waypath_Test, "Debug_Mode=0:int")
  426. {
  427. bool debug_mode;
  428. // Register variables to be Auto-Saved
  429. // All variables must have a unique ID, less than 256, that never changes
  430. REGISTER_VARIABLES()
  431. {
  432. SAVE_VARIABLE( debug_mode, 1 );
  433. }
  434. void Created (GameObject * obj)
  435. {
  436. ActionParamsStruct params;
  437. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 16 );
  438. params.Set_Movement( Vector3(0,0,0), 1.0f, 1.5f );
  439. params.WaypathID = 100001;
  440. params.WaypointStartID = 100002;
  441. params.WaypointEndID = 100009;
  442. params.Set_Attack (Commands->Find_Object(100021), 250.0f, 10.0f, 1);
  443. params.AttackCheckBlocked = false;
  444. Commands->Action_Attack( obj, params );
  445. }
  446. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  447. {
  448. ActionParamsStruct params;
  449. if((action_id == 15) && (reason == ACTION_COMPLETE_NORMAL))
  450. {
  451. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 16 );
  452. params.Set_Movement( Vector3(0,0,0), 1.0f, 1.5f );
  453. params.WaypathID = 100001;
  454. params.WaypointStartID = 100002;
  455. params.WaypointEndID = 100009;
  456. params.Set_Attack (Commands->Find_Object(100021), 250.0f, 10.0f, 1);
  457. params.AttackCheckBlocked = false;
  458. Commands->Action_Attack( obj, params );
  459. }
  460. if((action_id == 16) && (reason == ACTION_COMPLETE_NORMAL))
  461. {
  462. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 15 );
  463. params.Set_Movement( Vector3(0,0,0), 1.0f, 1.5f );
  464. params.WaypathID = 100011;
  465. params.WaypointStartID = 100012;
  466. params.WaypointEndID = 100019;
  467. params.Set_Attack (Commands->Find_Object(100021), 250.0f, 10.0f, 1);
  468. params.AttackCheckBlocked = false;
  469. Commands->Action_Attack( obj, params );
  470. }
  471. }
  472. };
  473. DECLARE_SCRIPT(M06_Camera_Behavior, "Angle:float")
  474. {
  475. int switcher, enemy_id;
  476. bool enemy_seen, timer_expired, alert;
  477. REGISTER_VARIABLES()
  478. {
  479. SAVE_VARIABLE(switcher, 1);
  480. SAVE_VARIABLE(enemy_seen, 2);
  481. SAVE_VARIABLE(enemy_id, 3);
  482. SAVE_VARIABLE(timer_expired, 4);
  483. SAVE_VARIABLE(alert, 5);
  484. }
  485. Vector3 Get_Target(void)
  486. {
  487. float facing = Commands->Get_Facing(Owner());
  488. Vector3 target = Commands->Get_Position(Owner());
  489. target.X += cos(DEG_TO_RADF(facing)) * 10.0f;
  490. target.Y += sin(DEG_TO_RADF(facing)) * 10.0f;
  491. target.Z -= 0.9f;
  492. float angle = Get_Float_Parameter(0);
  493. angle = WWMath::Clamp(angle, 0.0f, 360.0f);
  494. switch (switcher)
  495. {
  496. case 0: angle /= 2.0f;
  497. break;
  498. case 1: angle /= 4.0f;
  499. break;
  500. case 2: angle = 0.0f;
  501. break;
  502. case 3: angle /= -4.0f;
  503. break;
  504. case 4: angle /= -2.0f;
  505. break;
  506. case 5: angle /= -4.0f;
  507. break;
  508. case 6: angle = 0.0f;
  509. break;
  510. case 7: angle /= 4.0f;
  511. break;
  512. }
  513. target -= Commands->Get_Position(Owner());
  514. target.Rotate_Z(DEG_TO_RADF(angle));
  515. target += Commands->Get_Position(Owner());
  516. return target;
  517. }
  518. Vector3 Get_First_Target(void)
  519. {
  520. float angle = Get_Float_Parameter(0);
  521. float facing = Commands->Get_Facing(Owner());
  522. angle = angle / 2;
  523. Vector3 target = Commands->Get_Position(Owner());
  524. target.X += cos(DEG_TO_RADF(facing)) * 10.0f;
  525. target.Y += sin(DEG_TO_RADF(facing)) * 10.0f;
  526. target.Z -= 1.0f;
  527. target -= Commands->Get_Position(Owner());
  528. target.Rotate_Z(DEG_TO_RADF(angle));
  529. target += Commands->Get_Position(Owner());
  530. return target;
  531. }
  532. void Created(GameObject * obj)
  533. {
  534. switcher = enemy_id = 0;
  535. enemy_seen = timer_expired = alert = false;
  536. Commands->Enable_Enemy_Seen(obj);
  537. ActionParamsStruct params;
  538. params.Set_Basic(this, INNATE_PRIORITY_ENEMY_SEEN - 5, 0);
  539. params.Set_Attack(Get_First_Target(), 0.0f, 0.0f, true);
  540. Commands->Action_Attack(obj, params);
  541. Commands->Start_Timer(obj, this, Get_Int_Parameter(0) / 20.0f, 0);
  542. }
  543. void Resume(void)
  544. {
  545. Commands->Debug_Message("**** Enemy lost... resuming.\n");
  546. Commands->Action_Reset(Owner(), INNATE_PRIORITY_ENEMY_SEEN - 5);
  547. enemy_id = 0;
  548. enemy_seen = timer_expired = alert = false;
  549. }
  550. void Alarm(void)
  551. {
  552. // React with lots of violence
  553. Commands->Debug_Message("**** Alarm activated!\n");
  554. enemy_id = 0;
  555. enemy_seen = timer_expired = alert = false;
  556. }
  557. void Timer_Expired(GameObject * obj, int timer_id)
  558. {
  559. if (timer_id == 1)
  560. {
  561. timer_expired = true;
  562. Commands->Start_Timer(obj, this, 2.0f, 2);
  563. }
  564. else if (timer_id == 2)
  565. {
  566. if (!alert)
  567. {
  568. Resume();
  569. }
  570. else
  571. {
  572. Alarm();
  573. }
  574. }
  575. else
  576. {
  577. ++switcher %= 8;
  578. ActionParamsStruct params;
  579. params.Set_Basic(this, INNATE_PRIORITY_ENEMY_SEEN - 5, 0);
  580. params.Set_Attack(Get_Target(), 0.0f, 0.0f, true);
  581. Commands->Action_Attack(obj, params);
  582. Commands->Start_Timer(obj, this, Get_Float_Parameter(0) / 40.0f, 0);
  583. }
  584. }
  585. void Enemy_Seen(GameObject * obj, GameObject * enemy)
  586. {
  587. if (!enemy_seen)
  588. {
  589. Commands->Debug_Message("**** Enemy acquired.\n");
  590. enemy_id = Commands->Get_ID(enemy);
  591. enemy_seen = true;
  592. ActionParamsStruct params;
  593. params.Set_Basic(this, INNATE_PRIORITY_ENEMY_SEEN, 0);
  594. params.Set_Attack(enemy, 0.0f, 0.0f, true);
  595. Commands->Action_Attack(obj, params);
  596. Commands->Start_Timer(obj, this, 2.0f, 1);
  597. }
  598. if (enemy_seen && timer_expired && (enemy_id == Commands->Get_ID(enemy)))
  599. {
  600. Commands->Debug_Message("**** Enemy still seen.\n");
  601. alert = true;
  602. }
  603. }
  604. };
  605. DECLARE_SCRIPT(DLS_Test_Pickup, "Debug_Mode=0:int")
  606. {
  607. bool debug_mode;
  608. bool already_entered;
  609. enum {TROOP_PICKUP1, TROOP_PICKUP2, M06_STOP_PICKUP};
  610. // Register variables to be Auto-Saved
  611. // All variables must have a unique ID, less than 256, that never changes
  612. REGISTER_VARIABLES()
  613. {
  614. SAVE_VARIABLE( debug_mode, 1 );
  615. }
  616. void Created (GameObject * obj)
  617. {
  618. Commands->Start_Timer (obj, this, 0.0f, TROOP_PICKUP1);
  619. already_entered = false;
  620. }
  621. void Timer_Expired(GameObject * obj, int timer_id )
  622. {
  623. ActionParamsStruct params;
  624. if(timer_id == TROOP_PICKUP1 && (!already_entered))
  625. {
  626. float random = Commands->Get_Random(10.0f, 35.0f);
  627. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(1.548f, -3.497f, 3.595f));
  628. Commands->Set_Facing(controller, 45.000f);
  629. Commands->Attach_Script(controller, "Test_Cinematic", "X6I_TroopPickup.txt");
  630. Commands->Start_Timer (obj, this, random, TROOP_PICKUP2);
  631. Commands->Start_Timer (obj, this, random, TROOP_PICKUP1);
  632. }
  633. if(timer_id == TROOP_PICKUP2 && (!already_entered))
  634. {
  635. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(-58.759f, 29.089f, -6.875f));
  636. Commands->Set_Facing(controller, -90.000f);
  637. Commands->Attach_Script(controller, "Test_Cinematic", "X6I_TroopPickup.txt");
  638. }
  639. }
  640. void Entered (GameObject * obj, GameObject * enterer)
  641. {
  642. if ((Commands->Is_A_Star(enterer)) && (!already_entered))
  643. {
  644. already_entered = true;
  645. }
  646. }
  647. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  648. {
  649. ActionParamsStruct params;
  650. if (type == M06_STOP_PICKUP)
  651. {
  652. already_entered = true;
  653. Commands->Send_Custom_Event (obj, Commands->Find_Object(100018), M06_STOP_PICKUP, 1, 0.0f);
  654. Commands->Send_Custom_Event (obj, Commands->Find_Object(100018), M06_STOP_PICKUP, 1, 0.0f);
  655. }
  656. }
  657. };
  658. DECLARE_SCRIPT (DLS_Flame_Tank_Test, "")
  659. {
  660. // Register variables to be Auto-Saved
  661. // All variables must have a unique ID, less than 256, that never changes
  662. REGISTER_VARIABLES()
  663. {
  664. }
  665. void Created (GameObject * obj)
  666. {
  667. ActionParamsStruct params;
  668. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1 );
  669. params.Set_Movement( Commands->Get_Position(obj), WALK, 1.5f );
  670. params.Set_Attack (Commands->Find_Object(100001), 250.0f, 0.0f, true);
  671. params.AttackCheckBlocked = false;
  672. Commands->Action_Attack( obj, params );
  673. }
  674. };
  675. DECLARE_SCRIPT (DLS_Innate_Force_State, "")
  676. {
  677. enum {BULLET_HEARD, FOOTSTEPS_HEARD, GUNSHOTS_HEARD, ENEMY_SEEN};
  678. void Created (GameObject * obj)
  679. {
  680. Commands->Start_Timer (obj, this, 8.0f, FOOTSTEPS_HEARD);
  681. }
  682. void Timer_Expired(GameObject * obj, int timer_id )
  683. {
  684. Vector3 pos = Commands->Get_Position(obj);
  685. if(timer_id == FOOTSTEPS_HEARD)
  686. {
  687. Commands->Action_Reset(obj, 100.0f);
  688. Commands->Innate_Force_State_Footsteps_Heard(obj, pos);
  689. Commands->Start_Timer (obj, this, 5.0f, BULLET_HEARD);
  690. Commands->Debug_Message("**** Innate_Force_State_Footsteps_Heard.\n");
  691. }
  692. if(timer_id == BULLET_HEARD)
  693. {
  694. Commands->Innate_Force_State_Bullet_Heard(obj, pos);
  695. Commands->Start_Timer (obj, this, 5.0f, GUNSHOTS_HEARD);
  696. Commands->Debug_Message("**** Innate_Force_State_Bullet_Heard.\n");
  697. }
  698. if(timer_id == GUNSHOTS_HEARD)
  699. {
  700. Commands->Innate_Force_State_Gunshots_Heard(obj, pos);
  701. Commands->Start_Timer (obj, this, 5.0f, ENEMY_SEEN);
  702. Commands->Debug_Message("**** Innate_Force_State_Gunshots_Heard.\n");
  703. }
  704. if(timer_id == ENEMY_SEEN)
  705. {
  706. Commands->Innate_Force_State_Enemy_Seen(obj, STAR);
  707. Commands->Start_Timer (obj, this, 5.0f, FOOTSTEPS_HEARD);
  708. Commands->Debug_Message("**** Innate_Force_State_Enemy_Seen.\n");
  709. }
  710. }
  711. };
  712. DECLARE_SCRIPT (DLS_Cargo_Plane_Test, "")
  713. {
  714. // Register variables to be Auto-Saved
  715. // All variables must have a unique ID, less than 256, that never changes
  716. REGISTER_VARIABLES()
  717. {
  718. }
  719. void Damaged (GameObject * obj, GameObject * damager, float amount)
  720. {
  721. GameObject * chinook_obj = Commands->Create_Object ( "Invisible_Object", Commands->Get_Position(obj));
  722. Commands->Set_Facing(chinook_obj, 0.0f);
  723. // Commands->Attach_Script(chinook_obj, "Test_Cinematic", "X5D_C130Troopdrop.txt");
  724. Commands->Attach_Script(chinook_obj, "M00_C130_ParaDrop", "Nod_MiniGunner_0");
  725. }
  726. };
  727. DECLARE_SCRIPT(M00_C130_ParaDrop, "Preset:string")
  728. {
  729. int chinook_id;
  730. bool dead;
  731. int out;
  732. REGISTER_VARIABLES()
  733. {
  734. SAVE_VARIABLE(chinook_id, 1);
  735. SAVE_VARIABLE(dead, 2);
  736. SAVE_VARIABLE(out, 3);
  737. }
  738. void Created(GameObject * obj)
  739. {
  740. Vector3 loc = Commands->Get_Position(obj);
  741. float facing = Commands->Get_Facing(obj);
  742. GameObject *chinook_rail = Commands->Create_Object("Generic_Cinematic", loc);
  743. Commands->Set_Model(chinook_rail, "X5D_Chinookfly");
  744. Commands->Set_Facing(chinook_rail, facing);
  745. Commands->Set_Animation(chinook_rail, "X5D_Chinookfly.X5D_Chinookfly", false);
  746. GameObject *chinook = Commands->Create_Object("Nod_Cargo_Plane", loc);
  747. Commands->Set_Facing(chinook, facing);
  748. Commands->Set_Animation(chinook, "vf_nod c-130.vf_nod c130", true);
  749. Commands->Attach_To_Object_Bone(chinook, chinook_rail, "BN_Chinook_1");
  750. dead = false;
  751. out = 0;
  752. char params[10];
  753. sprintf(params, "%d", Commands->Get_ID(obj));
  754. Commands->Attach_Script(chinook, "M00_Reinforcement_C130", params);
  755. chinook_id = Commands->Get_ID(chinook);
  756. // Destroy Chinook
  757. Commands->Start_Timer(obj, this, 280.0f/30.0f, 0);
  758. // Parachutes
  759. Commands->Start_Timer(obj, this, 169.0f/30.0f, 1);
  760. Commands->Start_Timer(obj, this, 179.0f/30.0f, 2);
  761. Commands->Start_Timer(obj, this, 198.0f/30.0f, 3);
  762. // Soldiers
  763. Commands->Start_Timer(obj, this, 145.0f/30.0f, 4);
  764. Commands->Start_Timer(obj, this, 155.0f/30.0f, 5);
  765. Commands->Start_Timer(obj, this, 165.0f/30.0f, 6);
  766. }
  767. void Timer_Expired(GameObject * obj, int timer_id)
  768. {
  769. Vector3 loc = Commands->Get_Position(obj);
  770. const char * preset = Get_Parameter("Preset");
  771. float facing = Commands->Get_Facing(obj);
  772. switch (timer_id)
  773. {
  774. case 0:
  775. GameObject *chinook;
  776. chinook = Commands->Find_Object(chinook_id);
  777. Commands->Destroy_Object(chinook);
  778. break;
  779. case 1:
  780. if (out >= 1)
  781. {
  782. GameObject *para1;
  783. para1 = Commands->Create_Object("Generic_Cinematic", loc);
  784. Commands->Set_Facing(para1, facing);
  785. Commands->Set_Model(para1, "X5D_Parachute");
  786. Commands->Set_Animation(para1, "X5D_Parachute.X5D_ParaC_1", false);
  787. Commands->Create_3D_Sound_At_Bone("parachute_open", para1, "ROOTTRANSFORM");
  788. Commands->Attach_Script(para1, "M03_No_More_Parachute", "");
  789. }
  790. break;
  791. case 2:
  792. if (out >= 2)
  793. {
  794. GameObject *para2;
  795. para2 = Commands->Create_Object("Generic_Cinematic", loc);
  796. Commands->Set_Facing(para2, facing);
  797. Commands->Set_Model(para2, "X5D_Parachute");
  798. Commands->Set_Animation(para2, "X5D_Parachute.X5D_ParaC_2", false);
  799. Commands->Create_3D_Sound_At_Bone("parachute_open", para2, "ROOTTRANSFORM");
  800. Commands->Attach_Script(para2, "M03_No_More_Parachute", "");
  801. }
  802. break;
  803. case 3:
  804. if (out == 3)
  805. {
  806. GameObject *para3;
  807. para3 = Commands->Create_Object("Generic_Cinematic", loc);
  808. Commands->Set_Facing(para3, facing);
  809. Commands->Set_Model(para3, "X5D_Parachute");
  810. Commands->Set_Animation(para3, "X5D_Parachute.X5D_ParaC_3", false);
  811. Commands->Create_3D_Sound_At_Bone("parachute_open", para3, "ROOTTRANSFORM");
  812. Commands->Attach_Script(para3, "M03_No_More_Parachute", "");
  813. }
  814. break;
  815. case 4:
  816. if (!dead)
  817. {
  818. GameObject *box1 = Commands->Create_Object("Generic_Cinematic", loc);
  819. Commands->Set_Model(box1, "X5D_Box01");
  820. Commands->Set_Facing(box1, facing);
  821. Commands->Set_Animation(box1, "X5D_Box01.X5D_Box01", false);
  822. GameObject *soldier1;
  823. soldier1 = Commands->Create_Object_At_Bone(box1, preset, "Box01");
  824. Commands->Set_Facing(soldier1, facing);
  825. Commands->Attach_To_Object_Bone( soldier1, box1, "Box01" );
  826. Commands->Set_Animation(soldier1, "s_a_human.H_A_X5D_ParaT_1", false);
  827. out++;
  828. if ((out - 1) == DIFFICULTY)
  829. {
  830. dead = true;
  831. }
  832. }
  833. break;
  834. case 5:
  835. if (!dead)
  836. {
  837. GameObject *box2 = Commands->Create_Object("Generic_Cinematic", loc);
  838. Commands->Set_Model(box2, "X5D_Box02");
  839. Commands->Set_Facing(box2, facing);
  840. Commands->Set_Animation(box2, "X5D_Box02.X5D_Box02", false);
  841. GameObject *soldier2;
  842. soldier2 = Commands->Create_Object_At_Bone(box2, preset, "Box02");
  843. Commands->Set_Facing(soldier2, facing);
  844. Commands->Set_Animation(soldier2, "s_a_human.H_A_X5D_ParaT_2", false);
  845. Commands->Attach_To_Object_Bone( soldier2, box2, "Box02" );
  846. out++;
  847. if ((out - 1) == DIFFICULTY)
  848. {
  849. dead = true;
  850. }
  851. }
  852. break;
  853. case 6:
  854. if (!dead)
  855. {
  856. GameObject *box3 = Commands->Create_Object("Generic_Cinematic", loc);
  857. Commands->Set_Model(box3, "X5D_Box03");
  858. Commands->Set_Facing(box3, facing);
  859. Commands->Set_Animation(box3, "X5D_Box03.X5D_Box03", false);
  860. GameObject *soldier3;
  861. soldier3 = Commands->Create_Object_At_Bone(box3, preset, "Box03");
  862. Commands->Set_Facing(soldier3, facing);
  863. Commands->Set_Animation(soldier3, "s_a_human.H_A_X5D_ParaT_3", false);
  864. Commands->Attach_To_Object_Bone( soldier3, box3, "Box03" );
  865. out++;
  866. if ((out - 1) == DIFFICULTY)
  867. {
  868. dead = true;
  869. }
  870. }
  871. break;
  872. }
  873. }
  874. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  875. {
  876. if (type == 23000 && param == 23000)
  877. {
  878. dead = true;
  879. }
  880. }
  881. };
  882. DECLARE_SCRIPT(M00_Reinforcement_C130, "Controller_ID:int")
  883. {
  884. int sound_id;
  885. REGISTER_VARIABLES()
  886. {
  887. SAVE_VARIABLE(sound_id, 1);
  888. }
  889. void Created(GameObject * obj)
  890. {
  891. sound_id = Commands->Create_3D_Sound_At_Bone("C130_Idle_01", obj, "BODYMAIN");
  892. }
  893. void Killed(GameObject * obj, GameObject * killer)
  894. {
  895. GameObject * con = Commands->Find_Object(Get_Int_Parameter(0));
  896. Commands->Send_Custom_Event(obj, con, 23000, 23000);
  897. Commands->Stop_Sound(sound_id, true);
  898. }
  899. };
  900. DECLARE_SCRIPT(DLS_Test_Conversation, "Debug_Mode=0:int")
  901. {
  902. bool debug_mode;
  903. void Created(GameObject * obj)
  904. {
  905. Commands->Set_Innate_Is_Stationary(obj, true);
  906. }
  907. void Poked(GameObject * obj, GameObject * poker)
  908. {
  909. const char *conv_name = ("IDS_M00_Test");
  910. int conv_id = Commands->Create_Conversation (conv_name);
  911. Commands->Join_Conversation(Commands->Get_A_Star(Commands->Get_Position(obj)), conv_id, false, true);
  912. Commands->Join_Conversation(obj, conv_id, false, true);
  913. Commands->Start_Conversation (conv_id, 300001);
  914. Commands->Monitor_Conversation (obj, conv_id);
  915. }
  916. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  917. {
  918. SCRIPT_DEBUG_MESSAGE (("Action_Complete action_id %d reason %d.\n", action_id, reason));
  919. }
  920. };
  921. DECLARE_SCRIPT(DLS_Test_Zone_Timer, "Debug_Mode=0:int")
  922. {
  923. bool debug_mode;
  924. void Created (GameObject * obj)
  925. {
  926. SCRIPT_DEBUG_MESSAGE (("DLS_Test_Zone_Timer Created.\n"));
  927. Commands->Enable_Hibernation(obj, false);
  928. Commands->Start_Timer(obj, this, 1.0f, 666);
  929. }
  930. void Timer_Expired(GameObject * obj, int timer_id )
  931. {
  932. SCRIPT_DEBUG_MESSAGE (("Timer_Expired on DLS_Test_Zone_Timer timer_id: %d.\n", timer_id));
  933. Commands->Start_Timer(obj, this, 1.0f, 666);
  934. }
  935. };
  936. DECLARE_SCRIPT(DLS_Drop_Unit, "Box_ID:int")
  937. {
  938. void Damaged (GameObject * obj, GameObject * damager, float amount)
  939. {
  940. int box_id = Get_Int_Parameter("Box_ID");
  941. switch(box_id)
  942. {
  943. case 1:
  944. {
  945. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  946. Commands->Set_Facing(controller, 0.000f);
  947. Commands->Attach_Script(controller, "Test_Cinematic", "No_Definition.txt");
  948. }
  949. break;
  950. case 2:
  951. {
  952. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  953. Commands->Set_Facing(controller, 0.000f);
  954. Commands->Attach_Script(controller, "Test_Cinematic", "No_Definition2.txt");
  955. }
  956. break;
  957. }
  958. }
  959. };
  960. DECLARE_SCRIPT(DLS_CNC_Sound, "Box_ID:int")
  961. {
  962. void Damaged (GameObject * obj, GameObject * damager, float amount)
  963. {
  964. Commands->Create_Sound ( "CnC_Healer_Sound", Commands->Get_Position(obj), obj );
  965. }
  966. };
  967. DECLARE_SCRIPT(DLS_Spawn_Engineer, "")
  968. {
  969. void Damaged (GameObject * obj, GameObject * damager, float amount)
  970. {
  971. Commands->Set_Health(obj, Commands->Get_Max_Health(obj));
  972. Commands->Enable_Spawner(100001, true);
  973. }
  974. };
  975. DECLARE_SCRIPT(DLS_Spawn_Engineer2, "")
  976. {
  977. void Damaged (GameObject * obj, GameObject * damager, float amount)
  978. {
  979. Commands->Set_Health(obj, Commands->Get_Max_Health(obj));
  980. Commands->Enable_Spawner(100001, false);
  981. }
  982. };
  983. DECLARE_SCRIPT(DLS_Test_Homepoint, "")
  984. {
  985. void Created (GameObject * obj)
  986. {
  987. Commands->Set_Innate_Soldier_Home_Location(obj, Commands->Get_Position(obj), 2.0f);
  988. }
  989. };
  990. DECLARE_SCRIPT (DLS_Test_Apache, "")
  991. {
  992. void Created (GameObject *obj)
  993. {
  994. ActionParamsStruct params;
  995. params.Set_Basic( this, 100, 10 );
  996. params.Set_Movement( Vector3(0,0,0), 1.0f, 2.0f );
  997. params.WaypathID = 2000222;
  998. params.WaypathSplined = true;
  999. Commands->Action_Goto( obj, params );
  1000. }
  1001. };
  1002. DECLARE_SCRIPT (DLS_Test_Tank, "")
  1003. {
  1004. void Created (GameObject *obj)
  1005. {
  1006. ActionParamsStruct params;
  1007. params.Set_Basic( this, 100, 10 );
  1008. params.Set_Movement( Vector3(0,0,0), 1.0f, 2.0f );
  1009. params.WaypathID = 100002;
  1010. params.WaypathSplined = true;
  1011. Commands->Action_Goto( obj, params );
  1012. }
  1013. };
  1014. DECLARE_SCRIPT (DLS_Goto_Unit, "")
  1015. {
  1016. enum{GO_STAR};
  1017. void Created (GameObject *obj)
  1018. {
  1019. ActionParamsStruct params;
  1020. Commands->Start_Timer (obj, this, 5.0f, GO_STAR);
  1021. }
  1022. void Timer_Expired(GameObject * obj, int timer_id )
  1023. {
  1024. ActionParamsStruct params;
  1025. if(timer_id == GO_STAR)
  1026. {
  1027. params.Set_Basic( this, 100, 10 );
  1028. params.Set_Movement( STAR, 1.0f, 2.0f );
  1029. Commands->Action_Goto( obj, params );
  1030. }
  1031. }
  1032. };
  1033. DECLARE_SCRIPT (DLS_Playertype, "")
  1034. {
  1035. void Created (GameObject *obj)
  1036. {
  1037. }
  1038. void Poked(GameObject * obj, GameObject * poker)
  1039. {
  1040. Commands->Set_Player_Type(obj, SCRIPT_PLAYERTYPE_GDI );
  1041. Commands->Give_PowerUp(obj, "MG Weapon 1 Clip PowerUp");
  1042. Commands->Give_PowerUp(obj, "MiniGun 2 Clips PU");
  1043. }
  1044. };
  1045. DECLARE_SCRIPT (DLS_No_Innate, "")
  1046. {
  1047. void Created (GameObject *obj)
  1048. {
  1049. Commands->Innate_Disable(obj);
  1050. }
  1051. };
  1052. DECLARE_SCRIPT(DLS_ActionComplete_Test, "")
  1053. {
  1054. void Created (GameObject * obj)
  1055. {
  1056. ActionParamsStruct params;
  1057. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 16 );
  1058. params.Set_Movement( Vector3(0,0,0), 1.0f, 1.5f );
  1059. params.WaypathID = 100001;
  1060. Commands->Action_Goto( obj, params );
  1061. }
  1062. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  1063. {
  1064. Commands->Debug_Message("Action_Complete %d %d. \n", action_id, reason);
  1065. }
  1066. };
  1067. DECLARE_SCRIPT(DLS_Artillery_Test, "")
  1068. {
  1069. int artillery_loc[2];
  1070. enum{ARTILLERY_DROP};
  1071. // Register variables to be Auto-Saved
  1072. // All variables must have a unique ID, less than 256, that never changes
  1073. REGISTER_VARIABLES()
  1074. {
  1075. // SAVE_VARIABLE( poke_id, 1 );
  1076. }
  1077. void Created (GameObject *game_obj)
  1078. {
  1079. artillery_loc[0] = 100600;
  1080. artillery_loc[1] = 100601;
  1081. Commands->Start_Timer(game_obj, this, 10.0F, ARTILLERY_DROP);
  1082. }
  1083. void Timer_Expired (GameObject *game_obj, int timer_id)
  1084. {
  1085. if (timer_id == ARTILLERY_DROP)
  1086. {
  1087. }
  1088. return ;
  1089. }
  1090. };
  1091. DECLARE_SCRIPT(DLS_Cinematic_Test, "")
  1092. {
  1093. void Created (GameObject * obj)
  1094. {
  1095. /* Commands->Enable_Hibernation(obj, false);
  1096. Commands->Set_Player_Type(obj, PLAYERTYPE_NEUTRAL );
  1097. Commands->Create_Object ( "XG_TransprtBone", Vector3(0.0f, 0.0f, 0.0f));*/
  1098. }
  1099. void Damaged( GameObject * obj, GameObject * damager, float amount )
  1100. {
  1101. /* GameObject * chinook_obj0 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1102. Commands->Set_Facing(chinook_obj0, 0.0f);
  1103. Commands->Attach_Script(chinook_obj0, "Test_Cinematic", "X7A_TrnsptCt_00.txt");
  1104. GameObject * chinook_obj1 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1105. Commands->Set_Facing(chinook_obj1, 0.0f);
  1106. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X7A_TrnsptCt_01.txt");*/
  1107. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1108. Commands->Set_Facing(chinook_obj2, 0.0f);
  1109. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "XG_EV5.txt");
  1110. /* GameObject * nukebits = Commands->Create_Object("M07_Nukebits", Vector3(0.0f, 0.0f, 0.0f));
  1111. Commands->Set_Facing( nukebits, -10.000f );*/
  1112. // GameObject * napc = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1113. // Commands->Set_Model(napc, "e_chopperdust1");
  1114. /* Commands->Send_Custom_Event(obj, Commands->Find_Object(100001), M07_EVAC_INN, 1, 0.0f);
  1115. Commands->Enable_Spawner(100002, true);
  1116. Commands->Enable_Spawner(100004, true);
  1117. Commands->Enable_Spawner(100005, true);
  1118. Commands->Enable_Spawner(100006, true);
  1119. Commands->Enable_Spawner(100007, true);*/
  1120. }
  1121. };
  1122. DECLARE_SCRIPT(DLS_SSM_Test, "")
  1123. {
  1124. int ssm_missile_id;
  1125. void Created (GameObject * obj)
  1126. {
  1127. GameObject * ssm_missile = Commands->Create_Object_At_Bone(obj, "Invisible_Object", "V_LAUNCHER");
  1128. Commands->Set_Model(ssm_missile, "V_AG_NOD_SSM_MS");
  1129. Commands->Attach_To_Object_Bone(ssm_missile, obj, "V_LAUNCHER");
  1130. ssm_missile_id = Commands->Get_ID(ssm_missile);
  1131. }
  1132. void Damaged( GameObject * obj, GameObject * damager )
  1133. {
  1134. Commands->Set_Animation(obj, "V_NOD_SSM.V_NOD_SSM", 0);
  1135. Commands->Set_Animation(Commands->Find_Object(ssm_missile_id), "v_nod_ssm_Missl.v_nod_ssm_Missl", 0);
  1136. }
  1137. };
  1138. DECLARE_SCRIPT(DLS_Cinematic_Test2, "")
  1139. {
  1140. void Created (GameObject * obj)
  1141. {
  1142. /* Commands->Enable_Hibernation(obj, false);
  1143. Commands->Set_Player_Type(obj, PLAYERTYPE_NEUTRAL );
  1144. Commands->Create_Object ( "XG_TransprtBone", Vector3(0.0f, 0.0f, 0.0f));*/
  1145. }
  1146. void Damaged( GameObject * obj, GameObject * damager, float amount )
  1147. {
  1148. /* GameObject * chinook_obj0 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1149. Commands->Set_Facing(chinook_obj0, 0.0f);
  1150. Commands->Attach_Script(chinook_obj0, "Test_Cinematic", "X7A_TrnsptCt_00.txt");
  1151. GameObject * chinook_obj1 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1152. Commands->Set_Facing(chinook_obj1, 0.0f);
  1153. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X7A_TrnsptCt_01.txt");*/
  1154. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1155. Commands->Set_Facing(chinook_obj2, 0.0f);
  1156. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "X6C_MIDTRO.txt");
  1157. /* Commands->Send_Custom_Event(obj, Commands->Find_Object(100001), M07_EVAC_INN, 1, 0.0f);
  1158. Commands->Enable_Spawner(100002, true);
  1159. Commands->Enable_Spawner(100004, true);
  1160. Commands->Enable_Spawner(100005, true);
  1161. Commands->Enable_Spawner(100006, true);
  1162. Commands->Enable_Spawner(100007, true);*/
  1163. }
  1164. };
  1165. DECLARE_SCRIPT(DLS_Where_Am_I, "")
  1166. {
  1167. enum{WHERE_AM_I};
  1168. // Register variables to be Auto-Saved
  1169. // All variables must have a unique ID, less than 256, that never changes
  1170. REGISTER_VARIABLES()
  1171. {
  1172. // SAVE_VARIABLE( debug_mode, 2 );
  1173. }
  1174. void Created (GameObject * obj)
  1175. {
  1176. Vector3 pos = Commands->Get_Position(obj);
  1177. const char * preset_name = Commands->Get_Preset_Name( obj );
  1178. Commands->Debug_Message("%s at: X:%f Y:%f Z:%f \n", preset_name, pos.X, pos.Y, pos.Z);
  1179. Commands->Start_Timer (obj, this, 3.0f, WHERE_AM_I);
  1180. }
  1181. void Timer_Expired(GameObject * obj, int timer_id )
  1182. {
  1183. ActionParamsStruct params;
  1184. if(timer_id == WHERE_AM_I)
  1185. {
  1186. Vector3 pos = Commands->Get_Position(obj);
  1187. const char * preset_name = Commands->Get_Preset_Name( obj );
  1188. Commands->Debug_Message("%s at: X:%f Y:%f Z:%f \n", preset_name, pos.X, pos.Y, pos.Z);
  1189. Commands->Start_Timer (obj, this, 3.0f, WHERE_AM_I);
  1190. }
  1191. }
  1192. };
  1193. DECLARE_SCRIPT(DLS_Test_Flyovers, "")
  1194. {
  1195. enum{WHERE_AM_I};
  1196. // Register variables to be Auto-Saved
  1197. // All variables must have a unique ID, less than 256, that never changes
  1198. REGISTER_VARIABLES()
  1199. {
  1200. // SAVE_VARIABLE( debug_mode, 2 );
  1201. }
  1202. void Created (GameObject * obj)
  1203. {
  1204. Commands->Start_Timer (obj, this, 17.0f, WHERE_AM_I);
  1205. }
  1206. void Timer_Expired(GameObject * obj, int timer_id )
  1207. {
  1208. ActionParamsStruct params;
  1209. if(timer_id == WHERE_AM_I)
  1210. {
  1211. GameObject * chinook_obj1 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1212. Commands->Set_Facing(chinook_obj1, 0.0f);
  1213. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X7A_Apache_00.txt");
  1214. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1215. Commands->Set_Facing(chinook_obj2, 0.0f);
  1216. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "X7A_CPlane_00.txt");
  1217. GameObject * chinook_obj3 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1218. Commands->Set_Facing(chinook_obj3, 0.0f);
  1219. Commands->Attach_Script(chinook_obj3, "Test_Cinematic", "X7A_TrnsptCt_00.txt");
  1220. Commands->Start_Timer (obj, this, 17.0f, WHERE_AM_I);
  1221. }
  1222. }
  1223. };
  1224. DECLARE_SCRIPT(DLS_Test_Hand_Over_Head, "")
  1225. {
  1226. // Register variables to be Auto-Saved
  1227. // All variables must have a unique ID, less than 256, that never changes
  1228. REGISTER_VARIABLES()
  1229. {
  1230. // SAVE_VARIABLE( poked, 1 );
  1231. }
  1232. void Created(GameObject * obj)
  1233. {
  1234. ActionParamsStruct params;
  1235. Commands->Innate_Disable(obj);
  1236. params.Set_Basic(this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10);
  1237. params.Set_Animation("S_A_HUMAN.H_A_Host_L2b", true);
  1238. Commands->Action_Play_Animation(obj, params);
  1239. }
  1240. };
  1241. DECLARE_SCRIPT(DLS_Created_Too_Early, "")
  1242. {
  1243. void Created (GameObject * obj)
  1244. {
  1245. // Commands->Enable_Hibernation(obj, false);
  1246. // Commands->Set_Player_Type(obj, PLAYERTYPE_NEUTRAL );
  1247. // Commands->Create_Object ( "XG_TransprtBone", Vector3(0.0f, 0.0f, 0.0f));
  1248. }
  1249. void Damaged( GameObject * obj, GameObject * damager, float amount )
  1250. {
  1251. GameObject * chinook_obj3 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1252. Commands->Set_Facing(chinook_obj3, 0.0f);
  1253. Commands->Attach_Script(chinook_obj3, "Test_Cinematic", "Created_Too_Early.txt");
  1254. }
  1255. };
  1256. DECLARE_SCRIPT(DLS_Blink, "")
  1257. {
  1258. void Created (GameObject * obj)
  1259. {
  1260. // Commands->Enable_Hibernation(obj, false);
  1261. // Commands->Set_Player_Type(obj, PLAYERTYPE_NEUTRAL );
  1262. // Commands->Create_Object ( "XG_TransprtBone", Vector3(0.0f, 0.0f, 0.0f));
  1263. }
  1264. void Damaged( GameObject * obj, GameObject * damager, float amount )
  1265. {
  1266. GameObject * chinook_obj3 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1267. Commands->Set_Facing(chinook_obj3, 0.0f);
  1268. Commands->Attach_Script(chinook_obj3, "Test_Cinematic", "Blink.txt");
  1269. }
  1270. };
  1271. DECLARE_SCRIPT(DLS_Math, "")
  1272. {
  1273. void Created (GameObject * obj)
  1274. {
  1275. Vector3 pos = Commands->Get_Position(obj);
  1276. float facing = Commands->Get_Facing(obj);
  1277. float a = cos(DEG_TO_RADF(facing));
  1278. float b = sin(DEG_TO_RADF(facing));
  1279. Commands->Debug_Message("", a);
  1280. Commands->Debug_Message("", b);
  1281. }
  1282. };
  1283. DECLARE_SCRIPT(DLS_Test_Evac, "") // Deadeye2
  1284. {
  1285. enum{WAYPATH};
  1286. // Register variables to be Auto-Saved
  1287. // All variables must have a unique ID, less than 256, that never changes
  1288. REGISTER_VARIABLES()
  1289. {
  1290. // SAVE_VARIABLE( nuke_blast, 1 );
  1291. }
  1292. void Created(GameObject * obj)
  1293. {
  1294. Commands->Set_Animation ( obj, "S_A_Human.XG_EV5_troop", true );
  1295. Commands->Enable_Hibernation(obj, false);
  1296. ActionParamsStruct params;
  1297. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, WAYPATH );
  1298. params.Set_Movement( Vector3(0,0,0), RUN, 1.5f );
  1299. params.WaypathID = 100008;
  1300. Commands->Action_Goto( obj, params );
  1301. }
  1302. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  1303. {
  1304. if (action_id == WAYPATH)
  1305. {
  1306. int dead6_id = Commands->Get_ID(obj);
  1307. Commands->Send_Custom_Event(obj, Commands->Find_Object(100001), M07_DEAD6_EVAC, dead6_id, 0.0f);
  1308. }
  1309. }
  1310. };
  1311. DECLARE_SCRIPT(DLS_Innate_Disable, "") // Deadeye2
  1312. {
  1313. void Created(GameObject * obj)
  1314. {
  1315. Commands->Innate_Disable(obj);
  1316. }
  1317. };
  1318. /**********************************************************************************************
  1319. /*
  1320. /*
  1321. /*
  1322. /* MX0
  1323. /*
  1324. /*
  1325. /*
  1326. /**********************************************************************************************/
  1327. // MX0 Custom Enumerations
  1328. enum
  1329. {
  1330. MX0_STAR_AREA = 445000, // 0
  1331. MX0_VEHICLE_MOVE, // 1
  1332. MX0_SPECIFIC_ACTION, // 2
  1333. MX0_OBELISK_HUMVEE, // 3
  1334. MX0_OBELISK_DRIVER, // 4
  1335. MX0_OBELISK_MEDIUM_TANK, // 5
  1336. MX0_SOLDIER_MOVE, // 6
  1337. MX0_FIRE_SAM, // 7 Hardcoded into X0E_Obelisk.txt
  1338. MX0_A10_STRIKE, // 8
  1339. MX0_MISSION_SUCCESS, // 9 Hardcoded into X0Z_Finale.txt
  1340. MX0_DISCOVERS_NOD_BASE, // 10
  1341. MX0_HUMVEE_DRIVER_COWER, // 11
  1342. MX0_ROCKETTROOPER_SEES_OBELISK, // 12
  1343. MX0_ROCKETTROOPER_HOT_OBELISK, // 13
  1344. MX0_ROCKETTROOPER_OBELISK_DOWN, // 14
  1345. MX0_ROCKETTROOPER_TAKE_SAMS, // 15
  1346. MX0_ROCKETTROOPER_SAMS_HISTORY, // 16
  1347. MX0_TROOPER_UP_ON_WALL, // 17
  1348. MX0_DESTROY_OBELISK, // 18 Hardcoded into X0E_Obelisk.txt
  1349. MX0_GDI_REINFORCEMENT_KILLED, // 19
  1350. MX0_NEED_YOU_HERE, // 20
  1351. MX0_ROCKETTROOPER_CANT_TURN_BACK, // 21
  1352. };
  1353. #define WRONG_WAY_CONV_TABLE_SIZE ( sizeof(Wrong_Way_Conv_Table) / sizeof (Wrong_Way_Conv_Table[0]) )
  1354. const char * Wrong_Way_Conv_Table[] =
  1355. {
  1356. "MX0_A04_CON015", // You’re going the wrong way, Havoc!
  1357. "MX0_A04_CON016", // Stay with the Mission, Havoc!
  1358. "MX0_A04_CON017", // This area is already secure.
  1359. "MX0_A04_CON018", // Havoc, Did I say retreat? Now Turn Around!
  1360. };
  1361. DECLARE_SCRIPT (MX0_Area4_Controller_DLS, "")
  1362. {
  1363. int star_area;
  1364. bool area4_activated;
  1365. int humvee_id;
  1366. int medium_tank_blasted_id;
  1367. int medium_tank_escort_id;
  1368. int light_tank_a_id;
  1369. int light_tank_b_id;
  1370. int nod_base_rocketsoldier_a_id;
  1371. int nod_base_rocketsoldier_b_id;
  1372. int player_tank_id;
  1373. int gdi_trooper1_id;
  1374. int gdi_trooper2_id;
  1375. int gdi_trooper3_id;
  1376. int obelisk_id;
  1377. int obelisk_weapon_id;
  1378. int obelisk_orca_id;
  1379. int mobile_artillery_id;
  1380. bool orca_strike;
  1381. int basewall_id;
  1382. bool say_take_out_sams;
  1383. int mx0_gdi_reinforcement_killed;
  1384. int gdi_reinforcement1_id;
  1385. int gdi_reinforcement2_id;
  1386. int conv_num;
  1387. int say_need_here;
  1388. enum
  1389. {
  1390. AREA4_ACTIVATED = 0,
  1391. HUMMVEE_DESTRUCTION,
  1392. MEDIUM_TANK_DESTRUCTION,
  1393. OBELISK_DESTRUCTION,
  1394. SAMS_DESTRUCTION,
  1395. A10_STRIKE,
  1396. ION_CANNON_STRIKE,
  1397. ORCA_STRIKE1,
  1398. ORCA_STRIKE2,
  1399. FINALE,
  1400. CONVERSATION_HAVOC_TAKE_OUT_SAMS,
  1401. A10_HIT,
  1402. DESTROY_SAM1,
  1403. DESTROY_SAM2,
  1404. FLASH_TO_WHITE,
  1405. };
  1406. // Register variables to be Auto-Saved
  1407. // All variables must have a unique ID, less than 256, that never changes
  1408. REGISTER_VARIABLES()
  1409. {
  1410. SAVE_VARIABLE( star_area, 1 );
  1411. SAVE_VARIABLE( area4_activated, 2 );
  1412. SAVE_VARIABLE( humvee_id, 3 );
  1413. SAVE_VARIABLE( medium_tank_blasted_id, 4 );
  1414. SAVE_VARIABLE( medium_tank_escort_id, 5 );
  1415. SAVE_VARIABLE( light_tank_a_id, 6 );
  1416. SAVE_VARIABLE( light_tank_b_id, 7 );
  1417. SAVE_VARIABLE( nod_base_rocketsoldier_a_id, 8 );
  1418. SAVE_VARIABLE( nod_base_rocketsoldier_b_id, 9 );
  1419. SAVE_VARIABLE( player_tank_id, 10 );
  1420. SAVE_VARIABLE( gdi_trooper1_id, 11 );
  1421. SAVE_VARIABLE( gdi_trooper2_id, 12 );
  1422. SAVE_VARIABLE( gdi_trooper3_id, 13 );
  1423. SAVE_VARIABLE( obelisk_id, 14 );
  1424. SAVE_VARIABLE( obelisk_weapon_id, 15 );
  1425. SAVE_VARIABLE( obelisk_orca_id, 16 );
  1426. SAVE_VARIABLE( mobile_artillery_id, 17 );
  1427. SAVE_VARIABLE( orca_strike, 18 );
  1428. SAVE_VARIABLE( basewall_id, 19 );
  1429. SAVE_VARIABLE( say_take_out_sams, 20 );
  1430. SAVE_VARIABLE( mx0_gdi_reinforcement_killed, 21 );
  1431. SAVE_VARIABLE( gdi_reinforcement1_id, 22 );
  1432. SAVE_VARIABLE( gdi_reinforcement2_id, 23 );
  1433. SAVE_VARIABLE( conv_num, 24 );
  1434. SAVE_VARIABLE( say_need_here, 25 );
  1435. }
  1436. void Created( GameObject * obj )
  1437. {
  1438. star_area = 0;
  1439. area4_activated = false;
  1440. // Scale up the sight range of all units in game
  1441. Commands->Scale_AI_Awareness(3.0f, 1.0f);
  1442. say_take_out_sams = false;
  1443. orca_strike = false;
  1444. // Reinforcement counter
  1445. mx0_gdi_reinforcement_killed = 0;
  1446. // Wrong Way conversation
  1447. conv_num = 0;
  1448. // Rocket Trooper telling Havoc need up here
  1449. say_need_here = false;
  1450. }
  1451. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  1452. {
  1453. if(type == MX0_DESTROY_OBELISK)
  1454. {
  1455. // Remove old Obelisk
  1456. Commands->Destroy_Object(Commands->Find_Object(obelisk_id));
  1457. }
  1458. // What zone is the star in?
  1459. if(type == MX0_STAR_AREA)
  1460. {
  1461. star_area = param;
  1462. if(star_area == 1 && !area4_activated)
  1463. {
  1464. area4_activated = true;
  1465. Commands->Start_Timer (obj, this, 3.0f, AREA4_ACTIVATED);
  1466. // Start area4 actors
  1467. // Additional GDI troop drop
  1468. // GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Commands->Get_Position(Commands->Find_Object(1500051)));
  1469. // Commands->Set_Facing(chinook_obj2, 0.0f);
  1470. // Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "MX0_GDI_TroopDrop_Area4.txt");
  1471. // Humvee
  1472. GameObject * humvee = Commands->Find_Object(humvee_id);
  1473. Commands->Attach_Script(humvee, "MX0_Vehicle_DLS", "1500018, 1500019, 0, 0, 0.5f");
  1474. Commands->Attach_Script(humvee, "MX0_GDI_Killed_DLS", "1");
  1475. // Medium Tank Blasted *** Ajdusted 12/12/01 No longer gets destroyed
  1476. GameObject * medium_tank_blasted = Commands->Find_Object(medium_tank_blasted_id);
  1477. Commands->Attach_Script(medium_tank_blasted, "MX0_Vehicle_DLS", "1500022, 1500023, 0, 0, 1.0f");
  1478. Commands->Attach_Script(medium_tank_blasted, "MX0_GDI_Killed_DLS", "2");
  1479. Commands->Attach_Script(medium_tank_blasted, "M00_Damage_Modifier_DME", ".10f,1,1,1,1");
  1480. // Medium Tank Escort
  1481. GameObject * medium_tank_escort = Commands->Find_Object(medium_tank_escort_id);
  1482. Commands->Attach_Script(medium_tank_escort, "MX0_Vehicle_DLS", "1500027, 1500028, 1500029, 0, 1.0f");
  1483. // GDI Trooper 1
  1484. GameObject * gdi_trooper1 = Commands->Find_Object(gdi_trooper1_id);
  1485. Commands->Attach_Script(gdi_trooper1, "MX0_GDI_Soldier_DLS", "1500049, 1500050, 0, 0, 0.8f");
  1486. // GDI RocketTrooper
  1487. GameObject * gdi_trooper2 = Commands->Create_Object("GDI_RocketSoldier_0", Vector3(51.644f, 27.306f, 4.850f));
  1488. Commands->Attach_Script(gdi_trooper2, "M00_Send_Object_ID", "1500017, 12, 0.0f");
  1489. Commands->Attach_Script(gdi_trooper2, "MX0_GDI_Soldier_DLS", "1500053, 1500070, 0, 0, 0.8f");
  1490. // Humvee announces discovery of Nod Base
  1491. Commands->Send_Custom_Event( obj, Commands->Find_Object(humvee_id), MX0_SPECIFIC_ACTION, MX0_DISCOVERS_NOD_BASE, 0.0f);
  1492. }
  1493. }
  1494. // Actor IDs
  1495. if(type == M00_SEND_OBJECT_ID)
  1496. {
  1497. if(param == 1)
  1498. {
  1499. humvee_id = Commands->Get_ID(sender);
  1500. }
  1501. if(param == 3)
  1502. {
  1503. medium_tank_blasted_id = Commands->Get_ID(sender);
  1504. }
  1505. if(param == 4)
  1506. {
  1507. medium_tank_escort_id = Commands->Get_ID(sender);
  1508. }
  1509. if(param == 5)
  1510. {
  1511. light_tank_a_id = Commands->Get_ID(sender);
  1512. }
  1513. if(param == 6)
  1514. {
  1515. light_tank_b_id = Commands->Get_ID(sender);
  1516. }
  1517. if(param == 8)
  1518. {
  1519. nod_base_rocketsoldier_a_id = Commands->Get_ID(sender);
  1520. }
  1521. if(param == 9)
  1522. {
  1523. nod_base_rocketsoldier_b_id = Commands->Get_ID(sender);
  1524. }
  1525. if(param == 10)
  1526. {
  1527. player_tank_id = Commands->Get_ID(sender);
  1528. }
  1529. if(param == 11)
  1530. {
  1531. gdi_trooper1_id = Commands->Get_ID(sender);
  1532. }
  1533. if(param == 12)
  1534. {
  1535. gdi_trooper2_id = Commands->Get_ID(sender);
  1536. }
  1537. if(param == 13)
  1538. {
  1539. gdi_trooper3_id = Commands->Get_ID(sender);
  1540. }
  1541. if(param == 14)
  1542. {
  1543. obelisk_id = Commands->Get_ID(sender);
  1544. }
  1545. if(param == 15)
  1546. {
  1547. obelisk_weapon_id = Commands->Get_ID(sender);
  1548. }
  1549. if(param == 16)
  1550. {
  1551. obelisk_orca_id = Commands->Get_ID(sender);
  1552. }
  1553. if(param == 17)
  1554. {
  1555. mobile_artillery_id = Commands->Get_ID(sender);
  1556. }
  1557. if(param == 18)
  1558. {
  1559. basewall_id = Commands->Get_ID(sender);
  1560. }
  1561. if(param == 19)
  1562. {
  1563. gdi_reinforcement1_id = Commands->Get_ID(sender);
  1564. }
  1565. if(param == 20)
  1566. {
  1567. gdi_reinforcement2_id = Commands->Get_ID(sender);
  1568. }
  1569. }
  1570. // Commands for SAMs to fire on incoming Orca
  1571. if (type == MX0_FIRE_SAM)
  1572. {
  1573. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500015), MX0_FIRE_SAM, obelisk_orca_id, 0.0f);
  1574. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500016), MX0_FIRE_SAM, obelisk_orca_id, 0.0f);
  1575. }
  1576. // Commands to destroy Mobile Artillery in front of base
  1577. if (type == MX0_A10_STRIKE)
  1578. {
  1579. Commands->Apply_Damage( Commands->Find_Object(mobile_artillery_id), 50000.0f, "STEEL");
  1580. }
  1581. // Finale concludes, mission success
  1582. if(type == MX0_MISSION_SUCCESS)
  1583. {
  1584. Commands->Mission_Complete(true);
  1585. }
  1586. if(type == MX0_GDI_REINFORCEMENT_KILLED)
  1587. {
  1588. mx0_gdi_reinforcement_killed++;
  1589. if(mx0_gdi_reinforcement_killed == 2)
  1590. {
  1591. mx0_gdi_reinforcement_killed = 0;
  1592. // Additional GDI troop drop
  1593. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Commands->Get_Position(Commands->Find_Object(1500102)));
  1594. Commands->Set_Facing(chinook_obj2, Commands->Get_Facing(Commands->Find_Object(1500102)));
  1595. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "MX0_GDI_Reinforce_Area4.txt");
  1596. }
  1597. }
  1598. }
  1599. // Simple Function to move reinforcement troops
  1600. void Relocate_Soldiers (GameObject * obj)
  1601. {
  1602. // Initial Chinook Drops
  1603. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SOLDIER_MOVE, 1, 0.0f);
  1604. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper3_id), MX0_SOLDIER_MOVE, 1, 0.0f);
  1605. // GDI Reinforcements
  1606. int rand = Commands->Get_Random_Int(0, 3);
  1607. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_reinforcement1_id), MX0_SOLDIER_MOVE, rand, 0.0f);
  1608. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_reinforcement2_id), MX0_SOLDIER_MOVE, rand, 0.0f);
  1609. }
  1610. void Wrong_Way(GameObject * obj)
  1611. {
  1612. if(conv_num == WRONG_WAY_CONV_TABLE_SIZE)
  1613. {
  1614. conv_num = 0;
  1615. }
  1616. const char *conv_name = Wrong_Way_Conv_Table[conv_num];
  1617. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  1618. Commands->Join_Conversation(obj, conv_id, false, true);
  1619. Commands->Start_Conversation (conv_id, 10);
  1620. conv_num++;
  1621. }
  1622. void Timer_Expired(GameObject * obj, int timer_id )
  1623. {
  1624. ActionParamsStruct params;
  1625. if(timer_id == AREA4_ACTIVATED)
  1626. {
  1627. if(star_area > 0) // Area 2 or Area 3
  1628. {
  1629. // Start moving convoy forward with all GDI troops
  1630. // Humvee
  1631. Commands->Send_Custom_Event( obj, Commands->Find_Object(humvee_id), MX0_VEHICLE_MOVE, 1, 0.0f);
  1632. // Medium Tank Blasted
  1633. Commands->Send_Custom_Event( obj, Commands->Find_Object(medium_tank_blasted_id), MX0_VEHICLE_MOVE, 1, 0.0f);
  1634. // Medium Tank Escort
  1635. Commands->Send_Custom_Event( obj, Commands->Find_Object(medium_tank_escort_id), MX0_VEHICLE_MOVE, 1, 0.0f);
  1636. // GDI Trooper 1
  1637. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper1_id), MX0_SOLDIER_MOVE, 1, 0.0f);
  1638. // Relocate GDI Trooper2 & GDI Trooper3
  1639. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SOLDIER_MOVE, 1, 0.0f);
  1640. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper3_id), MX0_SOLDIER_MOVE, 1, 0.0f);
  1641. // Light Tank A
  1642. GameObject * light_tank_a = Commands->Find_Object(light_tank_a_id);
  1643. Commands->Attach_Script(light_tank_a, "MX0_Vehicle_DLS", "1500033, 1500034, 0, 0, 0.4f");
  1644. // Light Tank B
  1645. GameObject * light_tank_b = Commands->Find_Object(light_tank_b_id);
  1646. Commands->Attach_Script(light_tank_b, "MX0_Vehicle_DLS", "0, 0, 0, 0, 0.0f");
  1647. // Mobile Artillery
  1648. GameObject * mobile_artillery = Commands->Find_Object(mobile_artillery_id);
  1649. Commands->Attach_Script(mobile_artillery, "MX0_Vehicle_DLS", "1500084, 1500085, 0, 0, 1.0f");
  1650. // Move Nod tanks into position on far side of river
  1651. Commands->Start_Timer (obj, this, 2.0f, HUMMVEE_DESTRUCTION);
  1652. // Humvee is now vulnerable
  1653. Commands->Send_Custom_Event( obj, Commands->Find_Object(humvee_id), M00_ENABLE_DAMAGE_MOD, 0, 0.0f);
  1654. // RocketTrooper sees Obelisk
  1655. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper1_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_SEES_OBELISK, 4.0f);
  1656. }
  1657. else
  1658. {
  1659. if(!say_need_here)
  1660. {
  1661. say_need_here = true;
  1662. // We need you up here, Sir.
  1663. Commands->Send_Custom_Event( obj, Commands->Find_Object(humvee_id), MX0_SPECIFIC_ACTION, MX0_NEED_YOU_HERE, 0.0f);
  1664. }
  1665. // "We need you Commando"
  1666. Commands->Start_Timer (obj, this, 2.0f, AREA4_ACTIVATED);
  1667. }
  1668. }
  1669. if(timer_id == HUMMVEE_DESTRUCTION)
  1670. {
  1671. if(star_area > 1) // Area 2 or Area 3
  1672. {
  1673. // Light Tank A
  1674. Commands->Send_Custom_Event( obj, Commands->Find_Object(light_tank_a_id), MX0_VEHICLE_MOVE, 1, 0.0f);
  1675. // Obelisk blasts Hummvee
  1676. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500020), MX0_OBELISK_HUMVEE, 1, 0.0f);
  1677. // *** Adjusted 12/12/01 Medium Tank no longer destroyed, run through function anyways
  1678. // Obelisk blasts GDI Medium Tank
  1679. Commands->Start_Timer (obj, this, 0.0f, MEDIUM_TANK_DESTRUCTION);
  1680. // RocketTrooper - The Obelisk is hot! Look out!
  1681. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper1_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_HOT_OBELISK, 4.0f);
  1682. // Relocate Troops
  1683. Relocate_Soldiers (obj);
  1684. }
  1685. else
  1686. {
  1687. // We need your help - over here, Sir!
  1688. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_CANT_TURN_BACK, 0.0f);
  1689. // "We need you Commando"
  1690. Commands->Start_Timer (obj, this, 6.0f, HUMMVEE_DESTRUCTION);
  1691. }
  1692. }
  1693. if(timer_id == MEDIUM_TANK_DESTRUCTION)
  1694. {
  1695. switch(star_area)
  1696. {
  1697. case 0:
  1698. case 1:
  1699. {
  1700. Wrong_Way(obj);
  1701. // Shouts from units calling Havoc back
  1702. Commands->Start_Timer (obj, this, 5.0f, MEDIUM_TANK_DESTRUCTION);
  1703. }
  1704. break;
  1705. case 2:
  1706. {
  1707. // Shouts from units calling Havoc back
  1708. Commands->Start_Timer (obj, this, 5.0f, MEDIUM_TANK_DESTRUCTION);
  1709. }
  1710. break;
  1711. case 3:
  1712. {
  1713. // Activate Wall Nod Rocket Soldiers
  1714. Commands->Enable_Spawner(1500042, true);
  1715. Commands->Enable_Spawner(1500044, true);
  1716. // Activate Wall Gun Emplacement
  1717. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500039), MX0_SPECIFIC_ACTION, 1, 0.0f);
  1718. // Obelisk blasts GDI Medium Tank **** Ajdusted 12/12/01 No longer destroy tank
  1719. // Commands->Send_Custom_Event( obj, Commands->Find_Object(1500020), MX0_OBELISK_MEDIUM_TANK, 2, 0.0f);
  1720. // Relocate Medium Tank Escort
  1721. Commands->Send_Custom_Event( obj, Commands->Find_Object(medium_tank_escort_id), MX0_VEHICLE_MOVE, 2, 0.0f);
  1722. // Mobile Artillery
  1723. Commands->Send_Custom_Event( obj, Commands->Find_Object(mobile_artillery_id), MX0_VEHICLE_MOVE, 1, 0.0f);
  1724. // Orca is shot down with SAMs, slams into Obelisk
  1725. Commands->Start_Timer (obj, this, 8.0f, OBELISK_DESTRUCTION);
  1726. // Begin reinforcing GDI via Chinook
  1727. // Additional GDI troop drop
  1728. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Commands->Get_Position(Commands->Find_Object(1500102)));
  1729. Commands->Set_Facing(chinook_obj2, Commands->Get_Facing(Commands->Find_Object(1500102)));
  1730. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "MX0_GDI_Reinforce_Area4.txt");
  1731. // Relocate Troops
  1732. Relocate_Soldiers (obj);
  1733. }
  1734. break;
  1735. }
  1736. }
  1737. if(timer_id == OBELISK_DESTRUCTION)
  1738. {
  1739. switch(star_area)
  1740. {
  1741. case 0:
  1742. case 1:
  1743. {
  1744. Wrong_Way(obj);
  1745. // Shouts from units calling Havoc back
  1746. Commands->Start_Timer (obj, this, 5.0f, OBELISK_DESTRUCTION);
  1747. }
  1748. break;
  1749. case 2:
  1750. {
  1751. // Shouts from units calling Havoc back
  1752. Commands->Start_Timer (obj, this, 5.0f, OBELISK_DESTRUCTION);
  1753. }
  1754. break;
  1755. case 3:
  1756. {
  1757. // Orca Mix
  1758. Commands->Create_2D_Sound("MX0_A4_Orca_Mix");
  1759. // Cinematic of Orca
  1760. // Shot down by SAMs, slams into Obelisk
  1761. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1762. Commands->Set_Facing(controller, 0.000f);
  1763. Commands->Attach_Script(controller, "Test_Cinematic", "X0E_Obelisk.txt");
  1764. // Remove Obelisk weapon
  1765. Commands->Destroy_Object(Commands->Find_Object(obelisk_weapon_id));
  1766. // Orcas sweeping in to take out Obelisk
  1767. Commands->Start_Timer (obj, this, 5.0f, ORCA_STRIKE1);
  1768. Commands->Start_Timer (obj, this, 10.0f, ORCA_STRIKE2);
  1769. orca_strike = true;
  1770. // Commando, take out those SAMs
  1771. Commands->Start_Timer (obj, this, 8.0f, CONVERSATION_HAVOC_TAKE_OUT_SAMS);
  1772. // Nod soldiers being shot off balcony
  1773. Commands->Start_Timer (obj, this, 2.0f, SAMS_DESTRUCTION);
  1774. // Relocate Troops
  1775. Relocate_Soldiers (obj);
  1776. }
  1777. break;
  1778. }
  1779. }
  1780. // Commando, take out those SAMs
  1781. if(timer_id == CONVERSATION_HAVOC_TAKE_OUT_SAMS)
  1782. {
  1783. // Havoc, you’ve got to clear out those SAM sites!
  1784. const char *conv_name = ("MX0_A04_CON005");
  1785. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  1786. Commands->Join_Conversation(NULL, conv_id, false, true);
  1787. Commands->Start_Conversation (conv_id, 1);
  1788. // RocketTrooper - It’s down! The Obelisk is down!
  1789. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_OBELISK_DOWN, 3.0f);
  1790. }
  1791. if(timer_id == SAMS_DESTRUCTION)
  1792. {
  1793. switch(star_area)
  1794. {
  1795. case 0:
  1796. case 1:
  1797. {
  1798. Wrong_Way(obj);
  1799. // Shouts from units calling Havoc back
  1800. Commands->Start_Timer (obj, this, 5.0f, SAMS_DESTRUCTION);
  1801. }
  1802. break;
  1803. case 2:
  1804. {
  1805. // Shouts from units calling Havoc back
  1806. Commands->Start_Timer (obj, this, 5.0f, SAMS_DESTRUCTION);
  1807. }
  1808. break;
  1809. case 3:
  1810. {
  1811. // If the SAMs still exist get Havoc to take them out
  1812. if(Commands->Find_Object(1500015) || Commands->Find_Object(1500016))
  1813. {
  1814. // Orcas sweeping in to take out Obelisk
  1815. Commands->Start_Timer (obj, this, 5.0f, ORCA_STRIKE1);
  1816. Commands->Start_Timer (obj, this, 10.0f, ORCA_STRIKE2);
  1817. orca_strike = false;
  1818. // Commando, take out those SAMs ** Only say it once
  1819. if(!say_take_out_sams)
  1820. {
  1821. say_take_out_sams = true;
  1822. // RocketTrooper - Go! Go! Knock out those SAMs!
  1823. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_TAKE_SAMS, 9.0f);
  1824. // Send custom to disable damage modifier on SAMs
  1825. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500015), M00_ENABLE_DAMAGE_MOD, 0, 0.0f);
  1826. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500016), M00_ENABLE_DAMAGE_MOD, 0, 0.0f);
  1827. // Start timer to take out SAMs regardless of player intervention
  1828. Commands->Start_Timer (obj, this, 20.0f, DESTROY_SAM1);
  1829. Commands->Start_Timer (obj, this, 24.0f, DESTROY_SAM2);
  1830. }
  1831. // Nod soldiers being shot off balcony
  1832. Commands->Start_Timer (obj, this, 5.0f, SAMS_DESTRUCTION);
  1833. }
  1834. // If SAMs no longer exist, trigger A10 strike
  1835. else
  1836. {
  1837. //Nice job Havoc
  1838. // RocketTrooper - The SAMs are history!
  1839. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper2_id), MX0_SPECIFIC_ACTION, MX0_ROCKETTROOPER_SAMS_HISTORY, 0.0f);
  1840. // Trooper1 - There, on the wall!
  1841. Commands->Send_Custom_Event( obj, Commands->Find_Object(gdi_trooper1_id), MX0_SPECIFIC_ACTION, MX0_TROOPER_UP_ON_WALL, 2.0f);
  1842. // Nod RocketSoldier on base wall fire at Havoc's tank
  1843. Commands->Send_Custom_Event (obj, Commands->Find_Object(nod_base_rocketsoldier_a_id), MX0_SPECIFIC_ACTION, player_tank_id, 0.0f);
  1844. Commands->Send_Custom_Event (obj, Commands->Find_Object(nod_base_rocketsoldier_b_id), MX0_SPECIFIC_ACTION, player_tank_id, 0.0f);
  1845. // A10 strike and destruction
  1846. Commands->Start_Timer (obj, this, 5.0f, A10_STRIKE);
  1847. }
  1848. }
  1849. break;
  1850. }
  1851. }
  1852. if(timer_id == DESTROY_SAM1)
  1853. {
  1854. Commands->Apply_Damage(Commands->Find_Object(1500015), 50000.0f, "STEEL");
  1855. }
  1856. if(timer_id == DESTROY_SAM2)
  1857. {
  1858. Commands->Apply_Damage(Commands->Find_Object(1500016), 50000.0f, "STEEL");
  1859. }
  1860. if(timer_id == A10_STRIKE)
  1861. {
  1862. switch(star_area)
  1863. {
  1864. case 0:
  1865. case 1:
  1866. {
  1867. Wrong_Way(obj);
  1868. // Shouts from units calling Havoc back
  1869. Commands->Start_Timer (obj, this, 5.0f, A10_STRIKE);
  1870. }
  1871. break;
  1872. case 2:
  1873. {
  1874. // Shouts from units calling Havoc back
  1875. Commands->Start_Timer (obj, this, 5.0f, A10_STRIKE);
  1876. }
  1877. break;
  1878. case 3:
  1879. {
  1880. // Start A10 - Outro muzak
  1881. Commands->Fade_Background_Music( "Renegade_A10_Outro.mp3", 1, 1);
  1882. // A10 - This is Eagle Claw 1 –Starting attack run
  1883. const char *conv_name = ("MX0_A04_CON010");
  1884. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  1885. Commands->Join_Conversation(NULL, conv_id, false, true);
  1886. Commands->Start_Conversation (conv_id, 1);
  1887. // A10 - I’m hit! I’m hit!
  1888. Commands->Start_Timer (obj, this, 5.0f, A10_HIT);
  1889. // A10 cinematic
  1890. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1891. Commands->Set_Facing(controller, 0.000f);
  1892. Commands->Attach_Script(controller, "Test_Cinematic", "X0D_A10_Crash.txt");
  1893. // Apaches rise up from behind wall, Ion cannon strike
  1894. Commands->Start_Timer (obj, this, 6.0f, ION_CANNON_STRIKE);
  1895. // Relocate Troops
  1896. Relocate_Soldiers (obj);
  1897. }
  1898. break;
  1899. }
  1900. }
  1901. // A10 - I’m hit! I’m hit!
  1902. if(timer_id == A10_HIT)
  1903. {
  1904. const char *conv_name = ("MX0_A04_CON011");
  1905. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  1906. Commands->Join_Conversation(NULL, conv_id, false, true);
  1907. Commands->Start_Conversation (conv_id, 1);
  1908. }
  1909. if(timer_id == ION_CANNON_STRIKE)
  1910. {
  1911. // We have a lock on that base
  1912. // This is Eagle Base. I’m not risking any more pilots.
  1913. const char *conv_name = ("MX0_A04_CON012");
  1914. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  1915. Commands->Join_Conversation(NULL, conv_id, false, true);
  1916. Commands->Start_Conversation (conv_id, 1);
  1917. // Ion Cannon strike
  1918. GameObject * ion_cannon_strike = Commands->Create_Object("Nod_RocketSoldier_1Off", Commands->Get_Position(Commands->Find_Object(1500087)));
  1919. Commands->Attach_Script(ion_cannon_strike, "MX0_Plant_Ion_Beacon_DLS", "");
  1920. Commands->Start_Timer (obj, this, 22.0f, FLASH_TO_WHITE);
  1921. Commands->Start_Timer (obj, this, 25.0f, FINALE);
  1922. // Relocate Troops
  1923. Relocate_Soldiers (obj);
  1924. }
  1925. if(timer_id == FLASH_TO_WHITE)
  1926. {
  1927. Commands->Set_Screen_Fade_Color(1.0f, 1.0f, 1.0f, 0.2f);
  1928. Commands->Set_Screen_Fade_Opacity(1.0f, 0.2f);
  1929. }
  1930. if(timer_id == FINALE)
  1931. {
  1932. Commands->Destroy_Object(Commands->Find_Object(basewall_id));
  1933. GameObject *controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1934. Commands->Set_Facing(controller, 0.000f);
  1935. Commands->Attach_Script(controller, "Test_Cinematic", "X0Z_Finale.txt");
  1936. }
  1937. if(timer_id == ORCA_STRIKE1 && orca_strike)
  1938. {
  1939. GameObject *orca_controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1940. Commands->Set_Facing(orca_controller, 0.000f);
  1941. Commands->Attach_Script(orca_controller, "Test_Cinematic", "X0C_Flyovers_01.txt");
  1942. }
  1943. if(timer_id == ORCA_STRIKE2 && orca_strike)
  1944. {
  1945. GameObject *orca_controller = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  1946. Commands->Set_Facing(orca_controller, 0.000f);
  1947. Commands->Attach_Script(orca_controller, "Test_Cinematic", "X0C_Flyovers_02.txt");
  1948. }
  1949. }
  1950. };
  1951. DECLARE_SCRIPT (MX0_Area4_Zone_DLS, "Area=0:int")
  1952. {
  1953. bool first_time;
  1954. // Register variables to be Auto-Saved
  1955. // All variables must have a unique ID, less than 256, that never changes
  1956. REGISTER_VARIABLES()
  1957. {
  1958. SAVE_VARIABLE( first_time, 1 );
  1959. }
  1960. void Created (GameObject * obj)
  1961. {
  1962. first_time = true;
  1963. }
  1964. void Entered (GameObject * obj, GameObject * enterer)
  1965. {
  1966. if(Commands->Is_A_Star(enterer) && first_time )
  1967. {
  1968. int area = Get_Int_Parameter("Area");
  1969. // Send custom to area controller to determine STAR location
  1970. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500017), MX0_STAR_AREA, area, 0.0f);
  1971. first_time = false;
  1972. }
  1973. }
  1974. };
  1975. DECLARE_SCRIPT (MX0_Vehicle_DLS, "Attack_Loc0=0:int, Attack_Loc1=0:int, Attack_Loc2=0:int, Attack_Loc3=0:int, Speed=1.0:float")
  1976. {
  1977. int attack_loc [4];
  1978. int loc;
  1979. float speed;
  1980. enum{CON001, CON002};
  1981. // Register variables to be Auto-Saved
  1982. // All variables must have a unique ID, less than 256, that never changes
  1983. REGISTER_VARIABLES()
  1984. {
  1985. SAVE_VARIABLE( attack_loc, 1 );
  1986. SAVE_VARIABLE( loc, 2 );
  1987. SAVE_VARIABLE( speed, 3 );
  1988. }
  1989. void Created (GameObject * obj)
  1990. {
  1991. Commands->Enable_Enemy_Seen( obj, true);
  1992. Commands->Enable_Engine(obj, true);
  1993. attack_loc [0] = Get_Int_Parameter("Attack_Loc0");
  1994. attack_loc [1] = Get_Int_Parameter("Attack_Loc1");
  1995. attack_loc [2] = Get_Int_Parameter("Attack_Loc2");
  1996. attack_loc [3] = Get_Int_Parameter("Attack_Loc3");
  1997. loc = 0;
  1998. speed = Get_Float_Parameter("Speed");
  1999. ActionParamsStruct params;
  2000. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2001. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2002. params.Set_Attack(Commands->Find_Object(1500024), 0.0f, 0.0f, true);
  2003. Commands->Action_Attack(obj, params);
  2004. }
  2005. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  2006. {
  2007. Commands->Debug_Message("ID %d sees Enemy ID %d \n", Commands->Get_ID(obj), Commands->Get_ID(enemy));
  2008. ActionParamsStruct params;
  2009. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2010. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2011. params.Set_Attack(enemy, 200.0f, 5.0f, true);
  2012. // params.AttackCheckBlocked = false;
  2013. // params.AttackForceFire = true;
  2014. Commands->Action_Attack(obj, params);
  2015. }
  2016. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  2017. {
  2018. ActionParamsStruct params;
  2019. if(type == MX0_VEHICLE_MOVE)
  2020. {
  2021. loc = param;
  2022. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2023. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2024. params.Set_Attack(Commands->Find_Object(1500024), 0.0f, 0.0f, true);
  2025. Commands->Action_Attack(obj, params);
  2026. Commands->Debug_Message("Attack_Loc [%d] = %d \n", loc, attack_loc[loc]);
  2027. }
  2028. if(type == MX0_SPECIFIC_ACTION)
  2029. {
  2030. // Humvee announces discovery of Nod Base
  2031. if(param == MX0_DISCOVERS_NOD_BASE)
  2032. {
  2033. // Eagle Base– We found it!
  2034. const char *conv_name = ("MX0_A04_CON001");
  2035. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2036. Commands->Join_Conversation(obj, conv_id, false, true);
  2037. Commands->Start_Conversation (conv_id, CON001);
  2038. Commands->Monitor_Conversation (obj, conv_id);
  2039. }
  2040. // We need you up here, Sir.
  2041. if(param == MX0_NEED_YOU_HERE)
  2042. {
  2043. // We need you up here, Sir.
  2044. const char *conv_name = ("MX0_A04_CON013");
  2045. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2046. Commands->Join_Conversation(obj, conv_id, false, true);
  2047. Commands->Start_Conversation (conv_id, 10);
  2048. }
  2049. }
  2050. }
  2051. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  2052. {
  2053. if((action_id == CON001) && (reason == ACTION_COMPLETE_CONVERSATION_ENDED))
  2054. {
  2055. // Confirmed. Excellent work!
  2056. const char *conv_name = ("MX0_A04_CON002");
  2057. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2058. Commands->Join_Conversation(NULL, conv_id, false, true);
  2059. Commands->Start_Conversation (conv_id, CON002);
  2060. // Commands->Monitor_Conversation (obj, conv_id);
  2061. }
  2062. if((action_id == CON002) && (reason == ACTION_COMPLETE_CONVERSATION_ENDED))
  2063. {
  2064. // They have an Obelisk!
  2065. const char *conv_name = ("MX0_A04_CON003");
  2066. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2067. Commands->Join_Conversation(obj, conv_id, false, true);
  2068. Commands->Start_Conversation (conv_id, CON002);
  2069. }
  2070. if(action_id == 10)
  2071. {
  2072. Commands->Debug_Message("Action_Complete");
  2073. }
  2074. }
  2075. };
  2076. DECLARE_SCRIPT (MX0_Obelisk_Weapon_DLS, "Max_Range=75.0f:float")
  2077. {
  2078. bool able_to_fire;
  2079. int current_target;
  2080. int powerup_effect_id;
  2081. int humvee_id;
  2082. int humvee_driver_id;
  2083. int medium_tank_blasted_id;
  2084. REGISTER_VARIABLES()
  2085. {
  2086. SAVE_VARIABLE (able_to_fire, 1);
  2087. SAVE_VARIABLE (current_target, 2);
  2088. SAVE_VARIABLE (powerup_effect_id, 3);
  2089. SAVE_VARIABLE (humvee_id, 4);
  2090. SAVE_VARIABLE (humvee_driver_id, 5);
  2091. SAVE_VARIABLE (medium_tank_blasted_id, 6);
  2092. }
  2093. void Created (GameObject * obj)
  2094. {
  2095. powerup_effect_id = 0;
  2096. current_target = 0;
  2097. able_to_fire = true;
  2098. Commands->Set_Player_Type (obj, SCRIPT_PLAYERTYPE_NOD);
  2099. Commands->Set_Is_Rendered (obj, false);
  2100. // Commands->Enable_Enemy_Seen (obj, true);
  2101. Commands->Enable_Hibernation (obj, false);
  2102. // Commands->Innate_Enable (obj);
  2103. Vector3 my_position = Commands->Get_Position (obj);
  2104. GameObject * effect = Commands->Create_Object ("Obelisk Effect", my_position);
  2105. if (effect)
  2106. {
  2107. powerup_effect_id = Commands->Get_ID (effect);
  2108. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  2109. }
  2110. }
  2111. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  2112. {
  2113. if(type == MX0_OBELISK_HUMVEE)
  2114. {
  2115. Commands->Send_Custom_Event (obj, obj, 2, humvee_id, 0.0f);
  2116. }
  2117. if(type == MX0_OBELISK_DRIVER)
  2118. {
  2119. Commands->Send_Custom_Event (obj, obj, 2, humvee_driver_id, 1.0f);
  2120. }
  2121. if(type == MX0_OBELISK_MEDIUM_TANK)
  2122. {
  2123. Commands->Send_Custom_Event (obj, obj, 2, medium_tank_blasted_id, 0.0f);
  2124. }
  2125. // Actor IDs
  2126. if(type == M00_SEND_OBJECT_ID)
  2127. {
  2128. if(param == 1)
  2129. {
  2130. humvee_id = Commands->Get_ID(sender);
  2131. }
  2132. if(param == 2)
  2133. {
  2134. humvee_driver_id = Commands->Get_ID(sender);
  2135. }
  2136. if(param == 3)
  2137. {
  2138. medium_tank_blasted_id = Commands->Get_ID(sender);
  2139. }
  2140. }
  2141. if (type == 1)
  2142. {
  2143. if (param == 0)
  2144. {
  2145. Commands->Enable_Enemy_Seen (obj, false);
  2146. able_to_fire = false;
  2147. ActionParamsStruct params;
  2148. params.Set_Basic (this, 100, 0);
  2149. params.Set_Attack (obj, 0.0f, 0.0f, true);
  2150. Commands->Action_Attack (obj, params);
  2151. Commands->Action_Reset (obj, 100.0f);
  2152. Destroy_Obelisk_Effect ();
  2153. }
  2154. else
  2155. {
  2156. Commands->Enable_Enemy_Seen (obj, true);
  2157. able_to_fire = true;
  2158. }
  2159. }
  2160. else if (type == 2)
  2161. {
  2162. if (able_to_fire)
  2163. {
  2164. GameObject * target_obj = Commands->Find_Object (param);
  2165. if (target_obj)
  2166. {
  2167. Vector3 enemy_position = Commands->Get_Position (target_obj);
  2168. Vector3 my_position = Commands->Get_Position (obj);
  2169. float distance = Commands->Get_Distance (my_position, enemy_position);
  2170. enemy_position.Z = 0.0f;
  2171. my_position.Z = 0.0f;
  2172. float difference = Commands->Get_Distance (my_position, enemy_position);
  2173. float max_range = Get_Float_Parameter("Max_Range");
  2174. if ((difference > 15.0f) && (distance < max_range))
  2175. {
  2176. current_target = param;
  2177. able_to_fire = false;
  2178. Commands->Start_Timer (obj, this, 2.5f, 1);
  2179. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  2180. if (effect)
  2181. {
  2182. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 1);
  2183. }
  2184. my_position.Z -= 20.0f;
  2185. Commands->Create_Sound ("Obelisk_Warm_Up", my_position, obj);
  2186. }
  2187. else
  2188. {
  2189. Destroy_Obelisk_Effect ();
  2190. Commands->Action_Reset (obj, 100.0f);
  2191. }
  2192. }
  2193. }
  2194. }
  2195. }
  2196. void Timer_Expired (GameObject * obj, int timer_id)
  2197. {
  2198. if (timer_id == 1)
  2199. {
  2200. GameObject * target_obj = Commands->Find_Object (current_target);
  2201. if (target_obj)
  2202. {
  2203. Vector3 my_position = Commands->Get_Position (obj);
  2204. Vector3 enemy_position = Commands->Get_Position (target_obj);
  2205. float distance = Commands->Get_Distance (my_position, enemy_position);
  2206. enemy_position.Z = 0.0f;
  2207. my_position.Z = 0.0f;
  2208. float difference = Commands->Get_Distance (my_position, enemy_position);
  2209. float max_range = Get_Float_Parameter("Max_Range");
  2210. if ((difference > 15.0f) && (distance < max_range))
  2211. {
  2212. ActionParamsStruct params;
  2213. params.Set_Basic (this, 100, 0);
  2214. params.Set_Attack (target_obj, max_range, 0.0f, true);
  2215. params.AttackCheckBlocked = false;
  2216. Commands->Action_Attack (obj, params);
  2217. current_target = 0;
  2218. Commands->Start_Timer (obj, this, 2.0f, 2);
  2219. }
  2220. else
  2221. {
  2222. Destroy_Obelisk_Effect ();
  2223. Commands->Action_Reset (obj, 100.0f);
  2224. able_to_fire = true;
  2225. }
  2226. }
  2227. else
  2228. {
  2229. Destroy_Obelisk_Effect ();
  2230. Commands->Action_Reset (obj, 100.0f);
  2231. able_to_fire = true;
  2232. }
  2233. }
  2234. else if (timer_id == 2)
  2235. {
  2236. Destroy_Obelisk_Effect ();
  2237. able_to_fire = true;
  2238. }
  2239. }
  2240. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  2241. {
  2242. if(action_id == 0)
  2243. {
  2244. Commands->Debug_Message("Action_Complete Obelisk Firing");
  2245. }
  2246. }
  2247. void Destroy_Obelisk_Effect (void)
  2248. {
  2249. if (powerup_effect_id)
  2250. {
  2251. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  2252. if (effect)
  2253. {
  2254. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  2255. }
  2256. }
  2257. }
  2258. void Destroyed(GameObject * obj )
  2259. {
  2260. if (powerup_effect_id)
  2261. {
  2262. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  2263. if (effect)
  2264. {
  2265. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  2266. }
  2267. }
  2268. }
  2269. };
  2270. DECLARE_SCRIPT (MX0_GDI_Killed_DLS, "Unit_ID=0:int")
  2271. {
  2272. // Register variables to be Auto-Saved
  2273. // All variables must have a unique ID, less than 256, that never changes
  2274. REGISTER_VARIABLES()
  2275. {
  2276. // SAVE_VARIABLE( attack_loc, 1 );
  2277. }
  2278. void Created (GameObject * obj)
  2279. {
  2280. }
  2281. void Damaged (GameObject * obj, GameObject * damager, float amount)
  2282. {
  2283. // If damaged by the Obelisk Weapon
  2284. if((damager == Commands->Find_Object(1500020)) && (Commands->Find_Object(1500020)))
  2285. {
  2286. Commands->Apply_Damage( obj, 50000.0f, "STEEL");
  2287. }
  2288. }
  2289. void Killed (GameObject * obj, GameObject * killer)
  2290. {
  2291. int unit_id = Get_Int_Parameter("Unit_ID");
  2292. switch(unit_id)
  2293. {
  2294. case 1:
  2295. {
  2296. GameObject * humvee_driver = Commands->Create_Object("GDI_Minigunner_1Off", Commands->Get_Position(obj));
  2297. Commands->Set_Facing(humvee_driver, 0.000f);
  2298. Commands->Attach_Script(humvee_driver, "M00_Send_Object_ID", "1500020, 2, 0.0f");
  2299. Commands->Attach_Script(humvee_driver, "MX0_GDI_Soldier_DLS", "0,0,0,0,0.0f");
  2300. // Custom for Humvee driver to be covwering and fleeing
  2301. Commands->Send_Custom_Event (obj, humvee_driver, MX0_SPECIFIC_ACTION, MX0_HUMVEE_DRIVER_COWER, 0.0f);
  2302. // Obelisk blasts Hummvee
  2303. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500020), MX0_OBELISK_DRIVER, 1, 1.0f);
  2304. }
  2305. break;
  2306. // When Medium Tank is destroyed replace with destroyed model
  2307. case 2:
  2308. {
  2309. GameObject * destroyed_medium_tank = Commands->Create_Object("MX0_GDI_Medium_Tank_Destroyed", Commands->Get_Position(obj));
  2310. Commands->Set_Facing(destroyed_medium_tank, Commands->Get_Facing(obj));
  2311. }
  2312. break;
  2313. // GDI Reinforcement, send custom to controller on killed
  2314. case 3:
  2315. {
  2316. Commands->Send_Custom_Event( obj, Commands->Find_Object(1500017), MX0_GDI_REINFORCEMENT_KILLED, 1, 1.0f);
  2317. }
  2318. break;
  2319. }
  2320. }
  2321. };
  2322. DECLARE_SCRIPT (MX0_GDI_Soldier_DLS, "Attack_Loc0=0:int, Attack_Loc1=0:int, Attack_Loc2=0:int, Attack_Loc3=0:int, Speed=1.0:float")
  2323. {
  2324. int attack_loc [4];
  2325. int loc;
  2326. float speed;
  2327. int mx0_soldier_move_attempts;
  2328. enum{CON001};
  2329. // Register variables to be Auto-Saved
  2330. // All variables must have a unique ID, less than 256, that never changes
  2331. REGISTER_VARIABLES()
  2332. {
  2333. SAVE_VARIABLE( attack_loc, 1 );
  2334. SAVE_VARIABLE( loc, 2 );
  2335. SAVE_VARIABLE( speed, 3 );
  2336. SAVE_VARIABLE( mx0_soldier_move_attempts, 4 );
  2337. }
  2338. void Created (GameObject * obj)
  2339. {
  2340. Commands->Enable_Enemy_Seen( obj, true);
  2341. Commands->Enable_Engine(obj, true);
  2342. attack_loc [0] = Get_Int_Parameter("Attack_Loc0");
  2343. attack_loc [1] = Get_Int_Parameter("Attack_Loc1");
  2344. attack_loc [2] = Get_Int_Parameter("Attack_Loc2");
  2345. attack_loc [3] = Get_Int_Parameter("Attack_Loc3");
  2346. loc = 0;
  2347. speed = Get_Float_Parameter("Speed");
  2348. ActionParamsStruct params;
  2349. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2350. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2351. params.Set_Attack(Commands->Find_Object(1500024), 0.0f, 0.0f, true);
  2352. Commands->Action_Attack(obj, params);
  2353. }
  2354. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  2355. {
  2356. Commands->Debug_Message("ID %d sees Enemy ID %d \n", Commands->Get_ID(obj), Commands->Get_ID(enemy));
  2357. ActionParamsStruct params;
  2358. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2359. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2360. params.Set_Attack(enemy, 200.0f, 5.0f, true);
  2361. // params.AttackCheckBlocked = false;
  2362. // params.AttackForceFire = true;
  2363. Commands->Action_Attack(obj, params);
  2364. }
  2365. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  2366. {
  2367. ActionParamsStruct params;
  2368. if(type == MX0_SOLDIER_MOVE)
  2369. {
  2370. loc = param;
  2371. bool move_crouched = Commands->Get_Random_Int(0, 1) ? false : true;
  2372. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, MX0_SOLDIER_MOVE );
  2373. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2374. params.Set_Attack(Commands->Find_Object(1500024), 0.0f, 0.0f, true);
  2375. params.MoveCrouched = move_crouched;
  2376. Commands->Action_Attack(obj, params);
  2377. Commands->Debug_Message("Attack_Loc [%d] = %d \n", loc, attack_loc[loc]);
  2378. }
  2379. if(type == MX0_SPECIFIC_ACTION)
  2380. {
  2381. // Soldier that pops out of destroyed Humvee
  2382. if(param == MX0_HUMVEE_DRIVER_COWER) // Cower animation
  2383. {
  2384. Commands->Innate_Disable(obj);
  2385. ActionParamsStruct params;
  2386. params.Set_Basic( this, 100, 1 );
  2387. params.Set_Animation ("H_A_A0A0_L51", true);
  2388. Commands->Action_Play_Animation (obj, params);
  2389. // Death #1 - Bullet death scream
  2390. const char *conv_name = ("MX0_A04_CON019");
  2391. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2392. Commands->Join_Conversation(obj, conv_id, false, true);
  2393. Commands->Start_Conversation (conv_id, 10);
  2394. }
  2395. // Rocket Trooper sights obelisk
  2396. if(param == MX0_ROCKETTROOPER_SEES_OBELISK)
  2397. {
  2398. // They have an Obelisk!
  2399. const char *conv_name = ("MX0_A04_CON003");
  2400. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2401. Commands->Join_Conversation(obj, conv_id, false, true);
  2402. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_SEES_OBELISK);
  2403. // Start Area4 muzak
  2404. Commands->Fade_Background_Music( "Level 0 Nod base.mp3", 2, 2);
  2405. }
  2406. // Rocket Trooper announces obelisk is hot
  2407. if(param == MX0_ROCKETTROOPER_HOT_OBELISK)
  2408. {
  2409. // The Obelisk is hot! Look out!
  2410. const char *conv_name = ("MX0_A04_CON004");
  2411. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2412. Commands->Join_Conversation(obj, conv_id, false, true);
  2413. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_HOT_OBELISK);
  2414. }
  2415. // Rocket Trooper - It’s down! The Obelisk is down!
  2416. if(param == MX0_ROCKETTROOPER_OBELISK_DOWN)
  2417. {
  2418. // It’s down! The Obelisk is down!
  2419. const char *conv_name = ("MX0_A04_CON006");
  2420. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2421. Commands->Join_Conversation(obj, conv_id, false, true);
  2422. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_OBELISK_DOWN);
  2423. }
  2424. // Rocket Trooper - Go! Go! Knock out those SAMs!
  2425. if(param == MX0_ROCKETTROOPER_TAKE_SAMS)
  2426. {
  2427. // Go! Go! Knock out those SAMs!
  2428. const char *conv_name = ("MX0_A04_CON007");
  2429. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2430. Commands->Join_Conversation(obj, conv_id, false, true);
  2431. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_TAKE_SAMS);
  2432. }
  2433. // Rocket Trooper - The SAMs are history!
  2434. if(param == MX0_ROCKETTROOPER_SAMS_HISTORY)
  2435. {
  2436. // The SAMs are history!
  2437. const char *conv_name = ("MX0_A04_CON008");
  2438. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2439. Commands->Join_Conversation(obj, conv_id, false, true);
  2440. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_SAMS_HISTORY);
  2441. }
  2442. // Trooper1 - There, on the wall!
  2443. if(param == MX0_TROOPER_UP_ON_WALL)
  2444. {
  2445. // There, on the wall!
  2446. const char *conv_name = ("MX0_A04_CON009");
  2447. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2448. Commands->Join_Conversation(obj, conv_id, false, true);
  2449. Commands->Start_Conversation (conv_id, MX0_TROOPER_UP_ON_WALL);
  2450. }
  2451. // If Havoc turns back and exits Area4
  2452. if(param == MX0_ROCKETTROOPER_CANT_TURN_BACK)
  2453. {
  2454. // We need your help - over here, Sir!
  2455. const char *conv_name = ("MX0_A04_CON014");
  2456. int conv_id = Commands->Create_Conversation (conv_name, 100.0f, 200.0f, false);
  2457. Commands->Join_Conversation(obj, conv_id, false, true);
  2458. Commands->Start_Conversation (conv_id, MX0_ROCKETTROOPER_CANT_TURN_BACK);
  2459. }
  2460. }
  2461. }
  2462. void Timer_Expired(GameObject * obj, int timer_id )
  2463. {
  2464. ActionParamsStruct params;
  2465. if(timer_id == MX0_SOLDIER_MOVE)
  2466. {
  2467. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, MX0_SOLDIER_MOVE );
  2468. params.Set_Movement( Commands->Get_Position (Commands->Find_Object (attack_loc [loc])), speed, 5.0f );
  2469. params.Set_Attack(Commands->Find_Object(1500024), 0.0f, 0.0f, true);
  2470. Commands->Action_Attack(obj, params);
  2471. }
  2472. }
  2473. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  2474. {
  2475. // If action fails, reattempt
  2476. if((action_id == MX0_SOLDIER_MOVE) && (reason != ACTION_COMPLETE_NORMAL) && (mx0_soldier_move_attempts < 4))
  2477. {
  2478. mx0_soldier_move_attempts++;
  2479. Commands->Start_Timer (obj, this, 4.0f, MX0_SOLDIER_MOVE);
  2480. Commands->Debug_Message("Attempt %d for MX0_SOLDIER_MOVE on loc %d");
  2481. }
  2482. if(action_id == 10)
  2483. {
  2484. Commands->Debug_Message("Action_Complete");
  2485. }
  2486. }
  2487. };
  2488. DECLARE_SCRIPT (MX0_Gun_Emplacement_DLS, "Left_Point=0:int, Right_Point=0:int")
  2489. {
  2490. bool left;
  2491. enum{STRAFE};
  2492. // Register variables to be Auto-Saved
  2493. // All variables must have a unique ID, less than 256, that never changes
  2494. REGISTER_VARIABLES()
  2495. {
  2496. SAVE_VARIABLE( left, 1 );
  2497. }
  2498. void Created (GameObject * obj)
  2499. {
  2500. left = true;
  2501. }
  2502. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  2503. {
  2504. ActionParamsStruct params;
  2505. if(type == MX0_SPECIFIC_ACTION)
  2506. {
  2507. Timer_Expired(obj, STRAFE);
  2508. }
  2509. }
  2510. void Timer_Expired(GameObject * obj, int timer_id )
  2511. {
  2512. ActionParamsStruct params;
  2513. if(timer_id == STRAFE)
  2514. {
  2515. if(left)
  2516. {
  2517. left = false;
  2518. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2519. params.Set_Attack (Commands->Find_Object(Get_Int_Parameter("Left_Point")), 0.0f, 0.0f, 1);
  2520. params.AttackCheckBlocked = false;
  2521. params.AttackForceFire = true;
  2522. Commands->Action_Attack( obj, params );
  2523. }
  2524. else
  2525. {
  2526. left = true;
  2527. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2528. params.Set_Attack (Commands->Find_Object(Get_Int_Parameter("Right_Point")), 0.0f, 0.0f, 1);
  2529. params.AttackCheckBlocked = false;
  2530. params.AttackForceFire = true;
  2531. Commands->Action_Attack( obj, params );
  2532. }
  2533. Commands->Start_Timer (obj, this, 4.0f, STRAFE);
  2534. }
  2535. }
  2536. };
  2537. DECLARE_SCRIPT (MX0_Nod_RocketSoldier_DLS, "Stationary_Point=0:int")
  2538. {
  2539. enum{GO_POSITION};
  2540. // Register variables to be Auto-Saved
  2541. // All variables must have a unique ID, less than 256, that never changes
  2542. REGISTER_VARIABLES()
  2543. {
  2544. // SAVE_VARIABLE( left, 1 );
  2545. }
  2546. void Created (GameObject * obj)
  2547. {
  2548. ActionParamsStruct params;
  2549. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, GO_POSITION );
  2550. params.Set_Movement( Commands->Find_Object(Get_Int_Parameter("Stationary_Point")), RUN, 0.0f );
  2551. Commands->Action_Goto(obj, params);
  2552. }
  2553. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  2554. {
  2555. ActionParamsStruct params;
  2556. if(type == MX0_SPECIFIC_ACTION)
  2557. {
  2558. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2559. params.Set_Attack (Commands->Find_Object(param), 150.0f, 0.0f, 1);
  2560. params.AttackCheckBlocked = false;
  2561. params.AttackForceFire = true;
  2562. Commands->Action_Attack( obj, params );
  2563. }
  2564. }
  2565. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  2566. {
  2567. ActionParamsStruct params;
  2568. if((action_id == GO_POSITION) && (reason == ACTION_COMPLETE_NORMAL))
  2569. {
  2570. Commands->Set_Innate_Is_Stationary(obj, true);
  2571. }
  2572. }
  2573. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  2574. {
  2575. ActionParamsStruct params;
  2576. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2577. params.Set_Attack (enemy, 150.0f, 0.0f, 1);
  2578. params.AttackCheckBlocked = false;
  2579. params.AttackForceFire = true;
  2580. Commands->Action_Attack( obj, params );
  2581. }
  2582. };
  2583. DECLARE_SCRIPT (MX0_SAM_DLS, "")
  2584. {
  2585. // Register variables to be Auto-Saved
  2586. // All variables must have a unique ID, less than 256, that never changes
  2587. REGISTER_VARIABLES()
  2588. {
  2589. // SAVE_VARIABLE( left, 1 );
  2590. }
  2591. void Created (GameObject * obj)
  2592. {
  2593. Commands->Set_Innate_Is_Stationary(obj, true);
  2594. }
  2595. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  2596. {
  2597. ActionParamsStruct params;
  2598. if (type == MX0_FIRE_SAM)
  2599. {
  2600. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1 );
  2601. params.Set_Attack (Commands->Find_Object(1500081), 250.0f, 0.0f, 1);
  2602. params.AttackCheckBlocked = false;
  2603. Commands->Action_Attack( obj, params );
  2604. }
  2605. }
  2606. };
  2607. DECLARE_SCRIPT (MX0_Nod_Bunker_DLS, "")
  2608. {
  2609. enum{GO_POSITION};
  2610. // Register variables to be Auto-Saved
  2611. // All variables must have a unique ID, less than 256, that never changes
  2612. REGISTER_VARIABLES()
  2613. {
  2614. // SAVE_VARIABLE( left, 1 );
  2615. }
  2616. void Created (GameObject * obj)
  2617. {
  2618. Commands->Set_Innate_Is_Stationary(obj, true);
  2619. }
  2620. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  2621. {
  2622. ActionParamsStruct params;
  2623. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2624. params.Set_Attack (enemy, 0.0f, 0.0f, 1);
  2625. params.AttackCheckBlocked = false;
  2626. params.AttackCrouched = true;
  2627. params.AttackForceFire = true;
  2628. Commands->Action_Attack( obj, params );
  2629. }
  2630. };
  2631. DECLARE_SCRIPT (MX0_Plant_Ion_Beacon_DLS, "")
  2632. {
  2633. // Register variables to be Auto-Saved
  2634. // All variables must have a unique ID, less than 256, that never changes
  2635. REGISTER_VARIABLES()
  2636. {
  2637. // SAVE_VARIABLE( left, 1 );
  2638. }
  2639. void Created (GameObject * obj)
  2640. {
  2641. ActionParamsStruct params;
  2642. Commands->Give_PowerUp(obj, "POW_IonCannonBeacon_Ai" );
  2643. Commands->Select_Weapon(obj, "Weapon_IonCannonBeacon_Ai" );
  2644. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 10 );
  2645. params.Set_Attack (Commands->Get_Position(obj), 5.0f, 0.0f, 1);
  2646. params.AttackForceFire = true;
  2647. Commands->Action_Attack( obj, params );
  2648. }
  2649. };
  2650. DECLARE_SCRIPT (DLS_Star_No_Fall, "")
  2651. {
  2652. enum{ATTACH_SCRIPT};
  2653. // Register variables to be Auto-Saved
  2654. // All variables must have a unique ID, less than 256, that never changes
  2655. REGISTER_VARIABLES()
  2656. {
  2657. // SAVE_VARIABLE( left, 1 );
  2658. }
  2659. void Created (GameObject * obj)
  2660. {
  2661. Commands->Start_Timer (obj, this, 1.0f, ATTACH_SCRIPT);
  2662. }
  2663. void Timer_Expired(GameObject * obj, int timer_id )
  2664. {
  2665. if(timer_id == ATTACH_SCRIPT)
  2666. {
  2667. if(STAR)
  2668. {
  2669. Commands->Attach_Script(STAR, "M00_No_Falling_Damage_DME", "");
  2670. }
  2671. else
  2672. {
  2673. Commands->Start_Timer (obj, this, 1.0f, ATTACH_SCRIPT);
  2674. }
  2675. }
  2676. }
  2677. };
  2678. DECLARE_SCRIPT (MX0_Explosive_Barrels_DLS, "Logical_Sound=0:int, Radius:float")
  2679. {
  2680. // Register variables to be Auto-Saved
  2681. // All variables must have a unique ID, less than 256, that never changes
  2682. REGISTER_VARIABLES()
  2683. {
  2684. // SAVE_VARIABLE( left, 1 );
  2685. }
  2686. void Created (GameObject * obj)
  2687. {
  2688. }
  2689. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  2690. {
  2691. }
  2692. void Sound_Heard( GameObject * obj, const CombatSound & sound )
  2693. {
  2694. if(sound.Type == Get_Int_Parameter("Logical_Sound"))
  2695. {
  2696. Commands->Apply_Damage( obj, 50000.0f, "STEEL");
  2697. }
  2698. }
  2699. void Killed (GameObject * obj, GameObject * killer)
  2700. {
  2701. float radius = Get_Float_Parameter("Radius");
  2702. Commands->Create_Explosion("Air Explosions Twiddler", Commands->Get_Position(obj), obj);
  2703. Commands->Create_Logical_Sound(obj, Get_Int_Parameter("Logical_Sound"), Commands->Get_Position(obj), radius);
  2704. }
  2705. };