scriptcommands.cpp 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/scriptcommands.cpp $*
  25. * *
  26. * $Author:: Bhayes $*
  27. * *
  28. * $Modtime:: 2/16/02 8:37p $*
  29. * *
  30. * $Revision:: 285 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "scriptcommands.h"
  36. #include "debug.h"
  37. #include "combat.h"
  38. #include "smartgameobj.h"
  39. #include "damage.h"
  40. #include "gameobjmanager.h"
  41. #include "crandom.h"
  42. #include "scripts.h"
  43. #include "objlibrary.h"
  44. #include "phys.h"
  45. #include "ccamera.h"
  46. #include "sound3d.h"
  47. #include "combat.h"
  48. #include "radar.h"
  49. #include "explosion.h"
  50. #include "powerup.h"
  51. #include "soldier.h"
  52. #include "weapons.h"
  53. #include "pscene.h"
  54. #include "staticanimphys.h"
  55. #include "hanim.h"
  56. #include "objectives.h"
  57. #include "spawn.h"
  58. #include "assets.h"
  59. #include "widestring.h"
  60. #include "translatedb.h"
  61. #include "vehicle.h"
  62. #include "combatchunkid.h"
  63. #include "logicalsound.h"
  64. #include "soldierobserver.h"
  65. #include "cinematicgameobj.h"
  66. #include "dynamicanimphys.h"
  67. #include <stdio.h>
  68. #include "conversationmgr.h"
  69. #include "activeconversation.h"
  70. #include "orator.h"
  71. #include "gameobjobserver.h"
  72. #include "animcontrol.h"
  73. #include "playerdata.h"
  74. #include "building.h"
  75. #include "scriptzone.h"
  76. #include "hud.h"
  77. #include "backgroundmgr.h"
  78. #include "weathermgr.h"
  79. #include "mapmgr.h"
  80. #include "heightdb.h"
  81. #include "weaponbag.h"
  82. #include "ffactory.h"
  83. #include "playerterminal.h"
  84. #include "hudinfo.h"
  85. #include "globalsettings.h"
  86. #include "screenfademanager.h"
  87. #define SCRIPT_TRACE(x) if (ScriptTrace) {Debug_Say(x);}
  88. bool ScriptTrace = false;
  89. #define SCRIPT_PTR_CHECK( x ) if ( x == NULL ) { Debug_Say(( "NULL Script Ptr at %s line %d\n", __FILE__, __LINE__ )); return; }
  90. #define SCRIPT_PTR_CHECK_RET( x, ret ) if ( x == NULL ) { Debug_Say(( "NULL Script Ptr at %s line %d\n", __FILE__, __LINE__ )); return ret; }
  91. char DamageModelName[ 30 ]; // HACK
  92. bool DamageModelDirection; // HACK
  93. #define SCRIPT_PRIORITY 2
  94. /*
  95. ** Debug messages
  96. */
  97. void Debug_Message( char *format, ... )
  98. {
  99. #ifdef WWDEBUG
  100. SCRIPT_PTR_CHECK( format );
  101. va_list arg_list;
  102. va_start (arg_list, format);
  103. StringClass string(true);
  104. string.Format_Args( format, arg_list );
  105. va_end (arg_list);
  106. Debug_Script(( (const char *)string ));
  107. #endif
  108. }
  109. void Modify_Action( GameObject * obj, int action_id, const ActionParamsStruct & params, bool modify_move, bool modify_attack )
  110. {
  111. SCRIPT_PTR_CHECK( obj );
  112. SCRIPT_TRACE(( "ST>Modify_Action( %d, %d )\n", obj->Get_ID(), action_id ));
  113. SmartGameObj * smart = obj->As_SmartGameObj();
  114. if ( smart != NULL && smart->Get_Action() != NULL &&
  115. smart->Get_Action()->Get_Parameters().ActionID == action_id )
  116. {
  117. smart->Get_Action()->Modify( params, modify_move, modify_attack );
  118. }
  119. return ;
  120. }
  121. int Get_Action_ID( GameObject * obj )
  122. {
  123. SCRIPT_PTR_CHECK_RET( obj, 0 );
  124. SCRIPT_TRACE(( "ST>Get_Action_ID( %d )\n", obj->Get_ID() ));
  125. int retval = 0;
  126. //
  127. // Simply return the ID of the current action
  128. //
  129. SmartGameObj * smart = obj->As_SmartGameObj();
  130. if ( smart != NULL && smart->Get_Action() != NULL ) {
  131. retval = smart->Get_Action()->Get_Parameters().ActionID;
  132. }
  133. return retval;
  134. }
  135. bool Get_Action_Params( GameObject * obj, ActionParamsStruct & params )
  136. {
  137. SCRIPT_PTR_CHECK_RET( obj, false );
  138. SCRIPT_TRACE(( "ST>Get_Action_Params( %d )\n", obj->Get_ID() ));
  139. bool retval = false;
  140. //
  141. // Simply copy the parameters to the provided structure
  142. //
  143. SmartGameObj * smart = obj->As_SmartGameObj();
  144. if ( smart != NULL && smart->Get_Action() != NULL ) {
  145. params = smart->Get_Action()->Get_Parameters();
  146. params.MoveObject = smart->Get_Action()->Get_Parameters().MoveObjectRef;
  147. params.LookObject = smart->Get_Action()->Get_Parameters().LookObjectRef;
  148. params.AttackObject = smart->Get_Action()->Get_Parameters().AttackObjectRef;
  149. retval = true;
  150. }
  151. return retval;
  152. }
  153. bool Is_Performing_Pathfind_Action( GameObject * obj )
  154. {
  155. SCRIPT_PTR_CHECK_RET( obj, false );
  156. SCRIPT_TRACE(( "ST>Is_Performing_Pathfind_Action( %d )\n", obj->Get_ID() ));
  157. bool retval = false;
  158. //
  159. // Simply ask the action if its "busy", this means its doing something that
  160. // can't be interrupted
  161. //
  162. SmartGameObj * smart = obj->As_SmartGameObj();
  163. if ( smart != NULL && smart->Get_Action() != NULL ) {
  164. smart->Get_Action()->Is_Busy();
  165. }
  166. return retval;
  167. }
  168. void Action_Reset( GameObject * obj, float priority )
  169. {
  170. SCRIPT_PTR_CHECK( obj );
  171. SCRIPT_TRACE(( "ST>Action_Reset( %d, %f )\n", obj->Get_ID(), priority ));
  172. SmartGameObj * smart = obj->As_SmartGameObj();
  173. if ( smart ) {
  174. smart->Get_Action()->Reset( priority );
  175. }
  176. }
  177. void Action_Goto( GameObject * obj, const ActionParamsStruct & params )
  178. {
  179. SCRIPT_PTR_CHECK( obj );
  180. SCRIPT_TRACE(( "ST>Action_Goto( %d )\n", obj->Get_ID() ));
  181. SmartGameObj * smart = obj->As_SmartGameObj();
  182. if ( smart ) {
  183. smart->Get_Action()->Goto( params );
  184. }
  185. }
  186. void Action_Attack( GameObject * obj, const ActionParamsStruct & params )
  187. {
  188. SCRIPT_PTR_CHECK( obj );
  189. SCRIPT_TRACE(( "ST>Action_Attack( %d )\n", obj->Get_ID() ));
  190. SmartGameObj * smart = obj->As_SmartGameObj();
  191. if ( smart ) {
  192. smart->Get_Action()->Attack( params );
  193. }
  194. }
  195. void Action_Play_Animation( GameObject * obj, const ActionParamsStruct & params )
  196. {
  197. SCRIPT_PTR_CHECK( obj );
  198. SCRIPT_TRACE(( "ST>Action_Play_Animation( %d )\n", obj->Get_ID() ));
  199. SmartGameObj * smart = obj->As_SmartGameObj();
  200. if ( smart ) {
  201. smart->Get_Action()->Play_Animation( params );
  202. }
  203. }
  204. void Action_Enter_Exit( GameObject * obj, const ActionParamsStruct & params )
  205. {
  206. SCRIPT_PTR_CHECK( obj );
  207. SCRIPT_TRACE(( "ST>Action_Enter_Exit( %d )\n", obj->Get_ID() ));
  208. SmartGameObj * smart = obj->As_SmartGameObj();
  209. if ( smart ) {
  210. smart->Get_Action()->Enter_Exit( params );
  211. }
  212. }
  213. void Action_Face_Location( GameObject * obj, const ActionParamsStruct & params )
  214. {
  215. SCRIPT_PTR_CHECK( obj );
  216. SCRIPT_TRACE(( "ST>Action_Face_Location( %d )\n", obj->Get_ID() ));
  217. SmartGameObj * smart = obj->As_SmartGameObj();
  218. if ( smart ) {
  219. smart->Get_Action()->Face_Location( params );
  220. }
  221. }
  222. void Action_Dock( GameObject * obj, const ActionParamsStruct & params )
  223. {
  224. SCRIPT_PTR_CHECK( obj );
  225. SCRIPT_TRACE(( "ST>Action_Dock( %d )\n", obj->Get_ID() ));
  226. SmartGameObj * smart = obj->As_SmartGameObj();
  227. if ( smart ) {
  228. smart->Get_Action()->Dock_Vehicle( params );
  229. }
  230. }
  231. void Action_Follow_Input( GameObject * obj, const ActionParamsStruct & params )
  232. {
  233. SCRIPT_PTR_CHECK( obj );
  234. SCRIPT_TRACE(( "ST>Action_Follow_Input( %d )\n", obj->Get_ID() ));
  235. SmartGameObj * smart = obj->As_SmartGameObj();
  236. if ( smart ) {
  237. smart->Get_Action()->Follow_Input( params );
  238. }
  239. }
  240. /*
  241. ** Physical control
  242. */
  243. void Set_Position( GameObject * obj, const Vector3 & position )
  244. {
  245. SCRIPT_PTR_CHECK( obj );
  246. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  247. if ( pgobj == NULL ) {
  248. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  249. return;
  250. }
  251. SCRIPT_TRACE(( "ST>Set_Position( %d, (%f ,%f,%f) )\n", pgobj->Get_ID(), position[0], position[1], position[2] ));
  252. pgobj->Peek_Physical_Object()->Set_Position( position );
  253. }
  254. Vector3 Get_Position( GameObject * obj )
  255. {
  256. SCRIPT_PTR_CHECK_RET( obj, Vector3(0,0,0) );
  257. Vector3 pos;
  258. obj->Get_Position(&pos);
  259. return pos;
  260. }
  261. Vector3 Get_Bone_Position( GameObject * obj, const char * bone_name )
  262. {
  263. SCRIPT_PTR_CHECK_RET( obj, Vector3(0,0,0) );
  264. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  265. if ( pgobj == NULL ) {
  266. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  267. return Vector3(0,0,0);
  268. }
  269. SCRIPT_PTR_CHECK_RET( pgobj->Peek_Model(), Vector3(0,0,0) );
  270. Matrix3D tm = pgobj->Peek_Model()->Get_Bone_Transform( bone_name );
  271. return tm.Get_Translation();
  272. }
  273. float Get_Facing( GameObject * obj )
  274. {
  275. SCRIPT_PTR_CHECK_RET( obj, 0 );
  276. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  277. if ( pgobj == NULL ) {
  278. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  279. return 0;
  280. }
  281. return RAD_TO_DEG( pgobj->Get_Facing() );
  282. }
  283. void Set_Facing( GameObject * obj, float degrees )
  284. {
  285. SCRIPT_PTR_CHECK( obj );
  286. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  287. if ( pgobj == NULL ) {
  288. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  289. return;
  290. }
  291. SCRIPT_TRACE(( "ST>Set_Facing( %d, %f )\n", pgobj->Get_ID(), degrees ));
  292. Vector3 pos;
  293. pgobj->Get_Position(&pos);
  294. Matrix3D tm(1);
  295. tm.Translate(pos);
  296. tm.Rotate_Z( DEG_TO_RAD( degrees ) );
  297. pgobj->Set_Transform(tm);
  298. }
  299. /*
  300. ** Collision Control
  301. */
  302. void Disable_All_Collisions( GameObject * obj )
  303. {
  304. SCRIPT_PTR_CHECK( obj );
  305. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  306. if ( pgobj == NULL ) {
  307. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  308. return;
  309. }
  310. SCRIPT_TRACE(( "ST>Disable_All_Collisions( %d )\n", pgobj->Get_ID() ));
  311. pgobj->Set_Collision_Group( UNCOLLIDEABLE_GROUP );
  312. }
  313. void Disable_Physical_Collisions( GameObject * obj )
  314. {
  315. SCRIPT_PTR_CHECK( obj );
  316. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  317. if ( pgobj == NULL ) {
  318. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  319. return;
  320. }
  321. SCRIPT_TRACE(( "ST>Disable_Physical_Collisions( %d )\n", pgobj->Get_ID() ));
  322. pgobj->Set_Collision_Group( BULLET_ONLY_COLLISION_GROUP );
  323. }
  324. void Enable_Collisions( GameObject * obj )
  325. {
  326. SCRIPT_PTR_CHECK( obj );
  327. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  328. if ( pgobj == NULL ) {
  329. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  330. return;
  331. }
  332. SCRIPT_TRACE(( "ST>Enable_Collisions( %d )\n", pgobj->Get_ID() ));
  333. if ( pgobj->As_SoldierGameObj () != NULL ) {
  334. pgobj->Set_Collision_Group( SOLDIER_COLLISION_GROUP );
  335. } else {
  336. pgobj->Set_Collision_Group( DEFAULT_COLLISION_GROUP );
  337. }
  338. }
  339. /*
  340. ** Object Management
  341. */
  342. void Destroy_Object( GameObject * obj )
  343. {
  344. SCRIPT_PTR_CHECK( obj );
  345. SCRIPT_TRACE(( "ST>Destroy_Object( %d )\n", obj->Get_ID() ));
  346. obj->Set_Delete_Pending();
  347. }
  348. GameObject * Find_Object( int obj_id )
  349. {
  350. return GameObjManager::Find_ScriptableGameObj( obj_id );
  351. }
  352. int Get_ID( GameObject * obj )
  353. {
  354. SCRIPT_PTR_CHECK_RET( obj, 0 );
  355. return obj->Get_ID();
  356. }
  357. int Get_Preset_ID( GameObject * obj )
  358. {
  359. SCRIPT_PTR_CHECK_RET( obj, 0 );
  360. return obj->Get_Definition ().Get_ID ();
  361. }
  362. const char * Get_Preset_Name( GameObject * obj )
  363. {
  364. SCRIPT_PTR_CHECK_RET( obj, "" );
  365. return obj->Get_Definition ().Get_Name ();
  366. }
  367. /******************************************************************************
  368. *
  369. * NAME
  370. * Create_Object
  371. *
  372. * DESCRIPTION
  373. * Create an object with the specified transform.
  374. *
  375. * INPUTS
  376. * const char* name
  377. * const Matrix3D& tm
  378. *
  379. * RESULTS
  380. * GameObject*
  381. *
  382. ******************************************************************************/
  383. GameObject* Create_Object(const char* name, const Matrix3D& tm)
  384. {
  385. assert(name != NULL);
  386. GameObject* object = ObjectLibraryManager::Create_Object(name);
  387. if (object != NULL) {
  388. WWASSERT( object->As_PhysicalGameObj() );
  389. object->As_PhysicalGameObj()->Set_Transform(tm);
  390. object->Start_Observers();
  391. }
  392. return object;
  393. }
  394. GameObject* Create_Object(const char* type_name, const Vector3 & position)
  395. {
  396. SCRIPT_PTR_CHECK_RET(type_name, NULL);
  397. SCRIPT_TRACE(( "ST>Create_Object( %s (%f,%f,%f) )\n",
  398. type_name, position[0], position[1], position[2] ));
  399. #if(0) // Denzil
  400. GameObject* obj = ObjectLibraryManager::Create_Object(type_name);
  401. if (obj != NULL) {
  402. Matrix3D tm(1);
  403. tm.Set_Translation(position);
  404. obj->Set_Transform(tm);
  405. }
  406. return obj;
  407. #else
  408. Matrix3D tm(true);
  409. tm.Set_Translation(position);
  410. return Create_Object(type_name, tm);
  411. #endif
  412. }
  413. GameObject* Create_Object_At_Bone(GameObject* host_obj, const char* new_obj_type_name, const char* bone_name)
  414. {
  415. SCRIPT_PTR_CHECK_RET( host_obj, NULL );
  416. SCRIPT_PTR_CHECK_RET( new_obj_type_name, NULL );
  417. SCRIPT_PTR_CHECK_RET( bone_name, NULL );
  418. PhysicalGameObj * pgobj = host_obj->As_PhysicalGameObj();
  419. if ( pgobj == NULL ) {
  420. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  421. return NULL;
  422. }
  423. SCRIPT_TRACE(( "ST>Create_Object_At_Bone( %d %s %s )\n", host_obj->Get_ID(), new_obj_type_name, bone_name ));
  424. #if(0) // Denzil
  425. GameObject* obj = ObjectLibraryManager::Create_Object(new_obj_type_name);
  426. if (obj != NULL) {
  427. obj->Set_Transform(host_obj->Peek_Model()->Get_Bone_Transform(bone_name));
  428. }
  429. return obj;
  430. #else
  431. Matrix3D tm = pgobj->Peek_Model()->Get_Bone_Transform(bone_name);
  432. return Create_Object(new_obj_type_name, tm);
  433. #endif
  434. }
  435. // Attach a script to and object.
  436. void Attach_Script(GameObject* object, const char* scriptName, const char* scriptParams)
  437. {
  438. SCRIPT_PTR_CHECK( object );
  439. SCRIPT_PTR_CHECK( scriptName );
  440. // Create a script instance
  441. assert(scriptName != NULL);
  442. ScriptClass* script = ScriptManager::Create_Script(scriptName);
  443. if (script != NULL) {
  444. // Set the scripts parameters
  445. assert(scriptParams != NULL);
  446. script->Set_Parameters_String(scriptParams);
  447. // Add the script to the object
  448. assert(object != NULL);
  449. object->Add_Observer(script);
  450. } else {
  451. WWDEBUG_SAY(("Unable to create script: %s\r\n",scriptName));
  452. }
  453. }
  454. void Add_To_Dirty_Cull_List(GameObject* obj)
  455. {
  456. SCRIPT_PTR_CHECK( obj );
  457. PhysicalGameObj *physobj = obj->As_PhysicalGameObj();
  458. if ( physobj != NULL ) {
  459. COMBAT_SCENE->Add_To_Dirty_Cull_List( physobj->Peek_Physical_Object() );
  460. }
  461. }
  462. /*
  463. ** Timers
  464. */
  465. void Start_Timer( GameObject * obj, ScriptClass * script, float duration, int timer_id )
  466. {
  467. SCRIPT_PTR_CHECK( obj );
  468. SCRIPT_PTR_CHECK( script );
  469. SCRIPT_TRACE(( "ST>Start_Timer( %d, %d, %f, %d )\n", obj->Get_ID(), script->Get_ID(), duration, timer_id ));
  470. obj->Start_Observer_Timer( script->Get_ID(), duration, timer_id );
  471. }
  472. /*
  473. ** Weapons
  474. */
  475. void Trigger_Weapon( GameObject * obj, bool trigger, const Vector3 & target, bool primary_fire )
  476. {
  477. SCRIPT_PTR_CHECK( obj );
  478. SCRIPT_TRACE(( "ST>Trigger_Weapon( %d, %d, (%f %f %f ) %d\n", obj->Get_ID(), trigger, target.X, target.Y, target.Z, primary_fire ));
  479. PhysicalGameObj *phyobj = obj->As_PhysicalGameObj();
  480. if ( phyobj != NULL ) {
  481. ArmedGameObj *armed = phyobj->As_ArmedGameObj();
  482. if (armed) {
  483. WeaponClass * weapon = armed->Get_Weapon();
  484. if ( weapon != NULL ) {
  485. armed->Set_Targeting( target );
  486. if ( primary_fire ) {
  487. weapon->Set_Primary_Triggered( trigger );
  488. } else {
  489. weapon->Set_Secondary_Triggered( trigger );
  490. }
  491. } else {
  492. Debug_Say(( "This object does not have this weapon\n" ));
  493. }
  494. } else {
  495. Debug_Say(( "This object cannot fire weapons\n" ));
  496. }
  497. } else {
  498. Debug_Say(( "This object cannot fire weapons\n" ));
  499. }
  500. }
  501. void Select_Weapon( GameObject * obj, const char * weapon_name )
  502. {
  503. SCRIPT_PTR_CHECK( obj );
  504. SCRIPT_TRACE(( "ST>Select_Weapon( %d, %s\n", obj->Get_ID(), weapon_name ));
  505. PhysicalGameObj *phyobj = obj->As_PhysicalGameObj();
  506. if ( phyobj != NULL ) {
  507. ArmedGameObj *armed = phyobj->As_ArmedGameObj();
  508. if (armed) {
  509. armed->Get_Weapon_Bag()->Select_Weapon_Name( weapon_name );
  510. } else {
  511. Debug_Say(( "This object cannot fire weapons\n" ));
  512. }
  513. } else {
  514. Debug_Say(( "This object cannot fire weapons\n" ));
  515. }
  516. }
  517. /*
  518. **
  519. */
  520. void Send_Custom_Event( GameObject * from, GameObject * to, int type, int param, float delay )
  521. {
  522. #if(0) // Denzil 4/4/00 - From not required for most messages
  523. SCRIPT_PTR_CHECK( from );
  524. SCRIPT_PTR_CHECK( to ); // ?? This may be okay to be null
  525. SCRIPT_TRACE(( "ST>Send_Custom_Event( %d, %d %d, %d )\n", from->Get_ID(), to->Get_ID(), type, param ));
  526. #else
  527. SCRIPT_PTR_CHECK( to );
  528. SCRIPT_TRACE(("ST>Send_Custom_Event( %d, %d %d, %d )\n",
  529. ((from != NULL) ? from->Get_ID() : 0), to->Get_ID(), type, param));
  530. #endif
  531. WWASSERT( type < CUSTOM_EVENT_SYSTEM_FIRST );
  532. if ( to ) {
  533. if ( delay <= 0 ) {
  534. const GameObjObserverList & observer_list = to->Get_Observers();
  535. for( int index = 0; index < observer_list.Count(); index++ ) {
  536. observer_list[ index ]->Custom( to, type, param, from );
  537. }
  538. } else {
  539. to->Start_Custom_Timer( from, delay, type, param );
  540. }
  541. }
  542. }
  543. void Send_Damaged_Event( GameObject * object, GameObject * damager )
  544. {
  545. SCRIPT_PTR_CHECK( object );
  546. SCRIPT_TRACE(("ST>Send_Damaged_Event( %d, %d )\n",
  547. object->Get_ID(), ((damager != NULL) ? damager->Get_ID() : 0) ));
  548. if ( object ) {
  549. const GameObjObserverList & observer_list = object->Get_Observers();
  550. for( int index = 0; index < observer_list.Count(); index++ ) {
  551. observer_list[ index ]->Damaged( object, damager, 0 );
  552. }
  553. }
  554. }
  555. /*
  556. **
  557. */
  558. float Get_Random( float min, float max )
  559. {
  560. return FreeRandom.Get_Float( min, max );
  561. }
  562. int Get_Random_Int( int min, int max )
  563. {
  564. return FreeRandom.Get_Int( min, max );
  565. }
  566. /*
  567. ** Find_Random_Simple_Object
  568. */
  569. GameObject *Find_Random_Simple_Object ( const char *preset_name )
  570. {
  571. SCRIPT_TRACE(( "ST>Find_Random_Simple_Object( %s )\n", preset_name ));
  572. GameObject *retval = NULL;
  573. DynamicVectorClass<SimpleGameObj *> obj_list;
  574. //
  575. // Build a list of all the simple game objects that match the criteria
  576. //
  577. SLNode<BaseGameObj> *node = NULL;
  578. for (node = GameObjManager::Get_Game_Obj_List()->Head(); node; node = node->Next()) {
  579. WWASSERT(node->Data() != NULL);
  580. //
  581. // Is this a simple game obj?
  582. //
  583. PhysicalGameObj *physical_obj = node->Data()->As_PhysicalGameObj();
  584. if ( physical_obj != NULL ) {
  585. SimpleGameObj *simple_obj = physical_obj->As_SimpleGameObj();
  586. if ( simple_obj != NULL ) {
  587. //
  588. // Is this one of the objects we can choose from?
  589. //
  590. if ( ::stricmp ( simple_obj->Get_Definition ().Get_Name (), preset_name ) == 0 ) {
  591. obj_list.Add (simple_obj);
  592. }
  593. }
  594. }
  595. }
  596. //
  597. // Index randomly into the object list
  598. //
  599. int count = obj_list.Count ();
  600. if ( count > 0 ) {
  601. int random_index = FreeRandom.Get_Int( count );
  602. retval = obj_list[random_index];
  603. }
  604. return retval;
  605. }
  606. /*
  607. ** Object Display
  608. */
  609. void Set_Model( GameObject * obj, const char * model_name )
  610. {
  611. SCRIPT_PTR_CHECK( obj );
  612. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  613. if ( pgobj == NULL ) {
  614. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  615. return;
  616. }
  617. if ( obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_SimpleGameObj() ) {
  618. if ( obj->As_PhysicalGameObj()->As_SimpleGameObj()->Get_Definition().Get_Is_Editor_Object() ) {
  619. Debug_Say(( "Can't Set_Model on a IsEditorObject %s %s\n", obj->As_PhysicalGameObj()->As_SimpleGameObj()->Get_Definition().Get_Name(), model_name ));
  620. // WWASSERT(0);
  621. }
  622. }
  623. // Matrix3D tm = pgobj->Get_Transform();
  624. SCRIPT_TRACE(( "ST>Set_Model( %d, %s, %d )\n", obj->Get_ID(), model_name == NULL ? "NULL" : model_name ));
  625. if (pgobj->As_SoldierGameObj() ) {
  626. // For soldiers, call Set_Model, so the anim control will be updated
  627. pgobj->As_SoldierGameObj()->Set_Model( model_name );
  628. } else {
  629. pgobj->Peek_Physical_Object()->Set_Model_By_Name( model_name );
  630. if ( pgobj->Get_Anim_Control() != NULL ) {
  631. pgobj->Get_Anim_Control()->Set_Model( pgobj->Peek_Model() );
  632. }
  633. }
  634. pgobj->Set_Object_Dirty_Bit( NetworkObjectClass::BIT_RARE, true);
  635. pgobj->Hide_Muzzle_Flashes(); // Cinematics need this
  636. return ;
  637. }
  638. void Set_Animation( GameObject * obj, const char * anim_name, bool looping, const char * sub_obj_name, float start_frame, float end_frame, bool is_blended )
  639. {
  640. SCRIPT_PTR_CHECK( obj );
  641. SCRIPT_TRACE(( "ST>Set_Animation( %d, %s, %d )\n", obj->Get_ID(), anim_name == NULL ? "NULL" : anim_name, looping ));
  642. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  643. if ( pgobj == NULL ) {
  644. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  645. return;
  646. }
  647. // check that this object is not in Action_Play_Animation
  648. if ( pgobj->As_SmartGameObj() != NULL ) {
  649. if ( pgobj->As_SmartGameObj()->Get_Action()->Is_Animating() ) {
  650. Debug_Say(( "Can't Set_Animation when Action_Play_Animationing\n" ));
  651. WWASSERT( 0 );
  652. }
  653. }
  654. if ( ( sub_obj_name != NULL ) && ( *sub_obj_name != 0 ) ) {
  655. RenderObjClass * model = pgobj->Peek_Model();
  656. RenderObjClass * sub = model->Get_Sub_Object_By_Name( sub_obj_name );
  657. if ( sub != NULL ) {
  658. HAnimClass * anim = WW3DAssetManager::Get_Instance()->Get_HAnim( anim_name );
  659. if ( anim != NULL ) {
  660. sub->Set_Animation( anim, start_frame, looping ? RenderObjClass::ANIM_MODE_LOOP : RenderObjClass::ANIM_MODE_ONCE );
  661. anim->Release_Ref();
  662. }
  663. sub->Release_Ref();
  664. }
  665. } else {
  666. CinematicGameObj * cinobj = pgobj->As_CinematicGameObj();
  667. if (cinobj != NULL) {
  668. // CinematicGameObj's require you to use the physics animation interface
  669. DynamicAnimPhysClass * dynanim = cinobj->Peek_Physical_Object()->As_DynamicAnimPhysClass();
  670. if (dynanim != NULL) {
  671. AnimCollisionManagerClass & anim_mgr = dynanim->Get_Animation_Manager();
  672. if (anim_name != NULL) {
  673. anim_mgr.Set_Animation(anim_name);
  674. }
  675. anim_mgr.Set_Current_Frame( start_frame );
  676. if (looping) {
  677. anim_mgr.Set_Animation_Mode(AnimCollisionManagerClass::ANIMATE_LOOP);
  678. } else {
  679. anim_mgr.Set_Animation_Mode(AnimCollisionManagerClass::ANIMATE_TARGET);
  680. anim_mgr.Set_Target_Frame_End();
  681. }
  682. //
  683. // Specify the target frame (if necessary)
  684. //
  685. if ( end_frame >= 0 ) {
  686. anim_mgr.Set_Target_Frame( end_frame );
  687. }
  688. //
  689. // "Dirty" the object for networking
  690. //
  691. cinobj->Set_Object_Dirty_Bit( NetworkObjectClass::BIT_RARE, true );
  692. } else {
  693. WWDEBUG_SAY(("Error! cinematic game obj %s not using DynamicAnimPhys.\r\n"));
  694. }
  695. } else {
  696. //
  697. // Soldier's can blend their animation, so if the game object is
  698. // a soldier and the blend flag is set, then blend the animation.
  699. //
  700. SoldierGameObj *soldier = pgobj->As_SoldierGameObj();
  701. if ( soldier != NULL && is_blended ) {
  702. soldier->Set_Blended_Animation( anim_name, looping, start_frame );
  703. } else {
  704. pgobj->Set_Animation( anim_name, looping, start_frame );
  705. }
  706. //
  707. // If the anim_name is the same as the current anim, then the frame_offset isn't set, so
  708. // force it.
  709. //
  710. AnimControlClass *anim_control = pgobj->Get_Anim_Control();
  711. if (anim_control != NULL) {
  712. anim_control->Set_Mode( looping ? ANIM_MODE_LOOP : ANIM_MODE_ONCE, start_frame );
  713. //
  714. // Specify the target frame (if necessary)
  715. //
  716. if ( end_frame >= 0 ) {
  717. anim_control->Set_Mode( ANIM_MODE_TARGET, start_frame );
  718. anim_control->Set_Target_Frame( end_frame );
  719. }
  720. }
  721. }
  722. }
  723. }
  724. void Set_Animation_Frame( GameObject * obj, const char * anim_name, int frame )
  725. {
  726. SCRIPT_PTR_CHECK( obj );
  727. SCRIPT_TRACE(( "ST>Set_Animation_Frame( %d, %s, %d )\n", obj->Get_ID(), anim_name == NULL ? "NULL" : anim_name, frame ));
  728. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  729. if ( pgobj == NULL ) {
  730. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  731. return;
  732. }
  733. // check that this object is not in Action_Play_Animation
  734. if ( pgobj->As_SmartGameObj() != NULL ) {
  735. if ( pgobj->As_SmartGameObj()->Get_Action()->Is_Animating() ) {
  736. Debug_Say(( "Can't Set_Animation when Action_Play_Animationing\n" ));
  737. WWASSERT( 0 );
  738. }
  739. }
  740. pgobj->Set_Animation_Frame ( anim_name, frame );
  741. }
  742. /*
  743. **
  744. */
  745. int Create_Sound(const char* sound_name, const Vector3& position, GameObject* creator)
  746. {
  747. SCRIPT_TRACE(("ST>Create_Sound( %s, (%f,%f,%f) )\n", sound_name, position[0], position[1], position[2]));
  748. Matrix3D matrix(true);
  749. matrix.Set_Translation(position);
  750. WWAudioClass* audio = WWAudioClass::Get_Instance();
  751. assert(audio != NULL);
  752. RefCountedGameObjReference *owner_ref = new RefCountedGameObjReference;
  753. owner_ref->Set_Ptr( creator );
  754. int sound_id = audio->Create_Instant_Sound(sound_name, matrix, owner_ref);
  755. REF_PTR_RELEASE( owner_ref );
  756. return sound_id;
  757. }
  758. int Create_2D_Sound( const char * sound_preset_name )
  759. {
  760. WWAudioClass* audio = WWAudioClass::Get_Instance();
  761. assert(audio != NULL);
  762. //
  763. // Create the sound object from its preset
  764. //
  765. int sound_id = 0;
  766. AudibleSoundClass *sound = audio->Create_Sound( sound_preset_name );
  767. if ( sound != NULL ) {
  768. sound_id = sound->Get_ID ();
  769. sound->Play();
  770. sound->Release_Ref();
  771. }
  772. return sound_id;
  773. }
  774. int Create_2D_WAV_Sound( const char * wav_filename )
  775. {
  776. WWAudioClass* audio = WWAudioClass::Get_Instance();
  777. assert(audio != NULL);
  778. AudibleSoundClass * sound = audio->Create_Sound_Effect(wav_filename);
  779. int sound_id = 0;
  780. if ( sound != NULL ) {
  781. WWASSERT( sound->Get_Loop_Count() != 0 );
  782. sound_id = sound->Get_ID ();
  783. sound->Play();
  784. sound->Release_Ref();
  785. }
  786. return sound_id;
  787. }
  788. int Create_3D_Sound_At_Bone( const char * sound_preset_name, GameObject * obj, const char * bone_name )
  789. {
  790. WWAudioClass* audio = WWAudioClass::Get_Instance();
  791. assert(audio != NULL);
  792. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  793. if ( pgobj == NULL ) {
  794. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  795. return 0;
  796. }
  797. //
  798. // Create the sound object from its preset
  799. //
  800. int sound_id = 0;
  801. AudibleSoundClass *sound = audio->Create_Sound( sound_preset_name );
  802. if ( sound != NULL ) {
  803. //
  804. // Attach the sound to the bone
  805. //
  806. RenderObjClass * model = pgobj->Peek_Model();
  807. int bone_index = model->Get_Bone_Index( bone_name );
  808. sound->Attach_To_Object( model, bone_index );
  809. //
  810. // Add the sound to the world and release our hold on it
  811. //
  812. sound_id = sound->Get_ID ();
  813. sound->Add_To_Scene();
  814. REF_PTR_RELEASE( sound );
  815. }
  816. return sound_id;
  817. }
  818. int Create_3D_WAV_Sound_At_Bone( const char * wav_filename, GameObject * obj, const char * bone_name )
  819. {
  820. WWAudioClass* audio = WWAudioClass::Get_Instance();
  821. assert(audio != NULL);
  822. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  823. if ( pgobj == NULL ) {
  824. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  825. return 0;
  826. }
  827. int sound_id = 0;
  828. Sound3DClass * sound = audio->Create_3D_Sound( wav_filename );
  829. if ( sound ) {
  830. sound_id = sound->Get_ID ();
  831. sound->Set_Type ( AudibleSoundClass::TYPE_SOUND_EFFECT );
  832. sound->Set_Priority ( 1 );
  833. sound->Set_Volume ( 1 );
  834. sound->Set_Loop_Count ( 1 );
  835. sound->Set_DropOff_Radius ( 30 );
  836. sound->Set_Definition ( NULL );
  837. sound->Set_Max_Vol_Radius ( 30 );
  838. RenderObjClass * model = pgobj->Peek_Model();
  839. int bone_index = model->Get_Bone_Index( bone_name );
  840. sound->Attach_To_Object( model, bone_index );
  841. sound->Add_To_Scene();
  842. sound->Release_Ref();
  843. }
  844. return sound_id;
  845. }
  846. int Create_Logical_Sound( GameObject * creator, int type, const Vector3 & position, float radius )
  847. {
  848. SCRIPT_TRACE(("ST>Create_Sound( %d, (%f,%f,%f) )\n", type, position[0], position[1], position[2]));
  849. int sound_id = 0;
  850. WWAudioClass* audio = WWAudioClass::Get_Instance();
  851. if ( audio != NULL ) {
  852. LogicalSoundClass * sound = audio->Create_Logical_Sound();
  853. if ( sound != NULL ) {
  854. RefCountedGameObjReference *owner_ref = new RefCountedGameObjReference;
  855. owner_ref->Set_Ptr( creator );
  856. sound->Set_User_Data( owner_ref, 0 );
  857. REF_PTR_RELEASE( owner_ref );
  858. sound_id = sound->Get_ID ();
  859. sound->Set_Type_Mask( type );
  860. sound->Set_Notify_Delay( 0 );
  861. sound->Set_Single_Shot( true );
  862. sound->Set_DropOff_Radius( radius );
  863. sound->Set_Position( position );
  864. sound->Add_To_Scene ();
  865. sound->Release_Ref();
  866. }
  867. }
  868. return sound_id;
  869. }
  870. void Monitor_Sound( GameObject * game_obj, int sound_id )
  871. {
  872. SCRIPT_TRACE(("ST>Monitor_Sound( %d, %d )\n", game_obj->Get_ID(), sound_id));
  873. WWAudioClass* audio = WWAudioClass::Get_Instance();
  874. if ( audio != NULL ) {
  875. //
  876. // Lookup the sound object by its ID
  877. //
  878. SoundSceneObjClass *sound_obj = audio->Find_Sound_Object (sound_id);
  879. if ( sound_obj != NULL ) {
  880. //
  881. // Register the game object as a callback for the sound object
  882. //
  883. sound_obj->Register_Callback( AudioCallbackClass::EVENT_SOUND_ENDED, game_obj );
  884. }
  885. }
  886. return ;
  887. }
  888. void Fade_Background_Music( const char * wav_filename, int fade_out_time, int fade_in_time )
  889. {
  890. SCRIPT_TRACE(("ST>Fade_Background_Music( %s, %d, %d )\n", wav_filename, fade_out_time, fade_in_time));
  891. WWAudioClass* audio = WWAudioClass::Get_Instance();
  892. if ( audio != NULL ) {
  893. //
  894. // Pass the background music onto the sound library
  895. //
  896. audio->Fade_Background_Music( wav_filename, fade_out_time, fade_in_time );
  897. }
  898. return ;
  899. }
  900. void Set_Background_Music( const char * wav_filename )
  901. {
  902. SCRIPT_TRACE(("ST>Set_Background_Music( %s )\n", wav_filename));
  903. WWAudioClass* audio = WWAudioClass::Get_Instance();
  904. if ( audio != NULL ) {
  905. //
  906. // Pass the background music onto the sound library
  907. //
  908. audio->Set_Background_Music( wav_filename );
  909. }
  910. return ;
  911. }
  912. void Stop_Background_Music( void )
  913. {
  914. SCRIPT_TRACE(("ST>Stop_Background_Music( )\n"));
  915. WWAudioClass* audio = WWAudioClass::Get_Instance();
  916. if ( audio != NULL ) {
  917. //
  918. // Simply stop the background music
  919. //
  920. audio->Set_Background_Music( NULL );
  921. }
  922. return ;
  923. }
  924. void Start_Sound( int sound_id )
  925. {
  926. SCRIPT_TRACE(("ST>Stop_Sound( %d )\n", sound_id));
  927. WWAudioClass* audio = WWAudioClass::Get_Instance();
  928. if ( audio != NULL ) {
  929. //
  930. // Lookup the sound object by its ID
  931. //
  932. SoundSceneObjClass *sound_obj = audio->Find_Sound_Object( sound_id );
  933. if ( sound_obj != NULL) {
  934. //
  935. // Add the sound to the scene (if necessary)
  936. //
  937. if ( sound_obj->Is_In_Scene() == false ) {
  938. sound_obj->Add_To_Scene();
  939. }
  940. //
  941. // Start playing the sound
  942. //
  943. AudibleSoundClass *audible_sound = sound_obj->As_AudibleSoundClass();
  944. if (audible_sound != NULL) {
  945. audible_sound->Play();
  946. }
  947. }
  948. }
  949. return ;
  950. }
  951. void Stop_Sound( int sound_id, bool destroy_sound )
  952. {
  953. SCRIPT_TRACE(("ST>Stop_Sound( %d )\n", sound_id));
  954. WWAudioClass* audio = WWAudioClass::Get_Instance();
  955. if ( audio != NULL ) {
  956. //
  957. // Lookup the sound object by its ID
  958. //
  959. SoundSceneObjClass *sound_obj = audio->Find_Sound_Object( sound_id );
  960. if ( sound_obj != NULL ) {
  961. //
  962. // Stop playing the sound
  963. //
  964. AudibleSoundClass *audible_sound = sound_obj->As_AudibleSoundClass();
  965. if (audible_sound != NULL) {
  966. audible_sound->Stop();
  967. }
  968. //
  969. // Remove the sound from the world (this will destroy the sound)
  970. //
  971. if ( destroy_sound ) {
  972. sound_obj->Remove_From_Scene();
  973. }
  974. }
  975. }
  976. return ;
  977. }
  978. /*
  979. **
  980. */
  981. float Get_Health( GameObject * obj )
  982. {
  983. SCRIPT_PTR_CHECK_RET( obj, 0 );
  984. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  985. if ( dgobj == NULL ) {
  986. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  987. return 0;
  988. }
  989. return dgobj->Get_Defense_Object()->Get_Health();
  990. }
  991. float Get_Max_Health( GameObject * obj )
  992. {
  993. SCRIPT_PTR_CHECK_RET( obj, 0 );
  994. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  995. if ( dgobj == NULL ) {
  996. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  997. return 0;
  998. }
  999. return dgobj->Get_Defense_Object()->Get_Health_Max();
  1000. }
  1001. void Set_Health( GameObject * obj, float health )
  1002. {
  1003. SCRIPT_PTR_CHECK( obj );
  1004. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  1005. if ( dgobj == NULL ) {
  1006. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  1007. return;
  1008. }
  1009. dgobj->Get_Defense_Object()->Set_Health( health );
  1010. }
  1011. float Get_Shield_Strength( GameObject * obj )
  1012. {
  1013. SCRIPT_PTR_CHECK_RET( obj, 0 );
  1014. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  1015. if ( dgobj == NULL ) {
  1016. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  1017. return 0;
  1018. }
  1019. return dgobj->Get_Defense_Object()->Get_Shield_Strength();
  1020. }
  1021. float Get_Max_Shield_Strength( GameObject * obj )
  1022. {
  1023. SCRIPT_PTR_CHECK_RET( obj, 0 );
  1024. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  1025. if ( dgobj == NULL ) {
  1026. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  1027. return 0;
  1028. }
  1029. return dgobj->Get_Defense_Object()->Get_Shield_Strength_Max();
  1030. }
  1031. void Set_Shield_Strength( GameObject * obj, float strength )
  1032. {
  1033. SCRIPT_PTR_CHECK( obj );
  1034. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  1035. if ( dgobj == NULL ) {
  1036. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  1037. return;
  1038. }
  1039. dgobj->Get_Defense_Object()->Set_Shield_Strength( strength );
  1040. }
  1041. void Set_Shield_Type( GameObject * obj, const char * name )
  1042. {
  1043. SCRIPT_PTR_CHECK( obj );
  1044. DamageableGameObj * dgobj = obj->As_DamageableGameObj();
  1045. if ( dgobj == NULL ) {
  1046. Debug_Say(( "Not a DamageableGameObj at %s %d\n", __FILE__, __LINE__ ));
  1047. return;
  1048. }
  1049. dgobj->Get_Defense_Object()->Set_Shield_Type( ArmorWarheadManager::Get_Armor_Type( name ) );
  1050. }
  1051. int Get_Player_Type( GameObject * obj )
  1052. {
  1053. SCRIPT_PTR_CHECK_RET( obj, 0 );
  1054. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1055. if ( pgobj == NULL ) {
  1056. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1057. return 0;
  1058. }
  1059. return pgobj->Get_Player_Type();
  1060. }
  1061. void Set_Player_Type( GameObject * obj, int type )
  1062. {
  1063. SCRIPT_PTR_CHECK( obj );
  1064. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1065. if ( pgobj == NULL ) {
  1066. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1067. } else {
  1068. pgobj->Set_Player_Type( type );
  1069. }
  1070. }
  1071. /*
  1072. **
  1073. */
  1074. float Get_Distance( const Vector3 & p1, const Vector3 & p2 )
  1075. {
  1076. Vector3 v = p1 - p2;
  1077. return v.Length();
  1078. }
  1079. /*
  1080. **
  1081. */
  1082. void Set_Camera_Host( GameObject * obj )
  1083. {
  1084. //SCRIPT_PTR_CHECK( obj );
  1085. SCRIPT_TRACE(( "ST>Set_Camera_Host( %p )\n", obj ));
  1086. if ( obj == NULL ) {
  1087. COMBAT_CAMERA->Set_Host_Model( NULL );
  1088. } else {
  1089. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1090. if ( pgobj == NULL ) {
  1091. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1092. return;
  1093. }
  1094. COMBAT_CAMERA->Set_Host_Model( pgobj->Peek_Model() );
  1095. }
  1096. }
  1097. void Force_Camera_Look( const Vector3 & target )
  1098. {
  1099. //SCRIPT_PTR_CHECK( obj );
  1100. SCRIPT_TRACE(( "ST>Force_Camera_Look( %f %f %f )\n", target.X, target.Y, target.Z ));
  1101. if ( COMBAT_CAMERA ) {
  1102. COMBAT_CAMERA->Force_Look( target );
  1103. }
  1104. }
  1105. /*
  1106. **
  1107. ** Find_Closest_Soldier
  1108. **
  1109. */
  1110. GameObject * Find_Closest_Soldier( const Vector3 & pos, float min_dist, float max_dist, bool only_human )
  1111. {
  1112. AABoxClass box (pos, Vector3 (max_dist / 2, max_dist / 2, max_dist / 2));
  1113. //
  1114. // Collect all the dynamic objects in this box
  1115. //
  1116. NonRefPhysListClass obj_list;
  1117. PhysicsSceneClass::Get_Instance ()->Collect_Objects (box, false, true, &obj_list);
  1118. float closest_dist = max_dist;
  1119. GameObject *closest_obj = NULL;
  1120. //
  1121. // Loop over all the collected objects
  1122. //
  1123. NonRefPhysListIterator it (&obj_list);
  1124. for (it.First(); !it.Is_Done(); it.Next()) {
  1125. PhysClass *phys_obj = it.Peek_Obj ();
  1126. PhysicalGameObj *game_obj = NULL;
  1127. if ( phys_obj->Get_Observer() != NULL ) {
  1128. game_obj = ((CombatPhysObserverClass *)phys_obj->Get_Observer())->As_PhysicalGameObj();
  1129. }
  1130. if (game_obj != NULL && game_obj->As_PhysicalGameObj() != NULL ) {
  1131. Vector3 obj_pos;
  1132. game_obj->As_PhysicalGameObj()->Get_Position (&obj_pos);
  1133. //
  1134. // Is this object the closest one we found yet?
  1135. //
  1136. float len = (obj_pos - pos).Length ();
  1137. if (len >= min_dist && len <= closest_dist) {
  1138. //
  1139. // If only_human, see if this is a human. Duh.
  1140. //
  1141. if (!only_human ||
  1142. (game_obj->As_SmartGameObj() != NULL &&
  1143. game_obj->As_SmartGameObj()->Is_Human_Controlled())) {
  1144. closest_dist = len;
  1145. closest_obj = game_obj;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. return closest_obj;
  1151. }
  1152. /*
  1153. **
  1154. */
  1155. GameObject * Get_The_Star( void )
  1156. {
  1157. return (GameObject*)COMBAT_STAR;
  1158. }
  1159. GameObject * Get_A_Star( const Vector3 & pos )
  1160. {
  1161. SoldierGameObj * nearest_human_player = NULL;
  1162. Vector3 n_c_pos = Vector3( 1000000,1000000,1000000 );
  1163. n_c_pos += pos;
  1164. SLNode<SmartGameObj> *objnode;
  1165. for ( objnode = GameObjManager::Get_Smart_Game_Obj_List()->Head(); objnode; objnode = objnode->Next() ) {
  1166. SoldierGameObj * soldier = objnode->Data()->As_SoldierGameObj();
  1167. if ( soldier && soldier->Is_Human_Controlled() ) {
  1168. Vector3 c_pos;
  1169. soldier->Get_Position( &c_pos );
  1170. c_pos -= pos;
  1171. if ( c_pos.Length2() < n_c_pos.Length2() ) {
  1172. nearest_human_player = soldier;
  1173. n_c_pos = c_pos;
  1174. }
  1175. }
  1176. }
  1177. return nearest_human_player;
  1178. }
  1179. bool Is_A_Star( GameObject * obj )
  1180. {
  1181. SCRIPT_PTR_CHECK_RET( obj, false );
  1182. if ( obj->As_SmartGameObj() ) {
  1183. SoldierGameObj * soldier = obj->As_SmartGameObj()->As_SoldierGameObj();
  1184. return soldier && soldier->Is_Human_Controlled();
  1185. }
  1186. return false;
  1187. }
  1188. /*
  1189. ** HACK
  1190. */
  1191. const char * Get_Damage_Bone_Name( void )
  1192. {
  1193. return DamageModelName;
  1194. }
  1195. bool Get_Damage_Bone_Direction( void )
  1196. {
  1197. return DamageModelDirection;
  1198. }
  1199. /*
  1200. **
  1201. */
  1202. void Control_Enable( GameObject * obj, bool enable )
  1203. {
  1204. SCRIPT_PTR_CHECK( obj );
  1205. SCRIPT_TRACE(( "ST>Control_Enable( %d, %d )\n", obj->Get_ID(), enable ));
  1206. SmartGameObj *smart = obj->As_SmartGameObj();
  1207. if (smart) {
  1208. smart->Control_Enable( enable );
  1209. } else {
  1210. Debug_Say(( "This object can't Control_Enable\n" ));
  1211. }
  1212. }
  1213. /*
  1214. **
  1215. */
  1216. bool Is_Object_Visible( GameObject * looker, GameObject * obj )
  1217. {
  1218. SCRIPT_PTR_CHECK_RET( looker, false );
  1219. SCRIPT_PTR_CHECK_RET( obj, false );
  1220. SCRIPT_TRACE(( "ST>Is_Object_Visible( %d, %d )\n", looker->Get_ID(), obj->Get_ID() ));
  1221. SmartGameObj *smart = looker->As_SmartGameObj();
  1222. if (smart) {
  1223. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1224. if ( pgobj == NULL ) {
  1225. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1226. return false;
  1227. }
  1228. return smart->Is_Obj_Visible( pgobj );
  1229. } else {
  1230. Debug_Say(( "This object can't Is_Object_Visible\n" ));
  1231. }
  1232. return false;
  1233. }
  1234. void Enable_Enemy_Seen( GameObject * obj, bool enable )
  1235. {
  1236. SCRIPT_PTR_CHECK( obj );
  1237. SCRIPT_TRACE(( "ST>Enable_Enemy_Seen( %d, %d )\n", obj->Get_ID(), enable ));
  1238. SmartGameObj *smart = obj->As_SmartGameObj();
  1239. if (smart) {
  1240. smart->Set_Enemy_Seen_Enabled( enable );
  1241. } else {
  1242. Debug_Say(( "Only Smart Objs can Enable_Enemy_Seen\n" ));
  1243. }
  1244. }
  1245. /*
  1246. **
  1247. */
  1248. Vector3 _DisplayColor( 1,1,1 );
  1249. void Set_Display_Color( unsigned char red, unsigned char green, unsigned char blue )
  1250. {
  1251. _DisplayColor = Vector3( (float)red/255.0f, (float)green/255.0f, (float)blue/255.0f );
  1252. }
  1253. void Display_Text( int string_id )
  1254. {
  1255. TDBObjClass * obj = TranslateDBClass::Find_Object( string_id );
  1256. if ( obj ) {
  1257. DebugManager::Display_Text( obj->Get_String(), _DisplayColor );
  1258. int sound_def_id = (int)obj->Get_Sound_ID ();
  1259. if (sound_def_id > 0) {
  1260. // Create the sound object
  1261. AudibleSoundClass * sound = WWAudioClass::Get_Instance ()->Create_Sound (sound_def_id);
  1262. if (sound != NULL) {
  1263. sound->Add_To_Scene();
  1264. sound->Release_Ref();
  1265. }
  1266. }
  1267. }
  1268. }
  1269. void Display_Float( float value, const char * format )
  1270. {
  1271. WideStringClass wide_format;
  1272. wide_format.Convert_From( format );
  1273. WideStringClass string;
  1274. string.Format( wide_format, value );
  1275. DebugManager::Display_Text( string, _DisplayColor );
  1276. }
  1277. void Display_Int( int value, const char * format )
  1278. {
  1279. WideStringClass wide_format;
  1280. wide_format.Convert_From( format );
  1281. WideStringClass string;
  1282. string.Format( wide_format, value );
  1283. DebugManager::Display_Text( string, _DisplayColor );
  1284. }
  1285. /*
  1286. **
  1287. */
  1288. void Save_Data( ScriptSaver & saver, int id, int size, void * data )
  1289. {
  1290. SCRIPT_PTR_CHECK( data );
  1291. saver.CSave.Begin_Micro_Chunk(id);
  1292. saver.CSave.Write(data,size);
  1293. saver.CSave.End_Micro_Chunk();
  1294. WWASSERT((unsigned)size <= 250); // Make sure we don't save too much
  1295. }
  1296. void Save_Pointer(ScriptSaver& saver, int id, void* pointer)
  1297. {
  1298. SCRIPT_PTR_CHECK(pointer);
  1299. Save_Data(saver, id, sizeof(pointer), pointer);
  1300. }
  1301. bool Load_Begin( ScriptLoader & loader, int * id )
  1302. {
  1303. SCRIPT_PTR_CHECK_RET( id, false );
  1304. if ( !loader.CLoad.Open_Micro_Chunk()) {
  1305. return false;
  1306. }
  1307. *id = loader.CLoad.Cur_Micro_Chunk_ID();
  1308. return true;
  1309. }
  1310. void Load_Data( ScriptLoader & loader, int size, void * data )
  1311. {
  1312. SCRIPT_PTR_CHECK( data );
  1313. unsigned int chunkSize = loader.CLoad.Cur_Micro_Chunk_Length();
  1314. WWASSERT((unsigned)size >= chunkSize);
  1315. loader.CLoad.Read(data, chunkSize);
  1316. WWASSERT((unsigned)size <= 250); // Make sure we don't save too much
  1317. }
  1318. void Load_Pointer(ScriptLoader& loader, void** pointer)
  1319. {
  1320. SCRIPT_PTR_CHECK(pointer);
  1321. Load_Data(loader, sizeof(void*), pointer);
  1322. REQUEST_POINTER_REMAP(pointer);
  1323. }
  1324. void Load_End( ScriptLoader & loader )
  1325. {
  1326. loader.CLoad.Close_Micro_Chunk();
  1327. }
  1328. void Begin_Chunk(ScriptSaver& saver, unsigned int chunkID)
  1329. {
  1330. saver.CSave.Begin_Chunk(chunkID);
  1331. }
  1332. void End_Chunk(ScriptSaver& saver)
  1333. {
  1334. saver.CSave.End_Chunk();
  1335. }
  1336. bool Open_Chunk(ScriptLoader& loader, unsigned int* chunkID)
  1337. {
  1338. SCRIPT_PTR_CHECK_RET(chunkID, false);
  1339. if (loader.CLoad.Open_Chunk()) {
  1340. *chunkID = loader.CLoad.Cur_Chunk_ID();
  1341. return true;
  1342. }
  1343. return false;
  1344. }
  1345. void Close_Chunk(ScriptLoader& loader)
  1346. {
  1347. loader.CLoad.Close_Chunk();
  1348. }
  1349. //
  1350. // Clear_Map_Cell
  1351. //
  1352. void
  1353. Clear_Map_Cell( int cell_x, int cell_y )
  1354. {
  1355. SCRIPT_TRACE(( "ST>Clear_Map_Cell( %d, %d)\n", cell_x, cell_y ));
  1356. MapMgrClass::Clear_Cloud_Cell( cell_x, cell_y );
  1357. HUDClass::Add_Map_Reveal();
  1358. return ;
  1359. }
  1360. //
  1361. // Clear_Map_Cell_By_Pos
  1362. //
  1363. void
  1364. Clear_Map_Cell_By_Pos( const Vector3 &world_space_pos )
  1365. {
  1366. SCRIPT_TRACE(( "ST>Clear_Map_Cell_By_Pos( %f, %f, %f)\n", world_space_pos.X, world_space_pos.Y, world_space_pos.Z ));
  1367. MapMgrClass::Clear_Cloud_Cell( world_space_pos );
  1368. HUDClass::Add_Map_Reveal();
  1369. return ;
  1370. }
  1371. //
  1372. // Clear_Map_Region_By_Pos
  1373. //
  1374. void
  1375. Clear_Map_Region_By_Pos( const Vector3 &world_space_pos, int pixel_radius )
  1376. {
  1377. SCRIPT_TRACE(( "ST>Clear_Map_Region_By_Pos( %f, %f, %f, %d)\n", world_space_pos.X, world_space_pos.Y, world_space_pos.Z, pixel_radius ));
  1378. MapMgrClass::Clear_Cloud_Cells( world_space_pos, pixel_radius );
  1379. HUDClass::Add_Map_Reveal();
  1380. return ;
  1381. }
  1382. //
  1383. // Clear_Map_Cell_By_Pixel_Pos
  1384. //
  1385. void
  1386. Clear_Map_Cell_By_Pixel_Pos( int pixel_pos_x, int pixel_pos_y )
  1387. {
  1388. SCRIPT_TRACE(( "ST>Clear_Map_Cell_By_Pixel_Pos( %d, %d)\n", pixel_pos_x, pixel_pos_y ));
  1389. MapMgrClass::Clear_Cloud_Cell_By_Pixel( pixel_pos_x, pixel_pos_y );
  1390. HUDClass::Add_Map_Reveal();
  1391. return ;
  1392. }
  1393. //
  1394. // Show_Player_Map_Marker
  1395. //
  1396. void
  1397. Show_Player_Map_Marker( bool onoff )
  1398. {
  1399. SCRIPT_TRACE(( "ST>Show_Player_Map_Marker()\n" ));
  1400. MapMgrClass::Show_Player_Marker( onoff );
  1401. return ;
  1402. }
  1403. //
  1404. // Reveal_Map
  1405. //
  1406. void
  1407. Reveal_Map( void )
  1408. {
  1409. SCRIPT_TRACE(( "ST>Reveal_Map()\n" ));
  1410. MapMgrClass::Clear_All_Cloud_Cells();
  1411. HUDClass::Add_Map_Reveal();
  1412. return ;
  1413. }
  1414. //
  1415. // Shroud_Map
  1416. //
  1417. void
  1418. Shroud_Map( void )
  1419. {
  1420. SCRIPT_TRACE(( "ST>Shroud_Map()\n" ));
  1421. MapMgrClass::Cloud_All_Cells();
  1422. return ;
  1423. }
  1424. //
  1425. // Get_Safe_Flight_Height
  1426. //
  1427. float
  1428. Get_Safe_Flight_Height (float x_pos, float y_pos)
  1429. {
  1430. SCRIPT_TRACE(( "ST>Get_Safe_Flight_Height( %.2f, %.2f )\n", x_pos, y_pos ));
  1431. return HeightDBClass::Get_Height ( Vector3 ( x_pos, y_pos, 0 ) );
  1432. }
  1433. /*
  1434. **
  1435. */
  1436. void Clear_Radar_Markers( void )
  1437. {
  1438. SCRIPT_TRACE(( "ST>Clear_Radar_Markers()\n" ));
  1439. RadarManager::Clear_Markers();
  1440. }
  1441. void Clear_Radar_Marker( int id )
  1442. {
  1443. SCRIPT_TRACE(( "ST>Clear_Radar_Marker( %d )\n", id ));
  1444. RadarManager::Clear_Marker( id );
  1445. }
  1446. #if 0
  1447. void Add_Radar_Marker( int id, const Vector3& position, const Vector3& color, bool flash )
  1448. {
  1449. SCRIPT_TRACE(( "ST>Add_Radar_Marker( %d, (%f,%f,%f), (%f,%f,%f), %d)\n",
  1450. id, position.X, position.Y, position.Z, color.X, color.Y, color.Z, flash ));
  1451. /* RadarMarkerClass marker;
  1452. marker.ID = id;
  1453. marker.Position = position;
  1454. marker.Color = color;
  1455. marker.Flash = flash;
  1456. RadarManager::Add_Marker( marker );*/
  1457. }
  1458. #else
  1459. void Add_Radar_Marker( int id, const Vector3& position, int shape_type, int color_type )
  1460. {
  1461. SCRIPT_TRACE(( "ST>Add_Radar_Marker( %d, (%f,%f,%f), %d, %d)\n",
  1462. id, position.X, position.Y, position.Z, shape_type, color_type ));
  1463. RadarMarkerClass marker;
  1464. marker.ID = id;
  1465. marker.Position = position;
  1466. marker.Type = shape_type;
  1467. marker.Color = color_type;
  1468. RadarManager::Add_Marker( marker );
  1469. }
  1470. #endif
  1471. #if 0
  1472. void Add_Obj_Radar_Marker( int id, GameObject * obj, Vector3 color, bool flash )
  1473. {
  1474. SCRIPT_PTR_CHECK( obj );
  1475. SCRIPT_TRACE(( "ST>Add_Radar_Marker( %d, %d, (%f,%f,%f), %d)\n",
  1476. id, obj->Get_ID(), color.X, color.Y, color.Z, flash ));
  1477. SCRIPT_PTR_CHECK( obj );
  1478. /* RadarMarkerClass marker;
  1479. marker.ID = id;*/
  1480. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1481. if ( pgobj == NULL ) {
  1482. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1483. return;
  1484. }
  1485. /* marker.Set_Game_Object( pgobj );
  1486. marker.Color = color;
  1487. marker.Flash = flash;
  1488. RadarManager::Add_Marker( marker );*/
  1489. }
  1490. #endif
  1491. void Set_Obj_Radar_Blip_Shape( GameObject * obj, int shape_type )
  1492. {
  1493. SCRIPT_PTR_CHECK( obj );
  1494. SCRIPT_TRACE(( "ST>Set_Obj_Radar_Blip_Shape( %d, %d )\n", obj->Get_ID(), shape_type ));
  1495. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1496. if ( pgobj == NULL ) {
  1497. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1498. return;
  1499. }
  1500. if ( shape_type < 0 ) {
  1501. pgobj->Reset_Radar_Blip_Shape_Type();
  1502. } else {
  1503. pgobj->Set_Radar_Blip_Shape_Type( shape_type );
  1504. }
  1505. }
  1506. void Set_Obj_Radar_Blip_Color( GameObject * obj, int color_type )
  1507. {
  1508. SCRIPT_PTR_CHECK( obj );
  1509. SCRIPT_TRACE(( "ST>Set_Obj_Radar_Blip_Color( %d, %d )\n", obj->Get_ID(), color_type ));
  1510. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1511. if ( pgobj == NULL ) {
  1512. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1513. return;
  1514. }
  1515. if ( color_type < 0 ) {
  1516. pgobj->Reset_Radar_Blip_Color_Type();
  1517. } else {
  1518. pgobj->Set_Radar_Blip_Color_Type( color_type );
  1519. }
  1520. }
  1521. void Enable_Radar( bool enable )
  1522. {
  1523. SCRIPT_TRACE(( "ST>Enable_Radar( %d )\n", enable ));
  1524. RadarManager::Set_Hidden( !enable );
  1525. }
  1526. /*
  1527. **
  1528. */
  1529. void Create_Explosion( const char * explosion_def_name, const Vector3 & pos, GameObject * creator )
  1530. {
  1531. SCRIPT_PTR_CHECK( explosion_def_name );
  1532. SCRIPT_TRACE(( "ST>Create_Explosion( %s, (%f,%f,%f), %d )\n",
  1533. explosion_def_name, pos.X, pos.Y, pos.Z, (creator != NULL ) ? creator->Get_ID() : 0 ));
  1534. ExplosionDefinitionClass * explosion_def = (ExplosionDefinitionClass *)DefinitionMgrClass::Find_Typed_Definition( explosion_def_name, CLASSID_DEF_EXPLOSION );
  1535. if ( explosion_def != NULL )
  1536. {
  1537. int explosion_id = explosion_def->Get_ID();
  1538. SmartGameObj * smart = NULL;
  1539. if ( creator ) {
  1540. smart = creator->As_SmartGameObj();
  1541. }
  1542. ExplosionManager::Create_Explosion_At( explosion_id, pos, smart );
  1543. }
  1544. }
  1545. void Create_Explosion_At_Bone( const char * explosion_def_name, GameObject * object, const char * bone_name, GameObject * creator )
  1546. {
  1547. SCRIPT_PTR_CHECK( explosion_def_name );
  1548. SCRIPT_PTR_CHECK( object );
  1549. SCRIPT_PTR_CHECK( bone_name );
  1550. SCRIPT_TRACE(( "ST>Create_Explosion_At_Bone( %s, %d, %s, %d )\n",
  1551. explosion_def_name,
  1552. (object != NULL) ? object->Get_ID() : 0 ,
  1553. bone_name,
  1554. (creator != NULL ) ? creator->Get_ID() : 0 ));
  1555. ExplosionDefinitionClass * explosion_def = (ExplosionDefinitionClass *)DefinitionMgrClass::Find_Typed_Definition( explosion_def_name, CLASSID_DEF_EXPLOSION );
  1556. if ( explosion_def != NULL )
  1557. {
  1558. int explosion_id = explosion_def->Get_ID();
  1559. SmartGameObj * smart = NULL;
  1560. if ( creator ) {
  1561. smart = creator->As_SmartGameObj();
  1562. }
  1563. PhysicalGameObj * pgobj = object->As_PhysicalGameObj();
  1564. if ( pgobj == NULL ) {
  1565. Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1566. return;
  1567. }
  1568. Matrix3D tm = pgobj->Peek_Model()->Get_Bone_Transform( bone_name );
  1569. ExplosionManager::Create_Explosion_At( explosion_id, tm, smart );
  1570. }
  1571. }
  1572. /*
  1573. **
  1574. */
  1575. void Enable_HUD( bool enable )
  1576. {
  1577. SCRIPT_TRACE(( "ST>Enable_HUD( %d )\n", enable ));
  1578. HUDClass::Enable( enable );
  1579. }
  1580. void Mission_Complete( bool success )
  1581. {
  1582. SCRIPT_TRACE(( "ST>Mission_Complete( %d )\n", success ));
  1583. CombatManager::Mission_Complete( success );
  1584. }
  1585. void Give_PowerUp( GameObject * obj, const char * preset_name, bool display_on_hud )
  1586. {
  1587. SCRIPT_PTR_CHECK( obj );
  1588. SCRIPT_PTR_CHECK( preset_name );
  1589. SCRIPT_TRACE(( "ST>Give_PowerUp( %d, %s )\n", obj->Get_ID(), preset_name ));
  1590. SmartGameObj *smart = obj->As_SmartGameObj();
  1591. if (smart) {
  1592. PowerUpGameObjDef * def = (PowerUpGameObjDef*)DefinitionMgrClass::Find_Typed_Definition( preset_name, CLASSID_GAME_OBJECT_DEF_POWERUP );
  1593. if ( def != NULL ) {
  1594. def->Grant( smart, NULL, display_on_hud );
  1595. } else {
  1596. Debug_Say(( "Powerup Definition %s not found\n", preset_name ));
  1597. }
  1598. } else {
  1599. Debug_Say(( "Only Samrt objs can get powerups\n" ));
  1600. }
  1601. }
  1602. bool Innate_Soldier_Enable( GameObject * obj, int bits, bool state )
  1603. {
  1604. SCRIPT_PTR_CHECK_RET(obj, false);
  1605. SCRIPT_TRACE(( "ST>Innate_Soldier_Enable( %d, %d, %d )\n", obj->Get_ID(), bits, state ));
  1606. PhysicalGameObj * pgobj = obj->As_PhysicalGameObj();
  1607. if ( pgobj == NULL ) {
  1608. // Cinematics call this for non-soldiers
  1609. // Debug_Say(( "Not a PhysicalGameObj at %s %d\n", __FILE__, __LINE__ ));
  1610. return false;
  1611. }
  1612. SoldierGameObj * soldier = pgobj->As_SoldierGameObj();
  1613. if ( soldier == NULL ) {
  1614. // Cinematics call this for non-soldiers
  1615. // Debug_Say(( "Object is not a soldier!\n" ));
  1616. }
  1617. SCRIPT_PTR_CHECK_RET(soldier, false);
  1618. bool old_state = soldier->Is_Innate_Enabled( bits );
  1619. if ( state ) {
  1620. soldier->Innate_Enable( bits );
  1621. } else {
  1622. soldier->Innate_Disable( bits );
  1623. }
  1624. return old_state;
  1625. }
  1626. bool Innate_Soldier_Enable_Enemy_Seen( GameObject * obj, bool state )
  1627. {
  1628. return Innate_Soldier_Enable( obj, SOLDIER_INNATE_EVENT_ENEMY_SEEN, state );
  1629. }
  1630. bool Innate_Soldier_Enable_Gunshot_Heard( GameObject * obj, bool state )
  1631. {
  1632. return Innate_Soldier_Enable( obj, SOLDIER_INNATE_EVENT_GUNSHOT_HEARD, state );
  1633. }
  1634. bool Innate_Soldier_Enable_Footsteps_Heard( GameObject * obj, bool state )
  1635. {
  1636. return Innate_Soldier_Enable( obj, SOLDIER_INNATE_EVENT_FOOTSTEP_HEARD, state );
  1637. }
  1638. bool Innate_Soldier_Enable_Bullet_Heard( GameObject * obj, bool state )
  1639. {
  1640. return Innate_Soldier_Enable( obj, SOLDIER_INNATE_EVENT_BULLET_HEARD, state );
  1641. }
  1642. bool Innate_Soldier_Enable_Actions( GameObject * obj, bool state )
  1643. {
  1644. return Innate_Soldier_Enable( obj, SOLDIER_INNATE_ACTIONS, state );
  1645. }
  1646. // Disable all innate abilities
  1647. void Innate_Disable(GameObject* object)
  1648. {
  1649. Innate_Soldier_Enable(object, 0xFFFFFFFF, false);
  1650. }
  1651. // Enable all innate abilities
  1652. void Innate_Enable(GameObject* object)
  1653. {
  1654. Innate_Soldier_Enable(object, 0xFFFFFFFF, true);
  1655. }
  1656. void Set_Innate_Soldier_Home_Location( GameObject * obj, const Vector3& home_pos, float home_radius )
  1657. {
  1658. SCRIPT_PTR_CHECK( obj );
  1659. SCRIPT_TRACE(( "ST>Set_Innate_Soldier_Home_Location( %d, (%f %f %f), %f )\n", obj->Get_ID(), home_pos.X, home_pos.Y, home_pos.Z, home_radius ));
  1660. SmartGameObj * smart = obj->As_SmartGameObj();
  1661. if ( smart != NULL ) {
  1662. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1663. if ( soldier != NULL ) {
  1664. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1665. if ( innate ) {
  1666. innate->Set_Home_Location( home_pos, home_radius );
  1667. }
  1668. }
  1669. }
  1670. }
  1671. void Set_Innate_Aggressiveness( GameObject * obj, float aggressiveness )
  1672. {
  1673. SCRIPT_PTR_CHECK( obj );
  1674. SCRIPT_TRACE(( "ST>Set_Innate_Aggressiveness( %d, %f )\n", obj->Get_ID(), aggressiveness ));
  1675. bool set = false;
  1676. SmartGameObj * smart = obj->As_SmartGameObj();
  1677. if ( smart != NULL ) {
  1678. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1679. if ( soldier != NULL ) {
  1680. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1681. if ( innate ) {
  1682. innate->Set_Aggressiveness( aggressiveness );
  1683. set = true;
  1684. }
  1685. }
  1686. }
  1687. if ( !set ) {
  1688. Debug_Say(( "Can only Set_Innate_Aggressiveness on a soldier\n" ));
  1689. }
  1690. }
  1691. void Set_Innate_Take_Cover_Probability( GameObject * obj, float probability )
  1692. {
  1693. SCRIPT_PTR_CHECK( obj );
  1694. SCRIPT_TRACE(( "ST>Set_Innate_Take_Cover_Probability( %d, %f )\n", obj->Get_ID(), probability ));
  1695. bool set = false;
  1696. SmartGameObj * smart = obj->As_SmartGameObj();
  1697. if ( smart != NULL ) {
  1698. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1699. if ( soldier != NULL ) {
  1700. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1701. if ( innate ) {
  1702. innate->Set_Take_Cover_Probability( probability );
  1703. set = true;
  1704. }
  1705. }
  1706. }
  1707. if ( !set ) {
  1708. Debug_Say(( "Can only Set_Innate_Take_Cover_Probability on a soldier\n" ));
  1709. }
  1710. }
  1711. void Set_Innate_Is_Stationary( GameObject * obj, bool stationary )
  1712. {
  1713. SCRIPT_PTR_CHECK( obj );
  1714. SCRIPT_TRACE(( "ST>Set_Innate_Take_Cover_Probability( %d, %d )\n", obj->Get_ID(), stationary ));
  1715. bool set = false;
  1716. SmartGameObj * smart = obj->As_SmartGameObj();
  1717. if ( smart != NULL ) {
  1718. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1719. if ( soldier != NULL ) {
  1720. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1721. if ( innate ) {
  1722. innate->Set_Is_Stationary( stationary );
  1723. set = true;
  1724. }
  1725. }
  1726. }
  1727. if ( !set ) {
  1728. Debug_Say(( "Can only Set_Innate_Is_Stationary on a soldier\n" ));
  1729. }
  1730. }
  1731. void Innate_Force_State_Bullet_Heard( GameObject * obj, const Vector3 & pos )
  1732. {
  1733. SCRIPT_PTR_CHECK( obj );
  1734. SCRIPT_TRACE(( "ST>Innate_Force_State_Bullet_Heard( %d, ( %f, %f, %f, ) )\n", obj->Get_ID(), pos.X, pos.Y, pos.Z ));
  1735. bool set = false;
  1736. SmartGameObj * smart = obj->As_SmartGameObj();
  1737. if ( smart != NULL ) {
  1738. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1739. if ( soldier != NULL ) {
  1740. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1741. if ( innate ) {
  1742. innate->Set_State( soldier, SoldierObserverClass::SOLDIER_AI_BULLET_HEARD, pos);
  1743. set = true;
  1744. }
  1745. }
  1746. }
  1747. if ( !set ) {
  1748. Debug_Say(( "Can only Innate_Force_State_Bullet_Heard on a soldier with innate\n" ));
  1749. }
  1750. }
  1751. void Innate_Force_State_Footsteps_Heard( GameObject * obj, const Vector3 & pos )
  1752. {
  1753. SCRIPT_PTR_CHECK( obj );
  1754. SCRIPT_TRACE(( "ST>Innate_Force_State_Footsteps_Heard( %d, ( %f, %f, %f, ) )\n", obj->Get_ID(), pos.X, pos.Y, pos.Z ));
  1755. bool set = false;
  1756. SmartGameObj * smart = obj->As_SmartGameObj();
  1757. if ( smart != NULL ) {
  1758. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1759. if ( soldier != NULL ) {
  1760. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1761. if ( innate ) {
  1762. innate->Set_State( soldier, SoldierObserverClass::SOLDIER_AI_FOOTSTEPS_HEARD, pos);
  1763. set = true;
  1764. }
  1765. }
  1766. }
  1767. if ( !set ) {
  1768. Debug_Say(( "Can only Innate_Force_State_Footsteps_Heard on a soldier with innate\n" ));
  1769. }
  1770. }
  1771. void Innate_Force_State_Gunshots_Heard( GameObject * obj, const Vector3 & pos )
  1772. {
  1773. SCRIPT_PTR_CHECK( obj );
  1774. SCRIPT_TRACE(( "ST>Innate_Force_State_Gunshot_Heard( %d, ( %f, %f, %f, ) )\n", obj->Get_ID(), pos.X, pos.Y, pos.Z ));
  1775. bool set = false;
  1776. SmartGameObj * smart = obj->As_SmartGameObj();
  1777. if ( smart != NULL ) {
  1778. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1779. if ( soldier != NULL ) {
  1780. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1781. if ( innate ) {
  1782. innate->Set_State( soldier, SoldierObserverClass::SOLDIER_AI_GUNSHOT_HEARD, pos);
  1783. set = true;
  1784. }
  1785. }
  1786. }
  1787. if ( !set ) {
  1788. Debug_Say(( "Can only Innate_Force_State_Gunshot_Heard on a soldier with innate\n" ));
  1789. }
  1790. }
  1791. void Innate_Force_State_Enemy_Seen( GameObject * obj, GameObject * enemy )
  1792. {
  1793. SCRIPT_PTR_CHECK( obj );
  1794. SCRIPT_PTR_CHECK( enemy );
  1795. SCRIPT_TRACE(( "ST>Innate_Force_State_Enemy_Seen( %d, %d )\n", obj->Get_ID(), enemy->Get_ID() ));
  1796. bool set = false;
  1797. SmartGameObj * smart = obj->As_SmartGameObj();
  1798. if ( smart != NULL ) {
  1799. SoldierGameObj * soldier = smart->As_SoldierGameObj();
  1800. if ( soldier != NULL ) {
  1801. SoldierObserverClass * innate = soldier->Get_Innate_Controller();
  1802. if ( innate ) {
  1803. innate->Set_State( soldier, SoldierObserverClass::SOLDIER_AI_ENEMY_SEEN, Vector3(0,0,0), enemy );
  1804. set = true;
  1805. }
  1806. }
  1807. }
  1808. if ( !set ) {
  1809. Debug_Say(( "Can only Innate_Force_State_Enemy_Seen on a soldier with innate\n" ));
  1810. }
  1811. }
  1812. /*
  1813. **
  1814. */
  1815. void Static_Anim_Phys_Goto_Frame( int obj_id, float frame, const char * anim_name )
  1816. {
  1817. SCRIPT_TRACE(( "ST>Static_Anim_Phys_Goto_Frame( %d, %d )\n", obj_id, frame ));
  1818. StaticPhysClass * spc = COMBAT_SCENE->Find_Static_Object( obj_id );
  1819. if ( spc != NULL ) {
  1820. StaticAnimPhysClass * sapc = spc->As_StaticAnimPhysClass();
  1821. if ( sapc ) {
  1822. if ( anim_name != NULL ) {
  1823. sapc->Get_Animation_Manager().Set_Animation( anim_name );
  1824. }
  1825. sapc->Get_Animation_Manager().Set_Animation_Mode( AnimCollisionManagerClass::ANIMATE_TARGET );
  1826. sapc->Get_Animation_Manager().Set_Target_Frame( frame );
  1827. }
  1828. }
  1829. }
  1830. void Static_Anim_Phys_Goto_Last_Frame( int obj_id, const char * anim_name )
  1831. {
  1832. SCRIPT_TRACE(( "ST>Static_Anim_Phys_Goto_Last_Frame( %d )\n", obj_id ));
  1833. StaticPhysClass * spc = COMBAT_SCENE->Find_Static_Object( obj_id );
  1834. if ( spc != NULL ) {
  1835. StaticAnimPhysClass * sapc = spc->As_StaticAnimPhysClass();
  1836. if ( sapc ) {
  1837. if ( anim_name != NULL ) {
  1838. sapc->Get_Animation_Manager().Set_Animation( anim_name );
  1839. }
  1840. sapc->Get_Animation_Manager().Set_Animation_Mode( AnimCollisionManagerClass::ANIMATE_TARGET );
  1841. sapc->Get_Animation_Manager().Set_Target_Frame( sapc->Get_Animation_Manager().Peek_Animation()->Get_Num_Frames() - 1 );
  1842. }
  1843. }
  1844. }
  1845. unsigned int Get_Sync_Time( void )
  1846. {
  1847. return CombatManager::Get_Sync_Time();
  1848. }
  1849. /*
  1850. ** Objectives
  1851. */
  1852. void Add_Objective( int id, int type, int status, int short_description_id, char * description_sound_filename, int long_description_id )
  1853. {
  1854. SCRIPT_TRACE(( "ST>Add_Objective( %d, %d, %d, %d %d )\n", id, type, status, short_description_id, long_description_id ));
  1855. ObjectiveManager::Add_Objective( id, type, status, short_description_id, long_description_id, description_sound_filename );
  1856. }
  1857. void Remove_Objective( int id )
  1858. {
  1859. SCRIPT_TRACE(( "ST>Remove_Objective( %d )\n", id ));
  1860. ObjectiveManager::Remove_Objective( id );
  1861. }
  1862. void Set_Objective_Status( int id, int status )
  1863. {
  1864. SCRIPT_TRACE(( "ST>Set_Objective_Status( %d, %d )\n", id, status ));
  1865. ObjectiveManager::Set_Objective_Status( id, status );
  1866. }
  1867. void Change_Objective_Type( int id, int type )
  1868. {
  1869. SCRIPT_TRACE(( "ST>Change_Objective_Type( %d, %d )\n", id, type ));
  1870. ObjectiveManager::Change_Objective_Type( id, type );
  1871. }
  1872. void Set_Objective_Radar_Blip( int id, const Vector3 & position )
  1873. {
  1874. SCRIPT_TRACE(( "ST>Set_Objective_Radar_Blip( %d, %f %f %f )\n", id, position ));
  1875. ObjectiveManager::Set_Objective_Radar_Blip( id, position );
  1876. }
  1877. void Set_Objective_Radar_Blip_Object( int id, ScriptableGameObj * unit )
  1878. {
  1879. SCRIPT_PTR_CHECK( unit );
  1880. SCRIPT_TRACE(( "ST>Set_Objective_Radar_Blip_Object( %d, %d )\n", id, unit->Get_ID() ));
  1881. PhysicalGameObj * pobj = NULL;
  1882. if ( unit ) {
  1883. pobj = unit->As_PhysicalGameObj();
  1884. }
  1885. ObjectiveManager::Set_Objective_Radar_Blip( id, pobj );
  1886. }
  1887. void Set_Objective_HUD_Info( int id, float priority, const char * texture_name, int message_id )
  1888. {
  1889. SCRIPT_PTR_CHECK( texture_name );
  1890. SCRIPT_TRACE(( "ST>Set_Objective_HUD_Info( %d, %f, %s, %d )\n", id, priority, texture_name, message_id ));
  1891. ObjectiveManager::Set_Objective_HUD_Info( id, priority, texture_name, message_id );
  1892. }
  1893. void Set_Objective_HUD_Info_Position( int id, float priority, const char * texture_name, int message_id, const Vector3 & position )
  1894. {
  1895. SCRIPT_PTR_CHECK( texture_name );
  1896. SCRIPT_TRACE(( "ST>Set_Objective_HUD_Info_Position( %d, %f, %s, %d )\n", id, priority, texture_name, message_id ));
  1897. ObjectiveManager::Set_Objective_HUD_Info( id, priority, texture_name, message_id, position );
  1898. }
  1899. /*
  1900. **
  1901. */
  1902. void Shake_Camera( const Vector3 & pos, float radius, float intensity, float duration )
  1903. {
  1904. SCRIPT_TRACE(( "ST>Shake_Camera( (%f, %f, %f), %f, %f, %f\n",pos.X, pos.Y, pos.Z, radius, intensity, duration ));
  1905. if ( COMBAT_SCENE ) {
  1906. COMBAT_SCENE->Add_Camera_Shake( pos, radius, duration, intensity );
  1907. }
  1908. }
  1909. void Enable_Spawner( int id, bool enable )
  1910. {
  1911. SCRIPT_TRACE(( "ST>Enable_Spawned( %d, %d )\n",id, enable ));
  1912. SpawnManager::Spawner_Enable( id, enable );
  1913. }
  1914. GameObject * Trigger_Spawner( int id )
  1915. {
  1916. SCRIPT_TRACE(( "ST>Trigger_Spawned( %d )\n", id ));
  1917. return SpawnManager::Spawner_Trigger( id );
  1918. }
  1919. void Enable_Engine( GameObject* object, bool onoff )
  1920. {
  1921. SCRIPT_PTR_CHECK( object );
  1922. SCRIPT_TRACE(( "ST>Enable_Engine( %d, %d )\n", object, onoff ));
  1923. PhysicalGameObj *physical_obj = object->As_PhysicalGameObj ();
  1924. if ( physical_obj != NULL ) {
  1925. VehicleGameObj *vehicle = physical_obj->As_VehicleGameObj ();
  1926. if ( vehicle != NULL ) {
  1927. vehicle->Enable_Engine( onoff );
  1928. }
  1929. }
  1930. }
  1931. /*
  1932. **
  1933. */
  1934. int Get_Difficulty_Level( void )
  1935. {
  1936. return CombatManager::Get_Difficulty_Level();
  1937. }
  1938. void Grant_Key( GameObject* object, int key, bool grant = true )
  1939. {
  1940. SCRIPT_PTR_CHECK( object );
  1941. SCRIPT_TRACE(( "ST>Grant_Key( %d, %d )\n", object->Get_ID(), key, grant ));
  1942. SoldierGameObj * soldier = NULL;
  1943. if ( object->As_SmartGameObj() != NULL ) {
  1944. soldier = object->As_SmartGameObj()->As_SoldierGameObj();
  1945. }
  1946. if ( soldier == NULL ) {
  1947. Debug_Say(( "Object is not a soldier!\n" ));
  1948. } else {
  1949. if ( grant ) {
  1950. soldier->Give_Key( key );
  1951. } else {
  1952. soldier->Remove_Key( key );
  1953. }
  1954. }
  1955. }
  1956. bool Has_Key( GameObject* object, int key )
  1957. {
  1958. SoldierGameObj * soldier = NULL;
  1959. if ( object->As_SmartGameObj() != NULL ) {
  1960. soldier = object->As_SmartGameObj()->As_SoldierGameObj();
  1961. }
  1962. return soldier && soldier->Has_Key( key );
  1963. }
  1964. void Enable_Hibernation( GameObject * object, bool enable )
  1965. {
  1966. SCRIPT_PTR_CHECK( object );
  1967. SCRIPT_TRACE(( "ST>Enable_Hibernation( %d, %d )\n", object->Get_ID(), enable ));
  1968. if ( object->As_PhysicalGameObj() ) {
  1969. object->As_PhysicalGameObj()->Enable_Hibernation( enable );
  1970. }
  1971. }
  1972. void Attach_To_Object_Bone( GameObject * object, GameObject * host_object, const char * bone_name )
  1973. {
  1974. SCRIPT_PTR_CHECK( object );
  1975. if ( host_object == NULL ) {
  1976. SCRIPT_TRACE(( "ST>Attach_To_Object_Bone( %d, NULL )\n", object->Get_ID() ));
  1977. } else {
  1978. SCRIPT_TRACE(( "ST>Attach_To_Object_Bone( %d, %d, %s )\n", object->Get_ID(), host_object->Get_ID(), bone_name ? "NULL" : bone_name ));
  1979. }
  1980. if ( object->As_PhysicalGameObj() ) {
  1981. if ( host_object == NULL ) {
  1982. object->As_PhysicalGameObj()->Attach_To_Object_Bone( NULL, NULL );
  1983. } else {
  1984. WWASSERT( host_object->As_PhysicalGameObj() ) ;
  1985. object->As_PhysicalGameObj()->Attach_To_Object_Bone( host_object->As_PhysicalGameObj(), bone_name );
  1986. }
  1987. } else {
  1988. Debug_Say(( "Can only Attach_To_Object_Bone for PhysicalObjects\n" ));
  1989. }
  1990. }
  1991. int Create_Conversation( const char *conversation_name, int priority, float max_dist, bool is_interruptable )
  1992. {
  1993. int active_conversation_id = -1;
  1994. SCRIPT_TRACE(( "ST>Create_Conversation( %s )\n", conversation_name ));
  1995. //
  1996. // Try to find the requested conversation
  1997. //
  1998. ConversationClass *conversation = ConversationMgrClass::Find_Conversation( conversation_name );
  1999. if ( conversation != NULL ) {
  2000. //
  2001. // Create a new run-time conversation object
  2002. //
  2003. ActiveConversationClass *active_conversation = ConversationMgrClass::Create_New_Conversation( conversation );
  2004. if (active_conversation != NULL) {
  2005. if (priority > 0) {
  2006. active_conversation->Set_Priority (priority);
  2007. }
  2008. if (max_dist > 0) {
  2009. active_conversation->Set_Max_Dist (max_dist);
  2010. }
  2011. active_conversation->Set_Is_Interruptable (is_interruptable);
  2012. //
  2013. // Return the ID of the conversation to the caller
  2014. //
  2015. active_conversation_id = active_conversation->Get_ID ();
  2016. REF_PTR_RELEASE( active_conversation );
  2017. }
  2018. REF_PTR_RELEASE( conversation );
  2019. }
  2020. return active_conversation_id;
  2021. }
  2022. void Join_Conversation_Facing( GameObject * object, int active_conversation_id, int obj_id_to_face )
  2023. {
  2024. SCRIPT_PTR_CHECK( object );
  2025. SCRIPT_TRACE(( "ST>Join_Conversation_Facing( %d, %d, %d )\n", object->Get_ID (), active_conversation_id, obj_id_to_face ));
  2026. //
  2027. // Dig out the soldier pointer (if we have one)
  2028. //
  2029. PhysicalGameObj *game_obj = NULL;
  2030. if ( object != NULL ) {
  2031. game_obj = object->As_PhysicalGameObj();
  2032. }
  2033. //
  2034. // Lookup the run-time conversation object
  2035. //
  2036. ActiveConversationClass *active_conversation = NULL;
  2037. active_conversation = ConversationMgrClass::Find_Active_Conversation( active_conversation_id );
  2038. if (active_conversation != NULL) {
  2039. //
  2040. // Add this object to the conversation
  2041. //
  2042. OratorClass *orator = active_conversation->Add_Orator( game_obj );
  2043. //
  2044. // Set the flags
  2045. //
  2046. orator->Set_Flag( OratorClass::FLAG_DONT_MOVE, true );
  2047. orator->Set_Flag( OratorClass::FLAG_DONT_TURN_HEAD, false );
  2048. orator->Set_Flag( OratorClass::FLAG_DONT_FACE, false );
  2049. orator->Set_Look_At_Obj( obj_id_to_face );
  2050. REF_PTR_RELEASE( active_conversation );
  2051. }
  2052. return ;
  2053. }
  2054. void Join_Conversation( GameObject * object, int active_conversation_id, bool allow_move, bool allow_head_turn, bool allow_face )
  2055. {
  2056. int obj_id = 0;
  2057. if ( object != NULL ) {
  2058. obj_id = object->Get_ID();
  2059. }
  2060. SCRIPT_TRACE(( "ST>Join_Conversation( %d, %d, %d, %d )\n", obj_id, active_conversation_id, allow_move, allow_head_turn ));
  2061. //
  2062. // Dig out the soldier pointer (if we have one)
  2063. //
  2064. PhysicalGameObj *game_obj = NULL;
  2065. if ( object != NULL ) {
  2066. game_obj = object->As_PhysicalGameObj();
  2067. }
  2068. //
  2069. // Lookup the run-time conversation object
  2070. //
  2071. ActiveConversationClass *active_conversation = NULL;
  2072. active_conversation = ConversationMgrClass::Find_Active_Conversation( active_conversation_id);
  2073. if (active_conversation != NULL) {
  2074. //
  2075. // Add this object to the conversation
  2076. //
  2077. OratorClass *orator = active_conversation->Add_Orator( game_obj );
  2078. //
  2079. // Set the flags
  2080. //
  2081. orator->Set_Flag( OratorClass::FLAG_DONT_MOVE, !allow_move );
  2082. orator->Set_Flag( OratorClass::FLAG_DONT_TURN_HEAD, !allow_head_turn );
  2083. orator->Set_Flag( OratorClass::FLAG_DONT_FACE, !allow_face );
  2084. REF_PTR_RELEASE( active_conversation );
  2085. }
  2086. return ;
  2087. }
  2088. void Stop_All_Conversations( void )
  2089. {
  2090. SCRIPT_TRACE(( "ST>Stop_All_Conversations( )\n" ));
  2091. //
  2092. // Simply ask the conversation manager to end all playing conversations
  2093. //
  2094. ConversationMgrClass::Reset_Active_Conversations();
  2095. return ;
  2096. }
  2097. void Stop_Conversation( int active_conversation_id )
  2098. {
  2099. SCRIPT_TRACE(( "ST>Stop_Conversation( %d )\n", active_conversation_id ));
  2100. //
  2101. // Lookup the run-time conversation object
  2102. //
  2103. ActiveConversationClass *active_conversation = NULL;
  2104. active_conversation = ConversationMgrClass::Find_Active_Conversation( active_conversation_id);
  2105. if (active_conversation != NULL) {
  2106. //
  2107. // Stop the conversation
  2108. //
  2109. active_conversation->Stop_Conversation (ACTION_COMPLETE_CONVERSATION_INTERRUPTED);
  2110. }
  2111. return ;
  2112. }
  2113. void Start_Conversation( int active_conversation_id, int action_id )
  2114. {
  2115. SCRIPT_TRACE(( "ST>Start_Conversation( %d, %d )\n", active_conversation_id, action_id ));
  2116. //
  2117. // Lookup the run-time conversation object
  2118. //
  2119. ActiveConversationClass *active_conversation = NULL;
  2120. active_conversation = ConversationMgrClass::Find_Active_Conversation( active_conversation_id);
  2121. if (active_conversation != NULL) {
  2122. //
  2123. // Start the conversation
  2124. //
  2125. active_conversation->Set_Action_ID( action_id );
  2126. active_conversation->Start_Conversation();
  2127. REF_PTR_RELEASE( active_conversation );
  2128. }
  2129. return ;
  2130. }
  2131. void Monitor_Conversation( GameObject * object, int active_conversation_id )
  2132. {
  2133. SCRIPT_PTR_CHECK( object );
  2134. SCRIPT_TRACE(( "ST>Monitor_Conversation( %d, %d )\n", object->Get_ID (), active_conversation_id ));
  2135. //
  2136. // Lookup the run-time conversation object
  2137. //
  2138. ActiveConversationClass *active_conversation = NULL;
  2139. active_conversation = ConversationMgrClass::Find_Active_Conversation( active_conversation_id);
  2140. if (active_conversation != NULL) {
  2141. //
  2142. // Start the conversation
  2143. //
  2144. active_conversation->Register_Monitor( object );
  2145. REF_PTR_RELEASE( active_conversation );
  2146. }
  2147. return ;
  2148. }
  2149. void Start_Random_Conversation( GameObject * object )
  2150. {
  2151. SCRIPT_PTR_CHECK( object );
  2152. SCRIPT_TRACE(( "ST>Start_Random_Conversation( %d )\n", object->Get_ID() ));
  2153. //
  2154. // Dig the physical game obj out of the game object pointer
  2155. //
  2156. PhysicalGameObj *game_obj = NULL;
  2157. if ( object != NULL ) {
  2158. game_obj = object->As_PhysicalGameObj();
  2159. }
  2160. //
  2161. // Start any conversation
  2162. //
  2163. if ( game_obj != NULL ) {
  2164. ConversationMgrClass::Start_Conversation( game_obj );
  2165. }
  2166. return ;
  2167. }
  2168. /*
  2169. **
  2170. */
  2171. void Lock_Soldier_Facing( GameObject * object, GameObject * object_to_face, bool turn_body )
  2172. {
  2173. SCRIPT_PTR_CHECK( object );
  2174. SCRIPT_TRACE(( "ST>Lock_Soldier_Facing( %d, %d )\n", object->Get_ID(), turn_body ));
  2175. //
  2176. // Is this a physical game object?
  2177. //
  2178. PhysicalGameObj *phys_game_obj = object->As_PhysicalGameObj();
  2179. if (phys_game_obj != NULL) {
  2180. //
  2181. // Is this a soldier game object?
  2182. //
  2183. SoldierGameObj *soldier = phys_game_obj->As_SoldierGameObj();
  2184. if ( soldier != NULL ) {
  2185. if ( object_to_face != NULL ) {
  2186. soldier->Lock_Facing( object_to_face->As_PhysicalGameObj(), turn_body );
  2187. } else {
  2188. soldier->Lock_Facing( NULL, false );
  2189. }
  2190. }
  2191. }
  2192. return ;
  2193. }
  2194. /*
  2195. **
  2196. */
  2197. void Unlock_Soldier_Facing( GameObject * object )
  2198. {
  2199. SCRIPT_PTR_CHECK( object );
  2200. SCRIPT_TRACE(( "ST>Unlock_Soldier_Facing( %d )\n", object->Get_ID() ));
  2201. //
  2202. // Is this a physical game object?
  2203. //
  2204. PhysicalGameObj *phys_game_obj = object->As_PhysicalGameObj();
  2205. if (phys_game_obj != NULL) {
  2206. //
  2207. // Is this a soldier game object?
  2208. //
  2209. SoldierGameObj *soldier = phys_game_obj->As_SoldierGameObj();
  2210. if ( soldier != NULL ) {
  2211. soldier->Lock_Facing( NULL, false );
  2212. }
  2213. }
  2214. return ;
  2215. }
  2216. /*
  2217. **
  2218. */
  2219. void Apply_Damage( GameObject * object, float amount, const char * warhead_name, GameObject * damager = NULL )
  2220. {
  2221. SCRIPT_PTR_CHECK( object );
  2222. SCRIPT_TRACE(( "ST>Apply_Damage( %d, %f, %s )\n", object->Get_ID(), amount, warhead_name ));
  2223. DamageableGameObj * damgo = object->As_DamageableGameObj();
  2224. if ( damgo ) {
  2225. int warhead = ArmorWarheadManager::Get_Warhead_Type( warhead_name );
  2226. SmartGameObj * smart = NULL;
  2227. if ( damager ) {
  2228. smart = damager->As_SmartGameObj();
  2229. }
  2230. OffenseObjectClass offense( amount, warhead, smart );
  2231. if ( damgo->As_SmartGameObj() ) {
  2232. damgo->As_SmartGameObj()->Apply_Damage_Extended( offense );
  2233. } else {
  2234. damgo->Apply_Damage( offense );
  2235. }
  2236. } else {
  2237. Debug_Say(( "Can only Apply_Damage to a DamageableGameObj\n" ));
  2238. }
  2239. }
  2240. void Set_Loiters_Allowed( GameObject * object, bool allowed )
  2241. {
  2242. SCRIPT_PTR_CHECK( object );
  2243. SCRIPT_TRACE(( "ST>Set_Loiters_Allowed( %d, %d )\n", object->Get_ID(), allowed ));
  2244. PhysicalGameObj * physgo = object->As_PhysicalGameObj();
  2245. SoldierGameObj * soldier = NULL;
  2246. if ( physgo ) {
  2247. soldier = physgo->As_SoldierGameObj();
  2248. }
  2249. if ( soldier ) {
  2250. soldier->Set_Loiters_Allowed( allowed );
  2251. } else {
  2252. Debug_Say(( "Can only Set_Loiters_Allowed to a SoldierGameObj\n" ));
  2253. }
  2254. }
  2255. void Set_Is_Visible( GameObject * object, bool visible )
  2256. {
  2257. SCRIPT_PTR_CHECK( object );
  2258. SCRIPT_TRACE(( "ST>Set_Is_Visible( %d, %d )\n", object->Get_ID(), visible ));
  2259. PhysicalGameObj * physgo = object->As_PhysicalGameObj();
  2260. SoldierGameObj * soldier = NULL;
  2261. if ( physgo ) {
  2262. soldier = physgo->As_SoldierGameObj();
  2263. }
  2264. if ( soldier ) {
  2265. soldier->Set_Is_Visible( visible );
  2266. } else {
  2267. Debug_Say(( "Can only Set_Is_Visible on a SoldierGameObj\n" ));
  2268. }
  2269. }
  2270. void Set_Is_Rendered( GameObject * object, bool rendered )
  2271. {
  2272. SCRIPT_PTR_CHECK( object );
  2273. SCRIPT_TRACE(( "ST>Set_Is_Rendered( %d, %d )\n", object->Get_ID(), rendered ));
  2274. PhysicalGameObj * physgo = object->As_PhysicalGameObj();
  2275. if ( physgo ) {
  2276. physgo->Peek_Model()->Set_Hidden( !rendered );
  2277. physgo->Set_Object_Dirty_Bit (NetworkObjectClass::BIT_RARE, true);
  2278. } else {
  2279. Debug_Say(( "Can only Set_Is_Rendered on a PhysicalGameObj\n" ));
  2280. }
  2281. }
  2282. /*
  2283. **
  2284. */
  2285. float Get_Points( GameObject * object )
  2286. {
  2287. if ( object && object->As_SmartGameObj() && object->As_SmartGameObj()->Get_Player_Data() ) {
  2288. return object->As_SmartGameObj()->Get_Player_Data()->Get_Score();
  2289. }
  2290. Debug_Say(( "Cannot Get Points for object\n" ));
  2291. return 0;
  2292. }
  2293. void Give_Points( GameObject * object, float points, bool entire_team )
  2294. {
  2295. SCRIPT_PTR_CHECK( object );
  2296. SCRIPT_TRACE(( "ST>Give_Points( %d, %f, %d )\n", object->Get_ID(), points, entire_team ));
  2297. SmartGameObj * smart = object->As_SmartGameObj();
  2298. if ( smart ) {
  2299. if ( entire_team ) {
  2300. SLNode<SoldierGameObj> *objnode;
  2301. for ( objnode = GameObjManager::Get_Star_Game_Obj_List()->Head(); objnode; objnode = objnode->Next()) {
  2302. SoldierGameObj * obj = objnode->Data();
  2303. if ( obj && obj->Get_Player_Data() && obj->Is_Teammate( smart ) ) {
  2304. obj->Get_Player_Data()->Increment_Score( points );
  2305. }
  2306. }
  2307. } else {
  2308. if ( smart->Get_Player_Data() ) {
  2309. smart->Get_Player_Data()->Increment_Score( points );
  2310. }
  2311. }
  2312. } else {
  2313. Debug_Say(( "Cannot Give Points to object\n" ));
  2314. }
  2315. }
  2316. /*
  2317. **
  2318. */
  2319. float Get_Money( GameObject * object )
  2320. {
  2321. if ( object && object->As_SmartGameObj() && object->As_SmartGameObj()->Get_Player_Data() ) {
  2322. return object->As_SmartGameObj()->Get_Player_Data()->Get_Money();
  2323. }
  2324. Debug_Say(( "Cannot Get Money for object\n" ));
  2325. return 0;
  2326. }
  2327. void Give_Money( GameObject * object, float money, bool entire_team )
  2328. {
  2329. SCRIPT_PTR_CHECK( object );
  2330. SCRIPT_TRACE(( "ST>Give_Money( %d, %f, %d )\n", object->Get_ID(), money, entire_team ));
  2331. SmartGameObj * smart = object->As_SmartGameObj();
  2332. if ( smart ) {
  2333. if ( entire_team ) {
  2334. SLNode<SoldierGameObj> *objnode;
  2335. for ( objnode = GameObjManager::Get_Star_Game_Obj_List()->Head(); objnode; objnode = objnode->Next()) {
  2336. SoldierGameObj * obj = objnode->Data();
  2337. if ( obj && obj->Get_Player_Data() && obj->Is_Teammate( smart ) ) {
  2338. obj->Get_Player_Data()->Increment_Money( money );
  2339. }
  2340. }
  2341. } else {
  2342. if ( smart->Get_Player_Data() ) {
  2343. smart->Get_Player_Data()->Increment_Money( money );
  2344. }
  2345. }
  2346. } else {
  2347. Debug_Say(( "Cannot Give Money to object\n" ));
  2348. }
  2349. }
  2350. /*
  2351. **
  2352. */
  2353. bool Get_Building_Power( GameObject * object )
  2354. {
  2355. SCRIPT_PTR_CHECK_RET( object, false );
  2356. BuildingGameObj *building = object->As_BuildingGameObj();
  2357. if ( building ) {
  2358. return ( building->Is_Power_Enabled() );
  2359. }
  2360. Debug_Say(( "Object is not a Building\n" ));
  2361. return false;
  2362. }
  2363. void Set_Building_Power( GameObject * object, bool onoff )
  2364. {
  2365. SCRIPT_PTR_CHECK( object );
  2366. SCRIPT_TRACE(( "ST>Set_Building_Power( %d, %d )\n", object->Get_ID(), onoff ));
  2367. BuildingGameObj *building = object->As_BuildingGameObj();
  2368. if ( building ) {
  2369. building->Enable_Power( onoff );
  2370. } else {
  2371. Debug_Say(( "Object is not a Building\n" ));
  2372. }
  2373. }
  2374. void Play_Building_Announcement( GameObject * object, int text_id )
  2375. {
  2376. SCRIPT_PTR_CHECK( object );
  2377. SCRIPT_TRACE(( "ST>Play_Building_Announcement( %d, %d )\n", object->Get_ID(), text_id ));
  2378. BuildingGameObj *building = object->As_BuildingGameObj();
  2379. if ( building ) {
  2380. building->Play_Announcement( text_id, false );
  2381. } else {
  2382. Debug_Say(( "Object is not a Building\n" ));
  2383. }
  2384. }
  2385. GameObject * Find_Nearest_Building_To_Pos( const Vector3 & position, const char * mesh_prefix )
  2386. {
  2387. SCRIPT_PTR_CHECK_RET( mesh_prefix, NULL );
  2388. SCRIPT_TRACE(( "ST>Find_Nearest_Building_To_Pos( (%f,%f,%f), %s )\n", position.X, position.Y, position.Z, mesh_prefix ));
  2389. float best_dist2 = 99999.0F;
  2390. BuildingGameObj *best_building = NULL;
  2391. //
  2392. // Loop over all the buildings in the level
  2393. //
  2394. SLNode<BuildingGameObj> *obj_node = NULL;
  2395. for ( obj_node = GameObjManager::Get_Building_Game_Obj_List()->Head(); obj_node; obj_node = obj_node->Next() ) {
  2396. BuildingGameObj *building = obj_node->Data ()->As_BuildingGameObj ();
  2397. if (building != NULL) {
  2398. //
  2399. // Is this the type of building we're looking for?
  2400. //
  2401. const char *name_prefix = building->Get_Name_Prefix();
  2402. if (::lstrcmpi( mesh_prefix, name_prefix ) == 0) {
  2403. //
  2404. // Is this the closest building we've found yet?
  2405. //
  2406. Vector3 building_pos;
  2407. building->Get_Position (&building_pos);
  2408. float dist2 = (building_pos - position).Length2 ();
  2409. if (dist2 < best_dist2) {
  2410. best_building = building;
  2411. best_dist2 = dist2;
  2412. }
  2413. }
  2414. }
  2415. }
  2416. return best_building;
  2417. }
  2418. GameObject * Find_Nearest_Building( GameObject * object, const char * mesh_prefix )
  2419. {
  2420. SCRIPT_PTR_CHECK_RET( object, NULL );
  2421. SCRIPT_PTR_CHECK_RET( mesh_prefix, NULL );
  2422. SCRIPT_TRACE(( "ST>Find_Nearest_Building( %d, %s )\n", object->Get_ID(), mesh_prefix ));
  2423. //
  2424. // Get the position of the game object
  2425. //
  2426. Vector3 position;
  2427. object->Get_Position (&position);
  2428. //
  2429. // Return the building that's nearest to this position
  2430. //
  2431. return Find_Nearest_Building_To_Pos( position, mesh_prefix );
  2432. }
  2433. int Team_Members_In_Zone( GameObject * object, int player_type )
  2434. {
  2435. SCRIPT_PTR_CHECK_RET( object, 0 );
  2436. ScriptZoneGameObj *script_zone = object->As_ScriptZoneGameObj();
  2437. if ( script_zone ) {
  2438. return script_zone->Count_Team_Members_Inside( player_type );
  2439. } else {
  2440. Debug_Say(( "Object is not a ScriptZone\n" ));
  2441. }
  2442. return 0;
  2443. }
  2444. void Set_Clouds (float cloudcover, float cloudgloominess, float ramptime)
  2445. {
  2446. if (!BackgroundMgrClass::Set_Clouds (cloudcover, cloudgloominess, ramptime)) {
  2447. Debug_Say (("Cannot set clouds\n"));
  2448. }
  2449. }
  2450. void Set_Lightning (float intensity, float startdistance, float enddistance, float heading, float distribution, float ramptime)
  2451. {
  2452. if (!BackgroundMgrClass::Set_Lightning (intensity, startdistance, enddistance, heading, distribution, ramptime)) {
  2453. Debug_Say (("Cannot set lightning\n"));
  2454. }
  2455. }
  2456. void Set_War_Blitz (float intensity, float startdistance, float enddistance, float heading, float distribution, float ramptime)
  2457. {
  2458. if (!BackgroundMgrClass::Set_War_Blitz (intensity, startdistance, enddistance, heading, distribution, ramptime)) {
  2459. Debug_Say (("Cannot set war blitz\n"));
  2460. }
  2461. }
  2462. void Set_Wind (float heading, float speed, float variability, float ramptime)
  2463. {
  2464. if (!WeatherMgrClass::Set_Wind (heading, speed, variability, ramptime)) {
  2465. Debug_Say (("Cannot set wind\n"));
  2466. }
  2467. }
  2468. void Set_Rain (float density, float ramptime, bool prime)
  2469. {
  2470. if (!WeatherMgrClass::Set_Precipitation (WeatherMgrClass::PRECIPITATION_RAIN, density, ramptime)) {
  2471. Debug_Say (("Cannot set rain\n"));
  2472. }
  2473. }
  2474. void Set_Snow (float density, float ramptime, bool prime)
  2475. {
  2476. if (!WeatherMgrClass::Set_Precipitation (WeatherMgrClass::PRECIPITATION_SNOW, density, ramptime)) {
  2477. Debug_Say (("Cannot set snow\n"));
  2478. }
  2479. }
  2480. void Set_Ash (float density, float ramptime, bool prime)
  2481. {
  2482. if (!WeatherMgrClass::Set_Precipitation (WeatherMgrClass::PRECIPITATION_ASH, density, ramptime)) {
  2483. Debug_Say (("Cannot set ash\n"));
  2484. }
  2485. }
  2486. void Set_Fog_Enable (bool enabled)
  2487. {
  2488. WeatherMgrClass::Set_Fog_Enable (enabled);
  2489. }
  2490. void Set_Fog_Range (float startdistance, float enddistance, float ramptime)
  2491. {
  2492. if (!WeatherMgrClass::Set_Fog_Range (startdistance, enddistance, ramptime)) {
  2493. Debug_Say (("Cannot set fog range\n"));
  2494. }
  2495. }
  2496. void Enable_Stealth(GameObject * object, bool onoff)
  2497. {
  2498. SCRIPT_PTR_CHECK( object );
  2499. SCRIPT_TRACE(( "ST>Enable_Stealth( %d, %d )\n", object->Get_ID(), (onoff ? 1 : 0)));
  2500. SmartGameObj * smartobj = object->As_SmartGameObj();
  2501. if (smartobj != NULL) {
  2502. smartobj->Enable_Stealth(onoff);
  2503. }
  2504. }
  2505. void Cinematic_Sniper_Control(bool enabled, float zoom)
  2506. {
  2507. SCRIPT_TRACE(( "ST>Sniper_Control( %d, %f )\n", enabled, zoom ));
  2508. if ( COMBAT_CAMERA ) {
  2509. COMBAT_CAMERA->Cinematic_Sniper_Control( enabled, zoom );
  2510. }
  2511. }
  2512. /*
  2513. **
  2514. */
  2515. int Text_File_Open( const char * filename )
  2516. {
  2517. FileClass * file = _TheFileFactory->Get_File( filename );
  2518. if ( file ) {
  2519. file->Open();
  2520. if ( !file->Is_Available() ) {
  2521. _TheFileFactory->Return_File( file );
  2522. file = NULL;
  2523. }
  2524. }
  2525. return (int)( file );
  2526. }
  2527. bool Text_File_Get_String( int handle, char * buffer, int size )
  2528. {
  2529. FileClass * file = (FileClass *)handle;
  2530. char ch[4];
  2531. char *b = buffer;
  2532. while ( file->Read( &ch[0], 1 ) == 1 ) {
  2533. if ( size > 0 ) {
  2534. *b++ = ch[0];
  2535. size--;
  2536. }
  2537. if ( ch[0] == '\n' ) {
  2538. break;
  2539. }
  2540. }
  2541. *b = 0;
  2542. return (buffer[0] != 0);
  2543. }
  2544. void Text_File_Close( int handle )
  2545. {
  2546. FileClass * file = (FileClass *)handle;
  2547. if ( file != NULL ) {
  2548. file->Close();
  2549. _TheFileFactory->Return_File( file );
  2550. }
  2551. }
  2552. /*
  2553. **
  2554. */
  2555. void Enable_Vehicle_Transitions( GameObject * object, bool enable )
  2556. {
  2557. SCRIPT_PTR_CHECK( object );
  2558. SCRIPT_TRACE(( "ST>Enable_Vehicle_Transitions( %d, %d )\n", object->Get_ID(), enable ));
  2559. PhysicalGameObj * physgo = object->As_PhysicalGameObj();
  2560. VehicleGameObj * vehicle = NULL;
  2561. if ( physgo ) {
  2562. vehicle = physgo->As_VehicleGameObj();
  2563. }
  2564. if ( vehicle ) {
  2565. vehicle->Script_Enable_Transitions( enable );
  2566. } else {
  2567. Debug_Say(( "Can only Enable_Vehicle_Transitions on a Vehicle\n" ));
  2568. }
  2569. }
  2570. /*
  2571. **
  2572. */
  2573. void Display_GDI_Player_Terminal (void)
  2574. {
  2575. SCRIPT_TRACE(( "ST>Display_GDI_Player_Terminal( )\n" ));
  2576. PlayerTerminalClass::Get_Instance ()->Display_Terminal (COMBAT_STAR, PlayerTerminalClass::TYPE_GDI);
  2577. return ;
  2578. }
  2579. /*
  2580. **
  2581. */
  2582. void Display_NOD_Player_Terminal (void)
  2583. {
  2584. SCRIPT_TRACE(( "ST>Display_NOD_Player_Terminal( )\n" ));
  2585. PlayerTerminalClass::Get_Instance ()->Display_Terminal (COMBAT_STAR, PlayerTerminalClass::TYPE_NOD);
  2586. return ;
  2587. }
  2588. /*
  2589. **
  2590. */
  2591. void Display_Mutant_Player_Terminal (void)
  2592. {
  2593. SCRIPT_TRACE(( "ST>Display_Mutant_Player_Terminal( )\n" ));
  2594. PlayerTerminalClass::Get_Instance ()->Display_Terminal (COMBAT_STAR, PlayerTerminalClass::TYPE_MUTANT);
  2595. return ;
  2596. }
  2597. /*
  2598. **
  2599. */
  2600. bool Reveal_Encyclopedia_Character( int object_id )
  2601. {
  2602. SCRIPT_TRACE(( "ST>Reveal_Encyclopedia_Character( %d )\n", object_id ));
  2603. return EncyclopediaMgrClass::Reveal_Object( EncyclopediaMgrClass::TYPE_CHARACTER, object_id );
  2604. }
  2605. /*
  2606. **
  2607. */
  2608. bool Reveal_Encyclopedia_Weapon( int object_id )
  2609. {
  2610. SCRIPT_TRACE(( "ST>Reveal_Encyclopedia_Weapon( %d )\n", object_id ));
  2611. return EncyclopediaMgrClass::Reveal_Object( EncyclopediaMgrClass::TYPE_WEAPON, object_id );
  2612. }
  2613. /*
  2614. **
  2615. */
  2616. bool Reveal_Encyclopedia_Vehicle( int object_id )
  2617. {
  2618. SCRIPT_TRACE(( "ST>Reveal_Encyclopedia_Vehicle( %d )\n", object_id ));
  2619. return EncyclopediaMgrClass::Reveal_Object( EncyclopediaMgrClass::TYPE_VEHICLE, object_id );
  2620. }
  2621. /*
  2622. **
  2623. */
  2624. bool Reveal_Encyclopedia_Building( int object_id )
  2625. {
  2626. SCRIPT_TRACE(( "ST>Reveal_Encyclopedia_Building( %d )\n", object_id ));
  2627. return EncyclopediaMgrClass::Reveal_Object( EncyclopediaMgrClass::TYPE_BUILDING, object_id );
  2628. }
  2629. /*
  2630. **
  2631. */
  2632. void Display_Encyclopedia_Event_UI( void )
  2633. {
  2634. SCRIPT_TRACE(( "ST>Display_Encyclopedia_Event_UI( )\n" ));
  2635. EncyclopediaMgrClass::Display_Event_UI();
  2636. HUDClass::Add_Data_Link();
  2637. return ;
  2638. }
  2639. /*
  2640. **
  2641. */
  2642. void Scale_AI_Awareness( float sight_scale, float hearing_scale )
  2643. {
  2644. SCRIPT_TRACE(( "ST>Scale_AI_Awareness ( %f %f )\n", sight_scale, hearing_scale ));
  2645. SmartGameObj::Set_Global_Sight_Range_Scale( sight_scale );
  2646. // SoundSystem::Set_Global_Listener_Scale( hearing_scale );
  2647. }
  2648. /*
  2649. **
  2650. */
  2651. void Enable_Cinematic_Freeze( GameObject * object, bool enable )
  2652. {
  2653. SCRIPT_PTR_CHECK( object );
  2654. SCRIPT_TRACE(( "ST>Enable_Cinematic_Freeze( %d, %d )\n", object->Get_ID(), enable ));
  2655. object->Enable_Cinematic_Freeze( enable );
  2656. }
  2657. void Expire_Powerup( GameObject * object )
  2658. {
  2659. SCRIPT_PTR_CHECK( object );
  2660. SCRIPT_TRACE(( "ST>Expire_Powerup( %d )\n", object->Get_ID() ));
  2661. PowerUpGameObj * powerup = NULL;
  2662. if ( object->As_PhysicalGameObj() != NULL ) {
  2663. powerup = object->As_PhysicalGameObj()->As_PowerUpGameObj();
  2664. }
  2665. if ( powerup ) {
  2666. powerup->Expire();
  2667. }
  2668. }
  2669. void Set_HUD_Help_Text( int string_id, const Vector3 &color )
  2670. {
  2671. SCRIPT_TRACE(( "ST>Set_HUD_Help_Text( %d )\n", string_id ));
  2672. if (string_id == 0) {
  2673. //
  2674. // Clear the help text
  2675. //
  2676. HUDInfo::Set_HUD_Help_Text( L"" );
  2677. } else {
  2678. //
  2679. // Set the help text
  2680. //
  2681. HUDInfo::Set_HUD_Help_Text( TRANSLATE( string_id ), color );
  2682. //
  2683. // Lookup the sound to play
  2684. //
  2685. int sound_id = GlobalSettingsDef::Get_Global_Settings ()->Get_HUD_Help_Text_Sound_ID ();
  2686. if (sound_id != 0) {
  2687. //
  2688. // Play the sound
  2689. //
  2690. WWAudioClass* audio = WWAudioClass::Get_Instance();
  2691. assert(audio != NULL);
  2692. audio->Create_Instant_Sound( sound_id, Matrix3D(1) );
  2693. }
  2694. }
  2695. return ;
  2696. }
  2697. /*
  2698. **
  2699. */
  2700. void Enable_HUD_Pokable_Indicator( GameObject * object, bool enable )
  2701. {
  2702. SCRIPT_PTR_CHECK( object );
  2703. SCRIPT_TRACE(( "ST>Enable_HUD_Pokable_Indicator( %d, %d )\n", object->Get_ID(), enable ));
  2704. if ( object->As_PhysicalGameObj() != NULL ) {
  2705. object->As_PhysicalGameObj()->Enable_HUD_Pokable_Indicator( enable );
  2706. } else {
  2707. Debug_Say(( "Can only Enable_HUD_Pokable_Indicator on PhysicalGameObjs\n" ));
  2708. }
  2709. }
  2710. void Enable_Innate_Conversations( GameObject * object, bool enable )
  2711. {
  2712. SCRIPT_PTR_CHECK( object );
  2713. SCRIPT_TRACE(( "ST>Enable_Innate_Conversations( %d, %d )\n", object->Get_ID(), enable ));
  2714. if ( object->As_PhysicalGameObj() != NULL ) {
  2715. object->As_PhysicalGameObj()->Enable_Innate_Conversations( enable );
  2716. } else {
  2717. Debug_Say(( "Can only Enable_Innate_Conversations on PhysicalGameObjs\n" ));
  2718. }
  2719. }
  2720. void Display_Health_Bar( GameObject * object, bool display )
  2721. {
  2722. SCRIPT_PTR_CHECK( object );
  2723. SCRIPT_TRACE(( "ST>Display_Health_Bar( %d, %d )\n", object->Get_ID(), display ));
  2724. if ( object->As_DamageableGameObj() != NULL ) {
  2725. object->As_DamageableGameObj()->Set_Is_Health_Bar_Displayed( display );
  2726. } else {
  2727. Debug_Say(( "Can only Display_Health_Bar on DamageableGameObjs\n" ));
  2728. }
  2729. }
  2730. void Enable_Shadow( GameObject * object, bool enable )
  2731. {
  2732. SCRIPT_PTR_CHECK( object );
  2733. SCRIPT_TRACE(( "ST>Enable_Shadow( %d, %d )\n", object->Get_ID(), enable));
  2734. if ( object->As_PhysicalGameObj() != NULL) {
  2735. object->As_PhysicalGameObj()->Peek_Physical_Object()->Enable_Shadow_Generation(enable);
  2736. } else {
  2737. Debug_Say(( "Can only call Enable_Shadow on PhysicalGameObjs\n"));
  2738. }
  2739. }
  2740. void Clear_Weapons( GameObject * object )
  2741. {
  2742. SCRIPT_PTR_CHECK( object );
  2743. SCRIPT_TRACE(( "ST>Clear_Weapons( %d )\n", object->Get_ID() ));
  2744. if ( object->As_SmartGameObj() != NULL) {
  2745. object->As_SmartGameObj()->Get_Weapon_Bag()->Clear_Weapons();
  2746. } else {
  2747. Debug_Say(( "Can only call Clear_Weapons on SmartGameObjs\n"));
  2748. }
  2749. }
  2750. void Set_Num_Tertiary_Objectives( int count )
  2751. {
  2752. SCRIPT_TRACE(( "ST>Set_Num_Tertiary_Objectives( %d )\n", count ));
  2753. ObjectiveManager::Set_Num_Specified_Tertiary_Objectives( count );
  2754. }
  2755. void Enable_Letterbox( bool onoff, float seconds )
  2756. {
  2757. SCRIPT_TRACE(( "ST>Enable_Letterbox( %d, %f)\n", onoff,seconds ));
  2758. ScreenFadeManager::Enable_Letterbox(onoff,seconds);
  2759. }
  2760. void Set_Screen_Fade_Color( float r, float g, float b, float seconds )
  2761. {
  2762. SCRIPT_TRACE(( "ST>Set_Screen_Fade_Color( %f, %f, %f, %f)\n", r,g,b,seconds ));
  2763. ScreenFadeManager::Set_Screen_Overlay_Color(r,g,b,seconds);
  2764. }
  2765. void Set_Screen_Fade_Opacity( float opacity, float seconds )
  2766. {
  2767. SCRIPT_TRACE(( "ST>Set_Screen_Fade_Opacity( %f, %f)\n", opacity,seconds ));
  2768. ScreenFadeManager::Set_Screen_Overlay_Opacity(opacity,seconds);
  2769. }
  2770. /*
  2771. **
  2772. */
  2773. ScriptCommands* Get_Script_Commands( void )
  2774. {
  2775. static ScriptCommands EngineCommands;
  2776. memset(&EngineCommands, 0, sizeof(EngineCommands));
  2777. // Denzil 4/7/00 - Using the structure size automates the version check.
  2778. EngineCommands.Size = sizeof(EngineCommands);
  2779. EngineCommands.Version = SCRIPT_COMMANDS_VERSION;
  2780. EngineCommands.Debug_Message = &Debug_Message;
  2781. // Action Commands
  2782. EngineCommands.Action_Reset = Action_Reset;
  2783. EngineCommands.Action_Goto = Action_Goto;
  2784. EngineCommands.Action_Attack = Action_Attack;
  2785. EngineCommands.Action_Play_Animation = Action_Play_Animation;
  2786. EngineCommands.Action_Enter_Exit = Action_Enter_Exit;
  2787. EngineCommands.Action_Face_Location = Action_Face_Location;
  2788. EngineCommands.Action_Dock = Action_Dock;
  2789. EngineCommands.Action_Follow_Input = Action_Follow_Input;
  2790. EngineCommands.Modify_Action = Modify_Action;
  2791. EngineCommands.Set_Position = &Set_Position;
  2792. EngineCommands.Get_Position = &Get_Position;
  2793. EngineCommands.Get_Bone_Position = &Get_Bone_Position;
  2794. EngineCommands.Get_Facing = &Get_Facing;
  2795. EngineCommands.Set_Facing = &Set_Facing;
  2796. EngineCommands.Disable_All_Collisions = &Disable_All_Collisions;
  2797. EngineCommands.Disable_Physical_Collisions = &Disable_Physical_Collisions;
  2798. EngineCommands.Enable_Collisions = &Enable_Collisions;
  2799. EngineCommands.Destroy_Object = &Destroy_Object;
  2800. EngineCommands.Find_Object = &Find_Object;
  2801. EngineCommands.Create_Object = &Create_Object;
  2802. EngineCommands.Create_Object_At_Bone = &Create_Object_At_Bone;
  2803. EngineCommands.Attach_Script = Attach_Script;
  2804. EngineCommands.Add_To_Dirty_Cull_List = Add_To_Dirty_Cull_List;
  2805. EngineCommands.Get_ID = &Get_ID;
  2806. EngineCommands.Get_Preset_ID = &Get_Preset_ID;
  2807. EngineCommands.Get_Preset_Name = &Get_Preset_Name;
  2808. EngineCommands.Start_Timer = &Start_Timer;
  2809. EngineCommands.Trigger_Weapon = &Trigger_Weapon;
  2810. EngineCommands.Select_Weapon = &Select_Weapon;
  2811. EngineCommands.Send_Custom_Event = &Send_Custom_Event;
  2812. EngineCommands.Send_Damaged_Event = &Send_Damaged_Event;
  2813. EngineCommands.Get_Random = &Get_Random;
  2814. EngineCommands.Get_Random_Int = &Get_Random_Int;
  2815. EngineCommands.Find_Random_Simple_Object = &Find_Random_Simple_Object;
  2816. EngineCommands.Set_Model = &Set_Model;
  2817. EngineCommands.Set_Animation = &Set_Animation;
  2818. EngineCommands.Set_Animation_Frame = &Set_Animation_Frame;
  2819. EngineCommands.Create_Sound = Create_Sound;
  2820. EngineCommands.Create_2D_Sound = Create_2D_Sound;
  2821. EngineCommands.Create_2D_WAV_Sound = Create_2D_WAV_Sound;
  2822. EngineCommands.Create_3D_WAV_Sound_At_Bone = Create_3D_WAV_Sound_At_Bone;
  2823. EngineCommands.Create_3D_Sound_At_Bone = Create_3D_Sound_At_Bone;
  2824. EngineCommands.Create_Logical_Sound = Create_Logical_Sound;
  2825. EngineCommands.Set_Background_Music = Set_Background_Music;
  2826. EngineCommands.Fade_Background_Music = Fade_Background_Music;
  2827. EngineCommands.Stop_Background_Music = Stop_Background_Music;
  2828. EngineCommands.Monitor_Sound = Monitor_Sound;
  2829. EngineCommands.Stop_Sound = Stop_Sound;
  2830. EngineCommands.Start_Sound = Start_Sound;
  2831. EngineCommands.Get_Health = Get_Health;
  2832. EngineCommands.Get_Max_Health = Get_Max_Health;
  2833. EngineCommands.Set_Health = Set_Health;
  2834. EngineCommands.Get_Shield_Strength = Get_Shield_Strength;
  2835. EngineCommands.Get_Max_Shield_Strength = Get_Max_Shield_Strength;
  2836. EngineCommands.Set_Shield_Strength = Set_Shield_Strength;
  2837. EngineCommands.Set_Shield_Type = Set_Shield_Type;
  2838. EngineCommands.Get_Player_Type = Get_Player_Type;
  2839. EngineCommands.Set_Player_Type = Set_Player_Type;
  2840. EngineCommands.Get_Distance = Get_Distance;
  2841. EngineCommands.Set_Camera_Host = Set_Camera_Host;
  2842. EngineCommands.Force_Camera_Look = Force_Camera_Look;
  2843. EngineCommands.Get_The_Star = Get_The_Star;
  2844. EngineCommands.Get_A_Star = Get_A_Star;
  2845. EngineCommands.Find_Closest_Soldier = Find_Closest_Soldier;
  2846. EngineCommands.Is_A_Star = Is_A_Star;
  2847. EngineCommands.Control_Enable = Control_Enable;
  2848. EngineCommands.Get_Damage_Bone_Name = Get_Damage_Bone_Name;
  2849. EngineCommands.Get_Damage_Bone_Direction = Get_Damage_Bone_Direction;
  2850. EngineCommands.Is_Object_Visible = Is_Object_Visible;
  2851. EngineCommands.Enable_Enemy_Seen = Enable_Enemy_Seen;
  2852. EngineCommands.Set_Display_Color = Set_Display_Color;
  2853. EngineCommands.Display_Text = Display_Text;
  2854. EngineCommands.Display_Float = Display_Float;
  2855. EngineCommands.Display_Int = Display_Int;
  2856. EngineCommands.Save_Data = Save_Data;
  2857. EngineCommands.Save_Pointer = Save_Pointer;
  2858. EngineCommands.Load_Begin = Load_Begin;
  2859. EngineCommands.Load_Data = Load_Data;
  2860. EngineCommands.Load_Pointer = Load_Pointer;
  2861. EngineCommands.Load_End = Load_End;
  2862. EngineCommands.Begin_Chunk = Begin_Chunk;
  2863. EngineCommands.End_Chunk = End_Chunk;
  2864. EngineCommands.Open_Chunk = Open_Chunk;
  2865. EngineCommands.Close_Chunk = Close_Chunk;
  2866. EngineCommands.Clear_Radar_Markers = Clear_Radar_Markers;
  2867. EngineCommands.Clear_Radar_Marker = Clear_Radar_Marker;
  2868. EngineCommands.Add_Radar_Marker = Add_Radar_Marker;
  2869. // EngineCommands.Add_Obj_Radar_Marker = Add_Obj_Radar_Marker;
  2870. EngineCommands.Set_Obj_Radar_Blip_Shape = Set_Obj_Radar_Blip_Shape;
  2871. EngineCommands.Set_Obj_Radar_Blip_Color = Set_Obj_Radar_Blip_Color;
  2872. EngineCommands.Enable_Radar = Enable_Radar;
  2873. EngineCommands.Create_Explosion = Create_Explosion;
  2874. EngineCommands.Create_Explosion_At_Bone = Create_Explosion_At_Bone;
  2875. EngineCommands.Enable_HUD = Enable_HUD;
  2876. EngineCommands.Mission_Complete = Mission_Complete;
  2877. EngineCommands.Give_PowerUp = Give_PowerUp;
  2878. EngineCommands.Innate_Disable = Innate_Disable;
  2879. EngineCommands.Innate_Enable = Innate_Enable;
  2880. EngineCommands.Innate_Soldier_Enable_Enemy_Seen = &Innate_Soldier_Enable_Enemy_Seen;
  2881. EngineCommands.Innate_Soldier_Enable_Gunshot_Heard = &Innate_Soldier_Enable_Gunshot_Heard;
  2882. EngineCommands.Innate_Soldier_Enable_Footsteps_Heard = &Innate_Soldier_Enable_Footsteps_Heard;
  2883. EngineCommands.Innate_Soldier_Enable_Bullet_Heard = &Innate_Soldier_Enable_Bullet_Heard;
  2884. EngineCommands.Innate_Soldier_Enable_Actions = &Innate_Soldier_Enable_Actions;
  2885. EngineCommands.Set_Innate_Soldier_Home_Location = Set_Innate_Soldier_Home_Location;
  2886. EngineCommands.Set_Innate_Aggressiveness = Set_Innate_Aggressiveness;
  2887. EngineCommands.Set_Innate_Take_Cover_Probability = Set_Innate_Take_Cover_Probability;
  2888. EngineCommands.Set_Innate_Is_Stationary = Set_Innate_Is_Stationary;
  2889. EngineCommands.Innate_Force_State_Bullet_Heard = &Innate_Force_State_Bullet_Heard;
  2890. EngineCommands.Innate_Force_State_Footsteps_Heard = &Innate_Force_State_Footsteps_Heard;
  2891. EngineCommands.Innate_Force_State_Gunshots_Heard = &Innate_Force_State_Gunshots_Heard;
  2892. EngineCommands.Innate_Force_State_Enemy_Seen = &Innate_Force_State_Enemy_Seen;
  2893. EngineCommands.Static_Anim_Phys_Goto_Frame = &Static_Anim_Phys_Goto_Frame;
  2894. EngineCommands.Static_Anim_Phys_Goto_Last_Frame = &Static_Anim_Phys_Goto_Last_Frame;
  2895. EngineCommands.Get_Sync_Time = &Get_Sync_Time;
  2896. EngineCommands.Add_Objective = &Add_Objective;
  2897. EngineCommands.Remove_Objective = &Remove_Objective;
  2898. EngineCommands.Set_Objective_Status = &Set_Objective_Status;
  2899. EngineCommands.Change_Objective_Type = &Change_Objective_Type;
  2900. EngineCommands.Set_Objective_Radar_Blip = &Set_Objective_Radar_Blip;
  2901. EngineCommands.Set_Objective_Radar_Blip_Object = &Set_Objective_Radar_Blip_Object;
  2902. EngineCommands.Set_Objective_HUD_Info = &Set_Objective_HUD_Info;
  2903. EngineCommands.Set_Objective_HUD_Info_Position = &Set_Objective_HUD_Info_Position;
  2904. EngineCommands.Shake_Camera = Shake_Camera;
  2905. EngineCommands.Enable_Spawner = Enable_Spawner;
  2906. EngineCommands.Trigger_Spawner = Trigger_Spawner;
  2907. EngineCommands.Enable_Engine = Enable_Engine;
  2908. EngineCommands.Get_Difficulty_Level = Get_Difficulty_Level;
  2909. EngineCommands.Grant_Key = Grant_Key;
  2910. EngineCommands.Has_Key = Has_Key;
  2911. EngineCommands.Enable_Hibernation = Enable_Hibernation;
  2912. EngineCommands.Attach_To_Object_Bone = Attach_To_Object_Bone;
  2913. EngineCommands.Create_Conversation = Create_Conversation;
  2914. EngineCommands.Join_Conversation = Join_Conversation;
  2915. EngineCommands.Join_Conversation_Facing = Join_Conversation_Facing;
  2916. EngineCommands.Start_Conversation = Start_Conversation;
  2917. EngineCommands.Monitor_Conversation = Monitor_Conversation;
  2918. EngineCommands.Start_Random_Conversation = Start_Random_Conversation;
  2919. EngineCommands.Stop_Conversation = Stop_Conversation;
  2920. EngineCommands.Stop_All_Conversations = Stop_All_Conversations;
  2921. EngineCommands.Apply_Damage = Apply_Damage;
  2922. EngineCommands.Set_Loiters_Allowed = Set_Loiters_Allowed;
  2923. EngineCommands.Set_Is_Visible = Set_Is_Visible;
  2924. EngineCommands.Set_Is_Rendered = Set_Is_Rendered;
  2925. EngineCommands.Get_Points = Get_Points;
  2926. EngineCommands.Give_Points = Give_Points;
  2927. EngineCommands.Get_Money = Get_Money;
  2928. EngineCommands.Give_Money = Give_Money;
  2929. EngineCommands.Get_Building_Power = Get_Building_Power;
  2930. EngineCommands.Set_Building_Power = Set_Building_Power;
  2931. EngineCommands.Play_Building_Announcement = Play_Building_Announcement;
  2932. EngineCommands.Find_Nearest_Building = Find_Nearest_Building;
  2933. EngineCommands.Find_Nearest_Building_To_Pos = Find_Nearest_Building_To_Pos;
  2934. EngineCommands.Team_Members_In_Zone = Team_Members_In_Zone;
  2935. EngineCommands.Set_Clouds = Set_Clouds;
  2936. EngineCommands.Set_Lightning = Set_Lightning;
  2937. EngineCommands.Set_War_Blitz = Set_War_Blitz;
  2938. EngineCommands.Set_Wind = Set_Wind;
  2939. EngineCommands.Set_Rain = Set_Rain;
  2940. EngineCommands.Set_Snow = Set_Snow;
  2941. EngineCommands.Set_Ash = Set_Ash;
  2942. EngineCommands.Set_Fog_Enable = Set_Fog_Enable;
  2943. EngineCommands.Set_Fog_Range = Set_Fog_Range;
  2944. EngineCommands.Clear_Map_Cell = Clear_Map_Cell;
  2945. EngineCommands.Clear_Map_Cell_By_Pos = Clear_Map_Cell_By_Pos;
  2946. EngineCommands.Clear_Map_Cell_By_Pixel_Pos = Clear_Map_Cell_By_Pixel_Pos;
  2947. EngineCommands.Clear_Map_Region_By_Pos = Clear_Map_Region_By_Pos;
  2948. EngineCommands.Reveal_Map = Reveal_Map;
  2949. EngineCommands.Shroud_Map = Shroud_Map;
  2950. EngineCommands.Show_Player_Map_Marker = Show_Player_Map_Marker;
  2951. EngineCommands.Get_Safe_Flight_Height = Get_Safe_Flight_Height;
  2952. EngineCommands.Enable_Stealth = Enable_Stealth;
  2953. EngineCommands.Cinematic_Sniper_Control = Cinematic_Sniper_Control;
  2954. EngineCommands.Text_File_Open = Text_File_Open;
  2955. EngineCommands.Text_File_Get_String = Text_File_Get_String;
  2956. EngineCommands.Text_File_Close = Text_File_Close;
  2957. EngineCommands.Enable_Vehicle_Transitions = Enable_Vehicle_Transitions;
  2958. EngineCommands.Display_GDI_Player_Terminal = Display_GDI_Player_Terminal;
  2959. EngineCommands.Display_NOD_Player_Terminal = Display_NOD_Player_Terminal;
  2960. EngineCommands.Display_Mutant_Player_Terminal = Display_Mutant_Player_Terminal;
  2961. EngineCommands.Reveal_Encyclopedia_Character = Reveal_Encyclopedia_Character;
  2962. EngineCommands.Reveal_Encyclopedia_Weapon = Reveal_Encyclopedia_Weapon;
  2963. EngineCommands.Reveal_Encyclopedia_Vehicle = Reveal_Encyclopedia_Vehicle;
  2964. EngineCommands.Reveal_Encyclopedia_Building = Reveal_Encyclopedia_Building;
  2965. EngineCommands.Display_Encyclopedia_Event_UI = Display_Encyclopedia_Event_UI;
  2966. EngineCommands.Scale_AI_Awareness = Scale_AI_Awareness;
  2967. EngineCommands.Enable_Cinematic_Freeze = Enable_Cinematic_Freeze;
  2968. EngineCommands.Expire_Powerup = Expire_Powerup;
  2969. EngineCommands.Get_Action_ID = Get_Action_ID;
  2970. EngineCommands.Get_Action_Params = Get_Action_Params;
  2971. EngineCommands.Is_Performing_Pathfind_Action = Is_Performing_Pathfind_Action;
  2972. EngineCommands.Set_HUD_Help_Text = Set_HUD_Help_Text;
  2973. EngineCommands.Enable_HUD_Pokable_Indicator = Enable_HUD_Pokable_Indicator;
  2974. EngineCommands.Enable_Innate_Conversations = Enable_Innate_Conversations;
  2975. EngineCommands.Lock_Soldier_Facing = Lock_Soldier_Facing;
  2976. EngineCommands.Unlock_Soldier_Facing = Unlock_Soldier_Facing;
  2977. EngineCommands.Display_Health_Bar = Display_Health_Bar;
  2978. EngineCommands.Enable_Shadow = Enable_Shadow;
  2979. EngineCommands.Clear_Weapons = Clear_Weapons;
  2980. EngineCommands.Set_Num_Tertiary_Objectives = Set_Num_Tertiary_Objectives;
  2981. EngineCommands.Enable_Letterbox = Enable_Letterbox;
  2982. EngineCommands.Set_Screen_Fade_Color = Set_Screen_Fade_Color;
  2983. EngineCommands.Set_Screen_Fade_Opacity = Set_Screen_Fade_Opacity;
  2984. return &EngineCommands;
  2985. }