missiongui.cpp 170 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009
  1. //--------------------------------------------------------------------------------------
  2. //
  3. // MechCommander 2
  4. //
  5. // This header contains the mission classes for the GUI
  6. //
  7. // GUI is now single update driven. An event comes in, the manager decides who its for
  8. // and passes the event down. Eveything still know how to draw etc.
  9. //
  10. // All drawing is done through gos_drawQuad and drawTriangle
  11. //
  12. // Basic cycle is
  13. // call GObject->update with this frame's events.
  14. // This will check the events to see if any pertain to me.
  15. // Draw anything to the texture plane that needs drawing.
  16. // Call any code which the events might have trigged.
  17. // call GObject->render with this frame's events.
  18. // This draws the object to the screen.
  19. // called in order of depth.
  20. //
  21. //---------------------------------------------------------------------------//
  22. // Copyright (C) Microsoft Corporation. All rights reserved. //
  23. //===========================================================================//
  24. //--------------------------------------------------------------------------------------
  25. // Include Files
  26. #ifndef MISSIONGUI_H
  27. #include "missiongui.h"
  28. #endif
  29. #ifndef OBJMGR_H
  30. #include "objmgr.h"
  31. #endif
  32. #ifndef GAMESOUND_H
  33. #include "gamesound.h"
  34. #endif
  35. #ifndef SOUNDS_H
  36. #include "sounds.h"
  37. #endif
  38. #ifndef MULTPLYR_H
  39. #include "multplyr.h"
  40. #endif
  41. #ifndef TEAM_H
  42. #include "team.h"
  43. #endif
  44. #ifndef GAMECAM_H
  45. #include "gamecam.h"
  46. #endif
  47. #ifndef VERTEX_H
  48. #include "Vertex.h"
  49. #endif
  50. #ifndef MECH_H
  51. #include "Mech.h"
  52. #endif
  53. #ifndef ARTLRY_H
  54. #include "artlry.h"
  55. #endif
  56. #ifndef LOGISTICSPILOT_H
  57. #include "LogisticsPilot.h"
  58. #endif
  59. #ifndef LOGISTICSDATA_H
  60. #include "LogisticsData.h"
  61. #endif
  62. #ifndef MISSION_H
  63. #include "Mission.h"
  64. #endif
  65. #ifndef GROUP_H
  66. #include "group.h"
  67. #endif
  68. #ifndef MOVEMGR_H
  69. #include "movemgr.h"
  70. #endif
  71. #ifndef COMNDR_H
  72. #include "comndr.h"
  73. #endif
  74. #ifndef PREFS_H
  75. #include "Prefs.h"
  76. #endif
  77. #ifndef KEYBOARDREF_H
  78. #include "KeyboardRef.h"
  79. #endif
  80. #include "..\resource.h"
  81. #include "windows.h"
  82. #include "gvehicl.h" // remove
  83. static char* terrainStr[NUM_TERRAIN_TYPES] = {
  84. "Blue Water", //MC_BLUEWATER_TYPE
  85. "Green Water", //MC_GREEN_WATER_TYPE
  86. "Mud", //MC_MUD_TYPE
  87. "Moss", //MC_MOSS_TYPE
  88. "Dirt", //MC_DIRT_TYPE
  89. "Ash", //MC_ASH_TYPE
  90. "Mountain", //MC_MOUNTAIN_TYPE
  91. "Tundra", //MC_TUNDRA_TYPE
  92. "Forest", //MC_FORESTFLOOR_TYPE
  93. "Grass", //MC_GRASS_TYPE
  94. "Concrete", //MC_CONCRETE_TYPE
  95. "Cliff", //MC_CLIFF_TYPE
  96. "Slimy", //MC_SLIMY_TYPE
  97. "None" //MC_NONE_TYPE
  98. };
  99. extern void testKeyStuff();
  100. extern long helpTextHeaderID;
  101. extern long helpTextID;
  102. extern CPrefs prefs;
  103. extern bool invulnerableON;
  104. extern bool MLRVertexLimitReached;
  105. //--------------------------------------------------------------------------------------
  106. // Globals
  107. extern float frameLength;
  108. extern void DEBUGWINS_print (char* s, long window = 0);
  109. extern void DEBUGWINS_setGameObject (long debugObj, GameObjectPtr obj);
  110. extern void DEBUGWINS_toggle (bool* windowsOpen);
  111. extern void DEBUGWINS_display (bool* windowsOpen);
  112. extern void DEBUGWINS_viewGameObject (long debugObj);
  113. extern MidLevelRenderer::MLRClipper * theClipper;
  114. extern GameObjectPtr DebugGameObject[3];
  115. #ifndef FINAL
  116. extern float CheatHitDamage;
  117. #endif
  118. float MissionInterfaceManager::pauseWndVelocity = -50.f;
  119. //--------------------------------------------------------------------------------------
  120. //class MissionInterfaceManager : public InterfaceManager
  121. //--------------------------------------------------------------------------------------
  122. #define CTRL 0x10000000
  123. #define SHIFT 0x01000000
  124. #define ALT 0x00100000
  125. #define WAYPT 0x20000000
  126. #define ATTILA_FACTOR 1.0f
  127. #define ATTILA_ROTATION_FACTOR 4.1f
  128. #define ATTILA_THRESHOLD 0.01f
  129. int MissionInterfaceManager::mouseX = 0;
  130. int MissionInterfaceManager::mouseY = 0;
  131. GameObject* MissionInterfaceManager::target = NULL;
  132. MissionInterfaceManager* MissionInterfaceManager::s_instance = NULL;
  133. gosEnum_KeyIndex MissionInterfaceManager::WAYPOINT_KEY = (gosEnum_KeyIndex)-1;
  134. extern bool drawTerrainTiles;
  135. extern bool drawTerrainOverlays;
  136. extern bool renderObjects;
  137. extern bool drawTerrainGrid;
  138. extern bool drawLOSGrid;
  139. extern bool useClouds;
  140. extern bool useFog;
  141. extern bool useWaterInterestTexture;
  142. extern bool useShadows;
  143. extern bool useFaceLighting;
  144. extern bool useVertexLighting;
  145. extern bool renderTGLShapes;
  146. extern bool useLeftRightMouseProfile;
  147. bool drawGUIOn = true; //Used to shut off GUI for Screen Shots and Movie Mode
  148. bool toggledGUI = true; //Used to tell if I shut the GUI off or if its in movieMode
  149. long lightState = 0;
  150. extern bool ShowMovers;
  151. extern bool CullPathAreas;
  152. extern bool ZeroHPrime;
  153. extern bool CalcValidAreaTable;
  154. extern bool EnemiesGoalPlan;
  155. bool paintingMyVtol = false;
  156. long MissionInterfaceManager::OldKeys[MAX_COMMAND] = {-1};
  157. MissionInterfaceManager::Command MissionInterfaceManager::commands[MAX_COMMAND] = {
  158. KEY_S, mState_SHRTRNG_ATTACK, mState_SHRTRNG_LOS, false, &MissionInterfaceManager::attackShort, &MissionInterfaceManager::defaultAttack, 43200,
  159. KEY_M, mState_MEDRNG_ATTACK, mState_MEDRNG_LOS, false, &MissionInterfaceManager::attackMedium, &MissionInterfaceManager::defaultAttack, 43201,
  160. KEY_L, mState_LONGRNG_ATTACK, mState_LONGRNG_LOS, false, &MissionInterfaceManager::attackLong, &MissionInterfaceManager::defaultAttack, 43202,
  161. KEY_A, mState_ENERGY_WEAPONS, mState_ENERGY_WEAPONS_LOS, false, &MissionInterfaceManager::energyWeapons, &MissionInterfaceManager::energyWeapons, 43204,
  162. KEY_D, mState_GENERIC_ATTACK, mState_ATTACK_LOS, false, &MissionInterfaceManager::defaultAttack,0, -1,
  163. KEY_J, mState_JUMP1, mState_JUMP_LOS, false, &MissionInterfaceManager::jump, &MissionInterfaceManager::stopJump, 43205,
  164. KEY_J | WAYPT, mState_JUMPWAYPT, mState_JUMPWAYPT_LOS, false, &MissionInterfaceManager::jump, &MissionInterfaceManager::stopJump, -1,
  165. KEY_C, mState_CURPOS_ATTACK, mState_CURPOS_ATTACK_LOS, false, &MissionInterfaceManager::fireFromCurrentPos, &MissionInterfaceManager::stopFireFromCurrentPos, 43206,
  166. KEY_G, mState_GUARD, mState_GUARD, false, &MissionInterfaceManager::guard, &MissionInterfaceManager::stopGuard, 43207,
  167. KEY_W, mState_ENERGY_WEAPONS, mState_ENERGY_WEAPONS_LOS, false, &MissionInterfaceManager::conserveAmmo, 0, -1,
  168. KEY_E, -1, -1, false, &MissionInterfaceManager::selectVisible, 0, 43209,
  169. KEY_F, -1, -1, false, &MissionInterfaceManager::forceShot, 0, 43210,
  170. KEY_HOME, -1, -1, true, &MissionInterfaceManager::cameraNormal,0, -1,
  171. KEY_F2, -1, -1, true, &MissionInterfaceManager::cameraDefault,0, -1,
  172. KEY_F3, -1, -1, true, &MissionInterfaceManager::cameraMaxIn,0, -1,
  173. KEY_F4, -1, -1, true, &MissionInterfaceManager::cameraTight,0, -1,
  174. KEY_F5, -1, -1, true, &MissionInterfaceManager::cameraFour,0, -1,
  175. KEY_F2 | CTRL, -1, -1, true, &MissionInterfaceManager::cameraAssign0,0, -1,
  176. KEY_F3 | CTRL, -1, -1, true, &MissionInterfaceManager::cameraAssign1,0, -1,
  177. KEY_F4 | CTRL, -1, -1, true, &MissionInterfaceManager::cameraAssign2,0, -1,
  178. KEY_F5 | CTRL, -1, -1, true, &MissionInterfaceManager::cameraAssign3,0, -1,
  179. KEY_NUMPAD2, mState_DONT, mState_AIMED_ATTACK_LOS, false, &MissionInterfaceManager::aimLeg, 0, 43211,
  180. KEY_NUMPAD5, mState_DONT, mState_AIMED_ATTACK_LOS, false, &MissionInterfaceManager::aimArm, 0, 43212,
  181. KEY_NUMPAD8, mState_DONT, mState_AIMED_ATTACK_LOS, false, &MissionInterfaceManager::aimHead, 0, 43213,
  182. KEY_BACK, -1, -1, false, &MissionInterfaceManager::removeCommand, 0, 43214,
  183. KEY_NEXT | 0x100, -1, -1, false, &MissionInterfaceManager::powerDown, 0, 43215,
  184. KEY_PRIOR| 0x100, -1, -1, false, &MissionInterfaceManager::powerUp, 0, 43216,
  185. KEY_END| 0x100, mState_EJECT, mState_EJECT, false, &MissionInterfaceManager::eject, 0, 43217,
  186. KEY_SPACE, mState_RUN, mState_RUN_LOS, false, &MissionInterfaceManager::changeSpeed, &MissionInterfaceManager::stopChangeSpeed, 43218,
  187. KEY_SPACE | WAYPT, mState_RUNWAYPT, mState_RUNWAYPT_LOS, false, &MissionInterfaceManager::changeSpeed, &MissionInterfaceManager::stopChangeSpeed, -1,
  188. KEY_UP | 0x100, -1, -1, false, &MissionInterfaceManager::scrollUp, 0, IDS_HOTKEY_TRACKU,
  189. KEY_DOWN | 0x100, -1, -1, false, &MissionInterfaceManager::scrollDown, 0, IDS_HOTKEY_TRACKD,
  190. KEY_LEFT | 0x100, -1, -1, false, &MissionInterfaceManager::scrollLeft, 0, IDS_HOTKEY_TRACKL,
  191. KEY_RIGHT | 0x100, -1, -1, false, &MissionInterfaceManager::scrollRight, 0, IDS_HOTKEY_TRACKR,
  192. KEY_SUBTRACT, -1, -1, false, &MissionInterfaceManager::zoomOut,0, 43225,
  193. KEY_MINUS, -1, -1, false, &MissionInterfaceManager::zoomOut,0, -1,
  194. KEY_ADD, -1, -1, false, &MissionInterfaceManager::zoomIn,0, 43224,
  195. SHIFT | KEY_EQUALS, -1, -1, false, &MissionInterfaceManager::zoomIn,0, -1,
  196. KEY_LEFT | SHIFT | 0x100, -1, -1, false, &MissionInterfaceManager::rotateLeft, 0, IDS_HOTKEY_ROTATEL,
  197. KEY_RIGHT | SHIFT | 0x100, -1, -1, false, &MissionInterfaceManager::rotateRight, 0, IDS_HOTKEY_ROTATER,
  198. KEY_UP | SHIFT | 0x100, -1, -1, false, &MissionInterfaceManager::tiltUp, 0, IDS_HOTKEY_TILTU,
  199. KEY_DOWN | SHIFT | 0x100, -1, -1, false, &MissionInterfaceManager::tiltDown, 0, IDS_HOTKEY_TILTD,
  200. KEY_HOME | 0x100, -1, -1, false, &MissionInterfaceManager::centerCamera, 0, -1,
  201. KEY_LEFT | CTRL, -1, -1, false, &MissionInterfaceManager::rotateLightLeft, 0, -1,
  202. KEY_RIGHT | CTRL, -1, -1, false, &MissionInterfaceManager::rotateLightRight, 0, -1,
  203. KEY_UP | CTRL, -1, -1, false, &MissionInterfaceManager::rotateLightUp, 0, -1,
  204. KEY_DOWN | CTRL, -1, -1, false, &MissionInterfaceManager::rotateLightDown, 0, -1,
  205. KEY_T | CTRL | ALT, -1, -1, true, &MissionInterfaceManager::drawTerrain, 0, -1,
  206. KEY_O | CTRL | ALT, -1, -1, true, &MissionInterfaceManager::drawOverlays, 0, -1,
  207. KEY_B | CTRL | ALT, -1, -1, true, &MissionInterfaceManager::drawBuildings, 0, -1,
  208. CTRL | ALT | KEY_G, -1, -1, true, &MissionInterfaceManager::showGrid, 0, -1,
  209. CTRL | ALT | KEY_Q, -1, -1, true, &MissionInterfaceManager::recalcLights, 0, -1,
  210. CTRL | ALT | KEY_C, -1, -1, true, &MissionInterfaceManager::drawClouds, 0, -1,
  211. CTRL | ALT | KEY_F, -1, -1, true, &MissionInterfaceManager::drawFog, 0, -1,
  212. CTRL | ALT | KEY_P, -1, -1, true, &MissionInterfaceManager::usePerspective, 0, -1,
  213. CTRL | ALT | KEY_S, -1, -1, true, &MissionInterfaceManager::drawTGLShapes, 0, -1,
  214. CTRL | ALT | KEY_V, -1, -1, true, &MissionInterfaceManager::drawWaterEffects, 0, -1,
  215. CTRL | ALT | KEY_W, -1, -1, true, &MissionInterfaceManager::recalcWater, 0, -1,
  216. CTRL | ALT | KEY_D, -1, -1, true, &MissionInterfaceManager::drawShadows, 0, -1,
  217. CTRL | ALT | KEY_L, -1, -1, true, &MissionInterfaceManager::changeLighting, 0, -1,
  218. CTRL | ALT | KEY_Z, -1, -1, true, &MissionInterfaceManager::toggleGUI, 0, -1,
  219. KEY_V, -1, -1, true, &MissionInterfaceManager::vehicleCommand, 0, 43222,
  220. KEY_F9, -1, -1, true, &MissionInterfaceManager::showObjectives, 0, 43226,
  221. KEY_ESCAPE, -1, -1, true, &MissionInterfaceManager::togglePause, 0, 43234,
  222. KEY_F1, -1, -1, true, &MissionInterfaceManager::toggleHotKeys, 0, -1,
  223. KEY_P, -1, -1, true, &MissionInterfaceManager::togglePause, 0, -1,
  224. KEY_TAB, -1, -1, true, &MissionInterfaceManager::switchTab, 0, -1,
  225. KEY_TAB | SHIFT, -1, -1, true, &MissionInterfaceManager::reverseSwitchTab, 0, -1,
  226. KEY_I, -1, -1, true, &MissionInterfaceManager::infoCommand, &MissionInterfaceManager::infoButtonReleased, 43219,
  227. KEY_N, -1, -1, true, &MissionInterfaceManager::gotoNextNavMarker, 0, -1,
  228. KEY_MULTIPLY, mState_UNCERTAIN_AIRSTRIKE, mState_AIRSTRIKE, true, &MissionInterfaceManager::sendAirstrike, 0, 43220,
  229. KEY_DIVIDE, mState_SENSORSTRIKE, mState_SENSORSTRIKE, true, &MissionInterfaceManager::sendSensorStrike, 0, 43221,
  230. KEY_BACKSLASH, -1, -1, true, &MissionInterfaceManager::toggleCompass, 0, 43223,
  231. ALT | KEY_SLASH, -1, -1, false, &MissionInterfaceManager::quickDebugInfo, 0, -1,
  232. ALT | SHIFT | KEY_SLASH, -1, -1, false, &MissionInterfaceManager::setGameObjectWindow, 0, -1,
  233. ALT | CTRL | KEY_1, -1, -1, false, &MissionInterfaceManager::pageGameObjectWindow1, 0, -1,
  234. ALT | CTRL | KEY_2, -1, -1, false, &MissionInterfaceManager::pageGameObjectWindow2, 0, -1,
  235. ALT | CTRL | KEY_3, -1, -1, false, &MissionInterfaceManager::pageGameObjectWindow3, 0, -1,
  236. ALT | KEY_1, -1, -1, false, &MissionInterfaceManager::jumpToDebugGameObject1, 0, -1,
  237. ALT | KEY_2, -1, -1, false, &MissionInterfaceManager::jumpToDebugGameObject2, 0, -1,
  238. ALT | KEY_3, -1, -1, false, &MissionInterfaceManager::jumpToDebugGameObject3, 0, -1,
  239. ALT | KEY_T, -1, -1, false, &MissionInterfaceManager::teleport, 0, -1,
  240. ALT | KEY_W, -1, -1, false, &MissionInterfaceManager::toggleDebugWins, 0, -1,
  241. ALT | KEY_M, -1, -1, false, &MissionInterfaceManager::showMovers, 0, -1,
  242. ALT | KEY_C, -1, -1, false, &MissionInterfaceManager::cullPathAreas, 0, -1,
  243. ALT | KEY_Z, -1, -1, false, &MissionInterfaceManager::zeroHPrime, 0, -1,
  244. ALT | KEY_A, -1, -1, false, &MissionInterfaceManager::calcValidAreaTable, 0, -1,
  245. ALT | KEY_G, -1, -1, false, &MissionInterfaceManager::globalMapLog, 0, -1,
  246. ALT | KEY_B, -1, -1, false, &MissionInterfaceManager::brainDead, 0, -1,
  247. ALT | KEY_P, -1, -1, false, &MissionInterfaceManager::goalPlan, 0, -1,
  248. ALT | KEY_V, -1, -1, false, &MissionInterfaceManager::showVictim, 0, -1,
  249. ALT | CTRL | KEY_P, -1, -1, false, &MissionInterfaceManager::enemyGoalPlan, 0, -1,
  250. ALT | KEY_4, -1, -1, false, &MissionInterfaceManager::damageObject1, 0, -1,
  251. ALT | KEY_5, -1, -1, false, &MissionInterfaceManager::damageObject2, 0, -1,
  252. ALT | KEY_6, -1, -1, false, &MissionInterfaceManager::damageObject3, 0, -1,
  253. ALT | KEY_7, -1, -1, false, &MissionInterfaceManager::damageObject4, 0, -1,
  254. ALT | KEY_8, -1, -1, false, &MissionInterfaceManager::damageObject5, 0, -1,
  255. ALT | KEY_9, -1, -1, false, &MissionInterfaceManager::damageObject6, 0, -1,
  256. ALT | KEY_0, -1, -1, false, &MissionInterfaceManager::damageObject0, 0, -1,
  257. //ALT | KEY_8, -1, -1, false, &MissionInterfaceManager::damageObject8, 0, -1,
  258. //ALT | KEY_9, -1, -1, false, &MissionInterfaceManager::damageObject9, 0, -1,
  259. //ALT | KEY_0, -1, -1, false, &MissionInterfaceManager::damageObject0, 0, -1,
  260. KEY_H, -1, -1, true, &MissionInterfaceManager::toggleHoldPosition, 0, -1,
  261. KEY_RETURN, -1, -1, true, &MissionInterfaceManager::handleChatKey, 0, IDS_HOTKEY_CHAT,
  262. SHIFT | KEY_RETURN, -1, -1, true, &MissionInterfaceManager::handleTeamChatKey, 0, IDS_HOTKEY_CHAT_TEAM,
  263. KEY_E | SHIFT, -1, -1, false, &MissionInterfaceManager::addVisibleToSelection, 0, -1,
  264. KEY_EQUALS, -1, -1, false, &MissionInterfaceManager::zoomIn,0, -1,
  265. ALT | KEY_PERIOD, -1, -1, false, &MissionInterfaceManager::rotateObjectLeft, 0, -1,
  266. ALT | KEY_COMMA, -1, -1, false, &MissionInterfaceManager::rotateObjectRight, 0, -1,
  267. KEY_PAUSE, -1, -1, true, &MissionInterfaceManager::togglePause, 0, -1
  268. };
  269. extern bool drawTerrainGrid;
  270. extern long turn; //What frame of the scenario is it?
  271. extern char DebugStatusBarString[256];
  272. void MissionInterfaceManager::init (void)
  273. {
  274. realRotation = 0.0;
  275. dragStart.Zero();
  276. dragEnd.Zero();
  277. isDragging = FALSE;
  278. terrainLineChanged = 0;
  279. for (long i=0;i<MAX_TEAMS;i++)
  280. {
  281. vTol[i] = 0;
  282. paintingVtol[i] = 0;
  283. vTolTime[i] = 0.0f;
  284. dustCloud[i] = NULL;
  285. recoveryBeam[i] = NULL;
  286. mechRecovered[i] = false;
  287. mechToRecover[i] = 0;
  288. vehicleID[i] = 0;
  289. }
  290. bPaused = 0;
  291. bPausedWithoutMenu = 0;
  292. resolution = Environment.screenWidth;
  293. s_instance = this;
  294. bEnergyWeapons = 0;
  295. zoomChoice = 2;
  296. memset( oldTargets, 0, sizeof( GameObject*) * MAX_ICONS );
  297. bDrawHotKeys = 0;
  298. hotKeyFont.init( IDS_HOT_KEY_FONT );
  299. hotKeyHeaderFont.init( IDS_HOT_KEY_HEADER_FONT );
  300. lastUpdateDoubleClick = 0;
  301. keyboardRef = new KeyboardRef;
  302. animationRunning = false;
  303. timeLeftToScroll = 0.0f;
  304. targetButtonId = -1;
  305. buttonNumFlashes = 0;
  306. guiFrozen = false;
  307. reinforcement = NULL;
  308. bForcedShot = false;
  309. bAimedShot = false;
  310. }
  311. #define TACMAP_ID 0
  312. #define FLASH_JUMPERS 31798
  313. bool MissionInterfaceManager::startAnimation(long buttonId,bool isButton,bool isPressed,float timeToScroll,long numFlashes)
  314. {
  315. if (animationRunning)
  316. return false;
  317. else
  318. {
  319. animationRunning = true;
  320. timeLeftToScroll = timeToScroll;
  321. targetButtonId = buttonId;
  322. buttonNumFlashes = numFlashes;
  323. targetIsButton = isButton;
  324. targetIsPressed = isPressed;
  325. buttonFlashTime = 0.0f;
  326. if (buttonId < 0) //It means flash TacMap Objective using the ABS of this objective number
  327. {
  328. controlGui.animateTacMap(buttonId,timeToScroll,numFlashes);
  329. animationRunning = true;
  330. timeLeftToScroll = timeToScroll;
  331. targetButtonId = TACMAP_ID;
  332. buttonNumFlashes = numFlashes;
  333. targetIsButton = false;
  334. targetIsPressed = false;
  335. buttonFlashTime = 0.0f;
  336. }
  337. if (buttonId == RPTOTAL_CALLOUT) //RP total callout on Support Palette
  338. {
  339. controlGui.flashRPTotal(numFlashes);
  340. animationRunning = true;
  341. timeLeftToScroll = timeToScroll;
  342. targetButtonId = buttonId;
  343. buttonNumFlashes = numFlashes;
  344. targetIsButton = false;
  345. targetIsPressed = false;
  346. buttonFlashTime = 0.0f;
  347. }
  348. if (buttonId == FLASH_JUMPERS) //Just flash the mech Icons. Do not do anything else.
  349. {
  350. controlGui.forceGroupBar.flashJumpers(numFlashes);
  351. animationRunning = false;
  352. }
  353. }
  354. return true;
  355. }
  356. static char tutorialPlayerName[1024];
  357. void MissionInterfaceManager::setTutorialText(const char *text)
  358. {
  359. cLoadString(IDS_TUTORIAL,tutorialPlayerName,1023);
  360. controlGui.setChatText(tutorialPlayerName,text, 0x00ffffff, 0 );
  361. }
  362. void MissionInterfaceManager::update (void)
  363. {
  364. if ( Environment.screenWidth != resolution )
  365. {
  366. swapResolutions();
  367. }
  368. bForcedShot = false;
  369. bAimedShot = false;
  370. if (eye && eye->inMovieMode)
  371. {
  372. drawGUIOn = false;
  373. userInput->mouseOff();
  374. //Need to check for ESC key so user can end IMI IMMEDIATELY.
  375. // After that check, just return. Do NOT update any of the UI!!!!
  376. if (userInput->getKeyDown(KEY_ESCAPE))
  377. eye->forceMovieToEnd();
  378. controlGui.update(isPaused() && !isPausedWithoutMenu(), false );
  379. return;
  380. }
  381. else
  382. {
  383. drawGUIOn = toggledGUI;
  384. userInput->mouseOn();
  385. }
  386. if (animationRunning)
  387. {
  388. if (targetIsButton)
  389. {
  390. //Move mouse to correct position.
  391. ControlButton *targetButton = controlGui.getButton(targetButtonId);
  392. if (!targetButton)
  393. {
  394. animationRunning = false;
  395. return;
  396. }
  397. userInput->setMouseCursor(mState_TUTORIALS);
  398. //Get button position.
  399. float buttonPosX = (targetButton->location[0].x + targetButton->location[1].x +
  400. targetButton->location[2].x + targetButton->location[3].x) * 0.25f;
  401. float buttonPosY = (targetButton->location[0].y + targetButton->location[1].y +
  402. targetButton->location[2].y + targetButton->location[3].y) * 0.25f;
  403. //-------------------
  404. // Mouse Checks Next
  405. float realMouseX = userInput->realMouseX();
  406. float realMouseY = userInput->realMouseY();
  407. if (timeLeftToScroll > 0.0f)
  408. {
  409. float xDistLeft = buttonPosX - realMouseX;
  410. float yDistLeft = buttonPosY - realMouseY;
  411. float xDistThisFrame = xDistLeft / timeLeftToScroll * frameLength;
  412. float yDistThisFrame = yDistLeft / timeLeftToScroll * frameLength;
  413. userInput->setMousePos(realMouseX + xDistThisFrame, realMouseY+yDistThisFrame);
  414. timeLeftToScroll -= frameLength;
  415. }
  416. else
  417. {
  418. userInput->setMousePos(buttonPosX,buttonPosY);
  419. //We are there. Start flashing.
  420. if (buttonNumFlashes)
  421. {
  422. buttonFlashTime += frameLength;
  423. if ( buttonFlashTime > .5f )
  424. {
  425. controlGui.getButton( targetButtonId )->setColor( 0xffffffff );
  426. buttonFlashTime = 0.0f;
  427. buttonNumFlashes--;
  428. }
  429. else if ( buttonFlashTime > .25f )
  430. {
  431. controlGui.getButton( targetButtonId )->setColor( 0xff7f7f7f );
  432. }
  433. }
  434. else
  435. {
  436. //Flashing is done. We now return you to your regularly scheduled program.
  437. animationRunning = false;
  438. controlGui.getButton( targetButtonId )->setColor( 0xffffffff );
  439. if (targetIsPressed)
  440. controlGui.pushButton(targetButtonId);
  441. }
  442. }
  443. }
  444. else
  445. {
  446. ControlGui::RectInfo *targetButton = controlGui.getRect(targetButtonId);
  447. if (!targetButton)
  448. {
  449. animationRunning = false;
  450. }
  451. userInput->setMouseCursor(mState_TUTORIALS);
  452. //Get button position.
  453. float buttonPosX = (targetButton->rect.left + targetButton->rect.right) * 0.5f;
  454. float buttonPosY = (targetButton->rect.top + targetButton->rect.bottom) * 0.5f;
  455. //-------------------
  456. // Mouse Checks Next
  457. float realMouseX = userInput->realMouseX();
  458. float realMouseY = userInput->realMouseY();
  459. if (timeLeftToScroll > 0.0f)
  460. {
  461. float xDistLeft = buttonPosX - realMouseX;
  462. float yDistLeft = buttonPosY - realMouseY;
  463. float xDistThisFrame = xDistLeft / timeLeftToScroll * frameLength;
  464. float yDistThisFrame = yDistLeft / timeLeftToScroll * frameLength;
  465. userInput->setMousePos(realMouseX + xDistThisFrame, realMouseY+yDistThisFrame);
  466. timeLeftToScroll -= frameLength;
  467. }
  468. else
  469. {
  470. userInput->setMousePos(buttonPosX,buttonPosY);
  471. //We are there. Start flashing.
  472. if (buttonNumFlashes)
  473. {
  474. buttonFlashTime += frameLength;
  475. if ( buttonFlashTime > .5f )
  476. {
  477. targetButton->color = 0xff000000;
  478. buttonFlashTime = 0.0f;
  479. buttonNumFlashes--;
  480. }
  481. else if ( buttonFlashTime > .25f )
  482. {
  483. targetButton->color = 0xffffffff;
  484. }
  485. }
  486. else
  487. {
  488. //Flashing is done. We now return you to your regularly scheduled program.
  489. animationRunning = false;
  490. targetButton->color = 0xff000000;
  491. }
  492. }
  493. }
  494. return; //Don't let anything else in the GUI run!!
  495. }
  496. //Tutorial has locked out the gui. Move mouse to screen center and do nothing else!!
  497. if (guiFrozen)
  498. {
  499. userInput->setMouseCursor(mState_TUTORIALS);
  500. userInput->setMousePos(Environment.screenWidth * 0.5f,Environment.screenHeight * 0.5f);
  501. controlGui.update( isPaused() && !isPausedWithoutMenu(), false );
  502. return;
  503. }
  504. //---------------------------------------------------
  505. // Per Andy G. One check per frame saves log file!
  506. bool shiftDn = userInput->shift();
  507. bool altDn = userInput->alt();
  508. bool ctrlDn = userInput->ctrl();
  509. //Cheats
  510. // Comment out here if FINAL
  511. #ifndef FINAL
  512. #define MC2_DAMAGE_HEAD 0
  513. #define MC2_DAMAGE_LARM 1
  514. #define MC2_DAMAGE_RARM 2
  515. #define MC2_DAMAGE_LTORSO 3
  516. #define MC2_DAMAGE_RTORSO 4
  517. #define MC2_DAMAGE_CTORSO 5
  518. #define MC2_DAMAGE_LLEG 6
  519. #define MC2_DAMAGE_RLEG 7
  520. #define MC2_DAMAGE_RLTORSO 8
  521. #define MC2_DAMAGE_RRTORSO 9
  522. #define MC2_DAMAGE_RCTORSO 10
  523. DWORD CheatCommand = -1;
  524. if (userInput->getKeyDown(KEY_1) && shiftDn && ctrlDn && altDn)
  525. CheatCommand = MC2_DAMAGE_HEAD;
  526. if (userInput->getKeyDown(KEY_2) && shiftDn && ctrlDn && altDn)
  527. CheatCommand = MC2_DAMAGE_LARM;
  528. if (userInput->getKeyDown(KEY_3) && shiftDn && ctrlDn && altDn)
  529. CheatCommand = MC2_DAMAGE_RARM;
  530. if (userInput->getKeyDown(KEY_4) && shiftDn && ctrlDn && altDn)
  531. CheatCommand = MC2_DAMAGE_LTORSO;
  532. if (userInput->getKeyDown(KEY_5) && shiftDn && ctrlDn && altDn)
  533. CheatCommand = MC2_DAMAGE_RTORSO;
  534. if (userInput->getKeyDown(KEY_6) && shiftDn && ctrlDn && altDn)
  535. CheatCommand = MC2_DAMAGE_CTORSO;
  536. if (userInput->getKeyDown(KEY_7) && shiftDn && ctrlDn && altDn)
  537. CheatCommand = MC2_DAMAGE_LLEG;
  538. if (userInput->getKeyDown(KEY_8) && shiftDn && ctrlDn && altDn)
  539. CheatCommand = MC2_DAMAGE_RLEG;
  540. if (userInput->getKeyDown(KEY_9) && shiftDn && ctrlDn && altDn)
  541. CheatCommand = MC2_DAMAGE_RLTORSO;
  542. if (userInput->getKeyDown(KEY_0) && shiftDn && ctrlDn && altDn)
  543. CheatCommand = MC2_DAMAGE_RRTORSO;
  544. if (userInput->getKeyDown(KEY_MINUS) && shiftDn && ctrlDn && altDn)
  545. CheatCommand = MC2_DAMAGE_RCTORSO;
  546. WeaponShotInfo cheatHit;
  547. switch (CheatCommand)
  548. {
  549. case -1:
  550. break;
  551. case MC2_DAMAGE_HEAD:
  552. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_HEAD,0.0f);
  553. break;
  554. case MC2_DAMAGE_LARM:
  555. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_LARM,0.0f);
  556. break;
  557. case MC2_DAMAGE_RARM:
  558. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RARM,0.0f);
  559. break;
  560. case MC2_DAMAGE_LTORSO:
  561. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_LTORSO,0.0f);
  562. break;
  563. case MC2_DAMAGE_RTORSO:
  564. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RTORSO,0.0f);
  565. break;
  566. case MC2_DAMAGE_CTORSO:
  567. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_CTORSO,0.0f);
  568. break;
  569. case MC2_DAMAGE_LLEG:
  570. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_LLEG,0.0f);
  571. break;
  572. case MC2_DAMAGE_RLEG:
  573. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RLEG,0.0f);
  574. break;
  575. case MC2_DAMAGE_RLTORSO:
  576. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RLTORSO,0.0f);
  577. break;
  578. case MC2_DAMAGE_RRTORSO:
  579. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RRTORSO,0.0f);
  580. break;
  581. case MC2_DAMAGE_RCTORSO:
  582. cheatHit.init(0,-2,CheatHitDamage,MECH_ARMOR_LOCATION_RCTORSO,0.0f);
  583. break;
  584. }
  585. //Call handleWeaponHit for each selected Mech!
  586. if (CheatCommand != -1)
  587. {
  588. Team* pTeam = Team::home;
  589. for (long i = 0; i < pTeam->getRosterSize(); i++)
  590. {
  591. Mover* pMover = (Mover*)pTeam->getMover( i );
  592. if ( pMover->isSelected() && pMover->isMech())
  593. {
  594. pMover->handleWeaponHit(&cheatHit);
  595. }
  596. }
  597. }
  598. #endif
  599. if ( bDrawHotKeys )
  600. {
  601. keyboardRef->update();
  602. return;
  603. }
  604. //-------------------
  605. // Mouse Checks Next
  606. mouseX = userInput->getMouseX();
  607. mouseY = userInput->getMouseY();
  608. bool bGui = false;
  609. // check and see if its in the control area
  610. if ( controlGui.inRegion( mouseX, mouseY, isPaused() && !isPausedWithoutMenu() ) )
  611. {
  612. bGui = true;
  613. if ( userInput->isLeftClick() && !userInput->isLeftDrag() )
  614. {
  615. dragStart.x = 0.f;
  616. dragStart.y = 0.f;
  617. }
  618. }
  619. else
  620. {
  621. helpTextHeaderID = helpTextID = 0;
  622. }
  623. if (bGui)
  624. userInput->setMouseCursor( mState_NORMAL );
  625. // find out where the mouse is
  626. Stuff::Vector2DOf<long> mouseXY;
  627. mouseXY.x = mouseX;
  628. mouseXY.y = mouseY;
  629. eye->inverseProject(mouseXY, wPos);
  630. // find out if this position is passable, has line of sight
  631. long cellR, cellC;
  632. bool passable = 1;
  633. bool lineOfSight = 0;
  634. if ( Terrain::IsGameSelectTerrainPosition( wPos ) )
  635. {
  636. land->worldToCell(wPos, cellR, cellC);
  637. if (Team::home) //May go NULL during multiplayer when a player first dies?
  638. lineOfSight = Team::home->teamLineOfSight(wPos,0.0f);
  639. }
  640. // update buttons and stuff, even if not in region, it draws objectives and stuff
  641. controlGui.update( isPaused() && !isPausedWithoutMenu(), lineOfSight );
  642. bool leftClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isLeftClick());
  643. bool rightClicked = (!userInput->isLeftDrag() && !userInput->wasRightDrag() && userInput->rightMouseReleased());
  644. bool bLeftDouble = userInput->isLeftDoubleClick();
  645. updateTarget(bGui);
  646. //------------------------------------
  647. // Attila (Strategic Commander) Next
  648. attilaXAxis = userInput->getAttilaXAxis();
  649. attilaYAxis = userInput->getAttilaYAxis();
  650. attilaRZAxis = userInput->getAttilaRAxis();
  651. //-------------------------------
  652. // Update the Debug Status Bar...
  653. long row, col;
  654. land->worldToCell(wPos, row, col);
  655. sprintf(DebugStatusBarString, "TIME: %06d, MOUSE: [%d, %d] %d,%d,%d (%.2f, %.2f, %.2f), PATHMGR: %02d(%02d)",
  656. (long)scenarioTime,
  657. row, col,
  658. GlobalMoveMap[0]->calcArea(row, col),
  659. GlobalMoveMap[1]->calcArea(row, col),
  660. GlobalMoveMap[2]->calcArea(row, col),
  661. wPos.x, wPos.y, wPos.z,
  662. PathManager->numPaths, PathManager->peakPaths);
  663. if (MPlayer) {
  664. char mpStr[256];
  665. if (MPlayer->isServer())
  666. sprintf(mpStr, ", MULTIPLAY: %s-(%d)SERVER {%d,%d}", MPlayer->getPlayerName(), MPlayer->commanderID, MPlayer->maxReceiveLoad, MPlayer->maxReceiveSize);
  667. else
  668. sprintf(mpStr, ", MULTIPLAY: %s-(%d)CLIENT {%d,%d}", MPlayer->getPlayerName(), MPlayer->commanderID, MPlayer->maxReceiveLoad, MPlayer->maxReceiveSize);
  669. strcat(DebugStatusBarString, mpStr);
  670. }
  671. if (EnemiesGoalPlan)
  672. strcat(DebugStatusBarString, " [ENEMIES GOALPLAN]");
  673. if (ShowMovers)
  674. strcat(DebugStatusBarString, " [SHOW MOVERS]");
  675. if (CullPathAreas)
  676. strcat(DebugStatusBarString, " [CULL PATH AREAS]");
  677. if (ZeroHPrime)
  678. strcat(DebugStatusBarString, " [ZERO HPRIME]");
  679. if (CalcValidAreaTable)
  680. strcat(DebugStatusBarString, " [CALC VALID AREA]");
  681. if (GlobalMap::logEnabled)
  682. strcat(DebugStatusBarString, " [GLOBAL LOG]");
  683. if (!MechWarrior::brainsEnabled[1])
  684. strcat(DebugStatusBarString, " [BRAINDEAD: 1]");
  685. if ( bLeftDouble && target && target->isMover() && target->getTeam() == Team::home )
  686. {
  687. int forceGroup = -1;
  688. for ( int i = 0; i < 10; i++ )
  689. {
  690. if ( ((Mover*)target)->isInUnitGroup( i ) )
  691. {
  692. forceGroup = i;
  693. break;
  694. }
  695. }
  696. if ( forceGroup != -1 )
  697. selectForceGroup( forceGroup, true );
  698. lastUpdateDoubleClick = true;
  699. }
  700. Team* pTeam = Team::home;
  701. int moverCount = 0;
  702. int nonMoverCount = 0;
  703. for (long i=0;i<pTeam->getRosterSize();i++)
  704. {
  705. Mover* pMover = (Mover*)pTeam->getMover( i );
  706. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  707. {
  708. if ( pMover->maxMoveSpeed )
  709. {
  710. passable &= pMover->canMoveHere( wPos );
  711. moverCount++;
  712. }
  713. else
  714. nonMoverCount++;
  715. }
  716. }
  717. if( useLeftRightMouseProfile ) // using AOE control style
  718. {
  719. if ( WAYPOINT_KEY == -1 )
  720. WAYPOINT_KEY = KEY_LCONTROL;
  721. commandClicked = rightClicked;
  722. selectClicked = !bLeftDouble && !lastUpdateDoubleClick && userInput->leftMouseReleased() && !userInput->getKeyDown( KEY_T) && !isDragging;
  723. cameraClicked = gos_GetKeyStatus( KEY_LMENU ) == KEY_HELD;
  724. if ( moveCameraAround( lineOfSight, passable, ctrlDn, bGui, moverCount, nonMoverCount ) )
  725. {
  726. bool leftClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isLeftClick());
  727. bool rightClicked = (!userInput->isLeftDrag() && !userInput->wasRightDrag() && userInput->rightMouseReleased());
  728. // deal with the hot keys
  729. update( leftClicked, rightClicked, mouseX, mouseY, target, lineOfSight );
  730. return;
  731. }
  732. updateAOEStyle(shiftDn, altDn, ctrlDn, bGui, lineOfSight, passable, moverCount, nonMoverCount);
  733. }
  734. else // using mc1 style
  735. {
  736. commandClicked = leftClicked;
  737. selectClicked = leftClicked && !lastUpdateDoubleClick;
  738. cameraClicked = userInput->isRightDrag();
  739. if ( WAYPOINT_KEY == -1 )
  740. WAYPOINT_KEY = KEY_LCONTROL;
  741. if ( moveCameraAround( lineOfSight, passable, ctrlDn, bGui, moverCount, nonMoverCount ) )
  742. {
  743. bool leftClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isLeftClick());
  744. bool rightClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isRightClick());
  745. // deal with the hot keys
  746. update( leftClicked, rightClicked, mouseX, mouseY, target, lineOfSight );
  747. return;
  748. }
  749. updateOldStyle(shiftDn, altDn, ctrlDn, bGui, lineOfSight, passable, moverCount, nonMoverCount);
  750. }
  751. for ( i = 0; i < Team::home->getRosterSize(); i++ )
  752. {
  753. Mover* pMover = (Mover*)Team::home->getMover( i );
  754. MechWarrior* pilot = pMover->getPilot();
  755. if ( pilot && pMover->getCommander()->getId() == Commander::home->getId())
  756. {
  757. GameObject* pTmpTarget = pilot->getCurrentTarget( );
  758. if ( pTmpTarget && (i < MAX_ICONS)) //Must check this because old test maps have more then 16 movers on them!!
  759. {
  760. pTmpTarget->setDrawBars(true);
  761. oldTargets[i] = pTmpTarget;
  762. }
  763. }
  764. }
  765. if ( !bLeftDouble && !( lastUpdateDoubleClick &&
  766. userInput->getMouseLeftButtonState() == MC2_MOUSE_DOWN ) )// check for the hold )
  767. lastUpdateDoubleClick = false;
  768. updateRollovers();
  769. }
  770. void MissionInterfaceManager::updateVTol()
  771. {
  772. //We're probably going to use this alot!
  773. long commanderID = Commander::home->getId();
  774. paintingMyVtol = paintingVtol[commanderID];
  775. for (long vtolNum = 0;vtolNum < MAX_TEAMS; vtolNum++)
  776. {
  777. // update the vtol, if it needs it
  778. if ( paintingVtol[vtolNum] && (!bPaused || MPlayer))
  779. {
  780. if (vehicleID[vtolNum] != 147) //We are the standard vtol.
  781. {
  782. if (!vehicleDropped[vtolNum] && (vTol[vtolNum]->currentFrame >= 145))
  783. {
  784. vehicleDropped[vtolNum] = true;
  785. soundSystem->playDigitalSample(VTOL_DROP,vPos[vtolNum]);
  786. //OK, if this is another persons vtol, I probably shouldn't do this
  787. // Glenn, what should it do?
  788. // Just check my commanderID against the vtolNum and if they match do it?
  789. // Otherwise do nothing?
  790. // Help Me, Spock!
  791. // -fs
  792. if (MPlayer)
  793. {
  794. if (commanderID == vtolNum)
  795. {
  796. //--------------------------------------------------------
  797. // This will get the other machines to enable the mover...
  798. MPlayer->sendReinforcement(vehicleID[vtolNum], MPlayer->reinforcements[commanderID][0], "noname", commanderID, vPos[vtolNum], 2);
  799. }
  800. }
  801. else
  802. addVehicle( vPos[vtolNum] );
  803. }
  804. else if (vTol[vtolNum]->currentFrame >= 300)
  805. {
  806. paintingVtol[vtolNum] = 0;
  807. delete vTol[vtolNum];
  808. vTol[vtolNum] = NULL;
  809. if (dustCloud[vtolNum])
  810. {
  811. dustCloud[vtolNum]->Kill();
  812. delete dustCloud[vtolNum];
  813. dustCloud[vtolNum] = NULL;
  814. }
  815. if (recoveryBeam[vtolNum])
  816. {
  817. recoveryBeam[vtolNum]->Kill();
  818. delete recoveryBeam[vtolNum];
  819. recoveryBeam[vtolNum] = NULL;
  820. }
  821. //We should have set this when the helo was brought in.
  822. // Let it takeoff now that the vtol is out of the way.
  823. if (MPlayer) {
  824. if ((vtolNum < 0) || (vtolNum >= MAX_MC_PLAYERS))
  825. STOP(("updateVTOL: bad vtolNum"));
  826. if (MPlayer->reinforcements[vtolNum][0] < 0)
  827. STOP(("updateVTOL: bad reinforcement"));
  828. MoverPtr mover = MPlayer->moverRoster[MPlayer->reinforcements[vtolNum][0]];
  829. if (mover) {
  830. TacticalOrder tacOrder;
  831. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_POWERUP, true);
  832. tacOrder.pack(NULL, NULL);
  833. if (!MPlayer->isServer())
  834. MPlayer->sendPlayerOrder(&tacOrder, false, 1, &mover);
  835. else
  836. mover->handleTacticalOrder(tacOrder);
  837. }
  838. MPlayer->reinforcements[vtolNum][0] = -1;
  839. }
  840. else if (reinforcement)
  841. {
  842. reinforcement->getPilot()->orderPowerUp(true, ORDER_ORIGIN_SELF);
  843. reinforcement = NULL;
  844. }
  845. if ( !MPlayer || vtolNum == MPlayer->commanderID )
  846. controlGui.unPressAllVehicleButtons();
  847. }
  848. }
  849. else //Update the KARNOV animation
  850. {
  851. if ((vTol[vtolNum]->getCurrentGestureId() == 1) && !vTol[vtolNum]->getInTransition())
  852. {
  853. vTol[vtolNum]->setGesture(0);
  854. //Needs to STAY false, probably in MPlayer too because
  855. // If the mech we are about to recover gets destroyed, we need to abort!!
  856. // Probably in Multiplayer now its possible to recover even if destroyed!
  857. if (!MPlayer)
  858. mechRecovered[vtolNum] = false; //Need to know when mech is done so Karnov can fly away.
  859. vTolTime[vtolNum] = scenarioTime;
  860. //Start GOsFX - We are now hovering.
  861. if (recoveryBeam[vtolNum])
  862. {
  863. Stuff::LinearMatrix4D shapeOrigin;
  864. Stuff::LinearMatrix4D localToWorld;
  865. Stuff::LinearMatrix4D localResult;
  866. Stuff::Vector3D dustPos = vTol[vtolNum]->position;
  867. Stuff::Point3D wakePos;
  868. wakePos.x = -dustPos.x;
  869. wakePos.y = dustPos.z;
  870. wakePos.z = dustPos.y;
  871. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  872. shapeOrigin.BuildTranslation(wakePos);
  873. gosFX::Effect::ExecuteInfo info((Stuff::Time)scenarioTime,&shapeOrigin,NULL);
  874. recoveryBeam[vtolNum]->SetLoopOff();
  875. recoveryBeam[vtolNum]->SetExecuteOn();
  876. recoveryBeam[vtolNum]->Start(&info);
  877. }
  878. //Actually the Karnov Deploy Sound Effect!
  879. soundSystem->playDigitalSample(RADAR_HUM,vTol[vtolNum]->position,false);
  880. }
  881. else if ((vTol[vtolNum]->getCurrentGestureId() == 0) && !mechRecovered[vtolNum] && mechToRecover[vtolNum] && !mechToRecover[vtolNum]->isDestroyed())
  882. {
  883. if (scenarioTime > vTolTime[vtolNum] + Mover::recoverTime)
  884. {
  885. bool doIt = true;
  886. if (MPlayer)
  887. {
  888. if (commanderID == vtolNum)
  889. {
  890. //--------------------------------------------------------
  891. // This will get the other machines to enable the mover...
  892. MPlayer->sendReinforcement(vehicleID[vtolNum], MPlayer->reinforcements[vtolNum][1], MPlayer->reinforcementPilot[vtolNum], vtolNum, vPos[vtolNum], 5);
  893. }
  894. else
  895. doIt = false;
  896. }
  897. if (doIt && !mechToRecover[vtolNum]->isDestroyed())
  898. {
  899. //Seems like we don't want to do this on every machine, do we?
  900. // -fs
  901. //STAY in recover until its done. I know it shouldn't be possible but trust me, its happening.
  902. while (((MoverPtr)mechToRecover[vtolNum])->recover() == false)
  903. ;
  904. if (mechToRecover[vtolNum]->isDisabled())
  905. {
  906. mechToRecover[vtolNum]->setStatus(OBJECT_STATUS_SHUTDOWN,true);
  907. mechToRecover[vtolNum]->getSensorSystem()->broken = false;
  908. ((MoverPtr)mechToRecover[vtolNum])->timeLeft = 1.0f;
  909. ((MoverPtr)mechToRecover[vtolNum])->exploding = false;
  910. }
  911. char* newPilotName = NULL;
  912. if (MPlayer)
  913. newPilotName = MPlayer->reinforcementPilot[vtolNum];
  914. else
  915. newPilotName = (char*)LogisticsData::instance->getBestPilot( mechToRecover[vtolNum]->tonnage );
  916. mission->tradeMover(mechToRecover[vtolNum], Commander::commanders[vtolNum]->getTeam()->getId(), vtolNum, newPilotName, "pbrain");
  917. mechRecovered[vtolNum] = true;
  918. mechToRecover[vtolNum]->getPilot()->orderPowerUp(true, ORDER_ORIGIN_SELF);
  919. if (MPlayer)
  920. MPlayer->reinforcements[vtolNum][1] = -1;
  921. }
  922. }
  923. }
  924. else if ((vTol[vtolNum]->getCurrentGestureId() == 0) && (mechRecovered[vtolNum] || mechToRecover[vtolNum]->isDestroyed()) && (!vTol[vtolNum]->getInTransition()))
  925. {
  926. vTol[vtolNum]->setGesture(2); //Fly Away!!
  927. }
  928. else if ((vTol[vtolNum]->getCurrentGestureId() == 2) && (!vTol[vtolNum]->getInTransition()))
  929. {
  930. paintingVtol[vtolNum] = 0;
  931. delete vTol[vtolNum];
  932. vTol[vtolNum] = NULL;
  933. if (dustCloud[vtolNum])
  934. {
  935. dustCloud[vtolNum]->Kill();
  936. delete dustCloud[vtolNum];
  937. dustCloud[vtolNum] = NULL;
  938. }
  939. if (recoveryBeam[vtolNum])
  940. {
  941. recoveryBeam[vtolNum]->Kill();
  942. delete recoveryBeam[vtolNum];
  943. recoveryBeam[vtolNum] = NULL;
  944. }
  945. //Check if mech was recovered. If not, restore the resource points!!!
  946. // This can happen if we call in a recovery vehicle and the mech is destroyed
  947. // BEFORE the recovery vehicle recovers it!!
  948. if (!mechRecovered[vtolNum]) {
  949. if (MPlayer) {
  950. if (MPlayer->isServer()) {
  951. //MPlayer->playerInfo[vtolNum].resourcePoints += 10000;
  952. Stuff::Vector3D pos;
  953. MPlayer->sendReinforcement(10000, 0, "noname", vtolNum, pos, 6);
  954. }
  955. }
  956. else
  957. LogisticsData::instance->setResourcePoints(LogisticsData::instance->getResourcePoints() + 10000);
  958. }
  959. if ( !MPlayer || vtolNum == MPlayer->commanderID )
  960. controlGui.unPressAllVehicleButtons();
  961. }
  962. }
  963. if (dustCloud[vtolNum] && dustCloud[vtolNum]->IsExecuted())
  964. {
  965. Stuff::LinearMatrix4D shapeOrigin;
  966. Stuff::LinearMatrix4D localToWorld;
  967. Stuff::LinearMatrix4D localResult;
  968. Stuff::Vector3D dustPos = vTol[vtolNum]->position;
  969. Stuff::Point3D wakePos;
  970. wakePos.x = -dustPos.x;
  971. wakePos.y = dustPos.z;
  972. wakePos.z = dustPos.y;
  973. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  974. shapeOrigin.BuildTranslation(wakePos);
  975. Stuff::OBB boundingBox;
  976. gosFX::Effect::ExecuteInfo info((Stuff::Time)scenarioTime,&shapeOrigin,&boundingBox);
  977. dustCloud[vtolNum]->Execute(&info);
  978. }
  979. if (recoveryBeam[vtolNum] && recoveryBeam[vtolNum]->IsExecuted())
  980. {
  981. Stuff::LinearMatrix4D shapeOrigin;
  982. Stuff::LinearMatrix4D localToWorld;
  983. Stuff::LinearMatrix4D localResult;
  984. Stuff::Vector3D dustPos = vTol[vtolNum]->position;
  985. Stuff::Point3D wakePos;
  986. wakePos.x = -dustPos.x;
  987. wakePos.y = dustPos.z;
  988. wakePos.z = dustPos.y;
  989. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  990. shapeOrigin.BuildTranslation(wakePos);
  991. Stuff::OBB boundingBox;
  992. gosFX::Effect::ExecuteInfo info((Stuff::Time)scenarioTime,&shapeOrigin,&boundingBox);
  993. recoveryBeam[vtolNum]->Execute(&info);
  994. }
  995. if (vTol[vtolNum]) //Might have been deleted above!!
  996. {
  997. vTol[vtolNum]->recalcBounds();
  998. vTol[vtolNum]->update(); //Must update even if not on screen!
  999. }
  1000. }
  1001. else if (paintingVtol[vtolNum] && bPaused)
  1002. {
  1003. if (vTol[vtolNum]) //Might have been deleted above!!
  1004. {
  1005. long cFrame = vTol[vtolNum]->currentFrame;
  1006. vTol[vtolNum]->recalcBounds();
  1007. vTol[vtolNum]->update(); //Must update even if not on screen!
  1008. //If we are paused, do not animate.
  1009. vTol[vtolNum]->currentFrame = cFrame;
  1010. }
  1011. }
  1012. }
  1013. }
  1014. void MissionInterfaceManager::updateTarget( bool bGui)
  1015. {
  1016. // unset anything that isn't targeted
  1017. for ( int i = 0; i < MAX_ICONS; i++ )
  1018. {
  1019. if ( oldTargets[i] )
  1020. {
  1021. oldTargets[i]->setDrawBars( 0 );
  1022. oldTargets[i] = 0;
  1023. }
  1024. }
  1025. // if there was a target, unset it
  1026. if ( target )
  1027. target->setTargeted( 0 );
  1028. //----------------------------------------------------------------------------------------
  1029. // Get Any object we are over. Change cursor if appropriate. Set selected if necessary.
  1030. // Clear the target pointer if we have done all we need to do here. Otherwise, leave it
  1031. // set and issue an order below based on who is in the myForce pointers.
  1032. target = ObjectManager->findObjectByMouse(mouseX, mouseY);
  1033. if ( target )
  1034. {
  1035. if ( bGui )
  1036. target = 0;
  1037. else if ( target->isMover() && !ShowMovers && !(MPlayer && MPlayer->allUnitsDestroyed[MPlayer->commanderID]))
  1038. {
  1039. if ((target->getTeamId() != Team::home->getId()) &&
  1040. !target->isDisabled() &&
  1041. (((Mover *)target)->conStat < CONTACT_SENSOR_QUALITY_1))
  1042. target = NULL;
  1043. }
  1044. if ( target )
  1045. {
  1046. int descID = target->getDescription();
  1047. if ( descID != -1 )
  1048. {
  1049. int nameID = target->getAppearance()->getObjectNameId();
  1050. helpTextHeaderID = nameID;
  1051. helpTextID = descID;
  1052. }
  1053. if ( target->isDestroyed() )
  1054. {
  1055. target = 0;
  1056. }
  1057. else if ( target->isDisabled() && !target->isMover() )
  1058. target = 0;
  1059. else if ( !target->isSelectable())
  1060. {
  1061. if ( !target->isDisabled() && !target->isMover() )
  1062. target = NULL;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. void MissionInterfaceManager::drawWayPointPaths()
  1068. {
  1069. Team* pTeam = Team::home;
  1070. for (long i=0;i<pTeam->getRosterSize();i++)
  1071. {
  1072. Mover* pMover = (Mover*)pTeam->getMover( i );
  1073. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  1074. {
  1075. pMover->updateDrawWaypointPath();
  1076. }
  1077. }
  1078. }
  1079. void MissionInterfaceManager::updateOldStyle( bool shiftDn, bool altDn, bool ctrlDn,
  1080. bool bGui, bool lineOfSight, bool passable,
  1081. long moverCount, long nonMoverCount )
  1082. {
  1083. printDebugInfo();
  1084. //We're probably going to use this alot!
  1085. long commanderID = Commander::home->getId();
  1086. // Update the waypoint markers so that they are visible!
  1087. if ( userInput->getKeyDown( WAYPOINT_KEY ) || controlGui.getMines() )
  1088. {
  1089. drawWayPointPaths();
  1090. //Can Never make a patrol path. Causes movement wubbies!
  1091. // if ( makePatrolPath() )
  1092. // return;
  1093. }
  1094. int mState = userInput->getMouseCursor();
  1095. bool leftClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isLeftClick() && !lastUpdateDoubleClick);
  1096. bool rightClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isRightClick());
  1097. // deal with the hot keys
  1098. if ( update( leftClicked, rightClicked, mouseX, mouseY, target, lineOfSight ) )
  1099. return;
  1100. // special case for bottom of screen
  1101. if ( bGui ) // don't target or anything if we are int the control panel
  1102. {
  1103. // now check the selection versus the commands
  1104. if ( !canJump() && controlGui.getJump() )
  1105. controlGui.toggleJump();
  1106. userInput->setMouseCursor( mState );
  1107. if ( controlGui.mouseInVehicleStopButton )
  1108. return;
  1109. if ( !userInput->isLeftDrag() && !controlGui.isAddingAirstrike() && !controlGui.isAddingVehicle() )
  1110. return;
  1111. }
  1112. Team* pTeam = Team::home;
  1113. if (target) // if there is a target, make the appropritate cursor
  1114. {
  1115. userInput->setMouseCursor( makeTargetCursor( lineOfSight, moverCount, nonMoverCount ) );
  1116. }
  1117. else // make a move cursor
  1118. {
  1119. userInput->setMouseCursor( makeNoTargetCursor( passable, lineOfSight, ctrlDn, bGui, moverCount, nonMoverCount ) );
  1120. }
  1121. if ( userInput->leftMouseReleased() && !userInput->wasLeftDrag() && !bGui && !lastUpdateDoubleClick) // move on the mouse ups
  1122. {
  1123. if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && canAddVehicle( wPos )) ||
  1124. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && canRecover( wPos )))
  1125. {
  1126. // Target has already been confirmed as a mover(BattleMech) by canRecover
  1127. // OR it doesn't matter because the canAddVehicle part of the beginVtol function doesn't reference it!
  1128. // Again, Its OK because we only use it for salvage craft.
  1129. // Need to pass this in so that Multiplayer can pass it in.
  1130. beginVtol(-1,commanderID,NULL,(MoverPtr)target); //In Single player, this should always be zero?
  1131. return;
  1132. }
  1133. else if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && !canAddVehicle( wPos )) ||
  1134. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && !canRecover( wPos )))
  1135. {
  1136. soundSystem->playDigitalSample( INVALID_GUI );
  1137. return;
  1138. }
  1139. else if ( controlGui.isAddingAirstrike() && !paintingVtol[commanderID] ) // if we're painting the vtol, carry on
  1140. {
  1141. addAirstrike();
  1142. return;
  1143. }
  1144. else if (!target)
  1145. {
  1146. if ( controlGui.isSelectingInfoObject() )
  1147. {
  1148. soundSystem->playDigitalSample( INVALID_GUI );
  1149. controlGui.cancelInfo();
  1150. }
  1151. else if (Terrain::IsGameSelectTerrainPosition(wPos))
  1152. {
  1153. if (controlGui.getGuardTower())
  1154. doGuardTower();
  1155. else if ( passable || selectionIsHelicopters())
  1156. {
  1157. if ( controlGui.getGuard() )
  1158. {
  1159. doGuard(target);
  1160. }
  1161. else if (!bForcedShot)
  1162. doMove( wPos );
  1163. }
  1164. else
  1165. {
  1166. userInput->setMouseCursor(mState_DONT);
  1167. }
  1168. }
  1169. else
  1170. {
  1171. userInput->setMouseCursor(mState_DONT);
  1172. }
  1173. }
  1174. else
  1175. //We clicked on a target. If mouse cursor is normal, we want to select a friendly.
  1176. //if the mouse cursor is some form of attack, attack the target.
  1177. {
  1178. if ( target->isMover() && ( target->getTeamId() == Team::home->getId() ||
  1179. CONTACT_VISUAL == ((Mover*)target)->getContactStatus(Team::home->getId(), true)
  1180. || target->isDisabled() ) )
  1181. {
  1182. controlGui.setInfoWndMover( (Mover*)target );
  1183. }
  1184. if ( controlGui.getSalvage() )
  1185. doSalvage();
  1186. else if ( controlGui.getGuard() )
  1187. {
  1188. doGuard(target);
  1189. }
  1190. else if ( target->getTeamId() == Team::home->getId() && !target->isDisabled() )
  1191. {
  1192. //--------------------------------------------------------------------
  1193. // User wants to select the guy we are on. If he did
  1194. // it with a shift, add him. If not, whack all and just add target!
  1195. if (shiftDn && target->getCommanderId() == Commander::home->getId() )
  1196. {
  1197. bool alreadyThere = false;
  1198. //-------------------------------------------
  1199. // First, check if he's already there!
  1200. for (long i=0;i<pTeam->getRosterSize();i++)
  1201. {
  1202. Mover* pMover = (Mover*)pTeam->getMover( i );
  1203. if (pMover == target && pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId())
  1204. alreadyThere = true;
  1205. }
  1206. if (!alreadyThere && !target->isDisabled())
  1207. target->setSelected( true );
  1208. else
  1209. target->setSelected( false );
  1210. }
  1211. else if ( controlGui.getRepair() && canRepair( target ) )
  1212. {
  1213. doRepair(target);
  1214. }
  1215. else if ( controlGui.getSalvage() && canSalvage( target ))
  1216. doSalvage();
  1217. else if ( controlGui.getGuardTower() )
  1218. doGuardTower();
  1219. else if ( target->getTeam() && Team::home->isFriendly(target->getTeam()) && target->getFlag(OBJECT_FLAG_CANREFIT) && target->getFlag(OBJECT_FLAG_MECHBAY) && canRepairBay(target) )
  1220. doRepairBay(target);
  1221. else if ( controlGui.isSelectingInfoObject() && target->isMover() )
  1222. controlGui.setInfoWndMover( (Mover*)target );
  1223. else if ( target->isMover() && !target->isDisabled() && target->getCommanderId() == Commander::home->getId() )
  1224. {
  1225. for (long i=0;i<pTeam->getRosterSize();i++)
  1226. {
  1227. Mover* pMover = (Mover*)pTeam->getMover( i );
  1228. if (pMover->getCommander()->getId() == Commander::home->getId())
  1229. {
  1230. pMover->setSelected( false );
  1231. }
  1232. }
  1233. target->setSelected( true );
  1234. }
  1235. else
  1236. soundSystem->playDigitalSample( INVALID_GUI );
  1237. }
  1238. else
  1239. {
  1240. if ( controlGui.getGuard() ) // trying to guard invalid thing, cancel guard
  1241. controlGui.toggleGuard();
  1242. else if ( userInput->getMouseCursor() == mState_INFO &&
  1243. target->isMover() )
  1244. controlGui.setInfoWndMover( (Mover*)target );
  1245. else if ( !target->isDisabled() && !bForcedShot && !bAimedShot)
  1246. doAttack();
  1247. }
  1248. }
  1249. }
  1250. }
  1251. void MissionInterfaceManager::updateAOEStyle(bool shiftDn, bool altDn, bool ctrlDn,
  1252. bool bGui, bool lineOfSight, bool passable,
  1253. long moverCount, long nonMoverCount )
  1254. {
  1255. printDebugInfo();
  1256. //We're probably going to use this alot!
  1257. long commanderID = Commander::home->getId();
  1258. // Update the waypoint markers so that they are visible!
  1259. if ( userInput->getKeyDown( WAYPOINT_KEY ) || controlGui.getMines() )
  1260. {
  1261. drawWayPointPaths();
  1262. //Can Never make a patrol path. Causes movement wubbies!
  1263. // if ( makePatrolPath() )
  1264. // return;
  1265. }
  1266. int mState = userInput->getMouseCursor();
  1267. bool leftClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isLeftClick());
  1268. bool rightClicked = (!userInput->isLeftDrag() && !userInput->wasRightDrag() && userInput->rightMouseReleased());
  1269. // deal with the hot keys
  1270. if ( update( leftClicked, rightClicked, mouseX, mouseY, target, lineOfSight ) )
  1271. return;
  1272. // special case for bottom of screen
  1273. if ( bGui ) // don't target or anything if we are int the control panel
  1274. {
  1275. // now check the selection versus the commands
  1276. if ( !canJump() && controlGui.getJump() )
  1277. controlGui.toggleJump();
  1278. userInput->setMouseCursor( mState );
  1279. if ( controlGui.mouseInVehicleStopButton )
  1280. return;
  1281. if ( !userInput->isLeftDrag() && !controlGui.isAddingAirstrike() && !controlGui.isAddingVehicle() && !controlGui.isAddingSalvage() )
  1282. return;
  1283. }
  1284. Team* pTeam = Team::home;
  1285. if (target) // if there is a target, make the appropritate cursor
  1286. {
  1287. userInput->setMouseCursor( makeTargetCursor( lineOfSight, moverCount, nonMoverCount ) );
  1288. }
  1289. else // make a move cursor
  1290. {
  1291. userInput->setMouseCursor( makeNoTargetCursor( passable, lineOfSight, ctrlDn, bGui, moverCount, nonMoverCount ) );
  1292. }
  1293. if ( userInput->rightMouseReleased() && !userInput->wasRightDrag() && !bGui) // move on the mouse ups
  1294. {
  1295. if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && canAddVehicle( wPos )) ||
  1296. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && canRecover( wPos )))
  1297. {
  1298. // Target has already been confirmed as a mover(BattleMech) by canRecover
  1299. // OR it doesn't matter because the canAddVehicle part of the beginVtol function doesn't reference it!
  1300. // Again, Its OK because we only use it for salvage craft.
  1301. // Need to pass this in so that Multiplayer can pass it in.
  1302. beginVtol(-1,commanderID,NULL,(MoverPtr)target); //In Single player, this should always be zero?
  1303. return;
  1304. }
  1305. else if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && !canAddVehicle( wPos )) ||
  1306. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && !canRecover( wPos )))
  1307. {
  1308. soundSystem->playDigitalSample( INVALID_GUI );
  1309. return;
  1310. }
  1311. else if ( controlGui.isAddingAirstrike() && !paintingVtol[commanderID] ) // if we're painting the vtol, carry on
  1312. {
  1313. addAirstrike();
  1314. return;
  1315. }
  1316. else if (!target )
  1317. {
  1318. if ( controlGui.isSelectingInfoObject() )
  1319. {
  1320. soundSystem->playDigitalSample( INVALID_GUI );
  1321. controlGui.cancelInfo();
  1322. }
  1323. else if (Terrain::IsGameSelectTerrainPosition(wPos))
  1324. {
  1325. if ( passable || selectionIsHelicopters() )
  1326. {
  1327. if (controlGui.getGuardTower())
  1328. doGuardTower();
  1329. else if ( controlGui.getGuard() )
  1330. {
  1331. doGuard(NULL);
  1332. }
  1333. else
  1334. doMove( wPos );
  1335. }
  1336. else
  1337. {
  1338. userInput->setMouseCursor(mState_DONT);
  1339. }
  1340. }
  1341. else
  1342. {
  1343. userInput->setMouseCursor(mState_DONT);
  1344. }
  1345. }
  1346. else if ( controlGui.getSalvage() )
  1347. doSalvage();
  1348. else if ( controlGui.getGuard() )
  1349. doGuard(target);
  1350. else if ( controlGui.getRepair() && canRepair( target ) )
  1351. doRepair(target);
  1352. else if ( controlGui.getGuardTower() )
  1353. doGuardTower();
  1354. else if ( target->getTeam() && Team::home->isFriendly(target->getTeam()) && target->getFlag(OBJECT_FLAG_CANREFIT) && target->getFlag(OBJECT_FLAG_MECHBAY) && canRepairBay(target) )
  1355. doRepairBay(target);
  1356. else if ( controlGui.getSalvage() && canSalvage( target ))
  1357. doSalvage();
  1358. else if ( controlGui.isSelectingInfoObject() && target->isMover() )
  1359. controlGui.setInfoWndMover( (Mover*)target );
  1360. else if ( target->getTeam() != Team::home && !target->isDisabled() )
  1361. doAttack();
  1362. else if (!bForcedShot && !bAimedShot)
  1363. soundSystem->playDigitalSample( INVALID_GUI );
  1364. }
  1365. else if ( selectClicked && !bGui )
  1366. {
  1367. //We clicked on a target. If mouse cursor is normal, we want to select a friendly.
  1368. //if the mouse cursor is some form of attack, attack the target.
  1369. if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && canAddVehicle( wPos )) ||
  1370. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && canRecover( wPos )))
  1371. {
  1372. // Target has already been confirmed as a mover(BattleMech) by canRecover.
  1373. // OR it doesn't matter because the canAddVehicle part of the beginVtol function doesn't reference it!
  1374. // Again, Its OK because we only use it for salvage craft.
  1375. // Need to pass this in so that Multiplayer can pass it in.
  1376. beginVtol(-1,commanderID,NULL,(MoverPtr)target); //In Single player, this should always be zero?
  1377. return;
  1378. }
  1379. else if ( (controlGui.isAddingVehicle() && !paintingVtol[commanderID] && !canAddVehicle( wPos )) ||
  1380. (controlGui.isAddingSalvage() && !paintingVtol[commanderID] && !canRecover( wPos )))
  1381. {
  1382. soundSystem->playDigitalSample( INVALID_GUI );
  1383. return;
  1384. }
  1385. else if ( controlGui.isAddingAirstrike() && !paintingVtol[commanderID] ) // if we're painting the vtol, carry on
  1386. {
  1387. addAirstrike();
  1388. return;
  1389. }
  1390. else if ( target )
  1391. {
  1392. if ( target->isMover() && ( target->getTeamId() == Team::home->getId() ||
  1393. CONTACT_VISUAL == ((Mover*)target)->getContactStatus(Team::home->getId(), true)
  1394. || target->isDisabled() ) )
  1395. {
  1396. controlGui.setInfoWndMover( (Mover*)target );
  1397. }
  1398. if (target->getCommanderId() == Commander::home->getId() && !target->isDisabled() )
  1399. {
  1400. //--------------------------------------------------------------------
  1401. // User wants to select the guy we are on. If he did
  1402. // it with a shift, add him. If not, whack all and just add target!
  1403. if (shiftDn)
  1404. {
  1405. bool alreadyThere = false;
  1406. //-------------------------------------------
  1407. // First, check if he's already there!
  1408. for (long i=0;i<pTeam->getRosterSize();i++)
  1409. {
  1410. Mover* pMover = (Mover*)pTeam->getMover( i );
  1411. if (pMover == target && pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  1412. alreadyThere = true;
  1413. }
  1414. if (!alreadyThere && !target->isDisabled())
  1415. target->setSelected( true );
  1416. else
  1417. target->setSelected( false );
  1418. }
  1419. else if ( target->isMover() )
  1420. {
  1421. for (long i=0;i<pTeam->getRosterSize();i++)
  1422. {
  1423. Mover* pMover = (Mover*)pTeam->getMover( i );
  1424. if (pMover->getCommander()->getId() == Commander::home->getId())
  1425. {
  1426. pMover->setSelected( false );
  1427. }
  1428. }
  1429. target->setSelected( true );
  1430. }
  1431. }
  1432. }
  1433. else
  1434. {
  1435. // tried to select nothing
  1436. controlGui.cancelInfo();
  1437. soundSystem->playDigitalSample( INVALID_GUI );
  1438. }
  1439. }
  1440. }
  1441. void MissionInterfaceManager::updateWaypoints (void)
  1442. {
  1443. // Update the waypoint markers so that they are visible and must happen AFTER camera update!!
  1444. // Or they wiggle something fierce.
  1445. if ( userInput->getKeyDown( WAYPOINT_KEY ) || controlGui.getMines() )
  1446. {
  1447. Team* pTeam = Team::home;
  1448. for (long i=0;i<pTeam->getRosterSize();i++)
  1449. {
  1450. Mover* pMover = (Mover*)pTeam->getMover( i );
  1451. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  1452. {
  1453. pMover->updateDrawWaypointPath();
  1454. }
  1455. }
  1456. }
  1457. }
  1458. int MissionInterfaceManager::update( bool leftClickedClick, bool rightClickedClick, int MouseX, int MouseY, GameObject* pTarget, bool bLOS )
  1459. {
  1460. bool shiftDn = userInput->shift();
  1461. bool ctrlDn = userInput->ctrl();
  1462. bool altDn = userInput->alt();
  1463. bool wayPtDn = userInput->getKeyDown( WAYPOINT_KEY );
  1464. bool bRetVal = 0;
  1465. int i = 0;
  1466. int last = MAX_COMMAND;
  1467. // if chatting, ignore keyboard input
  1468. if ( controlGui.updateChat() )
  1469. {
  1470. i = 100;
  1471. last = 102;
  1472. bRetVal = 1;
  1473. }
  1474. if ( gos_GetKeyStatus( WAYPOINT_KEY ) == KEY_RELEASED )
  1475. {
  1476. Team* pTeam = Team::home;
  1477. for (long i = 0; i < pTeam->getRosterSize(); i++)
  1478. {
  1479. Mover* pMover = (Mover*)pTeam->getMover( i );
  1480. if ( pMover->isSelected() && !pMover->getPilot()->getExecutingTacOrderQueue() && pMover->getCommander()->getId() == Commander::home->getId() )
  1481. {
  1482. if (MPlayer && !MPlayer->isServer()) {
  1483. TacticalOrder tacOrder;
  1484. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_WAYPOINTS_DONE);
  1485. tacOrder.pack(NULL, NULL);
  1486. MPlayer->sendPlayerOrder(&tacOrder, false, 1, &pMover);
  1487. }
  1488. else {
  1489. pMover->getPilot()->setExecutingQueue(true);
  1490. pMover->getPilot()->executeTacOrderQueue();
  1491. }
  1492. }
  1493. }
  1494. bRetVal = 1;
  1495. }
  1496. mouseX = MouseX;
  1497. mouseY = mouseY;
  1498. setTarget( pTarget );
  1499. if ( !bRetVal )
  1500. {
  1501. for ( int j = KEY_0; j < KEY_9 + 1; j++ )
  1502. {
  1503. if ( userInput->getKeyDown( (gosEnum_KeyIndex)j )
  1504. && gos_GetKeyStatus( (gosEnum_KeyIndex)j ) != KEY_HELD )
  1505. {
  1506. if ( ctrlDn )
  1507. makeForceGroup( j - KEY_0 );
  1508. else if ( shiftDn )
  1509. selectForceGroup( j - KEY_0, 0 );
  1510. else
  1511. selectForceGroup( j - KEY_0, 1 );
  1512. }
  1513. }
  1514. }
  1515. for ( ; i < last; i++ )
  1516. {
  1517. int key = commands[i].key;
  1518. if ( userInput->getKeyDown( gosEnum_KeyIndex(key & 0x0000000ff) ) )
  1519. {
  1520. // check for shifts and stuff
  1521. // must check way pt first, because it can be shift or ctrl
  1522. if ( (key & WAYPT) )
  1523. { if ( !wayPtDn )
  1524. continue;
  1525. }
  1526. else if ( ((key & SHIFT) ? true : false) != shiftDn )
  1527. continue;
  1528. else if ( ((key & CTRL) ? true : false) != ctrlDn )
  1529. continue;
  1530. else if ( ((key & ALT) ? true : false) != altDn )
  1531. continue;
  1532. // got this far, call the command
  1533. if ( commands[i].key != -1 )
  1534. userInput->setMouseCursor(bLOS ? commands[i].cursorLOS : commands[i].cursor);
  1535. if ( !commands[i].singleClick )
  1536. {
  1537. if ( (this->*commands[i].function)() )
  1538. bRetVal = 1;
  1539. }
  1540. else if ( gos_GetKeyStatus( (gosEnum_KeyIndex)(key & 0x000fffff) ) != KEY_HELD )
  1541. {
  1542. if ( this->commands[i].function && (this->*commands[i].function)() )
  1543. bRetVal = 1;
  1544. terrainLineChanged = turn;
  1545. }
  1546. }
  1547. else if ( gos_GetKeyStatus( gosEnum_KeyIndex(key & 0x000fffff) ) == KEY_RELEASED
  1548. && commands[i].releaseFunction )
  1549. {
  1550. if ( (this->*commands[i].releaseFunction)() )
  1551. bRetVal = 1;
  1552. }
  1553. }
  1554. return bRetVal;
  1555. }
  1556. void MissionInterfaceManager::doAttack()
  1557. {
  1558. if ( userInput->getKeyDown( WAYPOINT_KEY ) || !target )
  1559. {
  1560. soundSystem->playDigitalSample( INVALID_GUI );
  1561. return; // don't do if in waypoint mode
  1562. }
  1563. TacticalOrder tacOrder;
  1564. bool bCapture = target->isCaptureable(Team::home->getId());
  1565. bool bFireFromCurrentPos = controlGui.getCurrentRange() == FIRERANGE_CURRENT ? 1 : 0;
  1566. if ( controlGui.getFireFromCurrentPos() )
  1567. bFireFromCurrentPos = true;
  1568. if (!bCapture)
  1569. {
  1570. if (!Team::home->isFriendly( target->getTeam() ))
  1571. {
  1572. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_ATTACK_OBJECT );
  1573. tacOrder.targetWID = target->getWatchID();
  1574. tacOrder.attackParams.type = bEnergyWeapons ? ATTACK_CONSERVING_AMMO : ATTACK_TO_DESTROY;
  1575. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  1576. tacOrder.attackParams.range = FIRERANGE_OPTIMAL;
  1577. tacOrder.attackParams.pursue = !bFireFromCurrentPos;
  1578. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1579. target->getAppearance()->flashBuilding(1.3f,0.2f,0xffff0000);
  1580. }
  1581. else
  1582. {
  1583. //Do NOT Attack friendlies unless force Fire.
  1584. // That TacOrder is issued elsewhere!!
  1585. return;
  1586. }
  1587. }
  1588. else
  1589. {
  1590. for (long i = 0; i < Team::home->getRosterSize(); i++)
  1591. {
  1592. Mover* pMover = (Mover*)Team::home->getMover( i );
  1593. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  1594. {
  1595. if ((pMover->getObjectClass() == BATTLEMECH) &&
  1596. (pMover->getMoveType() == MOVETYPE_GROUND))
  1597. {
  1598. if ( target->getCaptureBlocker(pMover) )
  1599. {
  1600. soundSystem->playDigitalSample( INVALID_GUI );
  1601. return;
  1602. }
  1603. }
  1604. else
  1605. {
  1606. //Can't capture player has at least one support thing selected
  1607. // At least until design tells me what they REALLY want!
  1608. // -fs
  1609. soundSystem->playDigitalSample( INVALID_GUI );
  1610. return;
  1611. }
  1612. }
  1613. }
  1614. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_CAPTURE );
  1615. tacOrder.targetWID = target->getWatchID();
  1616. tacOrder.attackParams.type = ATTACK_NONE;
  1617. tacOrder.attackParams.method = ATTACKMETHOD_RAMMING;
  1618. tacOrder.attackParams.pursue = true;
  1619. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1620. }
  1621. soundSystem->playDigitalSample(BUTTON5);
  1622. Team* pTeam = Team::home;
  1623. for (long i = 0; i < pTeam->getRosterSize(); i++)
  1624. {
  1625. Mover* pMover = (Mover*)pTeam->getMover( i );
  1626. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId())
  1627. {
  1628. tacOrder.attackParams.range = (FireRangeType)pMover->attackRange;
  1629. if (pMover->attackRange == FIRERANGE_CURRENT)
  1630. tacOrder.attackParams.pursue = false;
  1631. else if (controlGui.getFireFromCurrentPos())
  1632. tacOrder.attackParams.pursue = false;
  1633. else
  1634. tacOrder.attackParams.pursue = true;
  1635. tacOrder.pack(NULL, NULL);
  1636. //---------------------------------------------------------------------
  1637. // Helper function--perhaps this should just be a part of the mover and
  1638. // group handleTacticalOrder() functions?
  1639. if (MPlayer && !MPlayer->isServer())
  1640. MPlayer->sendPlayerOrder(&tacOrder, false, 1, &pMover);
  1641. else
  1642. pMover->handleTacticalOrder(tacOrder);
  1643. }
  1644. }
  1645. controlGui.setFireFromCurrentPos( 0 );
  1646. }
  1647. int MissionInterfaceManager::attackShort()
  1648. {
  1649. controlGui.setRange( FIRERANGE_SHORT );
  1650. if ( commandClicked && target )
  1651. {
  1652. doAttack();
  1653. return 1;
  1654. }
  1655. return 0;
  1656. }
  1657. int MissionInterfaceManager::attackMedium()
  1658. {
  1659. controlGui.setRange( FIRERANGE_MEDIUM );
  1660. if ( commandClicked && target )
  1661. {
  1662. doAttack();
  1663. return 1;
  1664. }
  1665. return 0;
  1666. }
  1667. int MissionInterfaceManager::attackLong()
  1668. {
  1669. controlGui.setRange( FIRERANGE_LONG );
  1670. if ( commandClicked && target )
  1671. {
  1672. doAttack();
  1673. return 1;
  1674. }
  1675. return 0;
  1676. }
  1677. int MissionInterfaceManager::alphaStrike()
  1678. {
  1679. return 0;
  1680. }
  1681. int MissionInterfaceManager::defaultAttack()
  1682. {
  1683. controlGui.setRange( FIRERANGE_OPTIMAL );
  1684. return 0;
  1685. }
  1686. int MissionInterfaceManager::jump()
  1687. {
  1688. if ( !canJump() )
  1689. {
  1690. soundSystem->playDigitalSample( INVALID_GUI );
  1691. return 0;
  1692. }
  1693. if ( !controlGui.getJump() )
  1694. controlGui.toggleJump();
  1695. return 0;
  1696. }
  1697. int MissionInterfaceManager::stopJump()
  1698. {
  1699. if ( controlGui.getJump() )
  1700. controlGui.toggleJump();
  1701. return 1;
  1702. }
  1703. void MissionInterfaceManager::doJump()
  1704. {
  1705. bool passable = 0;
  1706. if ( !target )
  1707. {
  1708. if (Terrain::IsGameSelectTerrainPosition(wPos))
  1709. {
  1710. long cellR, cellC;
  1711. land->worldToCell(wPos, cellR, cellC);
  1712. passable = GameMap->getPassable(cellR,cellC);
  1713. }
  1714. bool canJump = canJumpToWPos();
  1715. if (canJump)
  1716. {
  1717. TacticalOrder tacOrder;
  1718. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_JUMPTO_POINT, false);
  1719. tacOrder.moveParams.wait = false;
  1720. tacOrder.moveParams.wayPath.mode[0] = TRAVEL_MODE_JUMP;
  1721. tacOrder.setWayPoint( 0, wPos );
  1722. tacOrder.pack(NULL, NULL);
  1723. handleOrders(tacOrder);
  1724. controlGui.setDefaultSpeed();
  1725. soundSystem->playDigitalSample(BUTTON5);
  1726. controlGui.setDefaultSpeed();
  1727. }
  1728. else
  1729. {
  1730. userInput->setMouseCursor(mState_DONT);
  1731. soundSystem->playDigitalSample( INVALID_GUI );
  1732. }
  1733. }
  1734. else
  1735. {
  1736. userInput->setMouseCursor(mState_DONT);
  1737. soundSystem->playDigitalSample( INVALID_GUI );
  1738. }
  1739. }
  1740. int MissionInterfaceManager::fireFromCurrentPos()
  1741. {
  1742. if ( !controlGui.getFireFromCurrentPos() )
  1743. controlGui.toggleFireFromCurrentPos( );
  1744. return forceShot();
  1745. }
  1746. int MissionInterfaceManager::stopFireFromCurrentPos()
  1747. {
  1748. if ( controlGui.getFireFromCurrentPos() )
  1749. controlGui.toggleFireFromCurrentPos();
  1750. return 1;
  1751. }
  1752. void MissionInterfaceManager::doGuard(GameObject* who)
  1753. {
  1754. if ( who )
  1755. {
  1756. TacticalOrder tacOrder;
  1757. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_GUARD);
  1758. tacOrder.targetWID = who->getWatchID();
  1759. tacOrder.pack(NULL, NULL);
  1760. handleOrders( tacOrder );
  1761. controlGui.setDefaultSpeed();
  1762. }
  1763. else
  1764. {
  1765. LocationNode path;
  1766. path.location = wPos;
  1767. path.run = true;
  1768. path.next = NULL;
  1769. TacticalOrder tacOrder;
  1770. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_GUARD);
  1771. tacOrder.initWayPath( &path );
  1772. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1773. tacOrder.pack(NULL, NULL);
  1774. handleOrders( tacOrder );
  1775. controlGui.setDefaultSpeed();
  1776. }
  1777. soundSystem->playDigitalSample(BUTTON5);
  1778. }
  1779. int MissionInterfaceManager::guard()
  1780. {
  1781. if ( !controlGui.getGuard() )
  1782. controlGui.toggleGuard();
  1783. return 0;
  1784. }
  1785. int MissionInterfaceManager::stopGuard()
  1786. {
  1787. if ( controlGui.getGuard() )
  1788. controlGui.toggleGuard();
  1789. return 0;
  1790. }
  1791. int MissionInterfaceManager::conserveAmmo()
  1792. {
  1793. return 0;
  1794. }
  1795. int MissionInterfaceManager::selectVisible()
  1796. {
  1797. Team* pTeam = Team::home;
  1798. for (long i=0;i<pTeam->getRosterSize();i++)
  1799. {
  1800. Mover* pMover = (Mover*)pTeam->getMover( i );
  1801. if (pMover->getCommander()->getId() == Commander::home->getId())
  1802. {
  1803. pMover->setSelected( false );
  1804. }
  1805. }
  1806. return addVisibleToSelection();
  1807. }
  1808. int MissionInterfaceManager::addVisibleToSelection()
  1809. {
  1810. //----------------------------------------------------------------
  1811. // Grab each member of the homeTeam and see if they are onScreen
  1812. dragStart.Zero();
  1813. dragEnd = eye->getScreenRes();
  1814. for (int i=0;i<ObjectManager->getNumMovers();i++)
  1815. {
  1816. if (ObjectManager->moverInRect(i,dragStart,dragEnd))
  1817. {
  1818. GameObjectPtr mover = ObjectManager->getMover(i);
  1819. if (mover && (mover->getCommanderId() == Commander::home->getId()) && !mover->isDisabled())
  1820. {
  1821. mover->setSelected( true );
  1822. }
  1823. }
  1824. }
  1825. dragStart.Zero();
  1826. dragEnd.Zero();
  1827. return 1;
  1828. }
  1829. int MissionInterfaceManager::aimLeg()
  1830. {
  1831. if ( target )
  1832. {
  1833. BattleMech* pMech = dynamic_cast<BattleMech*>(target );
  1834. if ( pMech && pMech->getMoveType() == MOVETYPE_GROUND)
  1835. {
  1836. if (!anySelectedWithoutAreaEffect())
  1837. {
  1838. //Can't aim shot. No weapon which is not area effect available!
  1839. userInput->setMouseCursor( mState_DONT );
  1840. return 1;
  1841. }
  1842. else if ( pMech->body[MECH_BODY_LOCATION_LLEG].damageState == IS_DAMAGE_DESTROYED
  1843. && pMech->body[MECH_BODY_LOCATION_RLEG].damageState == IS_DAMAGE_DESTROYED )
  1844. {
  1845. userInput->setMouseCursor( mState_DONT );
  1846. return 1;
  1847. }
  1848. else if ( !commandClicked )// cursor already set above, however if in doubt
  1849. return 1;
  1850. else
  1851. {
  1852. TacticalOrder tacOrder;
  1853. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_ATTACK_OBJECT);
  1854. tacOrder.targetWID = target->getWatchID();
  1855. tacOrder.attackParams.type = ATTACK_TO_DESTROY;
  1856. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  1857. tacOrder.attackParams.range = FIRERANGE_OPTIMAL;
  1858. tacOrder.attackParams.pursue = controlGui.getFireFromCurrentPos() ? false : true;
  1859. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1860. bool bRight = pMech->body[MECH_BODY_LOCATION_LLEG].damageState == IS_DAMAGE_DESTROYED;
  1861. tacOrder.attackParams.aimLocation = bRight ? MECH_BODY_LOCATION_RLEG : MECH_BODY_LOCATION_LLEG;
  1862. tacOrder.pack( NULL, NULL);
  1863. handleOrders( tacOrder );
  1864. soundSystem->playDigitalSample(BUTTON5);
  1865. bAimedShot = true;
  1866. return 1;
  1867. }
  1868. }
  1869. }
  1870. else
  1871. {
  1872. userInput->setMouseCursor( mState_DONT );
  1873. return 1;
  1874. }
  1875. return 0;
  1876. }
  1877. int MissionInterfaceManager::aimArm()
  1878. {
  1879. BattleMech* pMech = dynamic_cast<BattleMech*>(target);
  1880. if ( pMech && pMech->getMoveType() == MOVETYPE_GROUND)
  1881. {
  1882. if ( anySelectedWithoutAreaEffect() && commandClicked )
  1883. {
  1884. TacticalOrder tacOrder;
  1885. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_ATTACK_OBJECT);
  1886. tacOrder.targetWID = target->getWatchID();
  1887. tacOrder.attackParams.type = ATTACK_TO_DESTROY;
  1888. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  1889. tacOrder.attackParams.pursue = controlGui.getFireFromCurrentPos() ? false : true;
  1890. tacOrder.attackParams.range = FIRERANGE_OPTIMAL;
  1891. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1892. bool bRight = pMech->body[MECH_BODY_LOCATION_LARM].damageState == IS_DAMAGE_DESTROYED;
  1893. tacOrder.attackParams.aimLocation = bRight ? MECH_BODY_LOCATION_RARM : MECH_BODY_LOCATION_LARM;
  1894. tacOrder.pack( NULL, NULL);
  1895. handleOrders( tacOrder );
  1896. soundSystem->playDigitalSample(BUTTON5);
  1897. bAimedShot = true;
  1898. return 1;
  1899. }
  1900. if (!anySelectedWithoutAreaEffect())
  1901. {
  1902. //Can't aim shot. No weapon which is not area effect available!
  1903. userInput->setMouseCursor( mState_DONT );
  1904. return 1;
  1905. }
  1906. else if ( pMech->body[MECH_BODY_LOCATION_LARM].damageState == IS_DAMAGE_DESTROYED
  1907. && pMech->body[MECH_BODY_LOCATION_RARM].damageState == IS_DAMAGE_DESTROYED )
  1908. {
  1909. userInput->setMouseCursor( mState_DONT );
  1910. return 1;
  1911. }
  1912. else // cursor already set above, however if in doubt
  1913. return 1;
  1914. }
  1915. else
  1916. {
  1917. userInput->setMouseCursor( mState_DONT );
  1918. return 1;
  1919. }
  1920. }
  1921. int MissionInterfaceManager::aimHead()
  1922. {
  1923. if ( target )
  1924. {
  1925. BattleMech* pMech = dynamic_cast<BattleMech*>(target);
  1926. if ( pMech && pMech->getMoveType() == MOVETYPE_GROUND)
  1927. {
  1928. if (anySelectedWithoutAreaEffect() && commandClicked )
  1929. {
  1930. TacticalOrder tacOrder;
  1931. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_ATTACK_OBJECT);
  1932. tacOrder.targetWID = target->getWatchID();
  1933. tacOrder.attackParams.type = ATTACK_TO_DESTROY;
  1934. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  1935. tacOrder.attackParams.pursue = controlGui.getFireFromCurrentPos() ? false : true;
  1936. tacOrder.attackParams.range = FIRERANGE_OPTIMAL;
  1937. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  1938. tacOrder.attackParams.aimLocation = MECH_BODY_LOCATION_HEAD;
  1939. tacOrder.pack( NULL, NULL);
  1940. handleOrders( tacOrder );
  1941. bAimedShot = true;
  1942. soundSystem->playDigitalSample(BUTTON5);
  1943. }
  1944. else if (!anySelectedWithoutAreaEffect())
  1945. {
  1946. //Can't aim shot. No weapon which is not area effect available!
  1947. userInput->setMouseCursor( mState_DONT );
  1948. return 1;
  1949. }
  1950. else if ( pMech->body[MECH_BODY_LOCATION_HEAD].damageState == IS_DAMAGE_DESTROYED )
  1951. {
  1952. userInput->setMouseCursor( mState_DONT );
  1953. return 1;
  1954. }
  1955. else // cursor already set above, however if in doubt
  1956. return 1;
  1957. }
  1958. else
  1959. {
  1960. userInput->setMouseCursor( mState_DONT );
  1961. return 1;
  1962. }
  1963. }
  1964. else
  1965. {
  1966. userInput->setMouseCursor( mState_DONT );
  1967. return 1;
  1968. }
  1969. return 0;
  1970. }
  1971. int MissionInterfaceManager::removeCommand()
  1972. {
  1973. controlGui.doStop();
  1974. return 1;
  1975. }
  1976. int MissionInterfaceManager::powerUp()
  1977. {
  1978. TacticalOrder tacOrder;
  1979. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_POWERUP, true);
  1980. tacOrder.pack(NULL, NULL);
  1981. handleOrders( tacOrder );
  1982. return 1;
  1983. }
  1984. int MissionInterfaceManager::powerDown()
  1985. {
  1986. TacticalOrder tacOrder;
  1987. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_POWERDOWN, true);
  1988. tacOrder.pack(NULL, NULL);
  1989. handleOrders( tacOrder );
  1990. return 1;
  1991. }
  1992. int MissionInterfaceManager::changeSpeed()
  1993. {
  1994. if ( controlGui.isDefaultSpeed() )
  1995. controlGui.toggleDefaultSpeed();
  1996. return 0;
  1997. }
  1998. int MissionInterfaceManager::stopChangeSpeed()
  1999. {
  2000. if ( !controlGui.isDefaultSpeed() )
  2001. controlGui.toggleDefaultSpeed();
  2002. return 1;
  2003. }
  2004. int MissionInterfaceManager::eject()
  2005. {
  2006. if ( target && target->isMover() && target->getCommanderId() == Commander::home->getId() && !invulnerableON)
  2007. {
  2008. if ( commandClicked )
  2009. {
  2010. doEject( target );
  2011. }
  2012. userInput->setMouseCursor( mState_EJECT );
  2013. }
  2014. else if ( !controlGui.forceGroupBar.inRegion( userInput->getMouseX(), userInput->getMouseY() ) )
  2015. userInput->setMouseCursor( mState_XEJECT );
  2016. return 1;
  2017. }
  2018. int MissionInterfaceManager::bigAirStrike()
  2019. {
  2020. Stuff::Vector3D v = makeAirStrikeTarget( wPos );
  2021. IfaceCallStrike (ARTILLERY_LARGE,&v,NULL);
  2022. // if ( !isPaused() )
  2023. soundSystem->playSupportSample(SUPPORT_AIRSTRIKE);
  2024. return 1;
  2025. }
  2026. int MissionInterfaceManager::smlAirStrike()
  2027. {
  2028. Stuff::Vector3D v = makeAirStrikeTarget( wPos );
  2029. IfaceCallStrike (ARTILLERY_SMALL,&v,NULL);
  2030. // if ( !isPaused() )
  2031. soundSystem->playSupportSample(SUPPORT_AIRSTRIKE);
  2032. return 1;
  2033. }
  2034. int MissionInterfaceManager::snsAirStrike()
  2035. {
  2036. Stuff::Vector3D v = makeAirStrikeTarget( wPos );
  2037. IfaceCallStrike (ARTILLERY_SENSOR,&v,NULL);
  2038. // if ( !isPaused() )
  2039. soundSystem->playSupportSample(SUPPORT_PROBE);
  2040. return 1;
  2041. }
  2042. Stuff::Vector3D MissionInterfaceManager::makeAirStrikeTarget( const Stuff::Vector3D& pos )
  2043. {
  2044. Stuff::Vector3D newPos = pos;
  2045. /* bool lineOfSight = Team::home->teamLineOfSight(pos);
  2046. if ( !lineOfSight )
  2047. {
  2048. // need to offset x, y, random amounts up to five tiles...
  2049. long randX = rand();
  2050. long randY = rand();
  2051. long offsetX = randX % (128*5);
  2052. long offsetY = randY % (128*5);
  2053. if ( randX % 2 )
  2054. offsetX = -offsetX;
  2055. if ( randY % 2 )
  2056. offsetY = -offsetY;
  2057. newPos.x += offsetX;
  2058. newPos.y += offsetY;
  2059. }*/
  2060. return newPos;
  2061. }
  2062. int MissionInterfaceManager::cameraAssign0()
  2063. {
  2064. Camera::cameraZoom[0] = eye->cameraAltitude;
  2065. Camera::cameraTilt[0] = eye->getProjectionAngle();
  2066. return 1;
  2067. }
  2068. int MissionInterfaceManager::cameraAssign1()
  2069. {
  2070. Camera::cameraZoom[1] = eye->cameraAltitude;
  2071. Camera::cameraTilt[1] = eye->getProjectionAngle();
  2072. return 1;
  2073. }
  2074. int MissionInterfaceManager::cameraAssign2()
  2075. {
  2076. Camera::cameraZoom[2] = eye->cameraAltitude;
  2077. Camera::cameraTilt[2] = eye->getProjectionAngle();
  2078. return 1;
  2079. }
  2080. int MissionInterfaceManager::cameraAssign3()
  2081. {
  2082. Camera::cameraZoom[3] = eye->cameraAltitude;
  2083. Camera::cameraTilt[3] = eye->getProjectionAngle();
  2084. return 1;
  2085. }
  2086. int MissionInterfaceManager::cameraNormal()
  2087. {
  2088. if (eye)
  2089. eye->allNormal();
  2090. return 1;
  2091. }
  2092. int MissionInterfaceManager::cameraDefault()
  2093. {
  2094. if (eye)
  2095. eye->setCameraView(0);
  2096. return 1;
  2097. }
  2098. int MissionInterfaceManager::cameraMaxIn()
  2099. {
  2100. if (eye)
  2101. eye->setCameraView(1);
  2102. return 1;
  2103. }
  2104. int MissionInterfaceManager::cameraTight()
  2105. {
  2106. if (eye)
  2107. eye->setCameraView(2);
  2108. return 1;
  2109. }
  2110. int MissionInterfaceManager::cameraFour()
  2111. {
  2112. if (eye)
  2113. eye->setCameraView(3);
  2114. return 1;
  2115. }
  2116. bool MissionInterfaceManager::anySelectedWithoutAreaEffect (void)
  2117. {
  2118. //Scan the list of selected movers and see if any have at least one non-area effect weapon
  2119. // Used for Called shots which cannot be called if weapon is area effect!!
  2120. Team* pTeam = Team::home;
  2121. for (long i = 0; i < pTeam->getRosterSize(); i++)
  2122. {
  2123. Mover* pMover = (Mover*)pTeam->getMover( i );
  2124. if ( pMover->isSelected() && pMover->hasNonAreaWeapon() && pMover->getCommander()->getId() == Commander::home->getId())
  2125. return true;
  2126. }
  2127. return false;
  2128. }
  2129. int MissionInterfaceManager::handleOrders( TacticalOrder& order)
  2130. {
  2131. Team* pTeam = Team::home;
  2132. //--------------------------------------------------------
  2133. // First, find out how many are jumping and calc a list of
  2134. // jump locations...
  2135. bool isMoveOrder = false;
  2136. Stuff::Vector3D moveGoals[MAX_MOVERS];
  2137. long numMovers = 0;
  2138. if (order.code == TACTICAL_ORDER_JUMPTO_POINT) {
  2139. for (long i = 0; i < pTeam->getRosterSize(); i++) {
  2140. Mover* pMover = pTeam->getMover(i);
  2141. if (pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId())
  2142. numMovers++;
  2143. }
  2144. MoverGroup::calcJumpGoals(order.getWayPoint(0), numMovers, moveGoals, NULL);
  2145. isMoveOrder = true;
  2146. }
  2147. else if (order.code == TACTICAL_ORDER_MOVETO_POINT) {
  2148. for (long i = 0; i < pTeam->getRosterSize(); i++) {
  2149. Mover* pMover = pTeam->getMover(i);
  2150. if (pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId())
  2151. numMovers++;
  2152. }
  2153. MoverGroup::calcMoveGoals(order.getWayPoint(0), numMovers, moveGoals);
  2154. isMoveOrder = true;
  2155. }
  2156. numMovers = 0;
  2157. for (long i = 0; i < pTeam->getRosterSize(); i++)
  2158. {
  2159. Mover* pMover = (Mover*)pTeam->getMover( i );
  2160. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  2161. {
  2162. //---------------------------------------------------------------------
  2163. // Helper function--perhaps this should just be a part of the mover and
  2164. // group handleTacticalOrder() functions?
  2165. if (isMoveOrder ) {
  2166. order.setWayPoint(0, moveGoals[numMovers++]);
  2167. order.pack(NULL, NULL);
  2168. }
  2169. if (MPlayer && !MPlayer->isServer()) {
  2170. MPlayer->sendPlayerOrder(&order, false, 1, &pMover, 0, NULL, userInput->getKeyDown(WAYPOINT_KEY));
  2171. //pMover->getPilot()->setExecutingQueue(false);
  2172. //pMover->getPilot()->addQueuedTacOrder(order);
  2173. }
  2174. else
  2175. {
  2176. order.attackParams.range = (FireRangeType)pMover->attackRange;
  2177. order.pack( NULL, NULL );
  2178. if ( userInput->getKeyDown( WAYPOINT_KEY ) ) // way point one
  2179. {
  2180. pMover->getPilot()->setExecutingQueue(FALSE);
  2181. pMover->getPilot()->addQueuedTacOrder(order);
  2182. }
  2183. else if ( controlGui.getMines() )
  2184. {
  2185. pMover->getPilot()->addQueuedTacOrder(order);
  2186. pMover->getPilot()->setExecutingQueue(TRUE);
  2187. }
  2188. else
  2189. pMover->handleTacticalOrder(order);
  2190. }
  2191. }
  2192. }
  2193. return 1;
  2194. }
  2195. int MissionInterfaceManager::scrollUp()
  2196. {
  2197. float frameFactor = frameLength / baseFrameLength;
  2198. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2199. eye->moveUp(scrollFactor);
  2200. return 1;
  2201. }
  2202. int MissionInterfaceManager::scrollDown()
  2203. {
  2204. float frameFactor = frameLength / baseFrameLength;
  2205. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2206. eye->moveDown(scrollFactor);
  2207. return 1;
  2208. }
  2209. int MissionInterfaceManager::scrollLeft()
  2210. {
  2211. float frameFactor = frameLength / baseFrameLength;
  2212. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2213. eye->moveLeft(scrollFactor);
  2214. return 1;
  2215. }
  2216. int MissionInterfaceManager::scrollRight()
  2217. {
  2218. float frameFactor = frameLength / baseFrameLength;
  2219. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2220. eye->moveRight(scrollFactor);
  2221. return 1;
  2222. }
  2223. int MissionInterfaceManager::zoomOut()
  2224. {
  2225. float frameFactor = frameLength / baseFrameLength;
  2226. eye->ZoomOut(zoomInc * frameFactor * eye->getScaleFactor());
  2227. return 1;
  2228. }
  2229. int MissionInterfaceManager::zoomIn()
  2230. {
  2231. float frameFactor = frameLength / baseFrameLength;
  2232. eye->ZoomIn(zoomInc * frameFactor * eye->getScaleFactor());
  2233. return 1;
  2234. }
  2235. int MissionInterfaceManager::zoomChoiceOut()
  2236. {
  2237. float frameFactor = frameLength / baseFrameLength;
  2238. eye->ZoomOut(zoomInc * frameFactor * 5.0f * eye->getScaleFactor());
  2239. return 1;
  2240. }
  2241. int MissionInterfaceManager::zoomChoiceIn()
  2242. {
  2243. float frameFactor = frameLength / baseFrameLength;
  2244. eye->ZoomIn(zoomInc * frameFactor * 5.0f * eye->getScaleFactor());
  2245. return 1;
  2246. }
  2247. int MissionInterfaceManager::rotateLeft()
  2248. {
  2249. float frameFactor = frameLength / baseFrameLength;
  2250. realRotation += degPerSecRot * frameFactor;
  2251. if (realRotation >= rotationInc)
  2252. {
  2253. eye->rotateLeft(rotationInc);
  2254. realRotation = 0;
  2255. }
  2256. return 1;
  2257. }
  2258. int MissionInterfaceManager::rotateRight()
  2259. {
  2260. float frameFactor = frameLength / baseFrameLength;
  2261. realRotation -= degPerSecRot * frameFactor;
  2262. if (realRotation <= -rotationInc)
  2263. {
  2264. eye->rotateRight(rotationInc);
  2265. realRotation = 0;
  2266. }
  2267. return 1;
  2268. }
  2269. int MissionInterfaceManager::tiltUp()
  2270. {
  2271. float frameFactor = frameLength / baseFrameLength;
  2272. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2273. eye->tiltDown(scrollFactor * frameFactor * 30.0f);
  2274. return 1;
  2275. }
  2276. int MissionInterfaceManager::tiltDown()
  2277. {
  2278. float frameFactor = frameLength / baseFrameLength;
  2279. float scrollFactor = scrollInc / eye->getScaleFactor() * frameFactor;
  2280. eye->tiltUp(scrollFactor * frameFactor * 30.0f);
  2281. return 1;
  2282. }
  2283. int MissionInterfaceManager::centerCamera()
  2284. {
  2285. return 0;
  2286. }
  2287. int MissionInterfaceManager::rotateLightLeft()
  2288. {
  2289. #ifndef FINAL
  2290. eye->rotateLightLeft(rotationInc);
  2291. #endif
  2292. return 1;
  2293. }
  2294. int MissionInterfaceManager::rotateLightRight()
  2295. {
  2296. #ifndef FINAL
  2297. eye->rotateLightRight(rotationInc);
  2298. #endif
  2299. return 1;
  2300. }
  2301. int MissionInterfaceManager::rotateLightUp()
  2302. {
  2303. #ifndef FINAL
  2304. eye->rotateLightUp(rotationInc);
  2305. #endif
  2306. return 1;
  2307. }
  2308. int MissionInterfaceManager::rotateLightDown()
  2309. {
  2310. #ifndef FINAL
  2311. eye->rotateLightDown(rotationInc);
  2312. #endif
  2313. return 1;
  2314. }
  2315. int MissionInterfaceManager::drawTerrain()
  2316. {
  2317. #ifndef FINAL
  2318. drawTerrainTiles ^= TRUE;
  2319. #endif
  2320. return 1;
  2321. }
  2322. int MissionInterfaceManager::drawOverlays()
  2323. {
  2324. #ifndef FINAL
  2325. drawTerrainOverlays ^= TRUE;
  2326. #endif
  2327. return 1;
  2328. }
  2329. int MissionInterfaceManager::drawBuildings()
  2330. {
  2331. #ifndef FINAL
  2332. renderObjects ^= TRUE;
  2333. #endif
  2334. return 1;
  2335. }
  2336. int MissionInterfaceManager::showGrid()
  2337. {
  2338. #ifndef FINAL
  2339. drawTerrainGrid = !drawTerrainGrid;
  2340. #endif
  2341. return 1;
  2342. }
  2343. int MissionInterfaceManager::recalcLights()
  2344. {
  2345. #ifndef FINAL
  2346. Terrain::recalcLight ^= TRUE;
  2347. Terrain::recalcShadows = false;
  2348. #endif
  2349. return 1;
  2350. }
  2351. int MissionInterfaceManager::drawClouds()
  2352. {
  2353. #ifndef FINAL
  2354. useClouds ^= TRUE;
  2355. #endif
  2356. return 1;
  2357. }
  2358. int MissionInterfaceManager::drawFog()
  2359. {
  2360. #ifndef FINAL
  2361. useFog ^= TRUE;
  2362. #endif
  2363. return 1;
  2364. }
  2365. int MissionInterfaceManager::usePerspective()
  2366. {
  2367. #ifndef FINAL
  2368. eye->usePerspective ^= true;
  2369. #endif
  2370. return 1;
  2371. }
  2372. int MissionInterfaceManager::toggleGUI()
  2373. {
  2374. #ifndef FINAL
  2375. drawGUIOn ^= true;
  2376. toggledGUI = drawGUIOn;
  2377. #endif
  2378. return 1;
  2379. }
  2380. int MissionInterfaceManager::drawTGLShapes()
  2381. {
  2382. #ifndef FINAL
  2383. renderTGLShapes ^= true;
  2384. terrainLineChanged = turn;
  2385. #endif
  2386. return 1;
  2387. }
  2388. int MissionInterfaceManager::drawWaterEffects()
  2389. {
  2390. #ifndef FINAL
  2391. useWaterInterestTexture ^= true;
  2392. terrainLineChanged = turn;
  2393. #endif
  2394. return 1;
  2395. }
  2396. int MissionInterfaceManager::recalcWater()
  2397. {
  2398. #ifndef FINAL
  2399. Terrain::mapData->recalcWater();
  2400. #endif
  2401. return 1;
  2402. }
  2403. int MissionInterfaceManager::drawShadows()
  2404. {
  2405. #ifndef FINAL
  2406. useShadows ^= TRUE;
  2407. #endif
  2408. return 1;
  2409. }
  2410. int MissionInterfaceManager::changeLighting()
  2411. {
  2412. #ifndef FINAL
  2413. drawLOSGrid ^= true;
  2414. #endif
  2415. return 1;
  2416. }
  2417. void MissionInterfaceManager::init (FitIniFilePtr loader)
  2418. {
  2419. long result = loader->seekBlock("CameraData");
  2420. gosASSERT(result == NO_ERR);
  2421. result = loader->readIdFloat("ScrollIncrement",scrollInc);
  2422. gosASSERT(result == NO_ERR);
  2423. result = loader->readIdFloat("RotationIncrement",rotationInc);
  2424. gosASSERT(result == NO_ERR);
  2425. result = loader->readIdFloat("ZoomIncrement",zoomInc);
  2426. gosASSERT(result == NO_ERR);
  2427. result = loader->readIdFloat("ScrollLeft",screenScrollLeft);
  2428. gosASSERT(result == NO_ERR);
  2429. result = loader->readIdFloat("ScrollRight",screenScrollRight);
  2430. gosASSERT(result == NO_ERR);
  2431. result = loader->readIdFloat("ScrollUp",screenScrollUp);
  2432. gosASSERT(result == NO_ERR);
  2433. result = loader->readIdFloat("ScrollDown",screenScrollDown);
  2434. gosASSERT(result == NO_ERR);
  2435. result = loader->readIdFloat("BaseFrameLength",baseFrameLength);
  2436. gosASSERT(result == NO_ERR);
  2437. result = loader->readIdFloat("RotationDegPerSec",degPerSecRot);
  2438. gosASSERT(result == NO_ERR);
  2439. float missionDragThreshold;
  2440. result = loader->readIdFloat("MouseDragThreshold",missionDragThreshold);
  2441. gosASSERT(result == NO_ERR);
  2442. float newThreshold = missionDragThreshold / Environment.screenHeight;
  2443. userInput->setMouseDragThreshold(newThreshold);
  2444. float missionDblClkThreshold;
  2445. result = loader->readIdFloat("MouseDoubleClickThreshold",missionDblClkThreshold);
  2446. gosASSERT(result == NO_ERR);
  2447. userInput->setMouseDoubleClickThreshold(missionDblClkThreshold);
  2448. swapResolutions();
  2449. }
  2450. //--------------------------------------------------------------------------------------
  2451. void MissionInterfaceManager::destroy (void)
  2452. {
  2453. hotKeyFont.destroy();
  2454. hotKeyHeaderFont.destroy();
  2455. delete keyboardRef;
  2456. keyboardRef = NULL;
  2457. }
  2458. //--------------------
  2459. // TO TEST LIGHTING MODEL
  2460. bool rotateLightRt = false;
  2461. bool rotateLightLf = false;
  2462. bool rotateLightUp = false;
  2463. bool rotateLightDn = false;
  2464. //--------------------------------------------------------------------------------------
  2465. void HandlePlayerOrder (MoverPtr mover, TacticalOrderPtr tacOrder) {
  2466. //---------------------------------------------------------------------
  2467. // Helper function--perhaps this should just be a part of the mover and
  2468. // group handleTacticalOrder() functions?
  2469. if (MPlayer && !MPlayer->isServer())
  2470. MPlayer->sendPlayerOrder(tacOrder, false, 1, &mover);
  2471. else
  2472. mover->handleTacticalOrder(*tacOrder);
  2473. }
  2474. //--------------------------------------------------------------------------------------
  2475. void MissionInterfaceManager::drawVTOL (void)
  2476. {
  2477. for (long vtolNum = 0;vtolNum < MAX_TEAMS; vtolNum++)
  2478. {
  2479. if ( paintingVtol[vtolNum] && vTol[vtolNum] )
  2480. {
  2481. vTol[vtolNum]->render();
  2482. vTol[vtolNum]->renderShadows();
  2483. if (dustCloud[vtolNum] && dustCloud[vtolNum]->IsExecuted())
  2484. {
  2485. gosFX::Effect::DrawInfo drawInfo;
  2486. drawInfo.m_clipper = theClipper;
  2487. Stuff::LinearMatrix4D shapeOrigin;
  2488. Stuff::LinearMatrix4D localToWorld;
  2489. Stuff::LinearMatrix4D localResult;
  2490. Stuff::Vector3D dustPos = vTol[vtolNum]->position;
  2491. Stuff::Point3D wakePos;
  2492. wakePos.x = -dustPos.x;
  2493. wakePos.y = dustPos.z;
  2494. wakePos.z = dustPos.y;
  2495. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  2496. shapeOrigin.BuildTranslation(wakePos);
  2497. drawInfo.m_parentToWorld = &shapeOrigin;
  2498. if (!MLRVertexLimitReached)
  2499. dustCloud[vtolNum]->Draw(&drawInfo);
  2500. }
  2501. if (recoveryBeam[vtolNum] && recoveryBeam[vtolNum]->IsExecuted())
  2502. {
  2503. gosFX::Effect::DrawInfo drawInfo;
  2504. drawInfo.m_clipper = theClipper;
  2505. Stuff::LinearMatrix4D shapeOrigin;
  2506. Stuff::LinearMatrix4D localToWorld;
  2507. Stuff::LinearMatrix4D localResult;
  2508. Stuff::Vector3D dustPos = vTol[vtolNum]->position;
  2509. Stuff::Point3D wakePos;
  2510. wakePos.x = -dustPos.x;
  2511. wakePos.y = dustPos.z;
  2512. wakePos.z = dustPos.y;
  2513. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  2514. shapeOrigin.BuildTranslation(wakePos);
  2515. drawInfo.m_parentToWorld = &shapeOrigin;
  2516. if (!MLRVertexLimitReached)
  2517. recoveryBeam[vtolNum]->Draw(&drawInfo);
  2518. }
  2519. }
  2520. }
  2521. }
  2522. //--------------------------------------------------------------------------------------
  2523. void MissionInterfaceManager::render (void)
  2524. {
  2525. if (drawGUIOn)
  2526. {
  2527. //-------------------------
  2528. // Draw the dragSelect Box
  2529. if (isDragging)
  2530. {
  2531. gos_VERTEX vertices[5];
  2532. DWORD color = SB_WHITE;
  2533. gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha );
  2534. gos_SetRenderState( gos_State_Specular,FALSE );
  2535. gos_SetRenderState( gos_State_AlphaTest, TRUE );
  2536. gos_SetRenderState( gos_State_Texture, 0 );
  2537. gos_SetRenderState( gos_State_Filter, gos_FilterNone );
  2538. Stuff::Vector4D screenPos;
  2539. eye->projectZ( dragStart, screenPos );
  2540. vertices[0].x = screenPos.x;
  2541. vertices[0].y = screenPos.y;
  2542. vertices[0].z = 0.0;
  2543. vertices[0].rhw = 0.5;
  2544. vertices[0].u = 0.0;
  2545. vertices[0].v = 0.0;
  2546. vertices[0].argb = color;
  2547. vertices[1].x = dragEnd.x;
  2548. vertices[1].y = screenPos.y;
  2549. vertices[1].z = 0.0;
  2550. vertices[1].rhw = 0.5;
  2551. vertices[1].u = 0.0;
  2552. vertices[1].v = 0.0;
  2553. vertices[1].argb = color;
  2554. vertices[2].x = dragEnd.x;
  2555. vertices[2].y = dragEnd.y;
  2556. vertices[2].z = 0.0;
  2557. vertices[2].rhw = 0.5;
  2558. vertices[2].u = 0.0;
  2559. vertices[2].v = 0.0;
  2560. vertices[2].argb = color;
  2561. vertices[3].x = screenPos.x;
  2562. vertices[3].y = dragEnd.y;
  2563. vertices[3].z = 0.0;
  2564. vertices[3].rhw = 0.5;
  2565. vertices[3].u = 0.0;
  2566. vertices[3].v = 0.0;
  2567. vertices[3].argb = color;
  2568. vertices[4].x = screenPos.x;
  2569. vertices[4].y = screenPos.y;
  2570. vertices[4].z = 0.0;
  2571. vertices[4].rhw = 0.5;
  2572. vertices[4].u = 0.0;
  2573. vertices[4].v = 0.0;
  2574. vertices[4].argb = color;
  2575. gos_DrawQuads(vertices,4);
  2576. vertices[0].argb = SB_BLACK;
  2577. vertices[1].argb = SB_BLACK;
  2578. vertices[2].argb = SB_BLACK;
  2579. vertices[3].argb = SB_BLACK;
  2580. vertices[4].argb = SB_BLACK;
  2581. gos_DrawLines(&vertices[0],2);
  2582. gos_DrawLines(&vertices[1],2);
  2583. gos_DrawLines(&vertices[2],2);
  2584. gos_DrawLines(&vertices[3],2);
  2585. }
  2586. if ( userInput->getKeyDown( WAYPOINT_KEY ) || controlGui.getMines() )
  2587. {
  2588. Team* pTeam = Team::home;
  2589. for (long i=0;i<pTeam->getRosterSize();i++)
  2590. {
  2591. Mover* pMover = (Mover*)pTeam->getMover( i );
  2592. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  2593. {
  2594. pMover->drawWaypointPath();
  2595. }
  2596. }
  2597. }
  2598. if ( bDrawHotKeys )
  2599. {
  2600. drawHotKeys();
  2601. return;
  2602. }
  2603. if (turn > 3 /*&& !controlGui.inRegion(userInput->getMouseX(), userInput->getMouseY())*/ )
  2604. {
  2605. #ifdef DRAW_CURSOR_CROSSHAIRS
  2606. Stuff::Vector4D cursorPos;
  2607. eye->projectZ(wPos,cursorPos);
  2608. DWORD color = SB_WHITE;
  2609. gos_SetRenderState( gos_State_Texture, 0 );
  2610. gos_SetRenderState( gos_State_Filter, gos_FilterNone );
  2611. Stuff::Vector4D ul, br, pos1, pos2;
  2612. pos1.x = cursorPos.x-5;
  2613. pos1.y = cursorPos.y;
  2614. pos1.z = 0.000001f;
  2615. pos2.x = cursorPos.x+5;
  2616. pos2.y = cursorPos.y;
  2617. pos2.z = 0.000001f;
  2618. pos2.w = pos1.w = 1.0f;
  2619. {
  2620. LineElement newElement(pos1,pos2,color,NULL,-1);
  2621. newElement.draw();
  2622. }
  2623. pos1.x = cursorPos.x;
  2624. pos1.y = cursorPos.y-5;
  2625. pos1.z = 0.000001f;
  2626. pos2.x = cursorPos.x;
  2627. pos2.y = cursorPos.y+5;
  2628. pos2.z = 0.000001f;
  2629. pos2.w = pos1.w = 1.0f;
  2630. {
  2631. LineElement newElement(pos1,pos2,color,NULL,-1);
  2632. newElement.draw();
  2633. }
  2634. #endif
  2635. if (eye->usePerspective)
  2636. {
  2637. //Depth cue the cursor.
  2638. Stuff::Vector3D Distance;
  2639. Stuff::Point3D objPosition;
  2640. Stuff::Point3D eyePosition(eye->getCameraOrigin());
  2641. objPosition.x = -wPos.x;
  2642. objPosition.y = wPos.z;
  2643. objPosition.z = wPos.y;
  2644. Distance.Subtract(objPosition,eyePosition);
  2645. float eyeDistance = Distance.GetApproximateLength();
  2646. float scaleFactor = 0.0f;
  2647. scaleFactor = eyeDistance / (Camera::MaxClipDistance * 2.0f);
  2648. scaleFactor = 1.5f - scaleFactor;
  2649. userInput->setMouseScale(scaleFactor);
  2650. }
  2651. }
  2652. }
  2653. controlGui.render( isPaused() && !isPausedWithoutMenu() );
  2654. /* if ( scenarioTime < 7.0 )
  2655. {
  2656. long color = 0xff000000;
  2657. if ( (prefs.resolution == 0 && Environment.screenWidth == 640)
  2658. || (prefs.resolution == 1 && Environment.screenWidth == 800)
  2659. || (prefs.resolution == 2 && Environment.screenWidth == 1024)
  2660. || (prefs.resolution == 3 && Environment.screenWidth == 1280)
  2661. ||(prefs.resolution == 4 && Environment.screenWidth == 1600))
  2662. {
  2663. color = interpolateColor( 0xff000000, 0x00000000, (scenarioTime-swapTime)/(7.0-swapTime) );
  2664. }
  2665. else
  2666. swapTime = scenarioTime;
  2667. GUI_RECT tmpRect = { 0,0, Environment.screenWidth, Environment.screenHeight };
  2668. drawRect( tmpRect, color );
  2669. }*/
  2670. }
  2671. void MissionInterfaceManager::initTacMap( PacketFile* file, int packet )
  2672. {
  2673. file->seekPacket(packet);
  2674. int size = file->getPacketSize( );
  2675. BYTE* mem = new BYTE[size];
  2676. file->readPacket( packet, mem );
  2677. controlGui.initTacMapBuildings( mem, size );
  2678. delete mem;
  2679. file->seekPacket(packet + 1);
  2680. size = file->getPacketSize( );
  2681. mem = new BYTE[size];
  2682. file->readPacket( packet + 1, mem );
  2683. controlGui.initTacMap( mem, size );
  2684. delete mem;
  2685. swapTime = 0.f;
  2686. for ( int i = 0; i < MAX_ICONS; i++ )
  2687. {
  2688. oldTargets[i] = NULL;
  2689. }
  2690. target = NULL;
  2691. }
  2692. void MissionInterfaceManager::printDebugInfo()
  2693. {
  2694. if (userInput->isLeftClick() || userInput->isRightClick()) {
  2695. long row, col;
  2696. land->worldToCell(wPos, row, col);
  2697. char debugString[256];
  2698. if (target)
  2699. sprintf(debugString, "POS = %s(%c) %d,%d [%d, %d] (%.4f, %.4f, %.4f) OBJ = %s\n", terrainStr[GameMap->getTerrain(row, col)], GameMap->getPassable(row, col) ? 'T' : 'F', GlobalMoveMap[0]->calcArea(row, col), GlobalMoveMap[1]->calcArea(row, col), row, col, wPos.x, wPos.y, wPos.z, target->getName());
  2700. else
  2701. sprintf(debugString, "POS = %s(%c) %d,%d [%d, %d] (%.4f, %.4f, %.4f)\n", terrainStr[GameMap->getTerrain(row, col)], GameMap->getPassable(row, col) ? 'T' : 'F', GlobalMoveMap[0]->calcArea(row, col), GlobalMoveMap[1]->calcArea(row, col), row, col, wPos.x, wPos.y, wPos.z);
  2702. DEBUGWINS_print(debugString);
  2703. }
  2704. }
  2705. void MissionInterfaceManager::doMove(const Stuff::Vector3D& pos)
  2706. {
  2707. /*if ( controlGui.getGuardTower() )
  2708. {
  2709. doGuardTower();
  2710. return;
  2711. }*/
  2712. if ( controlGui.isAddingAirstrike() && controlGui.isButtonPressed( ControlGui::SENSOR_PROBE ))
  2713. {
  2714. // tmp hack
  2715. Stuff::Vector3D tmp = wPos;
  2716. wPos = pos;
  2717. addAirstrike( );
  2718. wPos = tmp;
  2719. return;
  2720. }
  2721. LocationNode path;
  2722. path.location = pos;
  2723. path.run = true;
  2724. path.next = NULL;
  2725. TacticalOrder tacOrder;
  2726. if ( controlGui.getJump() )
  2727. {
  2728. doJump();
  2729. return;
  2730. }
  2731. else
  2732. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_MOVETO_POINT, false);
  2733. tacOrder.initWayPath(&path);
  2734. tacOrder.moveParams.wait = false;
  2735. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  2736. if ( controlGui.getMines() )
  2737. tacOrder.moveParams.mode = MOVE_MODE_MINELAYING;
  2738. tacOrder.pack(NULL, NULL);
  2739. handleOrders(tacOrder);
  2740. soundSystem->playDigitalSample(BUTTON5);
  2741. controlGui.setDefaultSpeed();
  2742. }
  2743. bool MissionInterfaceManager::makePatrolPath()
  2744. {
  2745. Team* pTeam = Team::home;
  2746. for (long i=0;i<pTeam->getRosterSize();i++)
  2747. {
  2748. Mover* pMover = (Mover*)pTeam->getMover( i );
  2749. if ( pMover->isSelected() && pMover->getPilot()->getNumTacOrdersQueued() && pMover->getCommander()->getId() == Commander::home->getId() )
  2750. {
  2751. if ( pMover->isCloseToFirstTacOrder( wPos ) )
  2752. {
  2753. userInput->setMouseCursor( mState_LINK );
  2754. if ( commandClicked )
  2755. {
  2756. pMover->getPilot()->setTacOrderQueueLooping( true );
  2757. }
  2758. return 1;
  2759. }
  2760. else
  2761. {
  2762. Stuff::Vector3D tmp;
  2763. tmp.Subtract( wPos, pMover->getPosition() );
  2764. if ( tmp.GetLength() < 25 ) // random amount
  2765. {
  2766. userInput->setMouseCursor( mState_LINK );
  2767. if ( commandClicked )
  2768. {
  2769. doMove(wPos);
  2770. pMover->getPilot()->setTacOrderQueueLooping( true );
  2771. }
  2772. return 1;
  2773. }
  2774. }
  2775. }
  2776. }
  2777. return 0;
  2778. }
  2779. int MissionInterfaceManager::forceShot()
  2780. {
  2781. bForcedShot = true;
  2782. userInput->setMouseCursor( mState_GENERIC_ATTACK );
  2783. if ( commandClicked )
  2784. {
  2785. TacticalOrder tacOrder;
  2786. tacOrder.init(ORDER_ORIGIN_PLAYER, target ? TACTICAL_ORDER_ATTACK_OBJECT : TACTICAL_ORDER_ATTACK_POINT);
  2787. tacOrder.targetWID = target ? target->getWatchID() : 0;
  2788. if ( !target )
  2789. tacOrder.attackParams.targetPoint = wPos;
  2790. tacOrder.attackParams.type = bEnergyWeapons ? ATTACK_CONSERVING_AMMO : ATTACK_TO_DESTROY;
  2791. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  2792. tacOrder.attackParams.range = (FireRangeType)FIRERANGE_OPTIMAL;
  2793. tacOrder.attackParams.pursue = controlGui.getFireFromCurrentPos() ? false : true;
  2794. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  2795. soundSystem->playDigitalSample(BUTTON5);
  2796. if (target)
  2797. target->getAppearance()->flashBuilding(1.3f,0.2f,0xffff0000);
  2798. handleOrders( tacOrder );
  2799. return 1;
  2800. }
  2801. return 0;
  2802. }
  2803. void MissionInterfaceManager::selectForceGroup( int forceGroup, bool deselect )
  2804. {
  2805. Team* pTeam = Team::home;
  2806. bool bAllSelected = deselect ? false : true;
  2807. if ( deselect )
  2808. {
  2809. for (long i=0;i<pTeam->getRosterSize();i++)
  2810. {
  2811. Mover* pMover = (Mover*)pTeam->getMover( i );
  2812. if (pMover && pMover->isOnGUI() && (pMover->getCommander()->getId() == Commander::home->getId()))
  2813. {
  2814. pMover->setSelected( 0 );
  2815. }
  2816. }
  2817. }
  2818. else // see if the whole force group is already seleced
  2819. {
  2820. for (long i=0;i<pTeam->getRosterSize();i++)
  2821. {
  2822. Mover* pMover = (Mover*)pTeam->getMover( i );
  2823. if (pMover && pMover->isInUnitGroup( forceGroup ) && !pMover->isDisabled() && !pMover->isSelected() && pMover->isOnGUI() && (pMover->getCommander()->getId() == Commander::home->getId()))
  2824. {
  2825. bAllSelected = false;
  2826. }
  2827. }
  2828. }
  2829. for (long i=0;i<pTeam->getRosterSize();i++)
  2830. {
  2831. Mover* pMover = (Mover*)pTeam->getMover( i );
  2832. if (pMover && pMover->isInUnitGroup( forceGroup ) && !pMover->isDisabled() && pMover->isOnGUI() && (pMover->getCommander()->getId() == Commander::home->getId()))
  2833. pMover->setSelected( !bAllSelected );
  2834. }
  2835. }
  2836. void MissionInterfaceManager::makeForceGroup( int forceGroup )
  2837. {
  2838. Team* pTeam = Team::home;
  2839. for (long i=0;i<pTeam->getRosterSize();i++)
  2840. {
  2841. Mover* pMover = (Mover*)pTeam->getMover( i );
  2842. if (pMover && (pMover->getCommander()->getId() == Commander::home->getId()))
  2843. {
  2844. if ( pMover->isInUnitGroup( forceGroup ) )
  2845. pMover->removeFromUnitGroup( forceGroup );
  2846. }
  2847. }
  2848. for (i=0;i<pTeam->getRosterSize();i++)
  2849. {
  2850. Mover* pMover = (Mover*)pTeam->getMover( i );
  2851. if (pMover && (pMover->getCommander()->getId() == Commander::home->getId()))
  2852. {
  2853. if (pMover->isSelected() )
  2854. pMover->addToUnitGroup( forceGroup );
  2855. }
  2856. }
  2857. }
  2858. bool MissionInterfaceManager::moveCameraAround( bool lineOfSight, bool passable, bool ctrl, bool bGui,
  2859. long moverCount, long nonMoverCount )
  2860. {
  2861. bool bRetVal = 0;
  2862. bool middleClicked = (!userInput->isLeftDrag() && !userInput->isRightDrag() && userInput->isMiddleClick());
  2863. if ( (useLeftRightMouseProfile && ((userInput->isLeftClick() && userInput->getKeyDown(KEY_T)) || userInput->isLeftDoubleClick()) && target)
  2864. || (!useLeftRightMouseProfile && userInput->isRightClick() && !userInput->isRightDrag() && target) && !bGui)
  2865. {
  2866. if (eye)
  2867. ((GameCamera *)eye)->setTarget(target);
  2868. }
  2869. if (!cameraClicked )
  2870. {
  2871. if ( mouseX <= (screenScrollLeft))
  2872. scrollLeft();
  2873. if ((mouseX >= (Environment.screenWidth - screenScrollRight)) )
  2874. scrollRight();
  2875. if ( (mouseY <= (screenScrollUp) && mouseY >= -screenScrollUp ) )
  2876. scrollUp();
  2877. if ( (mouseY >= (Environment.screenHeight - screenScrollDown) ) )
  2878. scrollDown();
  2879. }
  2880. if (attilaXAxis < -ATTILA_THRESHOLD)
  2881. {
  2882. float oldScrollInc = scrollInc;
  2883. scrollInc *= fabs(attilaXAxis) * ATTILA_FACTOR;
  2884. scrollLeft();
  2885. scrollInc = oldScrollInc;
  2886. }
  2887. if (attilaXAxis > ATTILA_THRESHOLD)
  2888. {
  2889. float oldScrollInc = scrollInc;
  2890. scrollInc *= fabs(attilaXAxis) * ATTILA_FACTOR;
  2891. scrollRight();
  2892. scrollInc = oldScrollInc;
  2893. }
  2894. if (attilaYAxis < -ATTILA_THRESHOLD)
  2895. {
  2896. float oldScrollInc = scrollInc;
  2897. scrollInc *= fabs(attilaYAxis) * ATTILA_FACTOR;
  2898. scrollUp();
  2899. scrollInc = oldScrollInc;
  2900. }
  2901. if (attilaYAxis > ATTILA_THRESHOLD)
  2902. {
  2903. float oldScrollInc = scrollInc;
  2904. scrollInc *= fabs(attilaYAxis) * ATTILA_FACTOR;
  2905. scrollDown();
  2906. scrollInc = oldScrollInc;
  2907. }
  2908. if (attilaRZAxis < -ATTILA_THRESHOLD)
  2909. {
  2910. eye->rotateLeft(rotationInc * fabs(attilaRZAxis) * frameLength * ATTILA_ROTATION_FACTOR);
  2911. }
  2912. if (attilaRZAxis > ATTILA_THRESHOLD)
  2913. {
  2914. eye->rotateRight(rotationInc * fabs(attilaRZAxis) * frameLength * ATTILA_ROTATION_FACTOR);
  2915. }
  2916. //------------------------------------------------
  2917. // Right drag is camera rotation and tilt now.
  2918. if (cameraClicked)
  2919. {
  2920. bRetVal = 1;
  2921. long mouseXDelta = userInput->getMouseXDelta();
  2922. float actualRot = rotationInc * 0.1f * abs(mouseXDelta);
  2923. if (mouseXDelta > 0)
  2924. {
  2925. eye->rotateRight(actualRot);
  2926. bRetVal = 1;
  2927. }
  2928. else if (mouseXDelta < 0)
  2929. {
  2930. eye->rotateLeft(actualRot);
  2931. bRetVal = 1;
  2932. }
  2933. long mouseYDelta = userInput->getMouseYDelta();
  2934. float actualTilt = rotationInc * 0.1f * abs(mouseYDelta);
  2935. if (mouseYDelta > 0)
  2936. {
  2937. eye->tiltDown(actualTilt);
  2938. bRetVal = 1;
  2939. }
  2940. else if (mouseYDelta < 0)
  2941. {
  2942. eye->tiltUp(actualTilt);
  2943. bRetVal = 1;
  2944. }
  2945. userInput->setMouseCursor( mState_ROTATE_CAMERA );
  2946. //--------------------------------------------------
  2947. // Zoom Camera based on Mouse Wheel input.
  2948. long mouseWheelDelta = userInput->getMouseWheelDelta();
  2949. if (mouseWheelDelta)
  2950. {
  2951. //Mouse wheel just picks zooms now.
  2952. //float actualZoom = zoomInc * abs(mouseWheelDelta) * 0.0001f * eye->getScaleFactor();
  2953. if (mouseWheelDelta > 0)
  2954. {
  2955. zoomChoiceOut();
  2956. }
  2957. else
  2958. {
  2959. zoomChoiceIn();
  2960. }
  2961. if ( target )
  2962. userInput->setMouseCursor( makeTargetCursor( lineOfSight, moverCount, nonMoverCount ) );
  2963. else
  2964. userInput->setMouseCursor( makeNoTargetCursor( passable, lineOfSight, ctrl, bGui, moverCount, nonMoverCount ) );
  2965. bRetVal = 1;
  2966. }
  2967. return bRetVal;
  2968. }
  2969. //--------------------------------------------------
  2970. // Zoom Camera based on Mouse Wheel input.
  2971. long mouseWheelDelta = userInput->getMouseWheelDelta();
  2972. if (mouseWheelDelta)
  2973. {
  2974. //Mouse wheel just picks zooms now.
  2975. //float actualZoom = zoomInc * abs(mouseWheelDelta) * 0.0001f * eye->getScaleFactor();
  2976. if (mouseWheelDelta > 0)
  2977. {
  2978. zoomChoiceOut();
  2979. }
  2980. else
  2981. {
  2982. zoomChoiceIn();
  2983. }
  2984. if ( target )
  2985. userInput->setMouseCursor( makeTargetCursor( lineOfSight, moverCount, nonMoverCount ) );
  2986. else
  2987. userInput->setMouseCursor( makeNoTargetCursor( passable, lineOfSight, ctrl, bGui, moverCount, nonMoverCount ) );
  2988. bRetVal = 1;
  2989. }
  2990. //-----------------------------------------------------------------
  2991. // If middle mouse button is pressed, go to normal tilt, 50% zoom
  2992. if (middleClicked)
  2993. {
  2994. cameraNormal();
  2995. }
  2996. doDrag(bGui);
  2997. return bRetVal;
  2998. }
  2999. bool MissionInterfaceManager::canJump()
  3000. {
  3001. bool canJump = true;
  3002. long i=0;
  3003. Team* pTeam = Team::home;
  3004. while ((i<pTeam->getRosterSize()))
  3005. {
  3006. Mover* pMover = (Mover*)pTeam->getMover( i );
  3007. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  3008. {
  3009. if ( !pMover->canJump() )
  3010. {
  3011. canJump = false;
  3012. break;
  3013. }
  3014. }
  3015. i++;
  3016. }
  3017. return canJump;
  3018. }
  3019. bool MissionInterfaceManager::canJumpToWPos()
  3020. {
  3021. bool passable = 0;
  3022. if ( Terrain::IsGameSelectTerrainPosition( wPos ) )
  3023. {
  3024. long cellR, cellC;
  3025. land->worldToCell(wPos, cellR, cellC);
  3026. passable = GameMap->getPassable(cellR,cellC);
  3027. }
  3028. if (passable)
  3029. {
  3030. bool canJump = true;
  3031. long i=0;
  3032. Team* pTeam = Team::home;
  3033. while ((i<pTeam->getRosterSize()))
  3034. {
  3035. Mover* pMover = (Mover*)pTeam->getMover( i );
  3036. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  3037. {
  3038. if ( pMover->canJump() )
  3039. {
  3040. TacticalOrder lastQueuedTacOrder;
  3041. long err = pMover->getPilot()->peekQueuedTacOrder(-1, &lastQueuedTacOrder);
  3042. Stuff::Vector3D lastWayPoint;
  3043. if (err)
  3044. lastWayPoint = pMover->getPosition();
  3045. else
  3046. lastWayPoint = lastQueuedTacOrder.getWayPoint(0);
  3047. Stuff::Vector3D distance;
  3048. distance.Subtract(lastWayPoint,wPos);
  3049. //JUMP distance is always JUST horizontal. NO Vertical!!
  3050. distance.z = 0.0f;
  3051. float dist = distance.GetLength();
  3052. if (dist > pMover->getJumpRange())
  3053. canJump = false;
  3054. }
  3055. else
  3056. canJump = false;
  3057. }
  3058. i++;
  3059. }
  3060. return canJump;
  3061. }
  3062. return 0;
  3063. }
  3064. void MissionInterfaceManager::doDrag(bool bGui)
  3065. {
  3066. //---------------------------------------------------------------------------
  3067. // Check if we wanted to select all visible. If so, do it!
  3068. // if ( ((GetAsyncKeyState( VK_LBUTTON ))) && !bGui && !cameraClicked )
  3069. if ( ((gos_GetKeyStatus( KEY_LMOUSE ) == KEY_PRESSED)) && !bGui && !cameraClicked
  3070. && !dragStart.x)
  3071. {
  3072. dragStart.x = wPos.x;
  3073. dragStart.y = wPos.y;
  3074. dragStart.z = wPos.z;
  3075. isDragging = 0;
  3076. }
  3077. else if ((gos_GetKeyStatus( KEY_LMOUSE ) == KEY_HELD)
  3078. && !isDragging && ( !(dragStart.x == 0.f && dragStart.y == 0.f )
  3079. && (dragStart.x != wPos.x && dragStart.y != wPos.y ) ) )
  3080. {
  3081. isDragging = TRUE;
  3082. dragEnd.x = mouseX;
  3083. dragEnd.y = mouseY;
  3084. }
  3085. else if (isDragging)
  3086. {
  3087. dragEnd.x = mouseX;
  3088. dragEnd.y = mouseY;
  3089. if ( (gos_GetKeyStatus( KEY_LMOUSE ) == KEY_RELEASED
  3090. || gos_GetKeyStatus( KEY_LMOUSE ) == KEY_FREE) && isDragging)
  3091. {
  3092. //----------------------------------------------
  3093. // We should select everything in the drag box.
  3094. // AND deselect anything outside of it.
  3095. GameObject* objsInRect[MAX_ICONS];
  3096. int count = 0;
  3097. memset( objsInRect, 0, sizeof( GameObject* ) * 16 );
  3098. for (long i=0;i<ObjectManager->getNumMovers();i++)
  3099. {
  3100. Stuff::Vector3D screenStart;
  3101. Stuff::Vector4D screenPos;
  3102. eye->projectZ( dragStart, screenPos );
  3103. screenStart.x = screenPos.x;
  3104. screenStart.y = screenPos.y;
  3105. GameObjectPtr mover = ObjectManager->getMover(i);
  3106. if (ObjectManager->moverInRect(i,screenStart,dragEnd) &&
  3107. mover->getCommanderId() == Commander::home->getId() &&
  3108. count < MAX_ICONS
  3109. && !mover->isDisabled())
  3110. {
  3111. objsInRect[count] = mover;
  3112. count++;
  3113. }
  3114. }
  3115. if ( count )
  3116. {
  3117. // empty the info window of any previously selected guys
  3118. controlGui.setInfoWndMover( NULL );
  3119. if ( !userInput->shift() )
  3120. {
  3121. for (i=0;i<ObjectManager->getNumMovers();i++)
  3122. {
  3123. ObjectManager->getMover(i)->setSelected( 0 );
  3124. }
  3125. }
  3126. for ( i = 0; i < count; i ++ )
  3127. {
  3128. objsInRect[i]->setSelected( true );
  3129. }
  3130. if ( count == 1 )
  3131. (controlGui).setInfoWndMover( (Mover*)objsInRect[0] );
  3132. }
  3133. dragStart.Zero();
  3134. dragEnd.Zero();
  3135. isDragging = FALSE;
  3136. }
  3137. }
  3138. else if ( gos_GetKeyStatus(KEY_LMOUSE) == KEY_RELEASED )
  3139. {
  3140. dragStart.Zero();
  3141. }
  3142. }
  3143. bool MissionInterfaceManager::canAddVehicle( const Stuff::Vector3D& pos )
  3144. {
  3145. //We're probably going to use this alot!
  3146. long commanderID = Commander::home->getId();
  3147. if ( paintingVtol[commanderID] )
  3148. return 0;
  3149. long tileI, tileJ;
  3150. land->worldToTile( pos, tileJ, tileI );
  3151. if ( tileJ > -1 && tileJ < land->realVerticesMapSide
  3152. && tileI > -1 && tileI < land->realVerticesMapSide )
  3153. {
  3154. if ( Team::home->teamLineOfSight(pos, 0.0f) )
  3155. {
  3156. if ( GameMap->getPassable( pos )
  3157. && (!land->getWater((Stuff::Vector3D)pos) ) )
  3158. return true;
  3159. else
  3160. return false;
  3161. }
  3162. }
  3163. return false;
  3164. }
  3165. bool MissionInterfaceManager::canRecover( const Stuff::Vector3D& pos )
  3166. {
  3167. //We're probably going to use this alot!
  3168. long commanderID = Commander::home->getId();
  3169. if ( paintingVtol[commanderID] )
  3170. return 0;
  3171. long tileI, tileJ;
  3172. land->worldToTile( pos, tileJ, tileI );
  3173. if ( tileJ > -1 && tileJ < land->realVerticesMapSide
  3174. && tileI > -1 && tileI < land->realVerticesMapSide )
  3175. {
  3176. if ( Team::home->teamLineOfSight(pos, 0.0f) )
  3177. {
  3178. if ( target && (target->getObjectClass() == BATTLEMECH) && target->isDisabled() && !target->isDestroyed() )
  3179. return true;
  3180. else
  3181. return false;
  3182. }
  3183. }
  3184. return false;
  3185. }
  3186. long MissionInterfaceManager::makeTargetCursor( bool lineOfSight, long moverCount, long nonMoverCount)
  3187. {
  3188. //We're probably going to use this alot!
  3189. long commanderID = Commander::home->getId();
  3190. long currentCursor = makeRangeCursor( lineOfSight );
  3191. if ( !moverCount && !nonMoverCount )
  3192. currentCursor = mState_NORMAL;
  3193. if ( ( userInput->getKeyDown( WAYPOINT_KEY ) ) )
  3194. {
  3195. currentCursor = mState_DONT;
  3196. return currentCursor;
  3197. }
  3198. if ( controlGui.isSelectingInfoObject() )
  3199. {
  3200. if ( target->isMover() )
  3201. {
  3202. currentCursor = mState_INFO;
  3203. }
  3204. else
  3205. currentCursor = mState_DONT;
  3206. return currentCursor;
  3207. }
  3208. else if ( controlGui.isAddingVehicle() && !paintingVtol[commanderID] )
  3209. {
  3210. currentCursor = mState_DONT;
  3211. return currentCursor;
  3212. }
  3213. else if ( controlGui.isAddingSalvage() && !paintingVtol[commanderID] )
  3214. {
  3215. if ( canSalvage(target) )
  3216. {
  3217. currentCursor = mState_SALVAGE;
  3218. target->setTargeted(true);
  3219. }
  3220. else
  3221. currentCursor = mState_XSALVAGE;
  3222. return currentCursor;
  3223. }
  3224. else if ( controlGui.isAddingAirstrike() && !paintingVtol[commanderID] )
  3225. {
  3226. if ( controlGui.getButton( ControlGui::SENSOR_PROBE )->state == ControlButton::PRESSED )
  3227. {
  3228. currentCursor = lineOfSight ? mState_SENSORSTRIKE : mState_UNCERTAIN_AIRSTRIKE ;
  3229. }
  3230. else
  3231. {
  3232. currentCursor = lineOfSight ? mState_AIRSTRIKE : mState_UNCERTAIN_AIRSTRIKE ;
  3233. }
  3234. return currentCursor;
  3235. }
  3236. else if ( controlGui.getSalvage() )
  3237. {
  3238. if ( canSalvage( target ) )
  3239. {
  3240. currentCursor = mState_SALVAGE;
  3241. target->setTargeted(true);
  3242. }
  3243. else
  3244. currentCursor = mState_XSALVAGE;
  3245. return currentCursor;
  3246. }
  3247. else if ( controlGui.getRepair() )
  3248. {
  3249. if ( canRepair( target ) )
  3250. currentCursor = mState_REPAIR;
  3251. else
  3252. currentCursor = mState_XREPAIR;
  3253. if (target)
  3254. target->setTargeted(true);
  3255. return currentCursor;
  3256. }
  3257. else if ( controlGui.getMines() )
  3258. {
  3259. currentCursor = mState_DONT;
  3260. return currentCursor;
  3261. }
  3262. else if ( controlGui.getGuardTower() )
  3263. {
  3264. currentCursor = lineOfSight ? mState_GUARDTOWER_LOS : mState_GUARDTOWER;
  3265. return currentCursor;
  3266. }
  3267. else if ( target->isCaptureable(Team::home->getId() ) && moverCount )
  3268. {
  3269. for ( int i = 0; i < Team::home->getRosterSize(); i++ )
  3270. {
  3271. Mover* pMvr = Team::home->getMover( i );
  3272. if ( pMvr->isSelected() && pMvr->getCommander()->getId() == Commander::home->getId() )
  3273. {
  3274. if ((pMvr->getObjectClass() == BATTLEMECH) &&
  3275. (pMvr->getMoveType() == MOVETYPE_GROUND))
  3276. {
  3277. if ( target->getCaptureBlocker( pMvr) )
  3278. {
  3279. currentCursor = mState_XCAPTURE;
  3280. break;
  3281. }
  3282. else
  3283. {
  3284. currentCursor = mState_CAPTURE;
  3285. }
  3286. }
  3287. else
  3288. {
  3289. currentCursor = mState_XCAPTURE;
  3290. }
  3291. }
  3292. }
  3293. }
  3294. switch (target->getObjectClass())
  3295. {
  3296. case BATTLEMECH:
  3297. case GROUNDVEHICLE:
  3298. case ELEMENTAL:
  3299. {
  3300. //---------------------------------------------------------------------------------------
  3301. // if target is enemy battleMech, select it, change cursor and check below for leftClick
  3302. if (target->getTeam() && !target->getTeam()->isFriendly(Team::home) && !target->getTeam()->isNeutral( Team::home ) )
  3303. {
  3304. target->setTargeted(true);
  3305. if ( target->isDisabled() )
  3306. {
  3307. currentCursor = mState_NORMAL;
  3308. // target = NULL;
  3309. }
  3310. }
  3311. else
  3312. {
  3313. //-------------------------------------------------------------------
  3314. // Otherwise we over a friendly. Assume we intend to select them if
  3315. // we click. If we shift-click, just add them.
  3316. target->setTargeted(true); //For friendlies, let us know we need to draw their names!
  3317. currentCursor = mState_NORMAL;
  3318. controlGui.setRolloverHelpText( IDS_UNIT_SELECT_HELP );
  3319. }
  3320. }
  3321. break;
  3322. case BUILDING:
  3323. case TREEBUILDING:
  3324. case TURRET:
  3325. case GATE:
  3326. case TREE:
  3327. case TERRAINOBJECT:
  3328. {
  3329. if ( target->getObjectType()->getSubType() == BUILDING_SUBTYPE_LANDBRIDGE )
  3330. {
  3331. //Check if forcing fire or fire from current. If so, shoot away.
  3332. if ( gos_GetKeyStatus( (gosEnum_KeyIndex)commands[FORCE_FIRE_KEY].key ) == KEY_HELD ||
  3333. controlGui.getFireFromCurrentPos() )
  3334. {
  3335. target->setTargeted(true);
  3336. }
  3337. else
  3338. {
  3339. target = NULL;
  3340. // find out if this position is passable. Landbridges kinda are, or they'd be useless.
  3341. long cellR, cellC;
  3342. bool passable = 1;
  3343. bool lineOfSight = 0;
  3344. if ( Terrain::IsGameSelectTerrainPosition( wPos ) )
  3345. {
  3346. land->worldToCell(wPos, cellR, cellC);
  3347. passable = GameMap->getPassable(cellR, cellC);
  3348. }
  3349. return makeNoTargetCursor( passable, lineOfSight, 0, 0, moverCount, nonMoverCount );
  3350. }
  3351. }
  3352. //------------------------------------------------------------------
  3353. // No matter what side this is on, change the cursor and select.
  3354. target->setTargeted(true);
  3355. TeamPtr targetTeam = target->getTeam();
  3356. if ( targetTeam && Team::home->isFriendly( targetTeam ) &&
  3357. target->getFlag(OBJECT_FLAG_CANREFIT) && target->getFlag(OBJECT_FLAG_MECHBAY) )
  3358. {
  3359. if (canRepairBay(target))
  3360. {
  3361. currentCursor = mState_REPAIR;
  3362. }
  3363. else
  3364. {
  3365. currentCursor = mState_XREPAIR;
  3366. }
  3367. }
  3368. else if ( targetTeam && !controlGui.getGuard() &&
  3369. Team::home->isFriendly( targetTeam ) &&
  3370. gos_GetKeyStatus( (gosEnum_KeyIndex)commands[FORCE_FIRE_KEY].key ) != KEY_HELD // not forcing fire
  3371. && controlGui.getCurrentRange() == FIRERANGE_OPTIMAL ) // range attacks now are force fire
  3372. {
  3373. return makeNoTargetCursor( false, lineOfSight, 0, 0, moverCount, nonMoverCount );
  3374. }
  3375. }
  3376. break;
  3377. case BRIDGE:
  3378. target = NULL;
  3379. return makeNoTargetCursor( false, lineOfSight, 0, 0, moverCount, nonMoverCount );
  3380. break;
  3381. case DEBRIS:
  3382. {
  3383. //----------------------------------
  3384. // Do nothing for Debris right now.
  3385. }
  3386. break;
  3387. }
  3388. if ( controlGui.getGuard() )
  3389. {
  3390. currentCursor = mState_GUARD;
  3391. if (target)
  3392. target->setTargeted(true);
  3393. }
  3394. else if ( gos_GetKeyStatus( (gosEnum_KeyIndex)commands[FORCE_FIRE_KEY].key ) == KEY_HELD
  3395. || ( controlGui.getCurrentRange() != FIRERANGE_OPTIMAL && controlGui.getCurrentRange() != FIRERANGE_CURRENT ) )
  3396. {
  3397. currentCursor = makeRangeCursor( lineOfSight );
  3398. }
  3399. return currentCursor;
  3400. }
  3401. long MissionInterfaceManager::makeRangeCursor( bool lineOfSight)
  3402. {
  3403. long currentCursor = mState_NORMAL;
  3404. long currentRange = controlGui.getCurrentRange();
  3405. if ( bEnergyWeapons )
  3406. return lineOfSight ? mState_ENERGY_WEAPONS_LOS : mState_ENERGY_WEAPONS;
  3407. switch( currentRange )
  3408. {
  3409. case FIRERANGE_SHORT:
  3410. currentCursor = lineOfSight ? mState_SHRTRNG_LOS : mState_SHRTRNG_ATTACK;
  3411. break;
  3412. case FIRERANGE_MEDIUM:
  3413. currentCursor = lineOfSight ? mState_MEDRNG_LOS : mState_MEDRNG_ATTACK;
  3414. break;
  3415. case FIRERANGE_LONG:
  3416. currentCursor = lineOfSight ? mState_LONGRNG_LOS : mState_LONGRNG_ATTACK;
  3417. break;
  3418. case FIRERANGE_OPTIMAL:
  3419. currentCursor = lineOfSight ? mState_ATTACK_LOS : mState_GENERIC_ATTACK;
  3420. break;
  3421. case FIRERANGE_CURRENT:
  3422. currentCursor = lineOfSight ? mState_CURPOS_ATTACK_LOS : mState_CURPOS_ATTACK;
  3423. break;
  3424. }
  3425. if ( controlGui.getFireFromCurrentPos() )
  3426. currentCursor = lineOfSight ? mState_CURPOS_ATTACK_LOS : mState_CURPOS_ATTACK;
  3427. return currentCursor;
  3428. }
  3429. long MissionInterfaceManager::makeNoTargetCursor( bool passable, bool lineOfSight, bool bCtrl, bool bGui,
  3430. long moverCount, long nonMoverCount )
  3431. {
  3432. //-------------------------------------------------------------------------
  3433. // We are not over enything. Switch to move cursor based on input.
  3434. // If we are on passable terrain, move.
  3435. // If passable and runCommand, run.
  3436. // If passable and jumpCommand and canJump, jump.
  3437. // If not passable, dont.
  3438. // If passable and jumpCommand and cantJump, dont.
  3439. //We're probably going to use this alot!
  3440. long commanderID = Commander::home->getId();
  3441. int cursorType = makeMoveCursor( lineOfSight );
  3442. if ( !moverCount )
  3443. cursorType = mState_NORMAL;
  3444. if ( gos_GetKeyStatus( (gosEnum_KeyIndex)commands[FORCE_FIRE_KEY].key ) == KEY_HELD // not forcing fire
  3445. || controlGui.getFireFromCurrentPos() )
  3446. {
  3447. return makeRangeCursor( lineOfSight );
  3448. }
  3449. if ( !passable && !selectionIsHelicopters() )
  3450. cursorType = mState_DONT;
  3451. if ( controlGui.isSelectingInfoObject() )
  3452. {
  3453. cursorType = mState_DONT;
  3454. return cursorType;
  3455. }
  3456. else if ( controlGui.isAddingAirstrike() && !paintingVtol[commanderID] )
  3457. {
  3458. if ( bGui && (!controlGui.isOverTacMap() || !controlGui.isButtonPressed( ControlGui::SENSOR_PROBE)) )
  3459. cursorType = mState_NORMAL;
  3460. else
  3461. {
  3462. if ( controlGui.getButton( ControlGui::SENSOR_PROBE )->state == ControlButton::PRESSED )
  3463. {
  3464. cursorType = lineOfSight ? mState_SENSORSTRIKE : mState_UNCERTAIN_AIRSTRIKE ;
  3465. }
  3466. else
  3467. cursorType = lineOfSight ? mState_AIRSTRIKE : mState_UNCERTAIN_AIRSTRIKE;
  3468. }
  3469. return cursorType;
  3470. }
  3471. else if ( controlGui.isAddingVehicle() )
  3472. {
  3473. if ( canAddVehicle( wPos ) && !bGui)
  3474. cursorType = mState_VEHICLE;
  3475. else if ( !paintingVtol[commanderID] && ! bGui)
  3476. cursorType = mState_CANTVEHICLE;
  3477. else if ( bGui )
  3478. cursorType = mState_NORMAL;
  3479. }
  3480. else if ( controlGui.isAddingSalvage())
  3481. {
  3482. if ( canRecover( wPos ) && !bGui )
  3483. cursorType = mState_SALVAGE;
  3484. else if ( !paintingVtol[commanderID] & !bGui)
  3485. cursorType = mState_XSALVAGE;
  3486. else if ( bGui )
  3487. cursorType = mState_NORMAL;
  3488. }
  3489. else if ( userInput->getKeyDown( WAYPOINT_KEY ) || controlGui.getMines() )
  3490. {
  3491. if ( controlGui.getMines() )
  3492. {
  3493. if ( !passable )
  3494. cursorType = mState_XMINES;
  3495. else
  3496. cursorType = mState_LAYMINES;
  3497. }
  3498. else
  3499. {
  3500. cursorType = lineOfSight ? mState_WALKWAYPT_LOS : mState_WALKWAYPT;
  3501. if ( controlGui.getRun() )
  3502. cursorType = lineOfSight ? mState_RUNWAYPT_LOS : mState_RUNWAYPT;
  3503. else if ( controlGui.getJump() )
  3504. cursorType = lineOfSight ? mState_JUMPWAYPT_LOS: mState_JUMPWAYPT;
  3505. }
  3506. return cursorType;
  3507. }
  3508. else if ( controlGui.getJump() )
  3509. {
  3510. if ( canJumpToWPos() )
  3511. {
  3512. if ( bCtrl )
  3513. cursorType = lineOfSight ? mState_JUMPWAYPT_LOS : mState_JUMPWAYPT;
  3514. else
  3515. cursorType = makeJumpCursor( lineOfSight );
  3516. controlGui.setRolloverHelpText( IDS_UNIT_HELP );
  3517. }
  3518. else
  3519. cursorType = mState_DONT;
  3520. if ( !passable && !selectionIsHelicopters() )
  3521. cursorType = mState_DONT;
  3522. }
  3523. else if ( controlGui.getRun() && moverCount )
  3524. {
  3525. if ( bCtrl )
  3526. cursorType = lineOfSight ? mState_RUNWAYPT_LOS : mState_RUNWAYPT;
  3527. else
  3528. cursorType = makeRunCursor( lineOfSight );
  3529. if ( !passable && !selectionIsHelicopters() )
  3530. cursorType = mState_DONT;
  3531. else
  3532. controlGui.setRolloverHelpText( IDS_UNIT_HELP );
  3533. }
  3534. else if ( controlGui.getMines() )
  3535. {
  3536. cursorType = mState_LAYMINES;
  3537. if ( !passable )
  3538. cursorType = mState_XMINES;
  3539. }
  3540. else if ( controlGui.getSalvage() )
  3541. {
  3542. cursorType = makeMoveCursor( lineOfSight );
  3543. if ( !passable )
  3544. cursorType = mState_DONT;
  3545. }
  3546. else if ( controlGui.getRepair() )
  3547. {
  3548. cursorType = makeMoveCursor( lineOfSight );
  3549. if ( !passable )
  3550. cursorType = mState_DONT;
  3551. }
  3552. else if ( controlGui.getGuard() )
  3553. {
  3554. cursorType = lineOfSight ? mState_GUARD_LOS : mState_GUARD;
  3555. if ( !passable )
  3556. cursorType = mState_DONT;
  3557. }
  3558. else if ( controlGui.getGuardTower() )
  3559. {
  3560. cursorType = lineOfSight ? mState_GUARDTOWER_LOS : mState_GUARDTOWER;
  3561. }
  3562. else if ( moverCount )
  3563. {
  3564. controlGui.setRolloverHelpText( IDS_UNIT_HELP );
  3565. }
  3566. userInput->setMouseFrame(0);
  3567. return cursorType;
  3568. }
  3569. void MissionInterfaceManager::addAirstrike()
  3570. {
  3571. if ( controlGui.isButtonPressed( ControlGui::LARGE_AIRSTRIKE ) )
  3572. bigAirStrike();
  3573. else if ( controlGui.isButtonPressed( ControlGui::LARGE_AIRSTRIKE ) )
  3574. smlAirStrike();
  3575. else if ( controlGui.isButtonPressed( ControlGui::SENSOR_PROBE ) )
  3576. snsAirStrike();
  3577. else
  3578. gosASSERT( false );
  3579. controlGui.unPressAllVehicleButtons();
  3580. }
  3581. //-----------------------------------------------------------------------------
  3582. MoverPtr BringInReinforcement (long vehicleID, long rosterIndex, long commanderID, Stuff::Vector3D pos, bool exists) {
  3583. MoverInitData data;
  3584. memset( &data, 0, sizeof( data ) );
  3585. char* vehicleFile = (char*)MissionInterfaceManager::instance()->getSupportVehicleNameFromID(vehicleID);
  3586. if (!vehicleFile) {
  3587. char s[1024];
  3588. sprintf(s, "BringInReinforcement: null behicleFile (%d)", vehicleID);
  3589. STOP((s));
  3590. //return(NULL);
  3591. }
  3592. strcpy( data.pilotFileName, vehicleFile );
  3593. strcpy( data.brainFileName, "pbrain" );
  3594. data.controlType = 2;
  3595. data.controlDataType = 2;
  3596. data.rosterIndex = rosterIndex;
  3597. data.objNumber = vehicleID;
  3598. data.position = pos;
  3599. data.rotation = 0;
  3600. data.teamID = Commander::commanders[commanderID]->team->getId();
  3601. data.commanderID = commanderID;
  3602. data.active = 1;
  3603. data.exists = exists;
  3604. data.capturable = 0;
  3605. data.baseColor = prefs.baseColor;
  3606. data.highlightColor1 = prefs.highlightColor;
  3607. data.highlightColor2 = prefs.highlightColor;
  3608. if ( MPlayer )
  3609. {
  3610. MC2Player* pInfo = MPlayer->getPlayerInfo( commanderID );
  3611. if ( pInfo )
  3612. {
  3613. data.baseColor = MPlayer->colors[pInfo->baseColor[BASECOLOR_TEAM]];
  3614. data.highlightColor1 = MPlayer->colors[pInfo->stripeColor];
  3615. data.highlightColor2 = MPlayer->colors[pInfo->stripeColor];
  3616. }
  3617. }
  3618. long moverId = mission->addMover( &data );
  3619. if ((moverId != -1) && (moverId != 0))
  3620. {
  3621. //Start the helicopters landed!!
  3622. MoverPtr newMover = (MoverPtr)ObjectManager->get(moverId);
  3623. if (!newMover)
  3624. return NULL;
  3625. if (newMover->getMoveType() == MOVETYPE_AIR)
  3626. newMover->startShutDown();
  3627. if (!MPlayer)
  3628. newMover->setLocalMoverId(0);
  3629. //Somehow this is set during a quickLoad?
  3630. newMover->disableThisFrame = false;
  3631. return(newMover);
  3632. }
  3633. return NULL;
  3634. }
  3635. //-----------------------------------------------------------------------------
  3636. void MissionInterfaceManager::addVehicle( const Stuff::Vector3D& pos )
  3637. {
  3638. // LogisticsPilot* pPilot = LogisticsData::instance->getFirstAvailablePilot();
  3639. // const char* pChar = pPilot->getFileName();
  3640. // if ( !pChar )
  3641. // return;
  3642. // Check if vehicleFile is NULL. If it is, simply get it.
  3643. // Can happen if we get here BEFORE beginVtol?
  3644. // Happens when we select a vehicle which costs exactly the number of points we have left.
  3645. // Heidi deletes the points, which shuts off the button, which causes getVehicleName to return NULL.
  3646. // D'OH!!!
  3647. // Delete the points in getVehicleName when the vehicle is actually added!!!
  3648. //
  3649. // -fs
  3650. if (!vehicleFile)
  3651. vehicleFile = controlGui.getVehicleName(vehicleID[Commander::home->getId()]);
  3652. if ( !vehicleFile )
  3653. return;
  3654. reinforcement = BringInReinforcement(vehicleID[Commander::home->getId()], 255, Commander::home->getId(), pos, true);
  3655. }
  3656. void MissionInterfaceManager::beginVtol (long supportID, long commanderID, Stuff::Vector3D* reinforcePos, MoverPtr salvageTarget)
  3657. {
  3658. Stuff::Vector3D vtolPos = wPos;
  3659. if (reinforcePos)
  3660. vtolPos = *reinforcePos;
  3661. if (supportID == -1) {
  3662. vehicleFile = controlGui.getVehicleName( vehicleID[commanderID] );
  3663. }
  3664. else
  3665. {
  3666. //-----------------------
  3667. // used in multiplayer...
  3668. vehicleID[commanderID] = supportID;
  3669. vehicleFile = controlGui.getVehicleNameFromID(supportID);
  3670. }
  3671. if (vehicleID[commanderID] == 0) {
  3672. char s[1024];
  3673. sprintf(s, "beginvtol: supportID = %d, commanderID = %d, vehicleID = %d, vehicleFile = %s", supportID, commanderID, vehicleID[commanderID], vehicleFile);
  3674. PAUSE((s));
  3675. }
  3676. if ( !vTol[commanderID] )
  3677. {
  3678. if (vehicleID[commanderID] != 147) //NOT a recovery vehicle. Standard VTOL
  3679. {
  3680. if (supportID == -1)
  3681. {
  3682. //Do not call this unless the commanderID passed in equals us or will you do something outside here?
  3683. if (MPlayer && !reinforcePos)
  3684. {
  3685. vPos[commanderID] = vtolPos;
  3686. MPlayer->sendReinforcement(vehicleID[commanderID], 255, "noone", commanderID, vPos[commanderID], 0);
  3687. return;
  3688. }
  3689. }
  3690. AppearanceType* appearanceType = appearanceTypeList->getAppearance( BLDG_TYPE << 24, "vtol" );
  3691. vTol[commanderID] = new BldgAppearance;
  3692. vTol[commanderID]->init( appearanceType );
  3693. if (!dustCloud[commanderID] && prefs.useNonWeaponEffects)
  3694. {
  3695. if (strcmp(weaponEffects->GetEffectName(VTOL_DUST_CLOUD),"NONE") != 0)
  3696. {
  3697. //--------------------------------------------
  3698. // Yes, load it on up.
  3699. unsigned flags = 0;
  3700. Check_Object(gosFX::EffectLibrary::Instance);
  3701. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(VTOL_DUST_CLOUD));
  3702. if (gosEffectSpec)
  3703. {
  3704. dustCloud[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  3705. gosASSERT(dustCloud[commanderID] != NULL);
  3706. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  3707. }
  3708. }
  3709. }
  3710. }
  3711. else //IS a recovery vehicle. DO NOT create VTOL, use KARNOV instead. NO Vehicle created either
  3712. {
  3713. if (supportID == -1)
  3714. {
  3715. if (MPlayer && !reinforcePos) //Probably same as above here, too.
  3716. {
  3717. vPos[commanderID] = vtolPos;
  3718. if (!salvageTarget)
  3719. STOP(("MissionGUI.beginvtol: null target PASSED IN."));
  3720. char* newPilotName = (char*)LogisticsData::instance->getBestPilot( salvageTarget->tonnage );
  3721. if (vehicleID[commanderID] != 147)
  3722. STOP(("missiongui.beginvtol: bad vehicleID"));
  3723. MPlayer->sendReinforcement(vehicleID[commanderID], salvageTarget->netRosterIndex, newPilotName, commanderID, vPos[commanderID], 3);
  3724. return;
  3725. }
  3726. }
  3727. AppearanceType* appearanceType = appearanceTypeList->getAppearance( BLDG_TYPE << 24, "karnov" );
  3728. vTol[commanderID] = new BldgAppearance;
  3729. vTol[commanderID]->init( appearanceType );
  3730. if (MPlayer)
  3731. mechToRecover[commanderID] = MPlayer->moverRoster[MPlayer->reinforcements[commanderID][1]];
  3732. else
  3733. mechToRecover[commanderID] = salvageTarget;
  3734. mechRecovered[commanderID] = false; //Need to know when mech is done so Karnov can fly away.
  3735. if (!dustCloud[commanderID] && prefs.useNonWeaponEffects)
  3736. {
  3737. if (strcmp(weaponEffects->GetEffectName(KARNOV_DUST_CLOUD),"NONE") != 0)
  3738. {
  3739. //--------------------------------------------
  3740. // Yes, load it on up.
  3741. unsigned flags = 0;
  3742. Check_Object(gosFX::EffectLibrary::Instance);
  3743. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(KARNOV_DUST_CLOUD));
  3744. if (gosEffectSpec)
  3745. {
  3746. dustCloud[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  3747. gosASSERT(dustCloud[commanderID] != NULL);
  3748. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  3749. }
  3750. }
  3751. }
  3752. if (!recoveryBeam[commanderID])
  3753. {
  3754. if (strcmp(weaponEffects->GetEffectName(KARNOV_RECOVERY_BEAM),"NONE") != 0)
  3755. {
  3756. //--------------------------------------------
  3757. // Yes, load it on up.
  3758. unsigned flags = 0;
  3759. Check_Object(gosFX::EffectLibrary::Instance);
  3760. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(KARNOV_RECOVERY_BEAM));
  3761. if (gosEffectSpec)
  3762. {
  3763. recoveryBeam[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  3764. gosASSERT(recoveryBeam[commanderID] != NULL);
  3765. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  3766. }
  3767. }
  3768. }
  3769. }
  3770. }
  3771. if (commanderID == Commander::home->getId())
  3772. {
  3773. switch (vehicleID[commanderID])
  3774. {
  3775. case 120: //Minelayer
  3776. soundSystem->playSupportSample(SUPPORT_MINELAYER);
  3777. break;
  3778. case 182: //Repair
  3779. soundSystem->playSupportSample(SUPPORT_REPAIR);
  3780. break;
  3781. case 393: //Scout
  3782. soundSystem->playSupportSample(SUPPORT_SCOUT);
  3783. break;
  3784. case 147: //Recovery
  3785. soundSystem->playSupportSample(SUPPORT_RECOVER);
  3786. break;
  3787. case 415: //Artillery
  3788. soundSystem->playSupportSample(SUPPORT_ARTILLERY);
  3789. break;
  3790. }
  3791. }
  3792. Stuff::Vector3D newPos = vtolPos;
  3793. float rotation = 0.f; // this needs to be pointing 180 degrees from drop point
  3794. if (vehicleID[commanderID] == 147)
  3795. {
  3796. //Move wPos to be over the cockpit of the downed mech.
  3797. if (mechToRecover[commanderID] && mechToRecover[commanderID]->appearance)
  3798. newPos = mechToRecover[commanderID]->appearance->getNodeNamePosition("cockpit");
  3799. }
  3800. if (vehicleID[commanderID] != 147)
  3801. soundSystem->playDigitalSample(VTOL_ANIMATE,newPos);
  3802. else
  3803. soundSystem->playDigitalSample(SALVAGE_CRAFT,newPos);
  3804. vTol[commanderID]->setObjectParameters( newPos, 0, false, Team::home->id, 0);
  3805. eye->update();
  3806. vTol[commanderID]->update();
  3807. vTol[commanderID]->setInView( true );
  3808. vTol[commanderID]->setVisibility( 1, 1 );
  3809. vTol[commanderID]->rotation = rotation;
  3810. if (vehicleID[commanderID] != 147)
  3811. vTol[commanderID]->setGesture(0); //Start Animation at beginning
  3812. else
  3813. vTol[commanderID]->setGesture(1); //Start Animation with Landing -- KARNOV
  3814. if (dustCloud[commanderID])
  3815. {
  3816. Stuff::LinearMatrix4D shapeOrigin;
  3817. Stuff::LinearMatrix4D localToWorld;
  3818. Stuff::LinearMatrix4D localResult;
  3819. Stuff::Vector3D dustPos = vTol[commanderID]->position;
  3820. Stuff::Point3D wakePos;
  3821. wakePos.x = -dustPos.x;
  3822. wakePos.y = dustPos.z;
  3823. wakePos.z = dustPos.y;
  3824. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  3825. shapeOrigin.BuildTranslation(wakePos);
  3826. gosFX::Effect::ExecuteInfo info((Stuff::Time)scenarioTime,&shapeOrigin,NULL);
  3827. dustCloud[commanderID]->SetLoopOff();
  3828. dustCloud[commanderID]->SetExecuteOn();
  3829. dustCloud[commanderID]->Start(&info);
  3830. }
  3831. paintingVtol[commanderID] = 1;
  3832. vTolSpeed = -75.f;
  3833. vPos[commanderID] = vtolPos;
  3834. vehicleDropped[commanderID] = false;
  3835. if ( !MPlayer || commanderID == MPlayer->commanderID )
  3836. controlGui.disableAllVehicleButtons();
  3837. }
  3838. bool MissionInterfaceManager::canSalvage( GameObject* pMover )
  3839. {
  3840. bool lineOfSight = Team::home->teamLineOfSight(pMover->getPosition(),0.0f);
  3841. return (controlGui.forceGroupBar.getIconCount() < MAX_ICONS
  3842. && target->isDisabled() && lineOfSight &&
  3843. target->getObjectClass() == BATTLEMECH ) ? 1 : 0;
  3844. }
  3845. void MissionInterfaceManager::doSalvage()
  3846. {
  3847. if ( canSalvage(target) )
  3848. {
  3849. TacticalOrder tacOrder;
  3850. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_RECOVER );
  3851. tacOrder.targetWID = target->getWatchID();
  3852. tacOrder.attackParams.type = ATTACK_NONE;
  3853. tacOrder.attackParams.method = ATTACKMETHOD_RAMMING;
  3854. tacOrder.attackParams.pursue = true;
  3855. tacOrder.moveParams.wayPath.mode[0] = TRAVEL_MODE_FAST;
  3856. handleOrders( tacOrder );
  3857. }
  3858. }
  3859. bool MissionInterfaceManager::canRepair( GameObject* pMover )
  3860. {
  3861. if ( !pMover )
  3862. return 0;
  3863. if ( !pMover->isMover() )
  3864. return 0;
  3865. if ( Team::home->isEnemy( pMover->getTeam() ) )
  3866. return 0;
  3867. if (pMover->isDisabled() || pMover->isDestroyed())
  3868. return 0;
  3869. // find the selected guy
  3870. int watchID = 0;
  3871. Team* pTeam = Team::home;
  3872. for (long i = 0; i < pTeam->getRosterSize(); i++)
  3873. {
  3874. Mover* pTmpMover = (Mover*)pTeam->getMover( i );
  3875. if ( pTmpMover->isSelected() && pTmpMover->getCommander()->getId() == Commander::home->getId() )
  3876. {
  3877. if ( !watchID )
  3878. watchID = pTmpMover->getWatchID();
  3879. else
  3880. watchID = -1;
  3881. }
  3882. }
  3883. if ( ((Mover*)pMover)->needsRefit() || ( ((Mover*)pMover)->refitBuddyWID == watchID && watchID) )
  3884. return true;
  3885. return 0;
  3886. }
  3887. void MissionInterfaceManager::doRepair(GameObject* who)
  3888. {
  3889. TacticalOrder tacOrder;
  3890. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_REFIT, false);
  3891. tacOrder.targetWID = who->getWatchID();
  3892. tacOrder.selectionIndex = -1;
  3893. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  3894. tacOrder.moveParams.faceObject = true;
  3895. tacOrder.moveParams.fromArea = -1;
  3896. tacOrder.moveParams.wait = false;
  3897. handleOrders( tacOrder );
  3898. soundSystem->playDigitalSample(BUTTON5);
  3899. controlGui.setDefaultSpeed();
  3900. }
  3901. bool MissionInterfaceManager::canRepairBay( GameObject* bay)
  3902. {
  3903. if (bay && bay->getRefitPoints() > 0.0f)
  3904. {
  3905. Team* pTeam = Team::home;
  3906. for (long i = 0; i < pTeam->getRosterSize(); i++)
  3907. {
  3908. Mover* pMover = (Mover*)pTeam->getMover( i );
  3909. if ( pMover->isSelected() && pMover->needsRefit() && pMover->getCommander()->getId() == Commander::home->getId() )
  3910. {
  3911. return true;
  3912. }
  3913. }
  3914. }
  3915. return false;
  3916. }
  3917. void MissionInterfaceManager::doRepairBay(GameObject* who)
  3918. {
  3919. TacticalOrder tacOrder;
  3920. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_GETFIXED, false);
  3921. tacOrder.targetWID = who->getWatchID();
  3922. tacOrder.selectionIndex = -1;
  3923. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  3924. tacOrder.moveParams.faceObject = true;
  3925. tacOrder.moveParams.fromArea = -1;
  3926. tacOrder.moveParams.wait = false;
  3927. handleOrders( tacOrder );
  3928. soundSystem->playDigitalSample(BUTTON5);
  3929. controlGui.setDefaultSpeed();
  3930. }
  3931. int MissionInterfaceManager::vehicleCommand()
  3932. {
  3933. if ( controlGui.getVehicleCommand() )
  3934. controlGui.setVehicleCommand( false );
  3935. else
  3936. controlGui.setVehicleCommand( true );
  3937. return 0;
  3938. }
  3939. int MissionInterfaceManager::showObjectives()
  3940. {
  3941. controlGui.startObjectives( !controlGui.objectivesStarted( ) );
  3942. return 0;
  3943. }
  3944. int MissionInterfaceManager::showObjectives(bool on)
  3945. {
  3946. controlGui.startObjectives( on );
  3947. return 0;
  3948. }
  3949. int MissionInterfaceManager::togglePause()
  3950. {
  3951. if ( !bPausedWithoutMenu )
  3952. {
  3953. bPaused ^= 1;
  3954. }
  3955. else
  3956. bPausedWithoutMenu = 0;
  3957. soundSystem->playDigitalSample( LOG_NEXTBACKBUTTONS );
  3958. if ( bPaused )
  3959. {
  3960. controlGui.beginPause();
  3961. }
  3962. else
  3963. {
  3964. controlGui.endPause();
  3965. }
  3966. return 1;
  3967. }
  3968. int MissionInterfaceManager::togglePauseWithoutMenu()
  3969. {
  3970. bPausedWithoutMenu;
  3971. if ( !bPausedWithoutMenu )
  3972. {
  3973. if ( !bPaused )
  3974. {
  3975. bPausedWithoutMenu = 1;
  3976. bPaused = 1;
  3977. return 1;
  3978. }
  3979. else
  3980. {
  3981. return 0;
  3982. }
  3983. }
  3984. else
  3985. {
  3986. gosASSERT(bPaused);
  3987. bPausedWithoutMenu = 0;
  3988. bPaused = 0;
  3989. return 1;
  3990. }
  3991. }
  3992. bool MissionInterfaceManager::isPaused()
  3993. {
  3994. return bPaused;
  3995. }
  3996. bool MissionInterfaceManager::isPausedWithoutMenu()
  3997. {
  3998. return bPausedWithoutMenu;
  3999. }
  4000. void MissionInterfaceManager::swapResolutions()
  4001. {
  4002. controlGui.swapResolutions( Environment.screenWidth );
  4003. resolution = Environment.screenWidth;
  4004. keyboardRef->init();
  4005. }
  4006. int MissionInterfaceManager::switchTab()
  4007. {
  4008. controlGui.switchTabs(1);
  4009. return 1;
  4010. }
  4011. int MissionInterfaceManager::reverseSwitchTab()
  4012. {
  4013. controlGui.switchTabs(-1);
  4014. return 1;
  4015. }
  4016. int MissionInterfaceManager::infoCommand()
  4017. {
  4018. if ( !controlGui.infoButtonPressed() )
  4019. controlGui.pressInfoButton();
  4020. return 1;
  4021. }
  4022. int MissionInterfaceManager::infoButtonReleased()
  4023. {
  4024. if ( controlGui.infoButtonPressed() )
  4025. controlGui.pressInfoButton();
  4026. return 1;
  4027. }
  4028. int MissionInterfaceManager::energyWeapons()
  4029. {
  4030. if ( gos_GetKeyStatus( (gosEnum_KeyIndex)(commands[ENERGY_WEAPON_INDEX].key & 0x0000ffff) ) == KEY_HELD )
  4031. bEnergyWeapons = 1;
  4032. else
  4033. bEnergyWeapons = 0;
  4034. return 0;
  4035. }
  4036. int MissionInterfaceManager::sendAirstrike()
  4037. {
  4038. controlGui.pressAirstrikeButton();
  4039. return 1;
  4040. }
  4041. int MissionInterfaceManager::sendLargeAirstrike()
  4042. {
  4043. controlGui.pressLargeAirstrikeButton();
  4044. return 1;
  4045. }
  4046. int MissionInterfaceManager::gotoNextNavMarker()
  4047. {
  4048. // need to find the next nav marker....
  4049. for ( CObjectives::EIterator iter = Team::home->objectives.Begin();
  4050. !iter.IsDone(); iter++ )
  4051. {
  4052. if ( (*iter)->Status(Team::home->objectives) == OS_UNDETERMINED && (*iter)->DisplayMarker() == NAV )
  4053. {
  4054. Stuff::Vector3D pos;
  4055. pos.x = (*iter)->MarkerX();
  4056. pos.y = (*iter)->MarkerY();
  4057. if ( !pos.x && !pos.y )
  4058. continue;
  4059. pos.z = land->getTerrainElevation( pos );
  4060. LocationNode path;
  4061. path.location = pos;
  4062. path.run = true;
  4063. path.next = NULL;
  4064. TacticalOrder tacOrder;
  4065. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_MOVETO_POINT, false);
  4066. tacOrder.initWayPath(&path);
  4067. tacOrder.moveParams.wait = false;
  4068. tacOrder.moveParams.wayPath.mode[0] = controlGui.getWalk() ? TRAVEL_MODE_SLOW : TRAVEL_MODE_FAST;
  4069. if ( controlGui.getMines() )
  4070. tacOrder.moveParams.mode = MOVE_MODE_MINELAYING;
  4071. tacOrder.pack(NULL, NULL);
  4072. handleOrders(tacOrder);
  4073. soundSystem->playDigitalSample(BUTTON5);
  4074. return 1;
  4075. }
  4076. }
  4077. // if we got here there weren't any valid markers, play bad sound
  4078. soundSystem->playDigitalSample( INVALID_GUI );
  4079. return 0;
  4080. }
  4081. int MissionInterfaceManager::sendSensorStrike()
  4082. {
  4083. controlGui.pressSensorStrikeButton();
  4084. return 1;
  4085. }
  4086. int MissionInterfaceManager::quickDebugInfo() {
  4087. #ifndef FINAL
  4088. static double lastTime = 0.0;
  4089. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4090. long row, col;
  4091. land->worldToCell(wPos, row, col);
  4092. char debugString[256];
  4093. if (target)
  4094. sprintf(debugString, "INFO = %s(%c%c) %d(W%d) [%d, %d] (%.4f, %.4f, %.4f) #Pth=%d(%d) OBJ = %s\n",
  4095. terrainStr[GameMap->getTerrain(row, col)],
  4096. GameMap->getPassable(row, col) ? 'T' : 'F',
  4097. GameMap->getForest(row, col) ? 'T' : 'F',
  4098. GlobalMoveMap[target->getMoveLevel()]->calcArea(row, col),
  4099. GameMap->getShallowWater(row, col) ? 1 : (GameMap->getDeepWater(row, col) ? 2 : 0),
  4100. row, col,
  4101. wPos.x, wPos.y, wPos.z,
  4102. PathManager->numPaths, PathManager->peakPaths, target->getName());
  4103. else
  4104. sprintf(debugString, "INFO = %s(%c%c) %d(W%d) [%d, %d] (%.4f, %.4f, %.4f) #Pth=%d(%d)\n",
  4105. terrainStr[GameMap->getTerrain(row, col)],
  4106. GameMap->getPassable(row, col) ? 'T' : 'F',
  4107. GameMap->getForest(row, col) ? 'T' : 'F',
  4108. GlobalMoveMap[0]->calcArea(row, col),
  4109. GameMap->getShallowWater(row, col) ? 1 : (GameMap->getDeepWater(row, col) ? 2 : 0),
  4110. row, col,
  4111. wPos.x, wPos.y, wPos.z,
  4112. PathManager->numPaths, PathManager->peakPaths);
  4113. DEBUGWINS_print(debugString);
  4114. sprintf(debugString, "REQ =");
  4115. char s[10];
  4116. for (long i = 0; i < 25; i++) {
  4117. sprintf(s, " %02d", PathManager->sourceTally[i]);
  4118. strcat(debugString, s);
  4119. }
  4120. DEBUGWINS_print(debugString);
  4121. lastTime = gos_GetElapsedTime();
  4122. }
  4123. #endif
  4124. return(1);
  4125. }
  4126. int MissionInterfaceManager::setGameObjectWindow() {
  4127. #ifndef FINAL
  4128. static double lastTime = 0.0;
  4129. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4130. DEBUGWINS_setGameObject(-1, target);
  4131. lastTime = gos_GetElapsedTime();
  4132. }
  4133. #endif
  4134. return(1);
  4135. }
  4136. int MissionInterfaceManager::pageGameObjectWindow1() {
  4137. #ifndef FINAL
  4138. static double lastTime = 0.0;
  4139. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4140. if (DebugGameObject[0] && DebugGameObject[0]->isMover())
  4141. ((MoverPtr)DebugGameObject[0])->debugPage++;
  4142. lastTime = gos_GetElapsedTime();
  4143. }
  4144. #endif
  4145. return(1);
  4146. }
  4147. int MissionInterfaceManager::pageGameObjectWindow2() {
  4148. #ifndef FINAL
  4149. static double lastTime = 0.0;
  4150. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4151. if (DebugGameObject[1] && DebugGameObject[1]->isMover())
  4152. ((MoverPtr)DebugGameObject[1])->debugPage++;
  4153. lastTime = gos_GetElapsedTime();
  4154. }
  4155. #endif
  4156. return(1);
  4157. }
  4158. int MissionInterfaceManager::pageGameObjectWindow3() {
  4159. #ifndef FINAL
  4160. static double lastTime = 0.0;
  4161. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4162. if (DebugGameObject[2] && DebugGameObject[2]->isMover())
  4163. ((MoverPtr)DebugGameObject[2])->debugPage++;
  4164. lastTime = gos_GetElapsedTime();
  4165. }
  4166. #endif
  4167. return(1);
  4168. }
  4169. int MissionInterfaceManager::rotateObjectLeft () {
  4170. #ifndef FINAL
  4171. static double lastTime = 0.0;
  4172. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4173. if (target)
  4174. target->rotate(4.0);
  4175. lastTime = gos_GetElapsedTime();
  4176. }
  4177. #endif
  4178. return(1);
  4179. }
  4180. int MissionInterfaceManager::rotateObjectRight () {
  4181. #ifndef FINAL
  4182. static double lastTime = 0.0;
  4183. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4184. if (target)
  4185. target->rotate(-4.0);
  4186. lastTime = gos_GetElapsedTime();
  4187. }
  4188. #endif
  4189. return(1);
  4190. }
  4191. int MissionInterfaceManager::jumpToDebugGameObject1() {
  4192. #ifndef FINAL
  4193. DEBUGWINS_viewGameObject(0);
  4194. #endif
  4195. return(1);
  4196. }
  4197. int MissionInterfaceManager::jumpToDebugGameObject2() {
  4198. #ifndef FINAL
  4199. DEBUGWINS_viewGameObject(1);
  4200. #endif
  4201. return(1);
  4202. }
  4203. int MissionInterfaceManager::jumpToDebugGameObject3() {
  4204. #ifndef FINAL
  4205. DEBUGWINS_viewGameObject(2);
  4206. #endif
  4207. return(1);
  4208. }
  4209. int MissionInterfaceManager::toggleDebugWins() {
  4210. #ifndef FINAL
  4211. static long debugWinsState = 0;
  4212. static double lastTime = 0.0;
  4213. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4214. debugWinsState = (++debugWinsState % 6);
  4215. bool debugStateFlags[6][7] = {
  4216. {false, false, false, false, false, false, false},
  4217. {false, false, false, false, false, true, false},
  4218. {false, false, false, false, false, true, true},
  4219. {false, true, true, true, false, true, true},
  4220. {true, true, true, true, false, true, true},
  4221. {false, false, false, false, true, false, true}
  4222. };
  4223. DEBUGWINS_display(debugStateFlags[debugWinsState]);
  4224. lastTime = gos_GetElapsedTime();
  4225. }
  4226. #endif
  4227. return(1);
  4228. }
  4229. extern bool ShowMovers;
  4230. int MissionInterfaceManager::showMovers() {
  4231. #ifndef FINAL
  4232. static double lastTime = 0.0;
  4233. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4234. ShowMovers = !ShowMovers;
  4235. lastTime = gos_GetElapsedTime();
  4236. }
  4237. #endif
  4238. return(1);
  4239. }
  4240. int MissionInterfaceManager::cullPathAreas () {
  4241. #ifndef FINAL
  4242. static double lastTime = 0.0;
  4243. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4244. CullPathAreas = !CullPathAreas;
  4245. lastTime = gos_GetElapsedTime();
  4246. }
  4247. #endif
  4248. return(1);
  4249. }
  4250. int MissionInterfaceManager::zeroHPrime() {
  4251. static double lastTime = 0.0;
  4252. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4253. ZeroHPrime = !ZeroHPrime;
  4254. lastTime = gos_GetElapsedTime();
  4255. }
  4256. return(1);
  4257. }
  4258. int MissionInterfaceManager::calcValidAreaTable() {
  4259. static double lastTime = 0.0;
  4260. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4261. CalcValidAreaTable = !CalcValidAreaTable;
  4262. lastTime = gos_GetElapsedTime();
  4263. }
  4264. return(1);
  4265. }
  4266. int MissionInterfaceManager::teleport() {
  4267. #ifndef FINAL
  4268. static double lastTime = 0.0;
  4269. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4270. Team* pTeam = Team::home;
  4271. Stuff::Vector3D moveGoals[MAX_MOVERS];
  4272. long numMovers = 0;
  4273. for (long i = 0; i < pTeam->getRosterSize(); i++) {
  4274. Mover* mover = pTeam->getMover(i);
  4275. if (mover->isSelected() && mover->getCommander()->getId() == Commander::home->getId())
  4276. numMovers++;
  4277. }
  4278. MoverGroup::calcMoveGoals(wPos, numMovers, moveGoals);
  4279. numMovers = 0;
  4280. for (i = 0; i < pTeam->getRosterSize(); i++) {
  4281. Mover* mover = (Mover*)pTeam->getMover( i );
  4282. if (mover->isSelected() && mover->getCommander()->getId() == Commander::home->getId() )
  4283. ((MoverPtr)mover)->setTeleportPosition(moveGoals[numMovers++]);
  4284. }
  4285. lastTime = gos_GetElapsedTime();
  4286. }
  4287. #endif
  4288. return(1);
  4289. }
  4290. extern GameLog* LRMoveLog;
  4291. extern bool quitGame;
  4292. int MissionInterfaceManager::globalMapLog () {
  4293. #ifndef FINAL
  4294. static double lastTime = 0.0;
  4295. if (MPlayer) //Otherwise we crash in singlePlayer!!
  4296. {
  4297. if ((lastTime + 0.5) < gos_GetElapsedTime())
  4298. {
  4299. //MPlayer->leaveSession();
  4300. //quitGame = true;
  4301. //GlobalMap::toggleLog();
  4302. lastTime = gos_GetElapsedTime();
  4303. }
  4304. }
  4305. #endif
  4306. return(1);
  4307. }
  4308. int MissionInterfaceManager::brainDead () {
  4309. #ifndef FINAL
  4310. static double lastTime = 0.0;
  4311. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4312. for (long i = 1; i < MAX_TEAMS; i++)
  4313. MechWarrior::brainsEnabled[i] = !MechWarrior::brainsEnabled[i];
  4314. lastTime = gos_GetElapsedTime();
  4315. }
  4316. #endif
  4317. return(1);
  4318. }
  4319. int MissionInterfaceManager::goalPlan() {
  4320. #ifndef FINAL
  4321. static double lastTime = 0.0;
  4322. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4323. Team* pTeam = Team::home;
  4324. long numMovers = 0;
  4325. for (long i = 0; i < pTeam->getRosterSize(); i++) {
  4326. Mover* mover = pTeam->getMover(i);
  4327. if (mover->isSelected() && mover->getCommander()->getId() == Commander::home->getId())
  4328. numMovers++;
  4329. }
  4330. for (i = 0; i < pTeam->getRosterSize(); i++) {
  4331. Mover* mover = (Mover*)pTeam->getMover( i );
  4332. if (mover->isSelected() && mover ->getCommander()->getId() == Commander::home->getId()) {
  4333. ((MoverPtr)mover)->getPilot()->setUseGoalPlan(!((MoverPtr)mover)->getPilot()->getUseGoalPlan());
  4334. ((MoverPtr)mover)->getPilot()->setMainGoal(GOAL_ACTION_NONE, NULL, NULL, -1.0);
  4335. }
  4336. }
  4337. lastTime = gos_GetElapsedTime();
  4338. }
  4339. #endif
  4340. return(1);
  4341. }
  4342. int MissionInterfaceManager::enemyGoalPlan() {
  4343. #ifndef FINAL
  4344. static double lastTime = 0.0;
  4345. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4346. EnemiesGoalPlan = !EnemiesGoalPlan;
  4347. for (long i = 0; i < ObjectManager->getNumMovers(); i++) {
  4348. Mover* mover = ObjectManager->getMover(i);
  4349. if (mover->getTeam() != Team::home) {
  4350. ((MoverPtr)mover)->getPilot()->setUseGoalPlan(EnemiesGoalPlan);
  4351. ((MoverPtr)mover)->getPilot()->setMainGoal(GOAL_ACTION_NONE, NULL, NULL, -1.0);
  4352. }
  4353. }
  4354. lastTime = gos_GetElapsedTime();
  4355. }
  4356. #endif
  4357. return(1);
  4358. }
  4359. int MissionInterfaceManager::showVictim () {
  4360. #ifndef FINAL
  4361. static double lastTime = 0.0;
  4362. if ((lastTime + 0.5) < gos_GetElapsedTime())
  4363. {
  4364. if (DebugGameObject[0] && DebugGameObject[0]->isMover())
  4365. {
  4366. GameObjectPtr targetObj = ((MoverPtr)DebugGameObject[0])->getPilot()->getCurTacOrder()->getTarget();
  4367. if (targetObj)
  4368. DEBUGWINS_setGameObject(-1, targetObj);
  4369. }
  4370. lastTime = gos_GetElapsedTime();
  4371. }
  4372. #endif
  4373. return(1);
  4374. }
  4375. void damageObject (GameObjectPtr victim, float damage) {
  4376. WeaponShotInfo shot;
  4377. switch (victim->getObjectClass()) {
  4378. case BATTLEMECH:
  4379. case GROUNDVEHICLE:
  4380. shot.init(NULL, -2, damage, victim->calcHitLocation(NULL,-1,ATTACKSOURCE_WEAPONFIRE,0), 0);
  4381. victim->handleWeaponHit(&shot, (MPlayer != NULL));
  4382. break;
  4383. default:
  4384. shot.init(NULL, -1, damage, 0, 0);
  4385. victim->handleWeaponHit(&shot, (MPlayer != NULL));
  4386. break;
  4387. }
  4388. }
  4389. int MissionInterfaceManager::damageObject1 ()
  4390. {
  4391. #ifndef FINAL
  4392. static double lastTime = 0.0;
  4393. if ((lastTime + 0.5) < gos_GetElapsedTime())
  4394. {
  4395. if (target)
  4396. target->repairAll();
  4397. lastTime = gos_GetElapsedTime();
  4398. }
  4399. #endif
  4400. return(1);
  4401. }
  4402. int MissionInterfaceManager::damageObject2 () {
  4403. #ifndef FINAL
  4404. static double lastTime = 0.0;
  4405. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4406. if (target)
  4407. damageObject(target, 4.0);
  4408. lastTime = gos_GetElapsedTime();
  4409. }
  4410. #endif
  4411. return(1);
  4412. }
  4413. int MissionInterfaceManager::damageObject3 () {
  4414. #ifndef FINAL
  4415. static double lastTime = 0.0;
  4416. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4417. if (target)
  4418. damageObject(target, 9.0);
  4419. lastTime = gos_GetElapsedTime();
  4420. }
  4421. #endif
  4422. return(1);
  4423. }
  4424. int MissionInterfaceManager::damageObject4 () {
  4425. #ifndef FINAL
  4426. static double lastTime = 0.0;
  4427. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4428. if (target)
  4429. damageObject(target, 16.0);
  4430. lastTime = gos_GetElapsedTime();
  4431. }
  4432. #endif
  4433. return(1);
  4434. }
  4435. int MissionInterfaceManager::damageObject5 () {
  4436. #ifndef FINAL
  4437. static double lastTime = 0.0;
  4438. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4439. if (target)
  4440. damageObject(target, 25.0);
  4441. lastTime = gos_GetElapsedTime();
  4442. }
  4443. #endif
  4444. return(1);
  4445. }
  4446. int MissionInterfaceManager::damageObject6 () {
  4447. #ifndef FINAL
  4448. static double lastTime = 0.0;
  4449. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4450. if (target)
  4451. damageObject(target, 36.0);
  4452. lastTime = gos_GetElapsedTime();
  4453. }
  4454. #endif
  4455. return(1);
  4456. }
  4457. int MissionInterfaceManager::damageObject7 () {
  4458. #ifndef FINAL
  4459. static double lastTime = 0.0;
  4460. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4461. if (target)
  4462. damageObject(target, 49.0);
  4463. lastTime = gos_GetElapsedTime();
  4464. }
  4465. #endif
  4466. return(1);
  4467. }
  4468. int MissionInterfaceManager::damageObject8 () {
  4469. #ifndef FINAL
  4470. static double lastTime = 0.0;
  4471. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4472. if (target)
  4473. damageObject(target, 64.0);
  4474. lastTime = gos_GetElapsedTime();
  4475. }
  4476. #endif
  4477. return(1);
  4478. }
  4479. int MissionInterfaceManager::damageObject9 () {
  4480. #ifndef FINAL
  4481. static double lastTime = 0.0;
  4482. if ((lastTime + 0.5) < gos_GetElapsedTime()) {
  4483. if (target)
  4484. damageObject(target, 81);
  4485. lastTime = gos_GetElapsedTime();
  4486. }
  4487. #endif
  4488. return(1);
  4489. }
  4490. int MissionInterfaceManager::damageObject0 () {
  4491. #ifndef FINAL
  4492. static double lastTime = 0.0;
  4493. if ((lastTime + 0.5) < gos_GetElapsedTime())
  4494. {
  4495. if (target)
  4496. {
  4497. if (target->isMover())
  4498. ((MoverPtr)target)->disable(0);
  4499. else
  4500. damageObject(target, 100.0);
  4501. }
  4502. lastTime = gos_GetElapsedTime();
  4503. }
  4504. #endif
  4505. return(1);
  4506. }
  4507. int MissionInterfaceManager::toggleCompass()
  4508. {
  4509. ((GameCamera*)eye)->toggleCompass();
  4510. return 0;
  4511. }
  4512. bool MissionInterfaceManager::selectionIsHelicopters( )
  4513. {
  4514. Team* pTeam = Team::home;
  4515. for (long i=0;i<pTeam->getRosterSize();i++)
  4516. {
  4517. Mover* pMover = (Mover*)pTeam->getMover( i );
  4518. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  4519. {
  4520. if ( pMover->getMoveType() != MOVETYPE_AIR )
  4521. {
  4522. return 0;
  4523. }
  4524. }
  4525. }
  4526. return true;
  4527. }
  4528. int MissionInterfaceManager::saveHotKeys( FitIniFile& file )
  4529. {
  4530. file.writeBlock( "Keyboard" );
  4531. for ( int i = 0; i < MAX_COMMAND; i++ )
  4532. {
  4533. char header[256];
  4534. sprintf( header, "Key%ld", i );
  4535. file.writeIdLong( header, commands[i].key );
  4536. }
  4537. file.writeIdLong( "WayPointKey", WAYPOINT_KEY );
  4538. file.writeIdBoolean( "UseLeftRightMouseProfile", useLeftRightMouseProfile );
  4539. return 0;
  4540. }
  4541. int MissionInterfaceManager::loadHotKeys( FitIniFile& file )
  4542. {
  4543. if ( OldKeys[0] == -1 )
  4544. {
  4545. for ( int i = 0; i < MAX_COMMAND; i++ )
  4546. {
  4547. OldKeys[i] = commands[i].key;
  4548. }
  4549. }
  4550. if ( NO_ERR == file.seekBlock( "Keyboard" ) )
  4551. {
  4552. for ( int i = 0; i < MAX_COMMAND; i++ )
  4553. {
  4554. char header[256];
  4555. sprintf( header, "Key%ld", i );
  4556. file.readIdLong( header, commands[i].key );
  4557. }
  4558. long tmp;
  4559. file.readIdLong( "WayPointKey", tmp );
  4560. WAYPOINT_KEY = gosEnum_KeyIndex( tmp );
  4561. file.readIdBoolean( "UseLeftRightMouseProfile", useLeftRightMouseProfile );
  4562. return 0;
  4563. }
  4564. return -1;
  4565. }
  4566. int MissionInterfaceManager::setHotKey( int whichCommand, gosEnum_KeyIndex newKey, bool bShift, bool bControl, bool bAlt )
  4567. {
  4568. gosASSERT( whichCommand < MAX_COMMAND );
  4569. long oldKey = commands[whichCommand].key;
  4570. long key = newKey;
  4571. if ( bShift )
  4572. key |= SHIFT;
  4573. if ( bControl )
  4574. key |= CTRL;
  4575. if ( bAlt )
  4576. key |= ALT;
  4577. if ( commands[whichCommand].key & WAYPT )
  4578. key |= WAYPT;
  4579. else
  4580. {
  4581. // change corresponding waypoint keys
  4582. for ( int i = 0; i < MAX_COMMAND; i++ )
  4583. {
  4584. if ( ((commands[i].key & 0x0000ffff) == oldKey) && (commands[i].key & WAYPT) )
  4585. {
  4586. commands[i].key = key | WAYPT;
  4587. }
  4588. }
  4589. }
  4590. commands[whichCommand].key = key;
  4591. return 0;
  4592. }
  4593. int MissionInterfaceManager::getHotKey( int whichCommand, gosEnum_KeyIndex& newKey, bool& bShift, bool& bControl, bool& bAlt )
  4594. {
  4595. gosASSERT( whichCommand < MAX_COMMAND );
  4596. long key = commands[whichCommand].key;
  4597. if ( key & SHIFT )
  4598. bShift = true;
  4599. if ( key & CTRL )
  4600. bControl = true;
  4601. if ( key & ALT )
  4602. bAlt = true;
  4603. key &= 0x0000ffff;
  4604. newKey = (gosEnum_KeyIndex)key;
  4605. return 0;
  4606. }
  4607. int MissionInterfaceManager::setWayPointKey( gosEnum_KeyIndex key )
  4608. {
  4609. WAYPOINT_KEY = key;
  4610. return 0;
  4611. }
  4612. void MissionInterfaceManager::setAOEStyle()
  4613. {
  4614. useLeftRightMouseProfile = true;
  4615. }
  4616. void MissionInterfaceManager::setMCStyle()
  4617. {
  4618. useLeftRightMouseProfile = false;
  4619. }
  4620. bool MissionInterfaceManager::isAOEStyle()
  4621. {
  4622. return useLeftRightMouseProfile == true;
  4623. }
  4624. bool MissionInterfaceManager::isMCStyle()
  4625. {
  4626. return useLeftRightMouseProfile == false;
  4627. }
  4628. void MissionInterfaceManager::doEject( GameObject* who )
  4629. {
  4630. TacticalOrder tacOrder;
  4631. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_EJECT, true);
  4632. tacOrder.pack(NULL, NULL);
  4633. MoverPtr pMover = (MoverPtr)who;
  4634. if (MPlayer && !MPlayer->isServer())
  4635. MPlayer->sendPlayerOrder(&tacOrder, false, 1, &pMover);
  4636. else
  4637. pMover->handleTacticalOrder(tacOrder);
  4638. }
  4639. bool MissionInterfaceManager::hotKeyIsPressed( int whichCommand )
  4640. {
  4641. long key = commands[whichCommand].key;
  4642. bool bShift = 0;
  4643. bool bControl = 0;
  4644. bool bAlt = 0;
  4645. if ( key & SHIFT )
  4646. bShift = true;
  4647. if ( key & CTRL )
  4648. bControl = true;
  4649. if ( key & ALT )
  4650. bAlt = true;
  4651. key &= 0x0000ffff;
  4652. bool shiftDn = userInput->shift();
  4653. bool ctrlDn = userInput->ctrl();
  4654. bool altDn = userInput->alt();
  4655. if ( gos_GetKeyStatus( (gosEnum_KeyIndex)(key&0x000000ff) ) == KEY_PRESSED ||
  4656. gos_GetKeyStatus( (gosEnum_KeyIndex)(key&0x000000ff) ) == KEY_HELD )
  4657. {
  4658. if ( shiftDn == bShift
  4659. && ctrlDn == bControl
  4660. && altDn == bAlt )
  4661. {
  4662. return true;
  4663. }
  4664. }
  4665. return false;
  4666. }
  4667. void testKeyStuff()
  4668. {
  4669. bool bShift, bCtrl, bAlt;
  4670. gosEnum_KeyIndex key = KEY_F9;
  4671. MissionInterfaceManager::instance()->getHotKey( 5, key, bShift, bCtrl, bAlt );
  4672. MissionInterfaceManager::instance()->setHotKey( 5, KEY_L, 0, 0, 0 );
  4673. MissionInterfaceManager::instance()->getHotKey( 6, key, bShift, bCtrl, bAlt );
  4674. FitIniFile file;
  4675. file.open( "keyboards.fit" );
  4676. MissionInterfaceManager::instance()->loadHotKeys( file );
  4677. MissionInterfaceManager::instance()->getHotKey( 6, key, bShift, bCtrl, bAlt );
  4678. }
  4679. int MissionInterfaceManager::toggleHotKeys()
  4680. {
  4681. bDrawHotKeys ^= 1;
  4682. if ( bDrawHotKeys )
  4683. {
  4684. keyboardRef->reseed( commands );
  4685. if ( !isPaused() )
  4686. togglePauseWithoutMenu();
  4687. }
  4688. else if ( !bDrawHotKeys && isPaused() && isPausedWithoutMenu() )
  4689. togglePauseWithoutMenu();
  4690. return 1;
  4691. }
  4692. void MissionInterfaceManager::drawHotKeys()
  4693. {
  4694. keyboardRef->render();
  4695. return;
  4696. }
  4697. void MissionInterfaceManager::drawHotKey( const char* keyString, const char* descString, long x, long y )
  4698. {
  4699. hotKeyFont.render( keyString, 0, y, x, Environment.screenHeight, 0xffffffff, 0, 1 );
  4700. hotKeyFont.render( descString, x + (10 * Environment.screenWidth/640.f), y,
  4701. Environment.screenWidth, Environment.screenHeight, 0xffffffff, 0, 0 );
  4702. }
  4703. void MissionInterfaceManager::doGuardTower()
  4704. {
  4705. for (long i = 0; i < Team::home->getRosterSize(); i++)
  4706. {
  4707. Mover* pMover = Team::home->getMover( i );
  4708. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId())
  4709. {
  4710. pMover->suppressionFire = true;
  4711. }
  4712. }
  4713. TacticalOrder tacOrder;
  4714. tacOrder.init(ORDER_ORIGIN_PLAYER, TACTICAL_ORDER_ATTACK_POINT);
  4715. //tacOrder.init(ORDER_ORIGIN_PLAYER, target ? TACTICAL_ORDER_ATTACK_OBJECT : TACTICAL_ORDER_ATTACK_POINT);
  4716. //tacOrder.targetWID = target ? target->getWatchID() : 0;
  4717. //if ( !target )
  4718. tacOrder.attackParams.targetPoint = wPos;
  4719. tacOrder.attackParams.type = bEnergyWeapons ? ATTACK_CONSERVING_AMMO : ATTACK_TO_DESTROY;
  4720. tacOrder.attackParams.method = ATTACKMETHOD_RANGED;
  4721. tacOrder.attackParams.range = FIRERANGE_CURRENT;
  4722. tacOrder.attackParams.pursue = false;
  4723. tacOrder.moveParams.faceObject = true;
  4724. tacOrder.moveParams.fromArea = -1;
  4725. tacOrder.moveParams.wait = false;
  4726. handleOrders( tacOrder );
  4727. controlGui.setDefaultSpeed();
  4728. }
  4729. int MissionInterfaceManager::toggleHoldPosition()
  4730. {
  4731. controlGui.toggleHoldPosition();
  4732. return 1;
  4733. }
  4734. int MissionInterfaceManager::handleChatKey()
  4735. {
  4736. controlGui.toggleChat(0);
  4737. return 1;
  4738. }
  4739. int MissionInterfaceManager::handleTeamChatKey()
  4740. {
  4741. controlGui.toggleChat(1);
  4742. return 1;
  4743. }
  4744. float slopeTest[8] = {0.09849140f, 0.30334668f, 0.53451114f, 0.82067879f, 1.21850353f, 1.87086841f, 3.29655821f, 10.15317039f};
  4745. long MissionInterfaceManager::makeMoveCursor( bool bLineOfSite )
  4746. {
  4747. long rotation = calcRotation();
  4748. // leigh put these in the file funny
  4749. // OK, rotations go clockwise starting from 180...
  4750. gosASSERT( rotation >= 0 && rotation < 32 );
  4751. return mState_WALK1 + 32 * bLineOfSite + rotation;
  4752. }
  4753. long MissionInterfaceManager::makeJumpCursor( bool bLineOfSite )
  4754. {
  4755. long rotation = calcRotation();
  4756. // leigh put these in the file funny
  4757. // OK, rotations go clockwise starting from 180...
  4758. gosASSERT( rotation >= 0 && rotation < 32 );
  4759. return mState_JUMP1 + 32 * bLineOfSite + rotation;
  4760. }
  4761. long MissionInterfaceManager::makeRunCursor( bool bLineOfSite )
  4762. {
  4763. long rotation = calcRotation();
  4764. // leigh put these in the file funny
  4765. // OK, rotations go clockwise starting from 180...
  4766. gosASSERT( rotation >= 0 && rotation < 32 );
  4767. return mState_RUN1 + 32 * bLineOfSite + rotation;
  4768. }
  4769. long MissionInterfaceManager::calcRotation()
  4770. {
  4771. Stuff::Vector3D pos;
  4772. pos.x = 0.f;
  4773. pos.y = 0.f;
  4774. pos.z = 0.f;
  4775. float count = 0;
  4776. for (long i = 0; i < Team::home->getRosterSize(); i++)
  4777. {
  4778. Mover* pMover = Team::home->getMover( i );
  4779. if ( pMover->isSelected() && pMover->getCommander()->getId() == Commander::home->getId() )
  4780. {
  4781. pos.x += pMover->getPosition().x;
  4782. pos.y += pMover->getPosition().y;
  4783. pos.z += pMover->getPosition().z;
  4784. count += 1.f;
  4785. }
  4786. }
  4787. if ( count && (turn > 3))
  4788. {
  4789. pos.x /= count;
  4790. pos.y /= count;
  4791. pos.z /= count;
  4792. }
  4793. else
  4794. return mState_NORMAL;
  4795. //Now works by finding the vector in world space between the mouse cursor
  4796. // and the movers. It then normalizes that vector and multiplies by 200
  4797. // to make large. It then adds that vector to the camera position and we
  4798. // do the projections based on the camera center (which is always the
  4799. // center of the screen) and the new vector. Complex but it works!!
  4800. // -fs
  4801. Stuff::Vector3D actualPos;
  4802. actualPos.Subtract(pos, wPos);
  4803. actualPos.z = 0.0f;
  4804. float actualLength = actualPos.GetLength();
  4805. if (actualLength > Stuff::SMALL)
  4806. actualPos /= actualLength;
  4807. actualPos *= 200.0f;
  4808. Stuff::Vector3D camPos = eye->getPosition();
  4809. Stuff::Vector4D screenPosMover;
  4810. Stuff::Vector4D screenPosGoal;
  4811. actualPos.Add(camPos,actualPos);
  4812. eye->projectZ( actualPos, screenPosMover );
  4813. // need to find second position
  4814. eye->projectZ( camPos, screenPosGoal );
  4815. //CRAZY ATAN code. Out for now.
  4816. // -fs
  4817. /*
  4818. // determine angle between the two
  4819. float deltaY = -(screenPosGoal.y - screenPosMover.y);
  4820. float deltaX = screenPosGoal.x - screenPosMover.x;
  4821. float theta = 0;
  4822. if ( deltaY && deltaX )
  4823. {
  4824. theta = atan( deltaY/deltaX );
  4825. theta *= RADS_TO_DEGREES;
  4826. }
  4827. if ( deltaX < 0 )
  4828. theta += 180.f;
  4829. long rotation = ((theta/360.f * 32.f));
  4830. */
  4831. //Do it the MC1 way!
  4832. float slope = 0.0f;
  4833. if (fabs(screenPosGoal.x - screenPosMover.x) > Stuff::SMALL)
  4834. slope = fabs(screenPosGoal.y - screenPosMover.y) / fabs(screenPosGoal.x - screenPosMover.x);
  4835. long counter = 0;
  4836. long rotation = 0;
  4837. while (slope > slopeTest[counter] && counter < 8)
  4838. counter++;
  4839. if (screenPosGoal.y < screenPosMover.y)
  4840. {
  4841. if (screenPosGoal.x < screenPosMover.x) // quadrant 0
  4842. rotation = counter;
  4843. else // quadrant 1
  4844. rotation = 8 + (8 - counter);
  4845. }
  4846. else
  4847. {
  4848. if (screenPosGoal.x > screenPosMover.x) // quadrant 2
  4849. {
  4850. rotation = 16 + counter;
  4851. }
  4852. else // quadrant 3
  4853. {
  4854. rotation = 24 + (8 - counter);
  4855. if (rotation == 32)
  4856. rotation = 0;
  4857. }
  4858. }
  4859. return rotation;
  4860. }
  4861. //--------------------------------------------------------------------------------------
  4862. void MissionInterfaceManager::Save (FitIniFilePtr file)
  4863. {
  4864. //If VTOL or Karnov are active AND HAVEN'T FINISHED THEIR OPERATION, save them, what vehicle they are going to drop or what mech they were fixing.
  4865. long vtolNum = Commander::home->getId();
  4866. if (vTol[vtolNum] && paintingVtol[vtolNum] && (!vehicleDropped[vtolNum] && !mechRecovered[vtolNum]))
  4867. {
  4868. //Save 'em
  4869. file->writeBlock("VTOLData");
  4870. file->writeIdFloat("VtolPosX",vPos[vtolNum].x);
  4871. file->writeIdFloat("VtolPosY",vPos[vtolNum].y);
  4872. file->writeIdFloat("VtolPosZ",vPos[vtolNum].z);
  4873. file->writeIdLong("VehicleID",vehicleID[vtolNum]);
  4874. if (mechToRecover[vtolNum])
  4875. file->writeIdLong("SalvageMechWID", mechToRecover[vtolNum]->getWatchID());
  4876. else
  4877. file->writeIdLong("SalvageMechWID", 0);
  4878. file->writeIdLong("VTOLFrame",vTol[vtolNum]->currentFrame);
  4879. file->writeIdLong("VTOLGesture",vTol[vtolNum]->getCurrentGestureId());
  4880. }
  4881. }
  4882. //--------------------------------------------------------------------------------------
  4883. void MissionInterfaceManager::Load (FitIniFilePtr file)
  4884. {
  4885. //Is there any VTOL data here? OK if not!
  4886. long vtolNum = Commander::home->getId();
  4887. long commanderID = vtolNum;
  4888. if (file->seekBlock("VTOLData") == NO_ERR)
  4889. {
  4890. //Load 'em
  4891. file->readIdFloat("VtolPosX",vPos[vtolNum].x);
  4892. file->readIdFloat("VtolPosY",vPos[vtolNum].y);
  4893. file->readIdFloat("VtolPosZ",vPos[vtolNum].z);
  4894. file->readIdLong("VehicleID",vehicleID[vtolNum]);
  4895. if (vehicleID[vtolNum] != 147) //NOT a recovery vehicle. Standard VTOL
  4896. {
  4897. //Go ahead and make a VTOL. We're gonna need it!
  4898. AppearanceType* appearanceType = appearanceTypeList->getAppearance( BLDG_TYPE << 24, "vtol" );
  4899. vTol[commanderID] = new BldgAppearance;
  4900. vTol[commanderID]->init( appearanceType );
  4901. }
  4902. else
  4903. {
  4904. AppearanceType* appearanceType = appearanceTypeList->getAppearance( BLDG_TYPE << 24, "karnov" );
  4905. vTol[commanderID] = new BldgAppearance;
  4906. vTol[commanderID]->init( appearanceType );
  4907. }
  4908. long mechWID = 0;
  4909. file->readIdLong("SalvageMechWID", mechWID);
  4910. mechToRecover[vtolNum] = (MoverPtr)ObjectManager->getByWatchID(mechWID);
  4911. file->readIdFloat("VTOLFrame",vTol[vtolNum]->currentFrame);
  4912. long gestureId = 0;
  4913. file->readIdLong("VTOLGesture",gestureId);
  4914. vTol[vtolNum]->setGesture(gestureId);
  4915. //Now setup everything else.
  4916. // Pretty much same code as beginVtol
  4917. vehicleFile = controlGui.getVehicleNameFromID(vehicleID[vtolNum]);
  4918. // if ( !vTol[vtolNum] )
  4919. {
  4920. if (vehicleID[vtolNum] != 147) //NOT a recovery vehicle. Standard VTOL
  4921. {
  4922. if (!dustCloud[commanderID] && prefs.useNonWeaponEffects)
  4923. {
  4924. if (strcmp(weaponEffects->GetEffectName(VTOL_DUST_CLOUD),"NONE") != 0)
  4925. {
  4926. //--------------------------------------------
  4927. // Yes, load it on up.
  4928. unsigned flags = 0;
  4929. Check_Object(gosFX::EffectLibrary::Instance);
  4930. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(VTOL_DUST_CLOUD));
  4931. if (gosEffectSpec)
  4932. {
  4933. dustCloud[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  4934. gosASSERT(dustCloud[commanderID] != NULL);
  4935. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  4936. }
  4937. }
  4938. }
  4939. }
  4940. else //IS a recovery vehicle. DO NOT create VTOL, use KARNOV instead. NO Vehicle created either
  4941. {
  4942. mechRecovered[commanderID] = false; //Need to know when mech is done so Karnov can fly away.
  4943. if (!dustCloud[commanderID] && prefs.useNonWeaponEffects)
  4944. {
  4945. if (strcmp(weaponEffects->GetEffectName(KARNOV_DUST_CLOUD),"NONE") != 0)
  4946. {
  4947. //--------------------------------------------
  4948. // Yes, load it on up.
  4949. unsigned flags = 0;
  4950. Check_Object(gosFX::EffectLibrary::Instance);
  4951. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(KARNOV_DUST_CLOUD));
  4952. if (gosEffectSpec)
  4953. {
  4954. dustCloud[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  4955. gosASSERT(dustCloud[commanderID] != NULL);
  4956. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  4957. }
  4958. }
  4959. }
  4960. if (!recoveryBeam[commanderID])
  4961. {
  4962. if (strcmp(weaponEffects->GetEffectName(KARNOV_RECOVERY_BEAM),"NONE") != 0)
  4963. {
  4964. //--------------------------------------------
  4965. // Yes, load it on up.
  4966. unsigned flags = 0;
  4967. Check_Object(gosFX::EffectLibrary::Instance);
  4968. gosFX::Effect::Specification* gosEffectSpec = gosFX::EffectLibrary::Instance->Find(weaponEffects->GetEffectName(KARNOV_RECOVERY_BEAM));
  4969. if (gosEffectSpec)
  4970. {
  4971. recoveryBeam[commanderID] = gosFX::EffectLibrary::Instance->MakeEffect(gosEffectSpec->m_effectID, flags);
  4972. gosASSERT(recoveryBeam[commanderID] != NULL);
  4973. MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
  4974. }
  4975. }
  4976. }
  4977. }
  4978. }
  4979. //Should we play another sample to let them know what is coming in after the load?
  4980. //For now, no!
  4981. /*
  4982. switch (vehicleID)
  4983. {
  4984. case 120: //Minelayer
  4985. soundSystem->playSupportSample(SUPPORT_MINELAYER);
  4986. break;
  4987. case 182: //Repair
  4988. soundSystem->playSupportSample(SUPPORT_REPAIR);
  4989. break;
  4990. case 221: //Scout
  4991. soundSystem->playSupportSample(SUPPORT_SCOUT);
  4992. break;
  4993. case 147: //Recovery
  4994. soundSystem->playSupportSample(SUPPORT_RECOVER);
  4995. break;
  4996. case 415: //Artillery
  4997. soundSystem->playSupportSample(SUPPORT_RECOVER);
  4998. break;
  4999. }
  5000. */
  5001. if (vehicleID[commanderID] != 147)
  5002. soundSystem->playDigitalSample(VTOL_ANIMATE,vPos[commanderID]);
  5003. else
  5004. soundSystem->playDigitalSample(SALVAGE_CRAFT,vPos[commanderID]);
  5005. Stuff::Vector3D newPos = vPos[commanderID];
  5006. float rotation = 0.f; // this needs to be pointing 180 degrees from drop point
  5007. vTol[commanderID]->setObjectParameters( newPos, 0, false, Team::home->id, 0);
  5008. //eye->update();
  5009. vTol[commanderID]->update();
  5010. vTol[commanderID]->setInView( true );
  5011. vTol[commanderID]->setVisibility( 1, 1 );
  5012. vTol[commanderID]->rotation = rotation;
  5013. if (dustCloud[commanderID])
  5014. {
  5015. Stuff::LinearMatrix4D shapeOrigin;
  5016. Stuff::LinearMatrix4D localToWorld;
  5017. Stuff::LinearMatrix4D localResult;
  5018. Stuff::Vector3D dustPos = vTol[commanderID]->position;
  5019. Stuff::Point3D wakePos;
  5020. wakePos.x = -dustPos.x;
  5021. wakePos.y = dustPos.z;
  5022. wakePos.z = dustPos.y;
  5023. shapeOrigin.BuildRotation(Stuff::EulerAngles(0.0f,0.0f,0.0f));
  5024. shapeOrigin.BuildTranslation(wakePos);
  5025. gosFX::Effect::ExecuteInfo info((Stuff::Time)scenarioTime,&shapeOrigin,NULL);
  5026. dustCloud[commanderID]->SetLoopOff();
  5027. dustCloud[commanderID]->SetExecuteOn();
  5028. dustCloud[commanderID]->Start(&info);
  5029. }
  5030. paintingVtol[commanderID] = 1;
  5031. vTolSpeed = -75.f;
  5032. vehicleDropped[commanderID] = false;
  5033. mechRecovered[commanderID] = false;
  5034. controlGui.disableAllVehicleButtons();
  5035. }
  5036. }
  5037. void MissionInterfaceManager::updateRollovers()
  5038. {
  5039. /* For all (both LOS and non-LOS) the run cursors, use strings 45149/45150
  5040. For all the jump cursors, use strings 45151/45152
  5041. For all the walk waypoint cursors, use strings 45153/45154
  5042. For all the run waypoint cursors, use strings 45155/45156
  5043. For all the jump waypoint cursors, use strings 45157/45158
  5044. For all the patrol path cursors, use strings 45159/45160
  5045. For all the standard attack cursors, use strings 45161/45162
  5046. For all the ammo conservation cursors, use strings 45163/45164
  5047. For all the fire from current position cursors, use strings 45165/45166
  5048. For all the short-range attack cursors, use strings 45167/45168
  5049. For all the medium-range attack cursors, use strings 45169/45170
  5050. For all the long-range attack cursors, use strings 45171/45172
  5051. For all the force-fire attack cursors, use strings 45173/45174
  5052. For the guard cursor, use strings 45147/45148 (one each for right-click and left-click models).*/
  5053. long cursor = userInput->getMouseCursor();
  5054. if ( ( cursor >= mState_RUN1 && cursor <= mState_RUN1 + 64) )
  5055. {
  5056. helpTextID = 0;
  5057. controlGui.setRolloverHelpText( IDS_RUN_CURSOR_LEFT_HELP );
  5058. }
  5059. else if ( ( cursor >= mState_JUMP1 && cursor <= mState_JUMP1 + 64 ) )
  5060. {
  5061. helpTextID = 0;
  5062. controlGui.setRolloverHelpText( IDS_JUMP_CURSOR_LEFT_HELP );
  5063. }
  5064. else
  5065. {
  5066. switch (cursor)
  5067. {
  5068. case mState_GUARD:
  5069. if ( target )
  5070. {
  5071. helpTextID = 0;
  5072. controlGui.setRolloverHelpText( IDS_GUARD_RECIPIENT_LEFT_HELP );
  5073. }
  5074. break;
  5075. case mState_JUMPWAYPT:
  5076. case mState_JUMPWAYPT_LOS:
  5077. helpTextID = 0;
  5078. controlGui.setRolloverHelpText( IDS_JUMP_WAYPOINT_CURSOR_LEFT_HELP );
  5079. break;
  5080. case mState_RUNWAYPT:
  5081. case mState_RUNWAYPT_LOS:
  5082. helpTextID = 0;
  5083. controlGui.setRolloverHelpText( IDS_RUN_WAYPOINT_CURSOR_LEFT_HELP );
  5084. break;
  5085. case mState_WALKWAYPT:
  5086. case mState_WALKWAYPT_LOS:
  5087. helpTextID = 0;
  5088. controlGui.setRolloverHelpText( IDS_WALK_WAYPOINT_CURSOR_LEFT_HELP );
  5089. break;
  5090. case mState_LINK:
  5091. helpTextID = 0;
  5092. controlGui.setRolloverHelpText( IDS_PATROL_CURSOR_LEFT_HELP );
  5093. break;
  5094. case mState_GENERIC_ATTACK:
  5095. case mState_ATTACK_LOS:
  5096. helpTextID = 0;
  5097. controlGui.setRolloverHelpText( IDS_ATTACK_CURSOR_LEFT_HELP );
  5098. break;
  5099. case mState_ENERGY_WEAPONS:
  5100. case mState_ENERGY_WEAPONS_LOS:
  5101. helpTextID = 0;
  5102. controlGui.setRolloverHelpText( IDS_AMMO_CONSERVE_CURSOR_LEFT_HELP );
  5103. break;
  5104. case mState_CURPOS_ATTACK:
  5105. case mState_CURPOS_ATTACK_LOS:
  5106. helpTextID = 0;
  5107. if ( gos_GetKeyStatus( (gosEnum_KeyIndex)commands[FORCE_FIRE_KEY].key ) == KEY_HELD )
  5108. controlGui.setRolloverHelpText( IDS_FORCE_FIRE_CURSOR_LEFT_HELP );
  5109. else
  5110. controlGui.setRolloverHelpText( IDS_FIRE_FROM_CURRENT_POSITION_CURSOR_LEFT_HELP );
  5111. break;
  5112. case mState_SHRTRNG_ATTACK:
  5113. case mState_SHRTRNG_LOS:
  5114. helpTextID = 0;
  5115. controlGui.setRolloverHelpText( IDS_SHORT_RANGE_CURSOR_LEFT_HELP );
  5116. break;
  5117. case mState_MEDRNG_ATTACK:
  5118. case mState_MEDRNG_LOS:
  5119. helpTextID = 0;
  5120. controlGui.setRolloverHelpText( IDS_MEDIUM_RANGE_CURSOR_LEFT_HELP );
  5121. break;
  5122. case mState_LONGRNG_ATTACK:
  5123. case mState_LONGRNG_LOS:
  5124. helpTextID = 0;
  5125. controlGui.setRolloverHelpText( IDS_LONG_RANGE_CURSOR_LEFT_HELP );
  5126. break;
  5127. }
  5128. }
  5129. }
  5130. //--------------------------------------------------------------------------------------