| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- // FILE: ScriptActions.cpp /////////////////////////////////////////////////////////////////////////
- // The game scripting engine. Interprets scripts.
- // Author: John Ahlquist, Nov. 2001
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #include "Common/AudioAffect.h"
- #include "Common/AudioHandleSpecialValues.h"
- #include "Common/GameAudio.h"
- #include "Common/GameEngine.h"
- #include "Common/MapObject.h" // For MAP_XY_FACTOR
- #include "Common/PartitionSolver.h"
- #include "Common/Player.h"
- #include "Common/PlayerList.h"
- #include "Common/PlayerTemplate.h"
- #include "Common/Radar.h" // For TheRadar
- #include "Common/SpecialPower.h"
- #include "Common/ThingFactory.h"
- #include "Common/ThingTemplate.h"
- #include "Common/Team.h"
- #include "Common/Upgrade.h"
- #include "GameClient/Anim2D.h"
- #include "GameClient/CampaignManager.h"
- #include "GameClient/CommandXlat.h"
- #include "GameClient/ControlBar.h"
- #include "GameClient/Drawable.h"
- #include "GameClient/Eva.h"
- #include "GameClient/GadgetStaticText.h"
- #include "GameClient/GameClient.h"
- #include "GameClient/GameText.h"
- #include "GameClient/GUICallbacks.h"
- #include "GameClient/InGameUI.h"
- #include "GameClient/LookAtXlat.h"
- #include "GameClient/MessageBox.h"
- #include "GameClient/Mouse.h"
- #include "GameClient/View.h"
- #include "GameClient/GlobalLanguage.h"
- #include "GameClient/Snow.h"
- #include "GameLogic/AI.h"
- #include "GameLogic/AISkirmishPlayer.h"
- #include "GameLogic/Locomotor.h"
- #include "GameLogic/Module/AIUpdate.h"
- #include "GameLogic/Module/CaveContain.h"
- #include "GameLogic/Module/CommandButtonHuntUpdate.h"
- #include "GameLogic/Module/ContainModule.h"
- #include "GameLogic/Module/DeliverPayloadAIUpdate.h"
- #include "GameLogic/Module/SpecialPowerModule.h"
- #include "GameLogic/Module/SupplyWarehouseDockUpdate.h"
- #include "GameLogic/Module/TransportContain.h"
- #include "GameLogic/Module/MobNexusContain.h"
- #include "GameLogic/Module/RailroadGuideAIUpdate.h"
- #include "GameLogic/Module/StickyBombUpdate.h"
- #include "GameLogic/ObjectTypes.h"
- #include "GameLogic/PartitionManager.h"
- #include "GameLogic/PolygonTrigger.h"
- #include "GameLogic/ScriptActions.h"
- #include "GameLogic/ScriptEngine.h"
- #include "GameLogic/Weapon.h"
- #include "GameLogic/VictoryConditions.h"
- #include "GameLogic/AIPathfind.h"
- #ifdef _INTERNAL
- // for occasional debugging...
- //#pragma optimize("", off)
- //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
- #endif
- // Kind of hacky, but we need to dance on the guts of the terrain.
- extern void oversizeTheTerrain(Int amount);
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- // when you set controlling player or merge teams, we don't always update all the upgrade stuff
- // or the indicator color. this allows us to force the situation. (srj)
- static void updateTeamAndPlayerStuff( Object *obj, void *userData )
- {
- if (obj)
- {
- obj->updateUpgradeModules();
-
- // srj sez: apparently we have to do this too, since Team::setControllingPlayer
- // does not. Might make more sense to do it there, but am scared to at this point.
- Drawable* draw = obj->getDrawable();
- if (draw)
- {
- if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)
- draw->setIndicatorColor(obj->getNightIndicatorColor());
- else
- draw->setIndicatorColor(obj->getIndicatorColor());
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- // STATICS ////////////////////////////////////////////////////////////////////////////////////////
- // DEFINES ////////////////////////////////////////////////////////////////////////////////////////
- #define REALLY_FAR (100000 * MAP_XY_FACTOR)
- // GLOBALS ////////////////////////////////////////////////////////////////////////////////////////
- ScriptActionsInterface *TheScriptActions = NULL;
- GameWindow *ScriptActions::m_messageWindow = NULL;
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- ScriptActions::ScriptActions()
- {
- m_suppressNewWindows = FALSE;
- m_unnamedUnit = AsciiString::TheEmptyString;
- } // end ScriptActions
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- ScriptActions::~ScriptActions()
- {
- reset(); // just in case.
- } // end ~ScriptActions
- //-------------------------------------------------------------------------------------------------
- /** Init */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::init( void )
- {
- reset();
- } // end init
- //-------------------------------------------------------------------------------------------------
- /** Reset */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::reset( void )
- {
- m_suppressNewWindows = FALSE;
- closeWindows(FALSE); // Close victory or defeat windows.
- } // end reset
- //-------------------------------------------------------------------------------------------------
- /** Update */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::update( void )
- {
- // Empty for now. jba.
- } // end update
- //-------------------------------------------------------------------------------------------------
- /** closeWindows */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::closeWindows( Bool suppressNewWindows )
- {
- m_suppressNewWindows = suppressNewWindows;
- if (m_messageWindow) {
- TheWindowManager->winDestroy(m_messageWindow);
- m_messageWindow = NULL;
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doQuickVictory */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doQuickVictory( void )
- {
- closeWindows(FALSE);
- TheGameLogic->closeWindows();
- doDisableInput();
- if(TheCampaignManager)
- TheCampaignManager->SetVictorious(TRUE);
- TheScriptEngine->startQuickEndGameTimer();
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetInfantryLightingOverride */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetInfantryLightingOverride(Real setting)
- {
- DEBUG_ASSERTCRASH( (setting == -1.0f) || (setting > 0.0f), ("Invalid setting (%d) in Infantry Lighting Override script.", setting) );
- TheWritableGlobalData->m_scriptOverrideInfantryLightScale = setting;
- }
- //-------------------------------------------------------------------------------------------------
- /** doVictory */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doVictory( void )
- {
- closeWindows(FALSE);
- TheGameLogic->closeWindows();
- doDisableInput();
- if (!m_suppressNewWindows)
- {
- const Player *localPlayer = ThePlayerList->getLocalPlayer();
- Bool showObserverWindow = localPlayer->isPlayerObserver() || TheScriptEngine->hasShownMPLocalDefeatWindow();
- if(showObserverWindow)
- m_messageWindow = TheWindowManager->winCreateFromScript("Menus/ObserverQuit.wnd");
- else
- {
- m_messageWindow = TheWindowManager->winCreateFromScript("Menus/Victorious.wnd");
- }
- }
- if(TheCampaignManager)
- TheCampaignManager->SetVictorious(TRUE);
- TheScriptEngine->startEndGameTimer();
- }
- //-------------------------------------------------------------------------------------------------
- /** doDefeat */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDefeat( void )
- {
- closeWindows(FALSE);
- TheGameLogic->closeWindows();
- doDisableInput();
- if (!m_suppressNewWindows)
- {
- const Player *localPlayer = ThePlayerList->getLocalPlayer();
- Bool showObserverWindow = localPlayer->isPlayerObserver() || TheScriptEngine->hasShownMPLocalDefeatWindow();
- if(showObserverWindow)
- m_messageWindow = TheWindowManager->winCreateFromScript("Menus/ObserverQuit.wnd");
- else
- {
- m_messageWindow = TheWindowManager->winCreateFromScript("Menus/Defeat.wnd");
- }
- }
- if(TheCampaignManager)
- TheCampaignManager->SetVictorious(FALSE);
- TheScriptEngine->startEndGameTimer();
- }
- //-------------------------------------------------------------------------------------------------
- /** doLocalDefeat */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doLocalDefeat( void )
- {
- TheScriptEngine->markMPLocalDefeatWindowShown();
- closeWindows(FALSE);
- TheGameLogic->closeWindows();
- if (!m_suppressNewWindows)
- {
- if(!TheVictoryConditions->amIObserver())
- m_messageWindow = TheWindowManager->winCreateFromScript("Menus/LocalDefeat.wnd");
- }
- if(TheCampaignManager)
- TheCampaignManager->SetVictorious(FALSE);
- TheScriptEngine->startCloseWindowTimer();
- }
- //-------------------------------------------------------------------------------------------------
- /** changeObjectPanelFlagForSingleObject */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::changeObjectPanelFlagForSingleObject(Object *obj, const AsciiString& flagToChange, Bool newVal )
- {
- // Enabled flag
- if (flagToChange == TheObjectFlagsNames[0])
- {
- obj->setScriptStatus(OBJECT_STATUS_SCRIPT_DISABLED, !newVal);
- return;
- }
- // Powered flag
- if (flagToChange == TheObjectFlagsNames[1])
- {
- obj->setScriptStatus(OBJECT_STATUS_SCRIPT_UNPOWERED, !newVal);
- return;
- }
- // Indestructible flag
- if (flagToChange == TheObjectFlagsNames[2])
- {
- BodyModuleInterface* body = obj->getBodyModule();
- if (body) {
- body->setIndestructible(newVal);
- }
- return;
- }
- // Unsellable flag
- if (flagToChange == TheObjectFlagsNames[3])
- {
- obj->setScriptStatus(OBJECT_STATUS_SCRIPT_UNSELLABLE, newVal);
- return;
- }
- // Selectable flag
- if (flagToChange == TheObjectFlagsNames[4])
- {
- if (obj->isSelectable() != newVal) {
- obj->setSelectable(newVal);
- }
- return;
- }
- // AI Recruitable flag
- if (flagToChange == TheObjectFlagsNames[5])
- {
- if (obj->getAIUpdateInterface()) {
- obj->getAIUpdateInterface()->setIsRecruitable(newVal);
- }
- return;
- }
- // Player targetable flag
- if( flagToChange == TheObjectFlagsNames[6] )
- {
- obj->setScriptStatus( OBJECT_STATUS_SCRIPT_TARGETABLE, newVal );
- return;
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doDebugMessage */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDebugMessage(const AsciiString& msg, Bool pause )
- {
- TheScriptEngine->AppendDebugMessage(msg, pause);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlaySoundEffect */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlaySoundEffect(const AsciiString& sound)
- {
- AudioEventRTS audioEvent(sound);
- audioEvent.setIsLogicalAudio(true);
- audioEvent.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());
- TheAudio->addAudioEvent( &audioEvent );
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlaySoundEffectAt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlaySoundEffectAt(const AsciiString& sound, const AsciiString& waypoint)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (!way) {
- return;
- }
- AudioEventRTS audioEvent(sound, way->getLocation());
- audioEvent.setIsLogicalAudio(true);
- audioEvent.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());
- TheAudio->addAudioEvent( &audioEvent );
- }
- //-------------------------------------------------------------------------------------------------
- /** doEnableObjectSound */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEnableObjectSound(const AsciiString& objectName, Bool enable )
- {
- Object *object = TheScriptEngine->getUnitNamed(objectName);
- if (!object)
- {
- return;
- }
- Drawable *drawable = object->getDrawable();
- if ( !drawable )
- {
- return;
- }
- drawable->enableAmbientSoundFromScript( enable );
- }
- //-------------------------------------------------------------------------------------------------
- /** doDamageTeamMembers */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDamageTeamMembers(const AsciiString& team, Real amount)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (theTeam) {
- theTeam->damageTeamMembers(amount);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoveToWaypoint */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoveToWaypoint(const AsciiString& team, const AsciiString& waypoint)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (theTeam) {
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (way) {
- Coord3D destination = *way->getLocation();
- //DEBUG_LOG(("Moving team to waypoint %f, %f, %f\n", destination.x, destination.y, destination.z));
- theGroup->groupMoveToPosition( &destination, false, CMD_FROM_SCRIPT );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedMoveToWaypoint */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedMoveToWaypoint(const AsciiString& unit, const AsciiString& waypoint)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (!way) {
- return;
- }
- Coord3D destination = *way->getLocation();
- AIUpdateInterface *aiUpdate = theObj->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
-
- aiUpdate->clearWaypointQueue();
- theObj->leaveGroup();
- aiUpdate->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- aiUpdate->aiMoveToPosition( &destination, CMD_FROM_SCRIPT );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraFollowNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraFollowNamed(const AsciiString& unit, Bool snapToUnit)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- TheTacticalView->setCameraLock(theObj->getID());
- if (snapToUnit)
- TheTacticalView->snapToCameraLock();
- TheTacticalView->setSnapMode( View::LOCK_FOLLOW, 0.0f );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doStopCameraFollowUnit */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doStopCameraFollowUnit(void)
- {
- TheTacticalView->setCameraLock(INVALID_ID);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetTeamState */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetTeamState(const AsciiString& team, const AsciiString& state)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (theTeam) {
- theTeam->setState(state);
- }
- }
- /** doCreateReinforcements */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCreateReinforcements(const AsciiString& team, const AsciiString& waypoint)
- {
- TeamPrototype *theTeamProto = TheTeamFactory->findTeamPrototype( team );
- Coord3D destination;
- Bool needToMoveToDestination = false;
- //Validate the waypoint
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (way==NULL)
- {
- return;
- }
- destination = *way->getLocation();
- if (!theTeamProto) {
- DEBUG_LOG(("***WARNING - Team %s not found.\n", team));
- return;
- }
- const TeamTemplateInfo *pInfo = theTeamProto->getTemplateInfo();
- Coord3D origin = destination;
- way = TheTerrainLogic->getWaypointByName(pInfo->m_startReinforceWaypoint);
- if (way) {
- origin = *way->getLocation();
- if (origin.x != destination.x || origin.y != destination.y) {
- needToMoveToDestination = true;
- }
- }
- //Create the team (not the units inside team).
- Team *theTeam = TheTeamFactory->createInactiveTeam( team );
- if (theTeam==NULL) {
- return;
- }
- const ThingTemplate *transportTemplate;
- const ThingTemplate *unitTemplate;
- //Create the transport first (if applicable), so we can determine if it has paradrop capabilities.
- //If so, we'll be doing a lot of things differently!
- Object *transport=NULL;
- ContainModuleInterface *contain = NULL;
- transportTemplate = TheThingFactory->findTemplate( pInfo->m_transportUnitType );
- if( transportTemplate )
- {
- transport = TheThingFactory->newObject( transportTemplate, theTeam );
- transport->setPosition( &origin );
- transport->setOrientation( 0.0f );
- if( transport )
- {
- contain = transport->getContain();
- }
- }
- Int transportCount = 1;
- //Check to see if we have a transport, and if our transport has paradrop capabilities. If this is the
- //case, we'll need to create each unit inside "parachute containers".
- static NameKeyType key_DeliverPayloadAIUpdate = NAMEKEY("DeliverPayloadAIUpdate");
- DeliverPayloadAIUpdate *dp = NULL;
- if( transport )
- {
- dp = (DeliverPayloadAIUpdate*)transport->findUpdateModule(key_DeliverPayloadAIUpdate);
- }
- //Our tranport has a deliverPayload update module. This means it'll do airborned drops.
- const ThingTemplate* putInContainerTemplate = NULL;
- if( dp )
- {
- //Check to see if we are packaging our units
- putInContainerTemplate = dp->getPutInContainerTemplateViaModuleData();
- }
- //Now create the units that make up the team.
- Int i, j;
- for (i=0; i<pInfo->m_numUnitsInfo; i++)
- {
- // get thing template based from map object name
- unitTemplate = TheThingFactory->findTemplate(pInfo->m_unitsInfo[i].unitThingName);
- Coord3D pos = origin;
- if (unitTemplate && theTeam)
- {
- Object *obj = NULL;
- for (j=0; j<pInfo->m_unitsInfo[i].maxUnits; j++)
- {
- // create new object in the world
- obj = TheThingFactory->newObject( unitTemplate, theTeam );
- if( obj )
- {
- /// @todo - have better positioning for reinforcement units.
- pos.x = origin.x + 2.25*(j)*obj->getGeometryInfo().getMajorRadius();
- pos.z = TheTerrainLogic->getGroundHeight(pos.x, pos.y);
- obj->setPosition( &pos );
- obj->setOrientation(0.0f);
-
- } // end if
- }
- if (obj) pos.y += 2*obj->getGeometryInfo().getMajorRadius();
- }
- origin.y = pos.y;
- }
- origin = destination;
- if (pInfo->m_teamStartsFull)
- {
- // Have them load into transports in the team.
- EntriesVec vecOfUnits;
- SpacesVec vecOfTransports;
-
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- if (!obj) {
- continue;
- }
- if (obj==transport) {
- continue; // Skip the one we created. The team loads into the transports on the team for team starts full. jba
- }
- if (obj->isKindOf(KINDOF_TRANSPORT))
- {
- ContainModuleInterface *contain = obj->getContain();
- if( contain )
- {
- vecOfTransports.push_back(std::make_pair(obj->getID(), ((TransportContain*)contain)->getContainMax()));
- }
- else
- {
- DEBUG_CRASH( ("doCreateReinforcement script -- transport doesn't have contain to hold guys.") );
- }
- }
- else
- {
- Int slots = obj->getTransportSlotCount();
- if (slots==0) slots = 0x7fffff; // 0 means lots.
- vecOfUnits.push_back(std::make_pair(obj->getID(), slots));
- }
- }
- // we've now built the necessary stuff. Partition the units.
- PartitionSolver partition(vecOfUnits, vecOfTransports, PREFER_FAST_SOLUTION);
- partition.solve();
- SolutionVec solution = partition.getSolution();
- for (int i = 0; i < solution.size(); ++i) {
- Object *unit = TheGameLogic->findObjectByID(solution[i].first);
- Object *trans = TheGameLogic->findObjectByID(solution[i].second);
- if (!unit || !trans) {
- continue;
- }
- ContainModuleInterface *contain = trans->getContain();
- if (contain)
- {
- contain->addToContain(unit);
- }
- }
- }
- contain = NULL;
- if( transport )
- {
- contain = transport->getContain();
- }
- if (contain)
- {
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- if (!obj)
- {
- continue;
- }
- if (obj->getTemplate()->isEquivalentTo(transport->getTemplate()) )
- {
- // it's our transport.
- continue;
- }
- if (obj->getContainedBy() != NULL)
- {
- continue;
- }
- //Check to see if it's a valid transport for this unit, even if it's full.
- Coord3D pos = origin;
- pos.x += transportCount*transport->getGeometryInfo().getMajorRadius();
- pos.z = TheTerrainLogic->getGroundHeight(pos.x, pos.y);
-
- if (contain && contain->isValidContainerFor(obj, false))
- {
- //Now that we know it fits in the transport, check to see if it's full. If it is,
- //then we'll create a new transport.
- if (!contain->isValidContainerFor(obj, true))
- {
- // full, try building another.
- transport = TheThingFactory->newObject( transportTemplate, theTeam );
- transport->setPosition( &pos );
- transportCount++;
- transport->setOrientation(0.0f);
- if (transport)
- {
- contain = transport->getContain();
- }
- }
- //If our unit is going to be put in another container (such as infantry being contained by a parachute)
- //do so now.
- if( putInContainerTemplate )
- {
- Object* container = TheThingFactory->newObject( putInContainerTemplate, theTeam );
- container->setPosition( &pos );
- //Make sure this is valid.
- if( container->getContain() && container->getContain()->isValidContainerFor( obj, true ) )
- {
- container->getContain()->addToContain( obj );
- obj = container;
- }
- else
- {
- DEBUG_CRASH( ("doCreateReinforcements: PutInContainer %s is full, or not valid for the payload %s!", putInContainerTemplate->getName().str(), obj->getTemplate()->getName().str() ) );
- }
- }
- //Add our unit to the transport.
- contain->addToContain( obj );
- }
- }
- }
- if (theTeam)
- {
- if (transport)
- {
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- if (!obj)
- {
- continue;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (obj->getTemplate()->isEquivalentTo(transport->getTemplate()) )
- {
- if( dp )
- {
- dp->deliverPayloadViaModuleData( &destination );
- }
- // it's our transport.
- else if( pInfo->m_transportsExit )
- {
- if( ai )
- {
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiMoveToAndEvacuateAndExit(&destination, CMD_FROM_SCRIPT);
- }
- }
- else
- {
- if( ai )
- {
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiMoveToAndEvacuate( &destination, CMD_FROM_SCRIPT );
- }
- }
- }
- else
- {
- // If there are any units that aren't transportable, move them to the goal.
- if( !obj->isDisabledByType( DISABLED_HELD ) )
- {
- if( ai )
- {
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiMoveToPosition(&destination, CMD_FROM_SCRIPT);
- }
- }
- }
- }
- }
- else
- {
- theTeam->setActive();
- if (needToMoveToDestination)
- {
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup)
- {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupMoveToPosition( &destination, false, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoveCameraTo */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoveCameraTo(const AsciiString& waypoint, Real sec, Real cameraStutterSec, Real easeIn, Real easeOut)
- {
- for (Waypoint *way = TheTerrainLogic->getFirstWaypoint(); way; way = way->getNext()) {
- if (way->getName() == waypoint) {
- Coord3D destination = *way->getLocation();
- TheTacticalView->moveCameraTo(&destination, sec*1000, cameraStutterSec*1000, true, easeIn*1000.0f, easeOut*1000.0f);
- break;
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doZoomCamera */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doZoomCamera(Real zoom, Real sec, Real easeIn, Real easeOut)
- {
- TheTacticalView->zoomCamera(zoom, sec*1000.0f, easeIn*1000.0f, easeOut*1000.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPitchCamera */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPitchCamera(Real pitch, Real sec, Real easeIn, Real easeOut)
- {
- TheTacticalView->pitchCamera(pitch, sec*1000.0f, easeIn*1000.0f, easeOut*1000.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doOversizeTheTerrain */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doOversizeTheTerrain(Int amount)
- {
- oversizeTheTerrain(amount);
- Coord2D offset;
- offset.x = 0.0001f;
- offset.y = 0.0001f;
- TheTacticalView->scrollBy(&offset);
- offset.x = -0.0001f;
- offset.y = -0.0001f;
- TheTacticalView->scrollBy(&offset);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetupCamera */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetupCamera(const AsciiString& waypoint, Real zoom, Real pitch, const AsciiString& lookAtWaypoint)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (way==NULL) return;
- Coord3D pos = *way->getLocation();
- Waypoint *lookat = TheTerrainLogic->getWaypointByName(lookAtWaypoint);
- if (lookat==NULL) return;
- Coord3D destination = *lookat->getLocation();
- TheTacticalView->moveCameraTo(&pos, 0, 0, true, 0.0f, 0.0f);
- TheTacticalView->cameraModLookToward(&destination);
- TheTacticalView->cameraModFinalPitch(pitch, 0.0f, 0.0f);
- TheTacticalView->cameraModFinalZoom(zoom, 0.0f, 0.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doModCameraLookToward */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doModCameraLookToward(const AsciiString& waypoint)
- {
- for (Waypoint *way = TheTerrainLogic->getFirstWaypoint(); way; way = way->getNext()) {
- if (way->getName() == waypoint) {
- Coord3D destination = *way->getLocation();
- TheTacticalView->cameraModLookToward(&destination);
- break;
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doModCameraFinalLookToward */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doModCameraFinalLookToward(const AsciiString& waypoint)
- {
- for (Waypoint *way = TheTerrainLogic->getFirstWaypoint(); way; way = way->getNext()) {
- if (way->getName() == waypoint) {
- Coord3D destination = *way->getLocation();
- TheTacticalView->cameraModFinalLookToward(&destination);
- break;
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doModCameraMoveToSelection */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doModCameraMoveToSelection(void)
- {
- Int count=0;
- Coord3D destination;
- destination.x=destination.y=destination.z = 0;
- for (Drawable *d = TheGameClient->firstDrawable(); d; d = d->getNextDrawable())
- {
- if (d->isSelected())
- {
- Coord3D pos = *d->getPosition();
- destination.x += pos.x;
- destination.y += pos.y;
- destination.z += pos.z;
- count++;
- }
- }
- if (count) {
- destination.z /= count;
- destination.x /= count;
- destination.y /= count;
- TheTacticalView->cameraModFinalMoveTo(&destination);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doResetCamera */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doResetCamera(const AsciiString& waypoint, Real sec, Real easeIn, Real easeOut)
- {
- for (Waypoint *way = TheTerrainLogic->getFirstWaypoint(); way; way = way->getNext()) {
- if (way->getName() == waypoint) {
- Coord3D destination = *way->getLocation();
- TheTacticalView->resetCamera(&destination, sec*1000, easeIn*1000.0f, easeOut*1000.0f);
- break;
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doRotateCamera around the object we are looking at. */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRotateCamera(Real rotations, Real sec, Real easeIn, Real easeOut)
- {
- TheTacticalView->rotateCamera(rotations, sec*1000.0f, easeIn*1000.0f, easeOut*1000.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRotateCameraTowardObject */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRotateCameraTowardObject(const AsciiString& unitName, Real sec, Real holdSec, Real easeIn, Real easeOut)
- {
- const Object *unit = TheScriptEngine->getUnitNamed(unitName);
- if (!unit)
- return;
- TheTacticalView->rotateCameraTowardObject(unit->getID(), sec*1000.0f, holdSec*1000.0f, easeIn*1000.0f, easeOut*1000.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRotateCameraTowardWaypoint */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRotateCameraTowardWaypoint(const AsciiString& waypointName, Real sec, Real easeIn, Real easeOut, Bool reverseRotation)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- if (way==NULL) return;
- TheTacticalView->rotateCameraTowardPosition(way->getLocation(), sec*1000.0f, easeIn*1000.0f, easeOut*1000.0f, reverseRotation);
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoveAlongWaypointPath */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoveCameraAlongWaypointPath(const AsciiString& waypoint, Real sec, Real cameraStutterSec, Real easeIn, Real easeOut)
- {
- for (Waypoint *way = TheTerrainLogic->getFirstWaypoint(); way; way = way->getNext()) {
- if (way->getName() == waypoint) {
- TheTacticalView->moveCameraAlongWaypointPath(way, sec*1000, cameraStutterSec*1000, true, easeIn*1000.0f, easeOut*1000.0f);
- break;
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doCreateObject */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCreateObject(const AsciiString& objectName, const AsciiString& thingName, const AsciiString& teamName, Coord3D *pos, Real angle )
- {
- Object* pOldObj = NULL;
- if (objectName != m_unnamedUnit) {
- pOldObj = TheScriptEngine->getUnitNamed(objectName);
- if (pOldObj && !pOldObj->isEffectivelyDead()) {
- AsciiString str = "WARNING - Object with name ";
- str.concat(objectName);
- str.concat(" already exists. Failed Create.");
- TheScriptEngine->AppendDebugMessage(str, false);
- // Unit by that name already exists
- return;
- }
- }
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (theTeam==NULL) {
- // We may need to create the team.
- theTeam = TheTeamFactory->createTeam( teamName );
- }
- if (!theTeam) {
- TheScriptEngine->AppendDebugMessage("***WARNING - Team not found:***", false);
- TheScriptEngine->AppendDebugMessage(teamName, true);
- DEBUG_LOG(("WARNING - Team %s not found.\n", teamName.str()));
- return;
- }
- const ThingTemplate *thingTemplate;
- // get thing template based from map object name
- thingTemplate = TheThingFactory->findTemplate(thingName);
- if (thingTemplate) {
- // create new object in the world
- Object *obj = TheThingFactory->newObject( thingTemplate, theTeam );
- if( obj )
- {
- if (objectName != m_unnamedUnit) {
- obj->setName(objectName);
- if (pOldObj || TheScriptEngine->didUnitExist(objectName)) {
- TheScriptEngine->transferObjectName(objectName, obj);
- } else {
- TheScriptEngine->addObjectToCache(obj);
- }
- }
- obj->setOrientation(angle);
- obj->setPosition( pos );
-
- if ( obj->isKindOf( KINDOF_BLAST_CRATER ) ) // since these footprints are permanent
- {
- TheTerrainLogic->createCraterInTerrain( obj );
- TheAI->pathfinder()->addObjectToPathfindMap( obj );
- }
- } // end if
- } else {
- DEBUG_LOG(("WARNING - ThingTemplate '%s' not found.\n", thingName.str()));
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doAttack */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAttack(const AsciiString& attackerName, const AsciiString& victimName)
- {
- Team *attackingTeam = TheScriptEngine->getTeamNamed( attackerName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- const Team *victimTeam = TheScriptEngine->getTeamNamed( victimName );
-
- // sanity
- if( attackingTeam == NULL || victimTeam == NULL )
- return;
- AIGroup *aiGroup = TheAI->createGroup();
- if (!aiGroup) {
- return;
- }
- attackingTeam->getTeamAsAIGroup(aiGroup);
- aiGroup->groupAttackTeam(victimTeam, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedAttack */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedAttack(const AsciiString& attackerName, const AsciiString& victimName)
- {
- /// @todo Implement me (MSB)
- Object *attackingObj = TheScriptEngine->getUnitNamed( attackerName );
- Object *victimObj = TheScriptEngine->getUnitNamed( victimName );
- if (!attackingObj || !victimObj) {
- return;
- }
- // tell every member of attacking team to attack a random member of victim team
- {
- AIUpdateInterface *aiUpdate = attackingObj->getAIUpdateInterface();
- if (aiUpdate)
- {
- /// @todo Teams should have a method that returns the number of members in the team (MSB)
- attackingObj->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiForceAttackObject( victimObj, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildBuilding(const AsciiString& buildingType)
- {
- // This action ALWAYS occur on the current player.
- Player *thePlayer = TheScriptEngine->getCurrentPlayer();
- if (thePlayer) {
- thePlayer->buildSpecificBuilding(buildingType);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildSupplyCenter */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildSupplyCenter(const AsciiString& player, const AsciiString& buildingType, Int cash)
- {
- Player* thePlayer = TheScriptEngine->getPlayerFromAsciiString(player);
- if (thePlayer) {
- thePlayer->buildBySupplies(cash, buildingType);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildObjectNearestTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildObjectNearestTeam( const AsciiString& playerName, const AsciiString& buildingType, const AsciiString& teamName )
- {
- Player *thePlayer = TheScriptEngine->getPlayerFromAsciiString( playerName );
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if( thePlayer && theTeam )
- {
- thePlayer->buildSpecificBuildingNearestTeam( buildingType, theTeam );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildUpgrade */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildUpgrade(const AsciiString& player, const AsciiString& upgrade)
- {
- Player* thePlayer = TheScriptEngine->getPlayerFromAsciiString(player);
- if (thePlayer) {
- thePlayer->buildUpgrade(upgrade);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildBaseDefense */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildBaseDefense(Bool flank)
- {
- // This action ALWAYS occur on the current player.
- Player *thePlayer = TheScriptEngine->getCurrentPlayer();
- if (thePlayer) {
- thePlayer->buildBaseDefense(flank);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildBaseStructure(const AsciiString& buildingType, Bool flank)
- {
- // This action ALWAYS occur on the current player.
- Player *thePlayer = TheScriptEngine->getCurrentPlayer();
- if (thePlayer) {
- thePlayer->buildBaseDefenseStructure(buildingType, flank);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** createUnitOnTeamAt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::createUnitOnTeamAt(const AsciiString& unitName, const AsciiString& objType, const AsciiString& teamName, const AsciiString& waypoint)
- {
- Object* pOldObj = TheScriptEngine->getUnitNamed(unitName);
- if (pOldObj && !pOldObj->isEffectivelyDead()) {
- AsciiString str = "WARNING - Object with name ";
- str.concat(unitName);
- str.concat(" already exists. Failed Create.");
- TheScriptEngine->AppendDebugMessage(str, false);
- // Unit by that name already exists
- return;
- }
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (theTeam==NULL) {
- // We may need to create the team.
- theTeam = TheTeamFactory->createTeam( teamName );
- }
- if (!theTeam) {
- TheScriptEngine->AppendDebugMessage("***WARNING - Team not found:***", false);
- TheScriptEngine->AppendDebugMessage(teamName, true);
- DEBUG_LOG(("WARNING - Team %s not found.\n", teamName.str()));
- return;
- }
- const ThingTemplate *thingTemplate;
- // get thing template based from map object name
- thingTemplate = TheThingFactory->findTemplate(objType);
- if (thingTemplate) {
- // create new object in the world
- Object *obj = TheThingFactory->newObject( thingTemplate, theTeam );
- if( obj )
- {
- if (unitName != m_unnamedUnit) {
- obj->setName(unitName);
- if (pOldObj || TheScriptEngine->didUnitExist(unitName)) {
- TheScriptEngine->transferObjectName(unitName, obj);
- } else {
- TheScriptEngine->addObjectToCache(obj);
- }
- }
-
- Waypoint *way = TheTerrainLogic->getWaypointByName( waypoint );
- if (way)
- {
- Coord3D destination = *way->getLocation();
- obj->setPosition(&destination);
- }
- } // end if
- } else {
- DEBUG_LOG(("WARNING - ThingTemplate '%s' not found.\n", objType.str()));
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** updateNamedAttackPrioritySet */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updateNamedAttackPrioritySet(const AsciiString& unitName, const AsciiString& attackPrioritySet)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!theSrcUnit) {
- return;
- }
- AIUpdateInterface *pInterface = theSrcUnit->getAIUpdateInterface();
- if (!pInterface) {
- return;
- }
-
- const AttackPriorityInfo *info = TheScriptEngine->getAttackInfo(attackPrioritySet);
- pInterface->setAttackInfo(info);
- }
- //-------------------------------------------------------------------------------------------------
- /** updateTeamAttackPrioritySet */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updateTeamAttackPrioritySet(const AsciiString& teamName, const AsciiString& attackPrioritySet)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- const AttackPriorityInfo *info = TheScriptEngine->getAttackInfo(attackPrioritySet);
-
- if (info->getName().isNotEmpty()) {
- team->setAttackPriorityName(info->getName());
- }
- // Set team member's attack priority.
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- ai->setAttackInfo(info);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** updateBaseConstructionSpeed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updateBaseConstructionSpeed(const AsciiString& playerName, Int delayInSeconds)
- {
- Player* thePlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (thePlayer) {
- thePlayer->setTeamDelaySeconds(delayInSeconds);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** updateNamedSetAttitude */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updateNamedSetAttitude(const AsciiString& unitName, Int attitude)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!theSrcUnit) {
- return;
- }
- AIUpdateInterface *pInterface = theSrcUnit->getAIUpdateInterface();
- if (!pInterface) {
- return;
- }
-
- pInterface->setAttitude((AttitudeType) attitude);
- }
- //-------------------------------------------------------------------------------------------------
- /** updateTeamSetAttitude */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updateTeamSetAttitude(const AsciiString& teamName, Int attitude)
- {
- Team *theSrcTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theSrcTeam) {
- return;
- }
- AIGroup *pAIGroup = TheAI->createGroup();
- if (!pAIGroup) {
- return;
- }
- theSrcTeam->getTeamAsAIGroup(pAIGroup);
- pAIGroup->setAttitude((AttitudeType) attitude);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetRepulsor */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetRepulsor(const AsciiString& unitName, Bool repulsor)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!theSrcUnit) {
- return;
- }
- theSrcUnit->setStatus( MAKE_OBJECT_STATUS_MASK( OBJECT_STATUS_REPULSOR ), repulsor);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamSetRepulsor */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSetRepulsor(const AsciiString& teamName, Bool repulsor)
- {
- Team *theSrcTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theSrcTeam) {
- return;
- }
- if (theSrcTeam)
- {
- for (DLINK_ITERATOR<Object> iter = theSrcTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- if (!obj)
- {
- continue;
- }
- obj->setStatus( MAKE_OBJECT_STATUS_MASK( OBJECT_STATUS_REPULSOR ), repulsor );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedAttackArea */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedAttackArea(const AsciiString& unitName, const AsciiString& areaName)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theSrcUnit) {
- return;
- }
-
- PolygonTrigger *pTrig = TheScriptEngine->getQualifiedTriggerAreaByName(areaName);
- if (!pTrig) {
- return;
- }
- AIUpdateInterface* aiUpdate = theSrcUnit->getAIUpdateInterface();
- if( !aiUpdate )
- {
- return;
- }
- theSrcUnit->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiAttackArea(pTrig, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedAttackTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedAttackTeam(const AsciiString& unitName, const AsciiString& teamName)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theSrcUnit) {
- return;
- }
-
- const Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIUpdateInterface* aiUpdate = theSrcUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- theSrcUnit->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiAttackTeam(theTeam, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamAttackArea */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamAttackArea(const AsciiString& teamName, const AsciiString& areaName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- PolygonTrigger *pTrig = TheScriptEngine->getQualifiedTriggerAreaByName(areaName);
- if (!pTrig) {
- return;
- }
- theGroup->groupAttackArea(pTrig, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamAttackNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamAttackNamed(const AsciiString& teamName, const AsciiString& unitName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (!theTeam) {
- return;
- }
- Object *theVictim = TheScriptEngine->getUnitNamed( unitName );
- if (!theVictim) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupAttackObject(theVictim, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doLoadAllTransports */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doLoadAllTransports(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if (!theTeam) {
- return;
- }
- EntriesVec vecOfUnits;
- SpacesVec vecOfTransports;
-
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- if (!obj) {
- continue;
- }
- if( obj->isKindOf(KINDOF_TRANSPORT) )
- {
- ContainModuleInterface *contain = obj->getContain();
- if( contain )
- {
- vecOfTransports.push_back(std::make_pair(obj->getID(), ((TransportContain*)obj->getContain())->getContainMax()));
- }
- else
- {
- DEBUG_CRASH( ("doLoadAllTransports script -- transport doesn't have a container!") );
- }
- }
- else
- {
- vecOfUnits.push_back(std::make_pair(obj->getID(), obj->getTransportSlotCount()));
- }
- }
- // we've now built the necessary stuff. Partition the units.
- PartitionSolver partition(vecOfUnits, vecOfTransports, PREFER_FAST_SOLUTION);
- partition.solve();
- SolutionVec solution = partition.getSolution();
- for (int i = 0; i < solution.size(); ++i) {
- Object *unit = TheGameLogic->findObjectByID(solution[i].first);
- Object *trans = TheGameLogic->findObjectByID(solution[i].second);
- if (!unit || !trans) {
- continue;
- }
- if( unit->getAIUpdateInterface() )
- {
- unit->getAIUpdateInterface()->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- unit->getAIUpdateInterface()->aiEnter(trans, CMD_FROM_SCRIPT);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedEnterNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedEnterNamed(const AsciiString& unitSrcName, const AsciiString& unitDestName)
- {
- Object *theSrcUnit = TheScriptEngine->getUnitNamed( unitSrcName );
- if (!theSrcUnit) {
- return;
- }
-
- Object *theTransport = TheScriptEngine->getUnitNamed( unitDestName );
- if (!theTransport) {
- return;
- }
- AIUpdateInterface* aiUpdate = theSrcUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- theSrcUnit->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiEnter(theTransport, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamEnterNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamEnterNamed(const AsciiString& teamName, const AsciiString& unitDestName)
- {
- Team *theSrcTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theSrcTeam) {
- return;
- }
-
- Object *theTransport = TheScriptEngine->getUnitNamed( unitDestName );
- if (!theTransport) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- theSrcTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupEnter(theTransport, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedExitAll */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedExitAll(const AsciiString& unitName)
- {
- Object *theTransport = TheScriptEngine->getUnitNamed( unitName );
- if (!theTransport) {
- return;
- }
- AIUpdateInterface* aiUpdate = theTransport->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- theTransport->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiEvacuate( FALSE, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamExitAll */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamExitAll(const AsciiString& teamName)
- {
- Team *theTeamOfTransports = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeamOfTransports) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- theTeamOfTransports->getTeamAsAIGroup(theGroup);
- theGroup->groupEvacuate( CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetGarrisonEvacDisposition */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetGarrisonEvacDisposition(const AsciiString& unitName, UnsignedInt disp )
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- ContainModuleInterface *contain = theUnit->getContain();
- if( contain )
- contain->setEvacDisposition( (EvacDisposition)disp );
- // should be safe to cast any-old int to this enum,
- // since only 1(EVAC_TO_LEFT) and 2(EVAC_TO_RIGHT) differ from default case
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFollowWaypoints */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFollowWaypoints(const AsciiString& unitName, const AsciiString& waypointPathLabel)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- Coord3D pos = *theUnit->getPosition();
- AIUpdateInterface* aiUpdate = theUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, waypointPathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
-
- theUnit->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiFollowWaypointPath(way, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFollowWaypointsExact */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFollowWaypointsExact(const AsciiString& unitName, const AsciiString& waypointPathLabel)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- Coord3D pos = *theUnit->getPosition();
- AIUpdateInterface* aiUpdate = theUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, waypointPathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
-
- theUnit->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiFollowWaypointPathExact(way, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamFollowSkirmishApproachPath */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFollowSkirmishApproachPath(const AsciiString& teamName, const AsciiString& waypointPathLabel, Bool asTeam)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Int count = 0;
- Coord3D pos;
- pos.x=pos.y=pos.z=0;
- Object *firstUnit=NULL;
- // Get the center point for the team
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- Coord3D objPos = *obj->getPosition();
- pos.x += objPos.x;
- pos.y += objPos.y;
- pos.z += objPos.z; // Not actually used by getClosestWaypointOnPath, but hey, might as well be correct.
- count++;
- if (firstUnit==NULL) {
- firstUnit = obj;
- }
- }
- if (count==0) return; // empty team.
- pos.x /= count;
- pos.y /= count;
- pos.z /= count;
- Player *enemyPlayer = TheScriptEngine->getSkirmishEnemyPlayer();
- if (enemyPlayer==NULL) return;
- Int mpNdx = enemyPlayer->getMpStartIndex()+1;
- AsciiString pathLabel;
- pathLabel.format("%s%d", waypointPathLabel.str(), mpNdx);
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, pathLabel );
- if (!way) {
- return;
- }
- Player *aiPlayer = TheScriptEngine->getCurrentPlayer();
- if (aiPlayer && firstUnit) {
- aiPlayer->checkBridges(firstUnit, way);
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, pathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
- if (asTeam)
- {
- theGroup->groupFollowWaypointPathAsTeam(way, CMD_FROM_SCRIPT);
- } else {
- theGroup->groupFollowWaypointPath(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamFollowSkirmishApproachPath */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamMoveToSkirmishApproachPath(const AsciiString& teamName, const AsciiString& waypointPathLabel)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Int count = 0;
- Coord3D pos;
- pos.x=pos.y=pos.z=0;
- // Get the center point for the team
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- Coord3D objPos = *obj->getPosition();
- pos.x += objPos.x;
- pos.y += objPos.y;
- pos.z += objPos.z; // Not actually used by getClosestWaypointOnPath, but hey, might as well be correct.
- count++;
- }
- if (count==0) return; // empty team.
- pos.x /= count;
- pos.y /= count;
- pos.z /= count;
- Player *enemyPlayer = TheScriptEngine->getSkirmishEnemyPlayer();
- if (enemyPlayer==NULL) return;
- Int mpNdx = enemyPlayer->getMpStartIndex()+1;
- AsciiString pathLabel;
- pathLabel.format("%s%d", waypointPathLabel.str(), mpNdx);
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, pathLabel );
- if (!way) {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, pathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
- theGroup->groupMoveToPosition(way->getLocation(), false, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamFollowWaypoints */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFollowWaypoints(const AsciiString& teamName, const AsciiString& waypointPathLabel, Bool asTeam)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Int count = 0;
- Coord3D pos;
- pos.x=pos.y=pos.z=0;
- // Get the center point for the team
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- Coord3D objPos = *obj->getPosition();
- pos.x += objPos.x;
- pos.y += objPos.y;
- pos.z += objPos.z; // Not actually used by getClosestWaypointOnPath, but hey, might as well be correct.
- count++;
- }
- if (count==0) return; // empty team.
- pos.x /= count;
- pos.y /= count;
- pos.z /= count;
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, waypointPathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
- if (asTeam)
- {
- theGroup->groupFollowWaypointPathAsTeam(way, CMD_FROM_SCRIPT);
- } else {
- theGroup->groupFollowWaypointPath(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamFollowWaypointsExact */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFollowWaypointsExact(const AsciiString& teamName, const AsciiString& waypointPathLabel, Bool asTeam)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Int count = 0;
- Coord3D pos;
- pos.x=pos.y=pos.z=0;
- // Get the center point for the team
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- Coord3D objPos = *obj->getPosition();
- pos.x += objPos.x;
- pos.y += objPos.y;
- pos.z += objPos.z; // Not actually used by getClosestWaypointOnPath, but hey, might as well be correct.
- count++;
- }
- if (count==0) return; // empty team.
- pos.x /= count;
- pos.y /= count;
- pos.z /= count;
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, waypointPathLabel), ("***Wrong waypoint purpose. Make jba fix this.\n"));
- if (asTeam)
- {
- theGroup->groupFollowWaypointPathAsTeamExact(way, CMD_FROM_SCRIPT);
- } else {
- theGroup->groupFollowWaypointPathExact(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedGuard */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedGuard(const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- AIUpdateInterface* aiUpdate = theUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
-
- theUnit->leaveGroup();
- Coord3D position = *theUnit->getPosition();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiGuardPosition(&position, GUARDMODE_NORMAL, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGuard */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuard(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- // Have all the members of the team guard at their current pos.
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- Coord3D pos = *obj->getPosition();
- ai->aiGuardPosition(&pos, GUARDMODE_NORMAL, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGuardPosition */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuardPosition(const AsciiString& teamName, const AsciiString& waypointName)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam || !way) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Coord3D position = *way->getLocation();
- theGroup->groupGuardPosition( &position, GUARDMODE_NORMAL, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGuardObject */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuardObject(const AsciiString& teamName, const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam || !theUnit) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupGuardObject( theUnit, GUARDMODE_NORMAL, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGuardArea */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuardArea(const AsciiString& teamName, const AsciiString& areaName)
- {
- PolygonTrigger *pTrig = TheScriptEngine->getQualifiedTriggerAreaByName(areaName);
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam || !pTrig) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupGuardArea( pTrig, GUARDMODE_NORMAL, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedHunt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedHunt(const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- AIUpdateInterface* aiUpdate = theUnit->getAIUpdateInterface();
- if (!aiUpdate) {
- return;
- }
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiHunt( CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamHunt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamHunt(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupHunt( CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamHunt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamHuntWithCommandButton(const AsciiString& teamName, const AsciiString& ability)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton( ability );
- if( !commandButton )
- {
- return;
- }
- switch( commandButton->getCommandType() )
- {
- case GUI_COMMAND_SPECIAL_POWER:
- if( commandButton->getSpecialPowerTemplate() )
- {
- if (BitTest( commandButton->getOptions(), COMMAND_OPTION_NEED_OBJECT_TARGET ))
- {
- // OK, we can hunt with a power that targets an object.
- break;
- }
- AsciiString msg = "ERROR-Team hunt with command button - cannot hunt with ability ";
- msg.concat(ability);
- TheScriptEngine->AppendDebugMessage(msg, false);
- return;
- }
- return;
- case GUI_COMMAND_SWITCH_WEAPON:
- case GUI_COMMAND_FIRE_WEAPON:
- {
- // ok, we can hunt with a weapon.
- break;
- }
-
- case GUICOMMANDMODE_HIJACK_VEHICLE:
- case GUICOMMANDMODE_CONVERT_TO_CARBOMB:
- case GUICOMMANDMODE_SABOTAGE_BUILDING:
- //Various enter type hunts.
- break;
- case GUI_COMMAND_OBJECT_UPGRADE:
- case GUI_COMMAND_PLAYER_UPGRADE:
- case GUI_COMMAND_DOZER_CONSTRUCT:
- case GUI_COMMAND_DOZER_CONSTRUCT_CANCEL:
- case GUI_COMMAND_UNIT_BUILD:
- case GUI_COMMAND_CANCEL_UNIT_BUILD:
- case GUI_COMMAND_CANCEL_UPGRADE:
- case GUI_COMMAND_ATTACK_MOVE:
- case GUI_COMMAND_GUARD:
- case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:
- case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:
- case GUI_COMMAND_WAYPOINTS:
- case GUI_COMMAND_EXIT_CONTAINER:
- case GUI_COMMAND_EVACUATE:
- case GUI_COMMAND_EXECUTE_RAILED_TRANSPORT:
- case GUI_COMMAND_BEACON_DELETE:
- case GUI_COMMAND_SET_RALLY_POINT:
- case GUI_COMMAND_SELL:
- case GUI_COMMAND_HACK_INTERNET:
- case GUI_COMMAND_TOGGLE_OVERCHARGE:
- #ifdef ALLOW_SURRENDER
- case GUI_COMMAND_POW_RETURN_TO_PRISON:
- #endif
- #ifdef ALLOW_SURRENDER
- case GUICOMMANDMODE_PICK_UP_PRISONER:
- #endif
- default:
- {
- AsciiString msg = "ERROR-Team hunt with command button - cannot hunt with ability ";
- msg.concat(ability);
- TheScriptEngine->AppendDebugMessage(msg, false);
- return;
- }
- break;
- }
- // Have all the members of the team do the command button.
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- Bool foundCommand = false;
- const CommandSet *commandSet = TheControlBar->findCommandSet( obj->getCommandSetString( ) );
- if( commandSet )
- {
- for( int i = 0; i < MAX_COMMANDS_PER_SET; i++ )
- {
- const CommandButton *aCommandButton = commandSet->getCommandButton(i);
- if( commandButton == aCommandButton )
- {
- //We found the matching command button so now order the unit to do what the button wants.
- foundCommand = true;
- break;
- }
- }
- }
- if (!foundCommand) {
- AsciiString msg = "Error - Team hunt with command button - unit type '";
- msg.concat(obj->getTemplate()->getName().str());
- msg.concat("' is not valid for ability ");
- msg.concat(ability);
- TheScriptEngine->AppendDebugMessage(msg, false);
- continue;
- }
- switch( commandButton->getCommandType() )
- {
- case GUI_COMMAND_FIRE_WEAPON:
- case GUI_COMMAND_SWITCH_WEAPON:
- case GUI_COMMAND_SPECIAL_POWER:
- case GUICOMMANDMODE_HIJACK_VEHICLE:
- case GUICOMMANDMODE_CONVERT_TO_CARBOMB:
- case GUICOMMANDMODE_SABOTAGE_BUILDING:
- {
- static NameKeyType key_CommandButtonHuntUpdate = NAMEKEY("CommandButtonHuntUpdate");
- CommandButtonHuntUpdate* huntUpdate = (CommandButtonHuntUpdate*)obj->findUpdateModule(key_CommandButtonHuntUpdate);
- if( huntUpdate )
- {
- huntUpdate->setCommandButton(ability);
- } else {
- AsciiString msg = "Error - Team hunt with command button - unit type '";
- msg.concat(obj->getTemplate()->getName().str());
- msg.concat("' requires CommandButtonHuntUpdate in .ini definition to hunt with ");
- msg.concat(ability);
- TheScriptEngine->AppendDebugMessage(msg, false);
- } // end if
- }
- break;
-
- }
-
- }
- }
-
- //-------------------------------------------------------------------------------------------------
- /** doTeamHunt */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerHunt(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setUnitsShouldHunt(true, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerSellEverything */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerSellEverything(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->sellEverythingUnderTheSun();
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerDisableBaseConstruction */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerDisableBaseConstruction(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setCanBuildBase(false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerDisableFactories */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerDisableFactories(const AsciiString& playerName, const AsciiString& objectName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setObjectsEnabled(objectName, false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerDisableUnitConstruction */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerDisableUnitConstruction(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
-
- if (!pPlayer) {
- return;
- }
- pPlayer->setCanBuildUnits(false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerEnableBaseConstruction */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerEnableBaseConstruction(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setCanBuildBase(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerEnableFactories */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerEnableFactories(const AsciiString& playerName, const AsciiString& objectName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setObjectsEnabled(objectName, true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerRepairStructure */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerRepairStructure(const AsciiString& playerName, const AsciiString& structureName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- Object *pStructure = TheScriptEngine->getUnitNamed(structureName);
- if (!pStructure) {
- return;
- }
- pPlayer->repairStructure(pStructure->getID());
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerEnableUnitConstruction */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerEnableUnitConstruction(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->setCanBuildUnits(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraMoveHome */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraMoveHome(void)
- {
- }
- //-------------------------------------------------------------------------------------------------
- /** doBuildTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBuildTeam(const AsciiString& teamName)
- {
- TeamPrototype *theTeamProto = TheTeamFactory->findTeamPrototype( teamName );
- if (theTeamProto) {
- Player *player = theTeamProto->getControllingPlayer();
- if (player) {
- player->buildSpecificTeam(theTeamProto);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doRecruitTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRecruitTeam(const AsciiString& teamName, Real recruitRadius)
- {
- TeamPrototype *theTeamProto = TheTeamFactory->findTeamPrototype( teamName );
- if (theTeamProto) {
- Player *player = theTeamProto->getControllingPlayer();
- if (player) {
- player->recruitSpecificTeam(theTeamProto, recruitRadius);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedDamage */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedDamage(const AsciiString& unitName, Int damageAmt)
- {
- Object *pUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!pUnit) {
- return;
- }
- DamageInfo damageInfo;
- damageInfo.in.m_damageType = DAMAGE_UNRESISTABLE;
- damageInfo.in.m_deathType = DEATH_NORMAL;
- damageInfo.in.m_sourceID = INVALID_ID;
- damageInfo.in.m_amount = damageAmt;
- pUnit->attemptDamage( &damageInfo );
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedDelete */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedDelete(const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- TheGameLogic->destroyObject(theUnit);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamDelete */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamDelete(const AsciiString& teamName, Bool ignoreDead)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- team->deleteTeam(ignoreDead);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamWander */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamWander(const AsciiString& teamName, const AsciiString& waypointPathLabel)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- // Have all the members of the team wander.
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- Coord3D pos = *obj->getPosition();
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_WANDER);
- ai->aiWander(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamIncreasePriority */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamIncreasePriority(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- const TeamPrototype *theTeamProto = team->getPrototype();
- if (!theTeamProto) {
- return;
- }
- theTeamProto->increaseAIPriorityForSuccess();
- AsciiString msg;
- msg.format("Team '%s' priority increased to %d for success.", teamName.str(), theTeamProto->getTemplateInfo()->m_productionPriority);
- TheScriptEngine->AppendDebugMessage(msg, false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamDecreasePriority */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamDecreasePriority(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- const TeamPrototype *theTeamProto = team->getPrototype();
- if (!theTeamProto) {
- return;
- }
- theTeamProto->decreaseAIPriorityForFailure();
- AsciiString msg;
- msg.format("Team '%s' priority decreased to %d for failure.", teamName.str(), theTeamProto->getTemplateInfo()->m_productionPriority);
- TheScriptEngine->AppendDebugMessage(msg, false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamWanderInPlace */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamWanderInPlace(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- // Have all the members of the team wander.
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_WANDER);
- ai->aiWanderInPlace(CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamPanic */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamPanic(const AsciiString& teamName, const AsciiString& waypointPathLabel)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- // Get the center point for the team
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- Coord3D pos = *obj->getPosition();
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPathLabel );
- if (!way) {
- return;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_PANIC);
- ai->aiPanic(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedKill */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedKill(const AsciiString& unitName)
- {
- Object *pUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!pUnit) {
- return;
- }
- pUnit->kill();
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamKill */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamKill(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- team->killTeam();
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerKill */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerKill(const AsciiString& playerName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer) {
- return;
- }
- pPlayer->killPlayer();
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisplayText */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisplayText(const AsciiString& displayText)
- {
- TheInGameUI->message(displayText);
- }
- //-------------------------------------------------------------------------------------------------
- /** doInGamePopupMessage */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doInGamePopupMessage( const AsciiString& message, Int x, Int y, Int width, Bool pause )
- {
- TheInGameUI->popupMessage(message, x,y,width, pause, FALSE);
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisplayCinematicText */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisplayCinematicText(const AsciiString& displayText, const AsciiString& fontType, Int timeInSeconds)
- {
- // set the text
- UnicodeString uStr = TheGameText->fetch( displayText );
- AsciiString aStr;
- aStr.translate( uStr );
- TheDisplay->setCinematicText( aStr );
- // Gets the font info from parsing through fontType
- // get the font name
- AsciiString fontName = AsciiString::TheEmptyString;
- char buf[256];
- char *c;
- strcpy(buf, fontType.str());
- for( c = buf; c != '\0'; *c++ )
- {
- if( *c != ' ' && *c++ != '-' )
- fontName.concat(c);
- else
- break;
- }
- while( *c != ':' )
- *c++;
- *c++; // eat through " - Size:"
- // get font size
- AsciiString fontSize = AsciiString::TheEmptyString;
- for( ; *c != '\0'; *c++ )
- {
- if( *c != '\0' && *c != ' ' )
- {
- fontSize.concat( *c );
- }
- else
- {
- break;
- }
- }
- Int size = atoi( fontSize.str() );
- // get font fold
- Bool bold = FALSE;
- if( fontType.endsWith( "[Bold]" ) )
- bold = TRUE;
- // phew, now set as new font
- GameFont *font = TheFontLibrary->getFont( fontName,
- TheGlobalLanguageData->adjustFontSize(size), bold );
- TheDisplay->setCinematicFont( font );
- // set time
- Int frames = LOGICFRAMES_PER_SECOND * timeInSeconds;
- TheDisplay->setCinematicTextFrames( frames );
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameoFlash */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameoFlash(const AsciiString& name, Int timeInSeconds)
- {
- const CommandButton *button;
- //sanity
- button = TheControlBar->findCommandButton( name );
- if( button == NULL )
- {
- DEBUG_CRASH(( "ScriptActions::doCameoFlash can't find AsciiString cameoflash" ));
- }
- Int frames = LOGICFRAMES_PER_SECOND * timeInSeconds;
- // every time the framecount % 20 == 0, controlbar:: update will do Cameo Flash
- Int count = frames / DRAWABLE_FRAMES_PER_FLASH;
- // make sure count is even, so the cameo will return to its original state
- if( count % 2 == 1 )
- count++;
- button->setFlashCount(count);
- TheControlBar->setFlash( TRUE );
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedCustomColor */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedCustomColor(const AsciiString& unitName, Color c)
- {
- //sanity
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if ( !obj )
- {
- return;
- }
- obj->setCustomIndicatorColor(c);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFlash */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFlash(const AsciiString& unitName, Int timeInSeconds, const RGBColor *color)
- {
- /** This is called the first time this unit is told by the script to flash. timeInSeconds will tell the drawable
- how long to flash for. Sets drawable to start flashing but only allows drawable's update to
- call the actual flash method */
- //sanity
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if ( !obj )
- {
- return;
- }
- Drawable *drawable = obj->getDrawable();
- if( !drawable )
- {
- return;
- }
- if( timeInSeconds > 0 )
- {
- // set count for drawable, but do not flash, allow drawable update to handle it
- /* The designer specifies how long he wants the unit to flash for. We will
- convert this number into a count of how many times to call the doNamedFlash method */
- Int frames = LOGICFRAMES_PER_SECOND * timeInSeconds;
- // every time the framecount % 20 == 0, drawable::update will call doNamedFlash
- Int count = frames / DRAWABLE_FRAMES_PER_FLASH;
- Color flashy = (color == NULL) ? obj->getIndicatorColor() : color->getAsInt();
- drawable->setFlashColor( flashy );
- drawable->setFlashCount( count );
- return;
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamFlash */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFlash(const AsciiString& teamName, Int timeInSeconds, const RGBColor *color)
- {
- Team *team = TheScriptEngine->getTeamNamed( teamName );
- if (team == NULL || !team->hasAnyObjects())
- return;
- DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList();
- while( !iter.done() ) {
- Object *nextObj = iter.cur();
- Object *obj = nextObj;
- if (!obj) {
- break;
- }
- iter.advance();
- Drawable *draw = obj->getDrawable();
- if( !draw )
- break;
- Int frames = LOGICFRAMES_PER_SECOND * timeInSeconds;
- Int count = frames / DRAWABLE_FRAMES_PER_FLASH;
- Color flashy = (color == NULL) ? obj->getIndicatorColor() : color->getAsInt();
- draw->setFlashColor( flashy );
- draw->setFlashCount( count );
- }
- }
- #define ARBITRARY_BUFFER_SIZE 128
- //-------------------------------------------------------------------------------------------------
- /** doMoviePlayFullScreen */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoviePlayFullScreen(const AsciiString& movieName)
- {
- TheDisplay->playMovie(movieName);
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoviePlayRadar */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoviePlayRadar(const AsciiString& movieName)
- {
- TheInGameUI->playMovie(movieName);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSoundPlayFromNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSoundPlayFromNamed(const AsciiString& soundName, const AsciiString& unitName)
- {
- Object *pUnit = TheScriptEngine->getUnitNamed(unitName);
- if (!pUnit) {
- return;
- }
-
- AudioEventRTS sfx(soundName, pUnit->getID());
- sfx.setIsLogicalAudio(true);
- TheAudio->addAudioEvent(&sfx);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSpeechPlay */
- //-------------------------------------------------------------------------------------------------
- enum
- {
- SUBTITLE_DURATION = 8000
- };
- void ScriptActions::doSpeechPlay(const AsciiString& speechName, Bool allowOverlap)
- {
- AudioEventRTS speech(speechName);
- speech.setIsLogicalAudio(true);
- speech.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());
- speech.setUninterruptable(!allowOverlap);
- TheAudio->addAudioEvent(&speech);
-
-
- AsciiString subtitleLabel("DIALOGEVENT:");
- subtitleLabel.concat(speechName);
- subtitleLabel.concat("Subtitle");
-
- // Found is important, because a failure will return a valid "Missing: 'Label'" string.
- Bool found = FALSE;
- UnicodeString subtitle = TheGameText->fetch(subtitleLabel, &found);
- if( found && !subtitle.isEmpty() && subtitle.getCharAt(0) != '*')
- {
- // Foreign versions can specify region specifc subtitle strings if they want.
- // English will have strings with / for easy translation, but they don't want to display.
- TheInGameUI->militarySubtitle( subtitleLabel, SUBTITLE_DURATION );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerTransferAssetsToPlayer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerTransferAssetsToPlayer(const AsciiString& playerSrcName, const AsciiString& playerDstName)
- {
- Player *pPlayerDest = TheScriptEngine->getPlayerFromAsciiString(playerDstName);
- Player *pPlayerSrc = TheScriptEngine->getPlayerFromAsciiString(playerSrcName);
- if (!pPlayerDest || !pPlayerSrc) {
- return;
- }
-
- pPlayerDest->transferAssetsFromThat(pPlayerSrc);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedTransferAssetsToPlayer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedTransferAssetsToPlayer(const AsciiString& unitName, const AsciiString& playerDstName)
- {
- Object *pObj = TheScriptEngine->getUnitNamed(unitName);
- Player *pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerDstName);
- if (!pObj || !pPlayer) {
- return;
- }
- Team *playerTeam = pPlayer->getDefaultTeam();
- if (!playerTeam) {
- return;
- }
- pObj->setTeam(playerTeam);
- updateTeamAndPlayerStuff(pObj, NULL);
- }
- //-------------------------------------------------------------------------------------------------
- /** excludePlayerFromScoreScreen */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::excludePlayerFromScoreScreen(const AsciiString& playerName)
- {
- Player *pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (pPlayer == NULL) {
- return;
- }
- pPlayer->setListInScoreScreen(FALSE);
- }
- //-------------------------------------------------------------------------------------------------
- /** excludePlayerFromScoreScreen */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::enableScoring(Bool score)
- {
- TheGameLogic->enableScoring(score);
- }
- //-------------------------------------------------------------------------------------------------
- /** updatePlayerRelationTowardPlayer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::updatePlayerRelationTowardPlayer(const AsciiString& playerSrcName, Int relationType, const AsciiString& playerDstName)
- {
- Player *pPlayerDest = TheScriptEngine->getPlayerFromAsciiString(playerDstName);
- Player *pPlayerSrc = TheScriptEngine->getPlayerFromAsciiString(playerSrcName);
- if (!pPlayerDest || !pPlayerSrc) {
- return;
- }
- pPlayerSrc->setPlayerRelationship(pPlayerDest, (Relationship) relationType);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRadarCreateEvent */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarCreateEvent(Coord3D *pos, Int eventType)
- {
- TheRadar->createEvent(pos, (RadarEventType)eventType);
- }
- //-------------------------------------------------------------------------------------------------
- /** doObjectRadarCreateEvent */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doObjectRadarCreateEvent(const AsciiString& unitName, Int eventType)
- {
- // get the building
- Object *theBuilding = TheScriptEngine->getUnitNamed( unitName );
- if (!theBuilding)
- return;
-
- // get building's position
- const Coord3D *pos = theBuilding->getPosition();
- if (!pos)
- return;
-
- // create event
- TheRadar->createEvent(pos, (RadarEventType)eventType);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamRadarCreateEvent */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamRadarCreateEvent(const AsciiString& teamName, Int eventType)
- {
- // get the team
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam)
- return;
- if (!theTeam->hasAnyUnits())
- return;
-
- // get team's position
- const Coord3D *pos = theTeam->getEstimateTeamPosition();
- if (!pos)
- return;
- // create event
- TheRadar->createEvent(pos, (RadarEventType)eventType);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRadarDisable */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarDisable(void)
- {
- TheRadar->hide(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRadarEnable */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarEnable(void)
- {
- TheRadar->hide(false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraMotionBlurJump - zoom in at the current location, jump to waypoint, and zoom out.*/
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraMotionBlurJump(const AsciiString& waypointName, Bool saturate)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- if (!way) {
- return;
- }
- Bool passed = FALSE; //assume all filters were applied correctly.
- Coord3D pos = *way->getLocation();
- if (TheTacticalView->setViewFilter(FT_VIEW_MOTION_BLUR_FILTER))
- {
- passed = TRUE;
- if (saturate) {
- if (!TheTacticalView->setViewFilterMode(FM_VIEW_MB_IN_AND_OUT_SATURATE))
- { //failed to set filter so restore default state
- TheTacticalView->setViewFilter(FT_NULL_FILTER);
- passed = FALSE;
- }
- } else {
- if (!TheTacticalView->setViewFilterMode(FM_VIEW_MB_IN_AND_OUT_ALPHA))
- { //failed to set filter so restore default state
- TheTacticalView->setViewFilter(FT_NULL_FILTER);
- passed = FALSE;
- };
- }
- if (passed)
- TheTacticalView->setViewFilterPos(&pos);
- }
- if (!passed)
- { //if we failed to apply the filter, we still need to get the camera to the target
- //so do it another way:
- TheTacticalView->lookAt(&pos);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraMotionBlurJump - zoom in at the current location, jump to waypoint, and zoom out.*/
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraMotionBlur(Bool zoomIn, Bool saturate)
- {
- if (TheTacticalView->setViewFilter(FT_VIEW_MOTION_BLUR_FILTER))
- {
- enum FilterModes mode;
- if (saturate) {
- if (zoomIn) {
- mode = FM_VIEW_MB_IN_SATURATE;
- } else {
- mode = FM_VIEW_MB_OUT_SATURATE;
- }
- } else {
- if (zoomIn) {
- mode = FM_VIEW_MB_IN_ALPHA;
- } else {
- mode = FM_VIEW_MB_OUT_ALPHA;
- }
- }
- if (!TheTacticalView->setViewFilterMode(mode))
- { //failed to set the filter so restore everything to normal
- TheTacticalView->setViewFilter(FT_NULL_FILTER);
- }
- }
- }
- static PlayerMaskType getHumanPlayerMask( void )
- {
- PlayerMaskType mask;
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- const Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- mask &= player->getPlayerMask();
- }
- //DEBUG_LOG(("getHumanPlayerMask(): mask was %4.4X\n", mask));
- return mask;
- }
- //-------------------------------------------------------------------------------------------------
- /** doRevealMapAtWaypoint */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRevealMapAtWaypoint(const AsciiString& waypointName, Real radiusToReveal, const AsciiString& playerName)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- if (!way) {
- return;
- }
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- PlayerMaskType playerMask;
- if (player && playerName.isNotEmpty())
- playerMask = player->getPlayerMask();
- else
- playerMask = getHumanPlayerMask();
- Real positionX = way->getLocation()->x;
- Real positionY = way->getLocation()->y;
- // A reveal script is a quick look. That way a Radar Jammer will still function correctly.
- ThePartitionManager->doShroudReveal(positionX, positionY, radiusToReveal, playerMask);
- ThePartitionManager->undoShroudReveal(positionX, positionY, radiusToReveal, playerMask);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRevealMapAtWaypoint */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doShroudMapAtWaypoint(const AsciiString& waypointName, Real radiusToShroud, const AsciiString& playerName)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- if (!way) {
- return;
- }
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- PlayerMaskType playerMask;
- if (player && playerName.isNotEmpty())
- playerMask = player->getPlayerMask();
- else
- playerMask = getHumanPlayerMask();
- Real positionX = way->getLocation()->x;
- Real positionY = way->getLocation()->y;
- // Likewise, this script does a dollop of shroud. Not permanent active shroud
- ThePartitionManager->doShroudCover(positionX, positionY, radiusToShroud, playerMask);
- ThePartitionManager->undoShroudCover(positionX, positionY, radiusToShroud, playerMask);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRevealMapEntire */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRevealMapEntire(const AsciiString& playerName)
- {
- DEBUG_LOG(("ScriptActions::doRevealMapEntire() for player named '%s'\n", playerName.str()));
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (player && playerName.isNotEmpty())
- {
- DEBUG_LOG(("ScriptActions::doRevealMapEntire() for player named '%ls' in position %d\n", player->getPlayerDisplayName().str(), player->getPlayerIndex()));
- ThePartitionManager->revealMapForPlayer( player->getPlayerIndex() );
- }
- else
- {
- DEBUG_LOG(("ScriptActions::doRevealMapEntire() - no player, so doing all human players\n"));
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- {
- DEBUG_LOG(("ScriptActions::doRevealMapEntire() for player %d\n", i));
- ThePartitionManager->revealMapForPlayer( i );
- }
- }
- }
- }
- void ScriptActions::doRevealMapEntirePermanently( Bool reveal, const AsciiString& playerName )
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (player && playerName.isNotEmpty())
- {
- if( reveal )
- ThePartitionManager->revealMapForPlayerPermanently( player->getPlayerIndex() );
- else
- ThePartitionManager->undoRevealMapForPlayerPermanently( player->getPlayerIndex() );
- }
- else
- {
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- {
- DEBUG_LOG(("ScriptActions::doRevealMapEntirePermanently() for player %d\n", i));
- if( reveal )
- ThePartitionManager->revealMapForPlayerPermanently( i );
- else
- ThePartitionManager->undoRevealMapForPlayerPermanently( i );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doShroudMapEntire */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doShroudMapEntire(const AsciiString& playerName)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (player && playerName.isNotEmpty())
- {
- ThePartitionManager->shroudMapForPlayer( player->getPlayerIndex() );
- }
- else
- {
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- {
- DEBUG_LOG(("ScriptActions::doShroudMapEntire() for player %d\n", i));
- ThePartitionManager->shroudMapForPlayer( i );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamAvailableForRecruitment */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamAvailableForRecruitment(const AsciiString& teamName, Bool availability)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theTeam) {
- return;
- }
- theTeam->setRecruitable(availability);
- }
- //-------------------------------------------------------------------------------------------------
- /** doCollectNearbyForTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCollectNearbyForTeam(const AsciiString& teamName)
- {
- DEBUG_CRASH(("You would think this has been implemented, but you'd be wrong. (doCollectNearbyForTeam)"));
- }
- //-------------------------------------------------------------------------------------------------
- /** doMergeTeamIntoTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMergeTeamIntoTeam(const AsciiString& teamSrcName, const AsciiString& teamDestName)
- {
- Team *teamSrc = TheScriptEngine->getTeamNamed(teamSrcName);
- Team *teamDest = TheScriptEngine->getTeamNamed(teamDestName);
- if (teamDest==NULL) {
- teamDest = TheTeamFactory->findTeam( teamDestName );
- }
- if (!teamSrc || !teamDest) {
- return;
- }
- // Bool done = FALSE;
-
- DLINK_ITERATOR<Object> iter = teamSrc->iterate_TeamMemberList();
- Object *nextObj = iter.cur();
- while (!iter.done()) {
- Object *obj = nextObj;
- if (!obj) {
- break;
- }
- // this has to be done here, setting the team will screw up the iterator. total bummer dude. jkmcd
- nextObj = iter.cur();
- iter.advance();
- obj->setTeam(teamDest);
- updateTeamAndPlayerStuff(obj, NULL);
- }
- if (nextObj) {
- nextObj->setTeam(teamDest);
- updateTeamAndPlayerStuff(nextObj, NULL);
- }
- teamSrc->deleteTeam();
- teamDest->setActive(); // in case we just created him.
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisableInput */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisableInput()
- {
- #if defined(_DEBUG) || defined(_INTERNAL)
- if (!TheGlobalData->m_disableScriptedInputDisabling)
- #endif
- {
- TheInGameUI->setInputEnabled(false);
- TheMouse->setVisibility(false);
- TheInGameUI->deselectAllDrawables();
- TheInGameUI->clearAttackMoveToMode();
- TheInGameUI->setWaypointMode( FALSE );
- TheControlBar->deleteBuildTooltipLayout();
- TheLookAtTranslator->resetModes();
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doEnableInput */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEnableInput()
- {
- TheInGameUI->setInputEnabled(true);
- TheMouse->setVisibility(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetBorderShroud */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetBorderShroud( Bool setting )
- {
- if( setting )
- TheDisplay->setBorderShroudLevel(TheGlobalData->m_shroudAlpha);
- else
- TheDisplay->setBorderShroudLevel(TheGlobalData->m_clearAlpha);
- }
- //-------------------------------------------------------------------------------------------------
- /** doIdleAllPlayerUnits */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doIdleAllPlayerUnits(const AsciiString& playerName)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (player && playerName.isNotEmpty())
- {
- player->setUnitsShouldIdleOrResume(true);
- }
- else
- {
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- {
- DEBUG_LOG(("ScriptActions::doIdleAllPlayerUnits() for player %d\n", i));
- player->setUnitsShouldIdleOrResume(true);
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doResumeSupplyTruckingForIdleUnits */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doResumeSupplyTruckingForIdleUnits(const AsciiString& playerName)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (player && playerName.isNotEmpty())
- {
- player->setUnitsShouldIdleOrResume(false);
- }
- else
- {
- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)
- {
- Player *player = ThePlayerList->getNthPlayer(i);
- if (player->getPlayerType() == PLAYER_HUMAN)
- {
- DEBUG_LOG(("ScriptActions::doResumeSupplyTruckingForIdleUnits() for player %d\n", i));
- player->setUnitsShouldIdleOrResume(false);
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doAmbientSoundsPause */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAmbientSoundsPause(Bool pausing) // if true, then pause, if false then resume.
- {
- TheAudio->pauseAmbient(pausing);
- }
- //-------------------------------------------------------------------------------------------------
- /** doMusicTrackChange */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMusicTrackChange(const AsciiString& newTrackName, Bool fadeout, Bool fadein)
- {
- // Stop playing the music
- if (fadeout) {
- TheAudio->removeAudioEvent(AHSV_StopTheMusicFade);
- } else {
- TheAudio->removeAudioEvent(AHSV_StopTheMusic);
- }
- AudioEventRTS event(newTrackName);
- event.setShouldFade(fadein);
- event.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());
- TheAudio->addAudioEvent(&event);
- TheScriptEngine->setCurrentTrackName(newTrackName);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGarrisonSpecificBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGarrisonSpecificBuilding(const AsciiString& teamName, const AsciiString& buildingName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
- Object *theBuilding = TheScriptEngine->getUnitNamed(buildingName);
- if (!theBuilding) {
- return;
- }
- if( !theBuilding->getContain() )
- {
- DEBUG_CRASH( ("doTeamGarrisonSpecificBuilding script -- building doesn't have a container!" ) );
- return;
- }
- PlayerMaskType player = theBuilding->getContain()->getPlayerWhoEntered();
- if (!(theBuilding->isKindOf(KINDOF_STRUCTURE) &&
- (player == 0) || (player == theTeam->getControllingPlayer()->getPlayerMask()))) {
- return;
- }
-
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
-
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupEnter(theBuilding, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doExitSpecificBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doExitSpecificBuilding(const AsciiString& buildingName)
- {
- Object *theBuilding = TheScriptEngine->getUnitNamed(buildingName);
- if (!theBuilding)
- {
- return;
- }
-
- if (!theBuilding->isKindOf(KINDOF_STRUCTURE))
- {
- return;
- }
- AIUpdateInterface *ai = theBuilding->getAIUpdateInterface();
- if (ai)
- {
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiEvacuate( FALSE, CMD_FROM_SCRIPT );
- return;
- }
- ContainModuleInterface *contain = theBuilding->getContain();
- if (contain)
- {
- contain->removeAllContained( FALSE );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGarrisonNearestBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGarrisonNearestBuilding(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
-
- DLINK_ITERATOR<Object> diter = theTeam->iterate_TeamMemberList();
- Object *leader = diter.cur();
- if (!leader) {
- return;
- }
- PartitionFilter *filters[16];
- Int count = 0;
- PartitionFilterAcceptByKindOf f1( MAKE_KINDOF_MASK( KINDOF_FS_INTERNET_CENTER ), KINDOFMASK_NONE );
- PartitionFilterGarrisonableByPlayer f2(theTeam->getControllingPlayer(), true, CMD_FROM_SCRIPT);
- if( leader->isKindOf( KINDOF_MONEY_HACKER ) )
- {
- //If the leader is a hacker, then look for an internet center instead of a normal building!
- filters[ count++ ] = &f1;
- }
- else
- {
- //If the leader ISN'T a hacker, then look for standard fare garrisonable buildings (internet centers won't show up)!
- filters[ count++ ] = &f2;
- }
- PartitionFilterSameMapStatus filterMapStatus(leader);
- filters[ count++ ] = &filterMapStatus;
- filters[count++] = NULL;
- ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange(leader, REALLY_FAR, FROM_CENTER_3D, filters, ITER_SORTED_NEAR_TO_FAR);
- MemoryPoolObjectHolder hold(iter);
-
- // here's what we do. Find out how many slots each building has open, and tell each unit individually to
- // garrison a specific building. We won't use the partition solver because we've already done most of the work
-
- for (Object *theBuilding = iter->first(); theBuilding; theBuilding = iter->next()) {
- ContainModuleInterface *cmi = theBuilding->getContain();
- if (!cmi) {
- continue;
- }
- Int slotsAvailable = cmi->getContainMax() - cmi->getContainCount();
- for (int i = 0; i < slotsAvailable; ) {
- Object *obj = diter.cur();
- if (diter.done() || !obj) {
- return;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (ai && obj->isKindOf(KINDOF_INFANTRY) && !obj->isKindOf(KINDOF_NO_GARRISON)) {
- ai->aiEnter(theBuilding, CMD_FROM_SCRIPT);
- ++i;
- }
- diter.advance();
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamExitAllBuildings */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamExitAllBuildings(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (!theTeam) {
- return;
- }
-
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance()) {
- Object *obj = iter.cur();
- if (!obj) {
- continue;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiExit(NULL, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitGarrisonSpecificBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitGarrisonSpecificBuilding(const AsciiString& unitName, const AsciiString& buildingName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- Object *theBuilding = TheScriptEngine->getUnitNamed(buildingName);
- if (!theBuilding) {
- return;
- }
- ContainModuleInterface *contain = theBuilding->getContain();
- if( !contain )
- {
- DEBUG_CRASH(("doUnitGarrisonSpecificBuilding script -- building doesn't have a container" ));
- return;
- }
- PlayerMaskType player = theBuilding->getContain()->getPlayerWhoEntered();
- if (!(theBuilding->isKindOf(KINDOF_STRUCTURE) &&
- (player == 0) || (player == theUnit->getControllingPlayer()->getPlayerMask()))) {
- return;
- }
- AIUpdateInterface *ai = theUnit->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiEnter(theBuilding, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitGarrisonNearestBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitGarrisonNearestBuilding(const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- AIUpdateInterface *ai = theUnit->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- PartitionFilter *filters[16];
- Int count = 0;
- PartitionFilterAcceptByKindOf f1(MAKE_KINDOF_MASK(KINDOF_STRUCTURE), KINDOFMASK_NONE);
- filters[ count++ ] = &f1;
- PartitionFilterSameMapStatus filterMapStatus(theUnit);
- filters[ count++ ] = &filterMapStatus;
- PartitionFilterAcceptByKindOf f2( MAKE_KINDOF_MASK( KINDOF_FS_INTERNET_CENTER ), KINDOFMASK_NONE );
- PartitionFilterRejectByKindOf f3( MAKE_KINDOF_MASK( KINDOF_FS_INTERNET_CENTER ), KINDOFMASK_NONE );
-
- if( theUnit->isKindOf( KINDOF_MONEY_HACKER ) )
- {
- //If the unit is a hacker, then look for an internet center instead of a normal building!
- filters[ count++ ] = &f2;
- }
- else
- {
- //If the unit ISN'T a hacker, then ignore internet centers!
- filters[ count++ ] = &f3;
- }
- filters[count++] = NULL;
-
- ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange(theUnit, REALLY_FAR, FROM_CENTER_3D, filters, ITER_SORTED_NEAR_TO_FAR);
- MemoryPoolObjectHolder hold(iter);
- for (Object *theBuilding = iter->first(); theBuilding; theBuilding = iter->next())
- {
- ContainModuleInterface *contain = theBuilding->getContain();
- if( !contain )
- {
- DEBUG_CRASH( ("doUnitGarrisonNearestBuilding script -- building doesn't have a container.") );
- continue;
- }
- PlayerMaskType player = theBuilding->getContain()->getPlayerWhoEntered();
- if (!((player == 0) || (player == theUnit->getControllingPlayer()->getPlayerMask()))) {
- continue;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiEnter(theBuilding, CMD_FROM_SCRIPT);
- return;
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedEnableStealth */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedEnableStealth( const AsciiString& unitName, Bool enabled )
- {
- Object *self = TheScriptEngine->getUnitNamed( unitName );
- if( self )
- {
- self->setScriptStatus( OBJECT_STATUS_SCRIPT_UNSTEALTHED, !enabled );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamEnableStealth */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamEnableStealth( const AsciiString& teamName, Bool enabled )
- {
- Team *team = TheScriptEngine->getTeamNamed( teamName );
- if( !team )
- {
- return;
- }
-
- for( DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )
- {
- Object *obj = iter.cur();
- if( obj )
- {
- obj->setScriptStatus( OBJECT_STATUS_SCRIPT_UNSTEALTHED, !enabled );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetUnmanned */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetUnmanned( const AsciiString& unitName )
- {
- Object *self = TheScriptEngine->getUnitNamed( unitName );
- if( self )
- {
- self->setDisabled( DISABLED_UNMANNED );
- TheGameLogic->deselectObject( self, PLAYERMASK_ALL, TRUE );
- // Convert it to the neutral team so it renders gray giving visual representation that it is unmanned.
- self->setTeam( ThePlayerList->getNeutralPlayer()->getDefaultTeam() );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamSetUnmanned */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSetUnmanned( const AsciiString& teamName )
- {
- Team *team = TheScriptEngine->getTeamNamed( teamName );
- if( !team )
- {
- return;
- }
-
- for( DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); )
- {
- Object *obj = iter.cur();
- //Advance the iterator NOW because when we unman the object, the team gets nuked, and
- //the iterator stops after the first iteration!
- iter.advance();
- //*************
- if( obj )
- {
- obj->setDisabled( DISABLED_UNMANNED );
- TheGameLogic->deselectObject( obj, PLAYERMASK_ALL, TRUE );
- // Convert it to the neutral team so it renders gray giving visual representation that it is unmanned.
- obj->setTeam( ThePlayerList->getNeutralPlayer()->getDefaultTeam() );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetBoobytrapped( const AsciiString& thingTemplateName, const AsciiString& unitName )
- {
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if( obj )
- {
- const ThingTemplate *thing = TheThingFactory->findTemplate( thingTemplateName );
- if( thing )
- {
- Object *boobytrap = TheThingFactory->newObject( thing, obj->getTeam() );
- if( boobytrap )
- {
- static NameKeyType key_StickyBombUpdate = NAMEKEY( "StickyBombUpdate" );
- StickyBombUpdate *update = (StickyBombUpdate*)boobytrap->findUpdateModule( key_StickyBombUpdate );
- if( update )
- {
- //The charge gets positioned randomly on the outside of the perimeter of the victim.
- Coord3D pos;
- obj->getGeometryInfo().makeRandomOffsetOnPerimeter( pos );
- //Get the angle and transform matrix from the obj... then transform the calculated
- //position
- const Matrix3D *transform = obj->getTransformMatrix();
- transform->Transform_Vector( *transform, *(Vector3*)(&pos), (Vector3*)(&pos) );
- update->initStickyBomb( obj, NULL, &pos );
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSetBoobytrapped( const AsciiString& thingTemplateName, const AsciiString& teamName )
- {
- Team *team = TheScriptEngine->getTeamNamed( teamName );
- if( !team )
- {
- return;
- }
-
- for( DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )
- {
- Object *obj = iter.cur();
- const ThingTemplate *thing = TheThingFactory->findTemplate( thingTemplateName );
- if( thing )
- {
- Object *boobytrap = TheThingFactory->newObject( thing, obj->getTeam() );
- if( boobytrap )
- {
- static NameKeyType key_StickyBombUpdate = NAMEKEY( "StickyBombUpdate" );
- StickyBombUpdate *update = (StickyBombUpdate*)boobytrap->findUpdateModule( key_StickyBombUpdate );
- if( update )
- {
- //The charge gets positioned randomly on the outside of the perimeter of the victim.
- Coord3D pos;
- obj->getGeometryInfo().makeRandomOffsetOnPerimeter( pos );
- //Get the angle and transform matrix from the obj... then transform the calculated
- //position
- const Matrix3D *transform = obj->getTransformMatrix();
- transform->Transform_Vector( *transform, *(Vector3*)(&pos), (Vector3*)(&pos) );
- update->initStickyBomb( obj, NULL, &pos );
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitExitBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitExitBuilding(const AsciiString& unitName)
- {
- Object *theUnit = TheScriptEngine->getUnitNamed( unitName );
- if (!theUnit) {
- return;
- }
- AIUpdateInterface *ai = theUnit->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiExit(NULL, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerGarrisonAllBuildings */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerGarrisonAllBuildings(const AsciiString& playerName)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
-
- if (!player) {
- return;
- }
- player->garrisonAllUnits(CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerExitAllBuildings */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerExitAllBuildings(const AsciiString& playerName)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
-
- if (!player) {
- return;
- }
- player->ungarrisonAllUnits(CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doLetterBoxMode */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doLetterBoxMode(Bool startLetterbox)
- {
- if (startLetterbox)
- {
- HideControlBar(TRUE);
- TheDisplay->enableLetterBox(TRUE);
- }
- else
- {
- ShowControlBar(FALSE);
- TheDisplay->enableLetterBox(FALSE);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBlackWhiteMode */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBlackWhiteMode(Bool startBWMode, Int frames)
- {
- if (startBWMode)
- {
- TheTacticalView->setViewFilterMode(FM_VIEW_BW_BLACK_AND_WHITE);
- TheTacticalView->setViewFilter(FT_VIEW_BW_FILTER);
- TheTacticalView->setFadeParameters(frames, 1);
- }
- else
- {
- if ((TheTacticalView->getViewFilterType()) == FT_VIEW_BW_FILTER)
- { //mode already set, turn it off
- TheTacticalView->setFadeParameters(frames, -1);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doSkyBox */
- //-------------------------------------------------------------------------------------------------
- extern void doSkyBoxSet(Bool startDraw); //hack to avoid including globaldata here.
- void ScriptActions::doSkyBox(Bool startDraw)
- {
- if (startDraw)
- {
- doSkyBoxSet(1);
- }
- else
- {
- doSkyBoxSet(0);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doWeather */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doWeather(Bool showWeather)
- {
- TheSnowManager->setVisible(showWeather);
- }
- //-------------------------------------------------------------------------------------------------
- /** Freeze time */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doFreezeTime(void)
- {
- TheScriptEngine->doFreezeTime();
- }
- //-------------------------------------------------------------------------------------------------
- /** Unfreeze time */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnfreezeTime(void)
- {
- TheScriptEngine->doUnfreezeTime();
- }
- //-------------------------------------------------------------------------------------------------
- /** Show a military briefing */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMilitaryCaption(const AsciiString& briefing, Int duration)
- {
- #if defined(_DEBUG) || defined(_INTERNAL)
- if (TheGlobalData->m_disableMilitaryCaption)
- duration = 1;
- #endif
- TheInGameUI->militarySubtitle(briefing, duration);
- }
- //-------------------------------------------------------------------------------------------------
- /** Set the audible distance for shots in which the camera is up, and is therefore the center */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraSetAudibleDistance(Real audibleDistance)
- {
- // No-op
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetStoppingDistance */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetStoppingDistance(const AsciiString& team, Real stoppingDistance)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- if (theTeam)
- {
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *aiUpdate = obj->getAIUpdateInterface();
- if (!aiUpdate || !aiUpdate->getCurLocomotor()) {
- return;
- }
-
- if (stoppingDistance >= 0.5f)
- {
- aiUpdate->getCurLocomotor()->setCloseEnoughDist(stoppingDistance);
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetHeld */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetHeld(const AsciiString& unit, Bool held)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- theObj->setDisabledUntil( DISABLED_HELD, held ? FOREVER : NEVER );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetStoppingDistance */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetStoppingDistance(const AsciiString& unit, Real stoppingDistance)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- AIUpdateInterface *aiUpdate = theObj->getAIUpdateInterface();
- if (!aiUpdate || !aiUpdate->getCurLocomotor()) {
- return;
- }
-
- if (stoppingDistance >= 0.5f)
- {
- aiUpdate->getCurLocomotor()->setCloseEnoughDist(stoppingDistance);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisableSpecialPowerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisableSpecialPowerDisplay(void)
- {
- TheInGameUI->setSuperweaponDisplayEnabledByScript(false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doEnableSpecialPowerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEnableSpecialPowerDisplay(void)
- {
- TheInGameUI->setSuperweaponDisplayEnabledByScript(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedHideSpecialPowerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedHideSpecialPowerDisplay(const AsciiString& unit)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- TheInGameUI->hideObjectSuperweaponDisplayByScript(theObj);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedShowSpecialPowerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedShowSpecialPowerDisplay(const AsciiString& unit)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- TheInGameUI->showObjectSuperweaponDisplayByScript(theObj);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doAudioSetVolume */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAudioSetVolume(AudioAffect whichToAffect, Real newVolumeLevel)
- {
- newVolumeLevel /= 100.0f;
- if (newVolumeLevel < 0.0f) {
- newVolumeLevel = 0.0f;
- } else if (newVolumeLevel > 1.0f) {
- newVolumeLevel = 1.0f;
- }
- TheAudio->setVolume(newVolumeLevel, whichToAffect);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTransferTeamToPlayer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTransferTeamToPlayer(const AsciiString& teamName, const AsciiString& playerName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed(teamName);
- Player* playerDest = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!(theTeam && playerDest)) {
- return;
- }
- theTeam->setControllingPlayer(playerDest);
- // srj sez: ensure that all these guys get the upgrades that belong to the new player
- theTeam->iterateObjects(updateTeamAndPlayerStuff, NULL);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetMoney */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetMoney(const AsciiString& playerName, Int money)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!player) {
- return;
- }
- Money *m = player->getMoney();
- if (!m)
- return;
- m->withdraw(m->countMoney());
- m->deposit(money);
- }
- //-------------------------------------------------------------------------------------------------
- /** doGiveMoney */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doGiveMoney(const AsciiString& playerName, Int money)
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!player) {
- return;
- }
- Money *m = player->getMoney();
- if (!m)
- return;
- if (money < 0)
- m->withdraw(-money);
- else
- m->deposit(money);
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisplayCounter */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisplayCounter(const AsciiString& counterName, const AsciiString& counterText)
- {
- TheInGameUI->addNamedTimer(counterName, TheGameText->fetch(counterText), false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doHideCounter */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doHideCounter(const AsciiString& counterName)
- {
- TheInGameUI->removeNamedTimer(counterName);
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisplayCountdownTimer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisplayCountdownTimer(const AsciiString& timerName, const AsciiString& timerText)
- {
- TheInGameUI->addNamedTimer(timerName, TheGameText->fetch(timerText), true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doHideCountdownTimer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doHideCountdownTimer(const AsciiString& timerName)
- {
- TheInGameUI->removeNamedTimer(timerName);
- }
- //-------------------------------------------------------------------------------------------------
- /** doDisableCountdownTimerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDisableCountdownTimerDisplay(void)
- {
- TheInGameUI->showNamedTimerDisplay(FALSE);
- }
- //-------------------------------------------------------------------------------------------------
- /** doEnableCountdownTimerDisplay */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEnableCountdownTimerDisplay(void)
- {
- TheInGameUI->showNamedTimerDisplay(TRUE);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedStopSpecialPowerCountdown */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedStopSpecialPowerCountdown(const AsciiString& unit, const AsciiString& specialPower, Bool stop)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (theObj && power)
- {
- SpecialPowerModuleInterface *mod = theObj->getSpecialPowerModule(power);
- if (mod)
- {
- mod->pauseCountdown(stop);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedSetSpecialPowerCountdown */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetSpecialPowerCountdown( const AsciiString& unit, const AsciiString& specialPower, Int seconds )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (theObj && power)
- {
- SpecialPowerModuleInterface *mod = theObj->getSpecialPowerModule(power);
- if (mod)
- {
- Int frames = LOGICFRAMES_PER_SECOND * seconds;
- mod->setReadyFrame(TheGameLogic->getFrame() + frames);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedAddSpecialPowerCountdown */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedAddSpecialPowerCountdown( const AsciiString& unit, const AsciiString& specialPower, Int seconds )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (theObj && power)
- {
- SpecialPowerModuleInterface *mod = theObj->getSpecialPowerModule(power);
- if (mod)
- {
- Int frames = LOGICFRAMES_PER_SECOND * seconds;
- mod->setReadyFrame(mod->getReadyFrame() + frames);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFireSpecialPowerAtArea */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFireSpecialPowerAtWaypoint( const AsciiString& unit, const AsciiString& specialPower, const AsciiString& waypoint )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (theObj && power)
- {
- SpecialPowerModuleInterface *mod = theObj->getSpecialPowerModule(power);
- if (mod)
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypoint);
- if (!way) {
- return;
- }
- mod->doSpecialPowerAtLocation(way->getLocation(), INVALID_ANGLE, COMMAND_FIRED_BY_SCRIPT );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFireSpecialPowerAtArea */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSkirmishFireSpecialPowerAtMostCost( const AsciiString &player, const AsciiString& specialPower )
- {
- Int enemyNdx;
- Player *enemyPlayer = TheScriptEngine->getSkirmishEnemyPlayer();
- if (enemyPlayer == NULL) return;
- enemyNdx = enemyPlayer->getPlayerIndex();
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (power==NULL)
- return;
- Real radius = 50.0f;
- if (power->getRadiusCursorRadius()>radius) {
- radius = power->getRadiusCursorRadius();
- }
-
- Player::PlayerTeamList::const_iterator it;
-
- Player *pPlayer = TheScriptEngine->getPlayerFromAsciiString(player);
- if (pPlayer==NULL)
- return;
- for (it = pPlayer->getPlayerTeams()->begin(); it != pPlayer->getPlayerTeams()->end(); ++it)
- {
- for (DLINK_ITERATOR<Team> iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance())
- {
- Team *team = iter.cur();
- if (!team)
- continue;
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *pObj = iter.cur();
- if (!pObj)
- continue;
- SpecialPowerModuleInterface *mod = pObj->getSpecialPowerModule(power);
- if (mod)
- {
- if( !mod->isReady() )
- continue;
-
-
- Coord3D location;
- Bool locationFound = FALSE;
- locationFound = pPlayer->computeSuperweaponTarget(power, &location, enemyNdx, radius);
- if( locationFound && power->getSpecialPowerType() == SPECIAL_SNEAK_ATTACK )
- {
- //We need to modify the location. We're already calculated the sweet spot, but we need to modify that
- //position if we can't place it in the current location.
- const ThingTemplate *sneakAttackTemplate = mod->getReferenceThingTemplate();
- if( sneakAttackTemplate )
- {
- locationFound = pPlayer->calcClosestConstructionZoneLocation( sneakAttackTemplate, &location );
- }
- }
- DEBUG_ASSERTCRASH( locationFound, ("ScriptActions::doSkirmishFireSpecialPowerAtMostCost() could not find a valid (costly) location.") );
- if( locationFound && location.lengthSqr() > 0.0f )
- {
- mod->doSpecialPowerAtLocation( &location, INVALID_ANGLE, COMMAND_FIRED_BY_SCRIPT );
- }
- break;
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedFireSpecialPowerAtNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFireSpecialPowerAtNamed( const AsciiString& unit, const AsciiString& specialPower, const AsciiString& target )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- Object *theTarget = TheScriptEngine->getUnitNamed( target );
- const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplate(specialPower);
- if (theObj && power && theTarget)
- {
- SpecialPowerModuleInterface *mod = theObj->getSpecialPowerModule(power);
- if (mod)
- {
- mod->doSpecialPowerAtObject(theTarget, COMMAND_FIRED_BY_SCRIPT );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedUseCommandButtonAbility( const AsciiString& unit, const AsciiString& ability )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
-
- //Sanity check
- if( !theObj )
- {
- return;
- }
- const CommandSet *commandSet = TheControlBar->findCommandSet( theObj->getCommandSetString() );
- if( commandSet )
- {
- for( Int i = 0; i < MAX_COMMANDS_PER_SET; i++ )
- {
- //Get the command button.
- const CommandButton *commandButton = commandSet->getCommandButton(i);
- if( commandButton )
- {
- if( !commandButton->getName().isEmpty() )
- {
- if( commandButton->getName() == ability )
- {
- theObj->doCommandButton( commandButton, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedUseCommandButtonAbilityOnNamed( const AsciiString& unit, const AsciiString& ability, const AsciiString& target )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- Object *theTarget = TheScriptEngine->getUnitNamed( target );
-
- //Sanity check
- if( !theObj || !theTarget )
- {
- return;
- }
- const CommandSet *commandSet = TheControlBar->findCommandSet( theObj->getCommandSetString() );
- if( commandSet )
- {
- for( Int i = 0; i < MAX_COMMANDS_PER_SET; i++ )
- {
- //Get the command button.
- const CommandButton *commandButton = commandSet->getCommandButton(i);
- if( commandButton )
- {
- if( !commandButton->getName().isEmpty() )
- {
- if( commandButton->getName() == ability )
- {
- theObj->doCommandButtonAtObject( commandButton, theTarget, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedUseCommandButtonAbilityAtWaypoint( const AsciiString& unit, const AsciiString& ability, const AsciiString& waypoint )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- Waypoint *pWaypoint = TheTerrainLogic->getWaypointByName( waypoint );
-
- //Sanity check
- if( !theObj || !pWaypoint )
- {
- return;
- }
- const CommandSet *commandSet = TheControlBar->findCommandSet( theObj->getCommandSetString() );
- if( commandSet )
- {
- for( Int i = 0; i < MAX_COMMANDS_PER_SET; i++ )
- {
- //Get the command button.
- const CommandButton *commandButton = commandSet->getCommandButton(i);
- if( commandButton )
- {
- if( !commandButton->getName().isEmpty() )
- {
- if( commandButton->getName() == ability )
- {
- theObj->doCommandButtonAtPosition( commandButton, pWaypoint->getLocation(), CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedUseCommandButtonAbilityUsingWaypointPath( const AsciiString& unit, const AsciiString& ability, const AsciiString& waypointPath )
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if( !theObj )
- {
- return;
- }
- Waypoint *pWaypoint = TheTerrainLogic->getClosestWaypointOnPath( theObj->getPosition(), waypointPath );
-
- //Sanity check
- if( !pWaypoint )
- {
- return;
- }
- const CommandSet *commandSet = TheControlBar->findCommandSet( theObj->getCommandSetString() );
- if( commandSet )
- {
- for( Int i = 0; i < MAX_COMMANDS_PER_SET; i++ )
- {
- //Get the command button.
- const CommandButton *commandButton = commandSet->getCommandButton(i);
- if( commandButton )
- {
- if( !commandButton->getName().isEmpty() )
- {
- if( commandButton->getName() == ability )
- {
- theObj->doCommandButtonUsingWaypoints( commandButton, pWaypoint, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonAbility( const AsciiString& team, const AsciiString& ability )
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if( !theTeam )
- {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton( ability );
- if( !commandButton )
- {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if( !theGroup )
- {
- return;
- }
- theTeam->getTeamAsAIGroup( theGroup );
-
- theGroup->groupDoCommandButton( commandButton, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonAbilityOnNamed( const AsciiString& team, const AsciiString& ability, const AsciiString& target )
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if( !theTeam )
- {
- return;
- }
- Object *theObj = TheScriptEngine->getUnitNamed( target );
- if( !theObj )
- {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton( ability );
- if( !commandButton )
- {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if( !theGroup )
- {
- return;
- }
- theTeam->getTeamAsAIGroup( theGroup );
-
- theGroup->groupDoCommandButtonAtObject( commandButton, theObj, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonAbilityAtWaypoint( const AsciiString& team, const AsciiString& ability, const AsciiString& waypoint )
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( team );
- // The team is the team based on the name, and the calling team (if any) and the team that
- // triggered the condition. jba. :)
- if( !theTeam )
- {
- return;
- }
- Waypoint *pWaypoint = TheTerrainLogic->getWaypointByName( waypoint );
- if( !pWaypoint )
- {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton( ability );
- if( !commandButton )
- {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if( !theGroup )
- {
- return;
- }
- theTeam->getTeamAsAIGroup( theGroup );
-
- theGroup->groupDoCommandButtonAtPosition( commandButton, pWaypoint->getLocation(), CMD_FROM_SCRIPT );
- }
-
- //-------------------------------------------------------------------------------------------------
- /** doRadarRefresh */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarRefresh( void )
- {
- TheRadar->refreshTerrain( TheTerrainLogic );
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraTetherNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraTetherNamed(const AsciiString& unit, Bool snapToUnit, Real play)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unit );
- if (theObj)
- {
- TheTacticalView->setCameraLock(theObj->getID());
- if (snapToUnit)
- TheTacticalView->snapToCameraLock();
- TheTacticalView->setSnapMode( View::LOCK_TETHER, play );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraStopTetherNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraStopTetherNamed(void)
- {
- TheTacticalView->setCameraLock(INVALID_ID);
- }
- //-------------------------------------------------------------------------------------------------
- /** doCameraSetDefault */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real maxHeight)
- {
- TheTacticalView->setDefaultView(pitch, angle, maxHeight);
- }
- //-------------------------------------------------------------------------------------------------
- /** doNamedStop */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedStop(const AsciiString& unitName)
- {
- Object *theObj = TheScriptEngine->getUnitNamed( unitName );
- if (!theObj) {
- return;
- }
- AIUpdateInterface *ai = theObj->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- ai->aiIdle(CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamStop */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamStop(const AsciiString& teamName, Bool shouldDisband)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- theGroup->groupIdle(CMD_FROM_SCRIPT);
- if (shouldDisband) {
- Team *playerDefaultTeam = theTeam->getControllingPlayer()->getDefaultTeam();
-
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance()) {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- ai->setIsRecruitable(TRUE);
- }
- doMergeTeamIntoTeam(teamName, playerDefaultTeam->getName());
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamSetOverrideRelationToTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSetOverrideRelationToTeam(const AsciiString& teamName, const AsciiString& otherTeam, Int relation)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- Team *theOtherTeam = TheScriptEngine->getTeamNamed( otherTeam );
- if (theTeam && theOtherTeam) {
- theTeam->setOverrideTeamRelationship(theOtherTeam->getID(), (Relationship)relation);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamRemoveOverrideRelationToTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamRemoveOverrideRelationToTeam(const AsciiString& teamName, const AsciiString& otherTeam)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- Team *theOtherTeam = TheScriptEngine->getTeamNamed( otherTeam );
- if (theTeam && theOtherTeam) {
- theTeam->removeOverrideTeamRelationship(theOtherTeam->getID());
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerSetOverrideRelationToTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerSetOverrideRelationToTeam(const AsciiString& playerName, const AsciiString& otherTeam, Int relation)
- {
- Player *thePlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
- Team *theOtherTeam = TheScriptEngine->getTeamNamed( otherTeam );
- if (thePlayer && theOtherTeam) {
- thePlayer->setTeamRelationship(theOtherTeam, (Relationship)relation);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doPlayerRemoveOverrideRelationToTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerRemoveOverrideRelationToTeam(const AsciiString& playerName, const AsciiString& otherTeam)
- {
- Player *thePlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
- Team *theOtherTeam = TheScriptEngine->getTeamNamed( otherTeam );
- if (thePlayer && theOtherTeam) {
- thePlayer->removeTeamRelationship(theOtherTeam);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamSetOverrideRelationToPlayer */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSetOverrideRelationToPlayer(const AsciiString& teamName, const AsciiString& otherPlayer, Int relation)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- Player *theOtherPlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(otherPlayer));
- if (theTeam && theOtherPlayer) {
- theTeam->setOverridePlayerRelationship(theOtherPlayer->getPlayerIndex(), (Relationship)relation);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamRemoveOverrideRelationToTeam */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamRemoveOverrideRelationToPlayer(const AsciiString& teamName, const AsciiString& otherPlayer)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- Player *theOtherPlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(otherPlayer));
- if (theTeam && theOtherPlayer) {
- theTeam->removeOverridePlayerRelationship(theOtherPlayer->getPlayerIndex());
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamRemoveAllOverrideRelations */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamRemoveAllOverrideRelations(const AsciiString& teamName)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if (theTeam) {
- // invalid ID is OK -- it removes all relationships
- theTeam->removeOverrideTeamRelationship( NULL );
- theTeam->removeOverridePlayerRelationship( NULL );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitStartSequentialScript */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitStartSequentialScript(const AsciiString& unitName, const AsciiString& scriptName, Int loopVal)
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- Script *script = const_cast<Script*>(TheScriptEngine->findScriptByName(scriptName));
- if (!script) {
- return;
- }
- SequentialScript* seqScript = newInstance(SequentialScript);
- seqScript->m_objectID = obj->getID();
- seqScript->m_scriptToExecuteSequentially = script;
- seqScript->m_timesToLoop = loopVal;
-
- TheScriptEngine->appendSequentialScript(seqScript);
- seqScript->deleteInstance();
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitStopSequentialScript */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitStopSequentialScript(const AsciiString& unitName)
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- TheScriptEngine->removeAllSequentialScripts(obj);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamStartSequentialScript */
- //-------------------------------------------------------------------------------------------------
- /** doNamedFireWeaponFollowingWaypointPath -- Kris
- Orders unit to fire a waypoint following capable weapon to follow a waypoint and attack the
- final waypoint position. */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFireWeaponFollowingWaypointPath( const AsciiString& unit, const AsciiString& waypointPath )
- {
- //Get the unit... if it fails, abort.
- Object *theUnit = TheScriptEngine->getUnitNamed( unit );
- if( !theUnit )
- {
- return;
- }
-
- Coord3D pos = *theUnit->getPosition();
- //Find the closest waypoint on the path.
- Waypoint *way = TheTerrainLogic->getClosestWaypointOnPath( &pos, waypointPath );
- if( !way )
- {
- return;
- }
- //We have to do special checking to make sure our unit even has a waypoint following capable weapon.
- Weapon *weapon = theUnit->findWaypointFollowingCapableWeapon();
- if( !weapon )
- {
- return;
- }
- Object *projectile = weapon->forceFireWeapon( theUnit, &pos );
- if( projectile )
- {
- //Get the AIUpdateInterface... if it fails, abort.
- AIUpdateInterface* aiUpdate = projectile->getAIUpdateInterface();
- if( !aiUpdate )
- {
- return;
- }
- DEBUG_ASSERTLOG(TheTerrainLogic->isPurposeOfPath(way, waypointPath), ("***Wrong waypoint purpose. Make jba fix this.\n"));
-
- projectile->leaveGroup();
- aiUpdate->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- aiUpdate->aiFollowWaypointPath(way, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamStartSequentialScript */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamStartSequentialScript(const AsciiString& teamName, const AsciiString& scriptName, Int loopVal)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- Script *script = const_cast<Script*>(TheScriptEngine->findScriptByName(scriptName));
- if (!script) {
- return;
- }
- // Idle the team so the seq script will start executing. jba.
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- team->getTeamAsAIGroup(theGroup);
- theGroup->groupIdle(CMD_FROM_SCRIPT);
- SequentialScript* seqScript = newInstance(SequentialScript);
- seqScript->m_teamToExecOn = team;
- seqScript->m_scriptToExecuteSequentially = script;
- seqScript->m_timesToLoop = loopVal;
-
- TheScriptEngine->appendSequentialScript(seqScript);
- seqScript->deleteInstance();
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamStopSequentialScript */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamStopSequentialScript(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- TheScriptEngine->removeAllSequentialScripts(team);
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitGuardForFramecount */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitGuardForFramecount(const AsciiString& unitName, Int framecount)
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- Coord3D pos = *obj->getPosition();
- ai->chooseLocomotorSet(LOCOMOTORSET_NORMAL);
- ai->aiGuardPosition(&pos, GUARDMODE_NORMAL, CMD_FROM_SCRIPT);
- TheScriptEngine->setSequentialTimer(obj, framecount);
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitIdleForFramecount */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitIdleForFramecount(const AsciiString& unitName, Int framecount)
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- return;
- }
- ai->aiIdle(CMD_FROM_SCRIPT);
- TheScriptEngine->setSequentialTimer(obj, framecount);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamGuardForFramecount */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuardForFramecount(const AsciiString& teamName, Int framecount)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theTeam) {
- return;
- }
- // Have all the members of the team guard at their current pos.
- for (DLINK_ITERATOR<Object> iter = theTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- Coord3D pos = *obj->getPosition();
- ai->aiGuardPosition(&pos, GUARDMODE_NORMAL, CMD_FROM_SCRIPT);
- }
- TheScriptEngine->setSequentialTimer(theTeam, framecount);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamIdleForFramecount */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamIdleForFramecount(const AsciiString& teamName, Int framecount)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed(teamName);
- if (!theTeam) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if (!theGroup) {
- return;
- }
- theTeam->getTeamAsAIGroup(theGroup);
- Coord3D center;
- theGroup->getCenter(¢er);
- theGroup->groupIdle(CMD_FROM_SCRIPT);
- TheScriptEngine->setSequentialTimer(theTeam, framecount);
- }
- //-------------------------------------------------------------------------------------------------
- /** doWaterChangeHeight */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doWaterChangeHeight(const AsciiString& waterName, Real newHeight)
- {
- const WaterHandle *water = TheTerrainLogic->getWaterHandleByName(waterName);
- if (!water) {
- return;
- }
- TheTerrainLogic->setWaterHeight(water, newHeight, 999999.9f, TRUE );
- }
- //-------------------------------------------------------------------------------------------------
- /** doWaterChangeHeightOverTime */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doWaterChangeHeightOverTime( const AsciiString& waterName, Real newHeight, Real time, Real damage )
- {
- const WaterHandle *water = TheTerrainLogic->getWaterHandleByName( waterName );
- if( water )
- {
- TheTerrainLogic->changeWaterHeightOverTime( water, newHeight, time, damage );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doBorderSwitch */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doBorderSwitch(Int borderToUse)
- {
- /*
- * The observer player always has to have the map completely revealed for him.
- * Border switching doesn't play nice with the permanent map reveal so for the
- * observer player we need to undo the old permanent reveal, switch map borders,
- * and re-reveal the map. BGC
- */
- Int observerPlayerIndex = -1;
- if (ThePlayerList != NULL)
- {
- Player *observer = ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey("ReplayObserver"));
- if (observer != NULL) {
- observerPlayerIndex = observer->getPlayerIndex();
- }
- }
- if (observerPlayerIndex != -1)
- {
- ThePartitionManager->undoRevealMapForPlayerPermanently( observerPlayerIndex );
- }
- TheTerrainLogic->setActiveBoundary(borderToUse);
- if (observerPlayerIndex != -1)
- {
- ThePartitionManager->revealMapForPlayerPermanently( observerPlayerIndex );
- }
-
- ThePartitionManager->refreshShroudForLocalPlayer();
- }
- //-------------------------------------------------------------------------------------------------
- /** doForceObjectSelection */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doForceObjectSelection(const AsciiString& teamName, const AsciiString& objectType, Bool centerInView, const AsciiString& audioToPlay)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
-
- if (!team) {
- return;
- }
- Object *bestGuess = NULL;
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance()) {
- Object *obj = iter.cur();
- if (!obj) {
- continue;
- }
-
- if (obj->getTemplate() && obj->getTemplate()->getName() == objectType) {
- if (bestGuess == NULL || obj->getID() < bestGuess->getID()) { // lower ID means its newer
- bestGuess = obj;
- }
- }
- }
-
- if (!(bestGuess && bestGuess->getDrawable())) {
- return;
- }
- TheInGameUI->deselectAllDrawables();
- TheInGameUI->selectDrawable(bestGuess->getDrawable());
- // play the sound
- AudioEventRTS audioEvent(audioToPlay);
- audioEvent.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());
- TheAudio->addAudioEvent(&audioEvent);
- if (centerInView) {
- Coord3D pos = *bestGuess->getPosition();
- TheTacticalView->moveCameraTo(&pos, 0, 0, FALSE, 0.0f, 0.0f);
- }
- }
- void* __cdecl killTheObject( Object *obj, void* userObj )
- {
- userObj;
- if (obj)
- obj->kill();
- return NULL;
- }
- //-------------------------------------------------------------------------------------------------
- /** doForceObjectSelection */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doDestroyAllContained(const AsciiString& unitName, Int damageType )
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- ContainModuleInterface *cmi = obj->getContain();
- if( !cmi || cmi->getContainCount() == 0 )
- {
- return;
- }
- cmi->iterateContained((ContainIterateFunc)killTheObject, NULL, false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRadarForceEnable */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarForceEnable(void)
- {
- TheRadar->forceOn(true);
- }
- //-------------------------------------------------------------------------------------------------
- /** doRadarRevertNormal */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRadarRevertNormal(void)
- {
- TheRadar->forceOn(false);
- }
- //-------------------------------------------------------------------------------------------------
- /** doScreenShake */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doScreenShake( UnsignedInt intensity )
- {
- Coord3D pos;
- TheTacticalView->getPosition( &pos );
- TheTacticalView->shake( &pos, (View::CameraShakeType)intensity );
- }
- //-------------------------------------------------------------------------------------------------
- /** doModifyBuildableStatus */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doModifyBuildableStatus( const AsciiString& objectType, Int buildableStatus )
- {
- const ThingTemplate *templ = TheThingFactory->findTemplate(objectType);
- if (!templ)
- {
- return;
- }
- TheGameLogic->setBuildableStatusOverride(templ, (BuildableStatus) buildableStatus);
- }
- //-------------------------------------------------------------------------------------------------
- static CaveInterface* findCave(Object* obj)
- {
- for (BehaviorModule** i = obj->getBehaviorModules(); *i; ++i)
- {
- CaveInterface* c = (*i)->getCaveInterface();
- if (c != NULL)
- return c;
- }
- return NULL;
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetCaveIndex */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetCaveIndex( const AsciiString& caveName, Int caveIndex )
- {
- Object *obj = TheScriptEngine->getUnitNamed(caveName);
- if (!obj)
- {
- return;
- }
- CaveInterface *caveModule = findCave(obj);
- if( caveModule == NULL )
- return;
- caveModule->tryToSetCaveIndex( caveIndex );
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetWarehouseValue */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetWarehouseValue( const AsciiString& warehouseName, Int cashValue )
- {
- Object *obj = TheScriptEngine->getUnitNamed(warehouseName);
- if (!obj)
- {
- return;
- }
- static const NameKeyType warehouseModuleKey = TheNameKeyGenerator->nameToKey( "SupplyWarehouseDockUpdate" );
- SupplyWarehouseDockUpdate *warehouseModule = (SupplyWarehouseDockUpdate *)obj->findUpdateModule( warehouseModuleKey );
- if( warehouseModule == NULL )
- return;
- warehouseModule->setCashValue( cashValue );
- }
- //-------------------------------------------------------------------------------------------------
- /** doSoundEnableType */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSoundEnableType( const AsciiString& soundEventName, Bool enable )
- {
- TheAudio->setAudioEventEnabled(soundEventName, enable);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSoundRemoveAllDisabled()
- {
- TheAudio->removeDisabledEvents();
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSoundRemoveType( const AsciiString& soundEventName )
- {
- TheAudio->removeAudioEvent( soundEventName );
- }
- //-------------------------------------------------------------------------------------------------
- /** doSoundOverrideVolume */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSoundOverrideVolume( const AsciiString& soundEventName, Real newVolume )
- {
- TheAudio->setAudioEventVolumeOverride(soundEventName, newVolume / 100.0f);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSetToppleDirection */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetToppleDirection( const AsciiString& unitName, const Coord3D *dir )
- {
- TheScriptEngine->setToppleDirection(unitName, dir);
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoveTeamTowardsNearest */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoveUnitTowardsNearest( const AsciiString& unitName, const AsciiString& objectType, AsciiString triggerName)
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj)
- {
- return;
- }
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai)
- {
- return;
- }
-
- PolygonTrigger *trig = TheScriptEngine->getQualifiedTriggerAreaByName(triggerName);
- if (!trig)
- {
- return;
- }
- Object *bestObj = NULL;
- const ThingTemplate *templ = TheThingFactory->findTemplate( objectType, FALSE );
- if( templ )
- {
- PartitionFilterThing thingsToAccept(templ, true);
- PartitionFilterPolygonTrigger acceptWithin(trig);
- PartitionFilterSameMapStatus filterMapStatus(obj);
- PartitionFilter *filters[] = { &thingsToAccept, &acceptWithin, &filterMapStatus, NULL };
- bestObj = ThePartitionManager->getClosestObject( obj->getPosition(), REALLY_FAR, FROM_CENTER_2D, filters );
- if( !bestObj )
- {
- return;
- }
- }
- else
- {
- ObjectTypes *objectTypes = TheScriptEngine->getObjectTypes( objectType );
- if( objectTypes )
- {
- PartitionFilterPolygonTrigger acceptWithin( trig );
- PartitionFilterSameMapStatus filterMapStatus( obj );
- Coord3D pos = *obj->getPosition();
- Real closestDist;
- Real dist;
- for( Int typeIndex = 0; typeIndex < objectTypes->getListSize(); typeIndex++ )
- {
- AsciiString thisTypeName = objectTypes->getNthInList( typeIndex );
- const ThingTemplate *thisType = TheThingFactory->findTemplate( thisTypeName );
- if( thisType )
- {
- PartitionFilterThing f2( thisType, true );
- PartitionFilter *filters[] = { &f2, &acceptWithin, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject( &pos, REALLY_FAR, FROM_CENTER_2D, filters, &dist );
- if( obj )
- {
- if( !bestObj || dist < closestDist )
- {
- bestObj = obj;
- closestDist = dist;
- }
- }
- }
- }
- }
- }
-
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiMoveToObject( bestObj, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doMoveTeamTowardsNearest */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMoveTeamTowardsNearest( const AsciiString& teamName, const AsciiString& objectType, AsciiString triggerName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team)
- {
- return;
- }
-
- PolygonTrigger *trig = TheScriptEngine->getQualifiedTriggerAreaByName(triggerName);
- if (!trig)
- {
- return;
- }
- //Get the first object (to use in the partition filter checks).
- Object *teamObj = NULL;
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- teamObj = iter.cur();
- if( teamObj )
- {
- AIUpdateInterface *ai = teamObj->getAIUpdateInterface();
- if( ai )
- {
- break;
- }
- }
- }
- if( !teamObj )
- {
- return;
- }
- Coord3D teamPos = *team->getEstimateTeamPosition();
- PartitionFilterSameMapStatus filterMapStatus( teamObj );
- PartitionFilterPolygonTrigger acceptWithin( trig );
- Object *bestObj = NULL;
- const ThingTemplate *templ = TheThingFactory->findTemplate( objectType, FALSE );
- if( templ )
- {
- //Find the closest specified template.
- PartitionFilterThing thingsToAccept( templ, true );
- PartitionFilter *filters[] = { &thingsToAccept, &acceptWithin, &filterMapStatus, NULL };
- bestObj = ThePartitionManager->getClosestObject( &teamPos, REALLY_FAR, FROM_CENTER_2D, filters );
- if (!bestObj)
- {
- return;
- }
- }
- else
- {
- //Find the closest object within the object template list.
- ObjectTypes *objectTypes = TheScriptEngine->getObjectTypes( objectType );
- if( objectTypes )
- {
- Real closestDist;
- Real dist;
- for( Int typeIndex = 0; typeIndex < objectTypes->getListSize(); typeIndex++ )
- {
- AsciiString thisTypeName = objectTypes->getNthInList( typeIndex );
- const ThingTemplate *thisType = TheThingFactory->findTemplate( thisTypeName );
- if( thisType )
- {
- PartitionFilterThing thingToAccept( thisType, true );
- PartitionFilter *filters[] = { &thingToAccept, &acceptWithin, &filterMapStatus, NULL };
-
- Object *obj = ThePartitionManager->getClosestObject( &teamPos, REALLY_FAR, FROM_CENTER_2D, filters, &dist );
- if( obj )
- {
- if( !bestObj || dist < closestDist )
- {
- bestObj = obj;
- closestDist = dist;
- }
- }
- }
- }
- }
- }
- for( iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )
- {
- Object *obj = iter.cur();
- if( !obj )
- {
- return;
- }
- AIUpdateInterface *ai = obj->getAI();
- if( !ai )
- {
- return;
- }
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiMoveToObject( bestObj, CMD_FROM_SCRIPT );
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doUnitReceiveUpgrade */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUnitReceiveUpgrade( const AsciiString& unitName, const AsciiString& upgradeName )
- {
- Object *obj = TheScriptEngine->getUnitNamed(unitName);
- if (!obj) {
- return;
- }
- const UpgradeTemplate *templ = TheUpgradeCenter->findUpgrade(upgradeName);
- if (!templ) {
- return;
- }
- DEBUG_ASSERTCRASH(obj->affectedByUpgrade(templ), ("Design bug: Unit '%s' was given upgrade '%s', but he is unaffected.", unitName.str(), upgradeName.str()));
- obj->giveUpgrade(templ);
- }
- //-------------------------------------------------------------------------------------------------
- /** doSkirmishAttackNearestGroupWithValue */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSkirmishAttackNearestGroupWithValue( const AsciiString& teamName, Int comparison, Int value )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- Player *player = team->getControllingPlayer();
- if (!player)
- return;
- Coord3D loc;
- Coord3D groupLoc;
- theGroup->getCenter(&groupLoc);
- if (comparison == Parameter::GREATER_EQUAL || comparison == Parameter::GREATER) {
- ThePartitionManager->getNearestGroupWithValue(player->getPlayerIndex(), ALLOW_ENEMIES, VOT_CashValue,
- &groupLoc, value, true, &loc);
- }
- theGroup->groupAttackMoveToPosition( &loc, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT );
- }
- //-------------------------------------------------------------------------------------------------
- /** doSkirmishCommandButtonOnMostValuable */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSkirmishCommandButtonOnMostValuable( const AsciiString& teamName, const AsciiString& ability, Real range, Bool allTeamMembers)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- Player *player = team->getControllingPlayer();
- if (!player)
- return;
- const CommandButton *commandButton = TheControlBar->findCommandButton( ability );
- if( !commandButton ) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if ( !srcObj ) {
- return;
- }
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterValidCommandButtonTarget f2(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- PartitionFilter *filters[] = { &f1, &f2, &filterMapStatus, 0 };
- // @todo: Should we add the group's radius to the range? Seems like a possibility.
- SimpleObjectIterator *iter = ThePartitionManager->iterateObjectsInRange(&pos, range, FROM_CENTER_2D, filters, ITER_SORTED_EXPENSIVE_TO_CHEAP);
- MemoryPoolObjectHolder hold(iter);
- if (iter && iter->first()) {
- theGroup->groupDoCommandButtonAtObject(commandButton, iter->first(), CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamSpinForFramecount */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamSpinForFramecount( const AsciiString& teamName, Int waitForFrames )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- TheScriptEngine->setSequentialTimer(team, waitForFrames);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNamed */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNamed( const AsciiString& teamName, const AsciiString& commandAbility, const AsciiString& unitName )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if(!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if (!obj) {
- return;
- }
- if (commandButton->isValidToUseOn(srcObj, obj, NULL, CMD_FROM_SCRIPT)) {
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestEnemy */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestEnemy( const AsciiString& teamName, const AsciiString& commandAbility )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if(!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterValidCommandButtonTarget f2(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestGarrisonedBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestGarrisonedBuilding( const AsciiString& teamName, const AsciiString& commandAbility )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if(!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterAcceptByKindOf f2(MAKE_KINDOF_MASK(KINDOF_STRUCTURE), KINDOFMASK_NONE);
- PartitionFilterGarrisonable f3(true);
- PartitionFilterValidCommandButtonTarget f4(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &f3, &f4, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestKindof */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestKindof( const AsciiString& teamName, const AsciiString& commandAbility, Int kindofBit )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if (!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterAcceptByKindOf f2(MAKE_KINDOF_MASK(kindofBit), KINDOFMASK_NONE);
- PartitionFilterValidCommandButtonTarget f3(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &f3, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestBuilding */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestBuilding( const AsciiString& teamName, const AsciiString& commandAbility )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if (!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterAcceptByKindOf f2(MAKE_KINDOF_MASK(KINDOF_STRUCTURE), KINDOFMASK_NONE);
- PartitionFilterValidCommandButtonTarget f3(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &f3, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestBuildingClass */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestBuildingClass( const AsciiString& teamName, const AsciiString& commandAbility, Int kindofBit )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if (!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES, true);
- PartitionFilterAcceptByKindOf f2(MAKE_KINDOF_MASK(KINDOF_STRUCTURE), KINDOFMASK_NONE);
- PartitionFilterAcceptByKindOf f3(MAKE_KINDOF_MASK(kindofBit), KINDOFMASK_NONE);
- PartitionFilterValidCommandButtonTarget f4(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &f3, &f4, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamUseCommandButtonOnNearestObjectType */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamUseCommandButtonOnNearestObjectType( const AsciiString& teamName, const AsciiString& commandAbility, const AsciiString& objectType )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if (!commandButton) {
- return;
- }
- Object *srcObj = NULL;
- if (commandButton->getSpecialPowerTemplate()) {
- srcObj = theGroup->getSpecialPowerSourceObject(commandButton->getSpecialPowerTemplate()->getID());
- } else {
- srcObj = theGroup->getCommandButtonSourceObject(commandButton->getCommandType());
- }
- if (!srcObj) {
- return;
- }
- Object *bestObj = NULL;
- //First look for a specific object type (object lists will fail)
- const ThingTemplate *thingTemplate = TheThingFactory->findTemplate( objectType, FALSE );
- if( thingTemplate )
- {
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES | ALLOW_NEUTRAL, true);
- PartitionFilterThing f2(thingTemplate, true);
- PartitionFilterValidCommandButtonTarget f3(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus filterMapStatus(srcObj);
- PartitionFilter *filters[] = { &f1, &f2, &f3, &filterMapStatus, 0 };
- Coord3D pos;
- theGroup->getCenter(&pos);
- bestObj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if( !bestObj )
- {
- return;
- }
- }
- else
- {
- ObjectTypes *objectTypes = TheScriptEngine->getObjectTypes( objectType );
- if( objectTypes )
- {
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES | ALLOW_NEUTRAL, true);
- PartitionFilterValidCommandButtonTarget f3(srcObj, commandButton, true, CMD_FROM_SCRIPT);
- PartitionFilterSameMapStatus f4(srcObj);
- Coord3D pos;
- theGroup->getCenter(&pos);
- Real closestDist;
- Real dist;
- for( Int typeIndex = 0; typeIndex < objectTypes->getListSize(); typeIndex++ )
- {
- AsciiString thisTypeName = objectTypes->getNthInList( typeIndex );
- const ThingTemplate *thisType = TheThingFactory->findTemplate( thisTypeName );
- if( thisType )
- {
- PartitionFilterThing f2( thisType, true );
- PartitionFilter *filters[] = { &f1, &f2, &f3, &f4, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters, &dist );
- if( obj )
- {
- if( !bestObj || dist < closestDist )
- {
- bestObj = obj;
- closestDist = dist;
- }
- }
- }
- }
- }
- }
- // already been checked for validity
- theGroup->groupDoCommandButtonAtObject(commandButton, bestObj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamPartialUseCommandButton */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamPartialUseCommandButton( Real percentage, const AsciiString& teamName, const AsciiString& commandAbility )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton(commandAbility);
- if (!commandButton) {
- return;
- }
- std::vector<Object *> objList;
- DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList();
- for (iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance()) {
- Object *obj = iter.cur();
- if (commandButton->isValidToUseOn(obj, NULL, NULL, CMD_FROM_SCRIPT)) {
- objList.push_back(obj);
- }
- }
-
- Int numObjs = /*REAL_TO_INT_CEIL*/(percentage / 100.0f * objList.size());
- Int count = 0;
- for (std::vector<Object*>::const_iterator it = objList.begin(); it != objList.end(); ++it)
- {
- Object *obj = (*it);
- if (count >= numObjs)
- return;
- obj->doCommandButton(commandButton, CMD_FROM_SCRIPT);
- ++count;
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** doTeamCaptureNearestUnownedFactionUnit */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamCaptureNearestUnownedFactionUnit( const AsciiString& teamName )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- AIGroup *theGroup = TheAI->createGroup();
- team->getTeamAsAIGroup(theGroup);
- PartitionFilterPlayerAffiliation f1(team->getControllingPlayer(), ALLOW_ENEMIES | ALLOW_NEUTRAL, true);
- PartitionFilterUnmannedObject f2(true);
- PartitionFilterOnMap filterMapStatus;
- Coord3D pos;
- theGroup->getCenter(&pos);
- PartitionFilter *filters[] = { &f1, &f2, &filterMapStatus, 0 };
- Object *obj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
- if (!obj) {
- return;
- }
- theGroup->groupEnter(obj, CMD_FROM_SCRIPT);
- }
- //-------------------------------------------------------------------------------------------------
- /** doCreateTeamFromCapturedUnits */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doCreateTeamFromCapturedUnits( const AsciiString& playerName, const AsciiString& teamName )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerAddSkillPoints(const AsciiString& playerName, Int delta)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer)
- return;
- pPlayer->addSkillPoints(delta);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerAddRankLevels(const AsciiString& playerName, Int delta)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer)
- return;
- pPlayer->setRankLevel(pPlayer->getRankLevel() + delta);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerSetRankLevel(const AsciiString& playerName, Int level)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer)
- return;
- pPlayer->setRankLevel(level);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doMapSetRankLevelLimit(Int level)
- {
- if (TheGameLogic)
- TheGameLogic->setRankLevelLimit(level);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerGrantScience(const AsciiString& playerName, const AsciiString& scienceName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer)
- return;
- ScienceType science = TheScienceStore->getScienceFromInternalName(scienceName);
- if (science == SCIENCE_INVALID)
- return;
- pPlayer->grantScience(science);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerPurchaseScience(const AsciiString& playerName, const AsciiString& scienceName)
- {
- Player* pPlayer = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!pPlayer)
- return;
- ScienceType science = TheScienceStore->getScienceFromInternalName(scienceName);
- if (science == SCIENCE_INVALID)
- return;
- pPlayer->attemptToPurchaseScience(science);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doPlayerSetScienceAvailability( const AsciiString& playerName, const AsciiString& scienceName, const AsciiString& scienceAvailability )
- {
- Player* player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if( player )
- {
- ScienceAvailabilityType saType = player->getScienceAvailabilityTypeFromString( scienceAvailability );
- if( saType != SCIENCE_AVAILABILITY_INVALID )
- {
- ScienceType science = TheScienceStore->getScienceFromInternalName( scienceName );
- if( science != SCIENCE_INVALID )
- {
- player->setScienceAvailability( science, saType );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamEmoticon(const AsciiString& teamName, const AsciiString& emoticonName, Real duration)
- {
- Team *theTeam = TheScriptEngine->getTeamNamed( teamName );
- if( !theTeam )
- {
- return;
- }
- AIGroup* theGroup = TheAI->createGroup();
- if( !theGroup )
- {
- return;
- }
- theTeam->getTeamAsAIGroup( theGroup );
-
- Int frames = (Int)( duration * LOGICFRAMES_PER_SECOND );
- theGroup->groupSetEmoticon( emoticonName, frames );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedEmoticon(const AsciiString& unitName, const AsciiString& emoticonName, Real duration)
- {
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if( obj )
- {
- Drawable *draw = obj->getDrawable();
- if( draw )
- {
- Int frames = (Int)( duration * LOGICFRAMES_PER_SECOND );
- draw->setEmoticon( emoticonName, frames );
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- // if addObject, we're adding an object to a list. If not addObject, we're removing the associated
- // object.
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doObjectTypeListMaintenance(const AsciiString& objectList, const AsciiString& objectType, Bool addObject)
- {
- TheScriptEngine->doObjectTypeListMaintenance( objectList, objectType, addObject );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRevealMapAtWaypointPermanent(const AsciiString& waypointName, Real radiusToReveal, const AsciiString& playerName, const AsciiString& lookName)
- {
- TheScriptEngine->createNamedMapReveal(lookName, waypointName, radiusToReveal, playerName);
- TheScriptEngine->doNamedMapReveal(lookName);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doUndoRevealMapAtWaypointPermanent(const AsciiString& lookName)
- {
- TheScriptEngine->undoNamedMapReveal(lookName);
- TheScriptEngine->removeNamedMapReveal(lookName);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEvaEnabledDisabled(Bool setEnabled)
- {
- TheEva->setEvaEnabled(setEnabled);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetOcclusionMode(Bool setEnabled)
- {
- TheGameLogic->setShowBehindBuildingMarkers(setEnabled);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetDrawIconUIMode(Bool setEnabled)
- {
- TheGameLogic->setDrawIconUI(setEnabled);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doSetDynamicLODMode(Bool setEnabled)
- {
- TheGameLogic->setShowDynamicLOD(setEnabled);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doOverrideHulkLifetime( Real seconds )
- {
- if( seconds < 0.0f )
- {
- // Turn it off.
- TheGameLogic->setHulkMaxLifetimeOverride(-1);
- }
- else
- {
- // Convert real seconds into frames.
- Int frames = (Int)(seconds * LOGICFRAMES_PER_SECOND);
- TheGameLogic->setHulkMaxLifetimeOverride(frames);
- }
- }
- //-------------------------------------------------------------------------------------------------
- // MBL CNC3 INCURSION - This is to Have Max camera animation playback
- //
- void ScriptActions::doC3CameraEnableSlaveMode
- (
- const AsciiString& thingTemplateName,
- const AsciiString& boneName
- )
- {
- TheTacticalView->cameraEnableSlaveMode( thingTemplateName, boneName );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doC3CameraDisableSlaveMode( void )
- {
- TheTacticalView->cameraDisableSlaveMode();
- }
- //-------------------------------------------------------------------------------------------------
- // WST 11.12.2002 CNC3 INCURSION - This is for New Camera Shake
- //
- void ScriptActions::doC3CameraShake
- (
- const AsciiString &waypointName,
- const Real amplitude,
- const Real duration_seconds,
- const Real radius
- )
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName(waypointName);
- DEBUG_ASSERTLOG( (way != NULL), ("Camera shake with No Valid Waypoint\n") );
- Coord3D pos = *way->getLocation();
- TheTacticalView->Add_Camera_Shake(pos, radius, duration_seconds, amplitude);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFaceNamed( const AsciiString &unitName, const AsciiString &faceUnitName )
- {
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if( obj )
- {
- Object *faceObj = TheScriptEngine->getUnitNamed( faceUnitName );
- if( faceObj )
- {
- AIUpdateInterface *ai = obj->getAI();
- if( ai )
- {
- ai->clearWaypointQueue();
- obj->leaveGroup();
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiFaceObject( faceObj, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedFaceWaypoint( const AsciiString &unitName, const AsciiString &faceWaypointName )
- {
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if( obj )
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName( faceWaypointName );
- if( way )
- {
- AIUpdateInterface *ai = obj->getAI();
- if( ai )
- {
- ai->clearWaypointQueue();
- obj->leaveGroup();
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiFacePosition( way->getLocation(), CMD_FROM_SCRIPT );
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFaceNamed( const AsciiString &teamName, const AsciiString &faceUnitName )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if( team )
- {
- Object *faceObj = TheScriptEngine->getUnitNamed( faceUnitName );
- if( faceObj )
- {
- DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList();
- for( iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )
- {
- Object *obj = iter.cur();
- if( obj )
- {
- AIUpdateInterface *ai = obj->getAI();
- if( ai )
- {
- ai->clearWaypointQueue();
- obj->leaveGroup();
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiFaceObject( faceObj, CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamFaceWaypoint( const AsciiString &teamName, const AsciiString &faceWaypointName )
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if( team )
- {
- Waypoint *way = TheTerrainLogic->getWaypointByName( faceWaypointName );
- if( way )
- {
- DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList();
- for( iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )
- {
- Object *obj = iter.cur();
- if( obj )
- {
- AIUpdateInterface *ai = obj->getAI();
- if( ai )
- {
- ai->clearWaypointQueue();
- obj->leaveGroup();
- ai->chooseLocomotorSet( LOCOMOTORSET_NORMAL );
- ai->aiFacePosition( way->getLocation(), CMD_FROM_SCRIPT );
- }
- }
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAffectObjectPanelFlagsUnit(const AsciiString& unitName, const AsciiString& flagName, Bool enable)
- {
- Object *obj = TheScriptEngine->getUnitNamed( unitName );
- if (!obj) {
- return;
- }
- changeObjectPanelFlagForSingleObject(obj, flagName, enable);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAffectObjectPanelFlagsTeam(const AsciiString& teamName, const AsciiString& flagName, Bool enable)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList();
- for (iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance()) {
- Object *obj = iter.cur();
- changeObjectPanelFlagForSingleObject(obj, flagName, enable);
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAffectPlayerSkillset(const AsciiString& playerName, Int skillset)
- {
- Player *player = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!player) {
- return;
- }
- --skillset;
- player->friend_setSkillset(skillset);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doGuardSupplyCenter(const AsciiString& teamName, Int supplies)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- Player *player = team->getControllingPlayer();
- if (!player) {
- return;
- }
- player->guardSupplyCenter(team, supplies);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doTeamGuardInTunnelNetwork(const AsciiString& teamName)
- {
- Team *team = TheScriptEngine->getTeamNamed(teamName);
- if (!team) {
- return;
- }
- // Have all the members of the team guard at a tunnel network.
- for (DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance())
- {
- Object *obj = iter.cur();
- AIUpdateInterface *ai = obj->getAIUpdateInterface();
- if (!ai) {
- continue;
- }
- ai->aiGuardTunnelNetwork(GUARDMODE_NORMAL, CMD_FROM_SCRIPT);
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doRemoveCommandBarButton(const AsciiString& buttonName, const AsciiString& objectType)
- {
- const ThingTemplate *templ = TheThingFactory->findTemplate(objectType);
- if (!templ) {
- return;
- }
- const CommandSet *cs = TheControlBar->findCommandSet(templ->friend_getCommandSetString());
- if (!cs) {
- return;
- }
- Int slotNum = -1;
- for (Int i = 0; i < MAX_COMMANDS_PER_SET; ++i)
- {
- if (cs->getCommandButton(i) && (cs->getCommandButton(i)->getName() == buttonName))
- {
- slotNum = i;
- break;
- }
- }
-
- if (slotNum >= 0)
- {
- TheGameLogic->setControlBarOverride(templ->friend_getCommandSetString(), slotNum, NULL);
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAddCommandBarButton(const AsciiString& buttonName, const AsciiString& objectType, Int slotNum)
- {
- const ThingTemplate *templ = TheThingFactory->findTemplate(objectType);
- if (!templ) {
- return;
- }
- const CommandButton *commandButton = TheControlBar->findCommandButton( buttonName );
- if (commandButton == NULL)
- {
- // not here. use doRemoveCommandBarButton to remove one.
- return;
- }
- // decrement it, so we can present it as 1-12 for the designers.
- --slotNum;
- if (slotNum < 0 || slotNum >= MAX_COMMANDS_PER_SET)
- return;
- TheGameLogic->setControlBarOverride(templ->friend_getCommandSetString(), slotNum, commandButton);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doAffectSkillPointsModifier(const AsciiString& playerName, Real newModifier)
- {
- Player *playerDst = TheScriptEngine->getPlayerFromAsciiString(playerName);
- if (!playerDst) {
- return;
- }
- playerDst->setSkillPointsModifier(newModifier);
-
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doResizeViewGuardband(const Real gbx, const Real gby)
- {
- Coord2D newGuardBand = { gbx, gby };
- TheTacticalView->setGuardBandBias( &newGuardBand );
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::deleteAllUnmanned()
- {
- Object *obj = TheGameLogic->getFirstObject();
- while (obj) {
- if (obj->isDisabledByType(DISABLED_UNMANNED))
- TheGameLogic->destroyObject(obj);
- obj = obj->getNextObject();
- }
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doEnableOrDisableObjectDifficultyBonuses(Bool enableBonuses)
- {
- // Loops over every object in the game, applying bonuses or not.
- Object *obj = TheGameLogic->getFirstObject();
- while (obj) {
- obj->setReceivingDifficultyBonus(enableBonuses);
- obj = obj->getNextObject();
- }
- // notify the script engine of our decision
- TheScriptEngine->setObjectsShouldReceiveDifficultyBonus(enableBonuses);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doChooseVictimAlwaysUsesNormal(Bool enable)
- {
- TheScriptEngine->setChooseVictimAlwaysUsesNormal(enable);
- }
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::doNamedSetTrainHeld( const AsciiString &locoName, const Bool set )
- {
- Object *obj = TheScriptEngine->getUnitNamed( locoName );
- if( obj )
- {
- static const NameKeyType rrkey = NAMEKEY( "RailroadBehavior" );
- RailroadBehavior *rBehavior = (RailroadBehavior*)obj->findUpdateModule( rrkey );
- if ( rBehavior )
- {
- rBehavior->RailroadBehavior::setHeld( set );
- }
-
- }
- }
- //-------------------------------------------------------------------------------------------------
- /** Execute an action */
- //-------------------------------------------------------------------------------------------------
- void ScriptActions::executeAction( ScriptAction *pAction )
- {
- switch (pAction->getActionType()) {
- default:
- DEBUG_CRASH(("Unknown ScriptAction type %d", pAction->getActionType())); return;
- case ScriptAction::DEBUG_MESSAGE_BOX:
- doDebugMessage(pAction->getParameter(0)->getString(), true);
- return;
- case ScriptAction::DEBUG_STRING:
- doDebugMessage(pAction->getParameter(0)->getString(), false);
- return;
- case ScriptAction::DAMAGE_MEMBERS_OF_TEAM:
- doDamageTeamMembers(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::MOVE_TEAM_TO:
- doMoveToWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::MOVE_NAMED_UNIT_TO:
- doNamedMoveToWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_SET_STATE:
- doSetTeamState(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_FOLLOW_WAYPOINTS:
- doTeamFollowWaypoints(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString(),
- pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::TEAM_FOLLOW_WAYPOINTS_EXACT:
- doTeamFollowWaypointsExact(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString(),
- pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::NAMED_FOLLOW_WAYPOINTS_EXACT:
- doNamedFollowWaypointsExact(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SKIRMISH_FOLLOW_APPROACH_PATH:
- doTeamFollowSkirmishApproachPath(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString(),
- pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::SKIRMISH_MOVE_TO_APPROACH_PATH:
- doTeamMoveToSkirmishApproachPath(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString());
- return;
- case ScriptAction::CREATE_REINFORCEMENT_TEAM:
- doCreateReinforcements(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SKIRMISH_BUILD_BUILDING:
- doBuildBuilding(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::AI_PLAYER_BUILD_SUPPLY_CENTER:
- doBuildSupplyCenter(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::AI_PLAYER_BUILD_TYPE_NEAREST_TEAM:
- doBuildObjectNearestTeam( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
- case ScriptAction::AI_PLAYER_BUILD_UPGRADE:
- doBuildUpgrade(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SKIRMISH_BUILD_BASE_DEFENSE_FRONT:
- doBuildBaseDefense(false);
- return;
- case ScriptAction::SKIRMISH_BUILD_BASE_DEFENSE_FLANK:
- doBuildBaseDefense(true);
- return;
- case ScriptAction::SKIRMISH_BUILD_STRUCTURE_FRONT:
- doBuildBaseStructure(pAction->getParameter(0)->getString(), false);
- return;
- case ScriptAction::SKIRMISH_BUILD_STRUCTURE_FLANK:
- doBuildBaseStructure(pAction->getParameter(0)->getString(), true);
- return;
- case ScriptAction::RECRUIT_TEAM:
- doRecruitTeam(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::PLAY_SOUND_EFFECT:
- doPlaySoundEffect(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MOVE_CAMERA_TO:
- doMoveCameraTo(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal(), pAction->getParameter(4)->getReal());
- return;
- case ScriptAction::SETUP_CAMERA:
- doSetupCamera(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getString());
- return;
- case ScriptAction::ZOOM_CAMERA:
- doZoomCamera(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal());
- return;
- case ScriptAction::PITCH_CAMERA:
- doPitchCamera(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal());
- return;
- case ScriptAction::CAMERA_FOLLOW_NAMED:
- doCameraFollowNamed(pAction->getParameter(0)->getString(), (pAction->getParameter(1) && pAction->getParameter(1)->getInt() != 0));
- return;
- case ScriptAction::CAMERA_STOP_FOLLOW:
- doStopCameraFollowUnit();
- return;
- case ScriptAction::OVERSIZE_TERRAIN:
- doOversizeTheTerrain(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::CAMERA_MOD_LOOK_TOWARD:
- doModCameraLookToward(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::CAMERA_MOD_FINAL_LOOK_TOWARD:
- doModCameraFinalLookToward(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MOVE_CAMERA_ALONG_WAYPOINT_PATH:
- doMoveCameraAlongWaypointPath(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal(), pAction->getParameter(4)->getReal());
- return;
- case ScriptAction::ROTATE_CAMERA:
- doRotateCamera(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal());
- return;
- case ScriptAction::CAMERA_LOOK_TOWARD_OBJECT:
- doRotateCameraTowardObject(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal(), pAction->getParameter(4)->getReal());
- return;
- case ScriptAction::CAMERA_LOOK_TOWARD_WAYPOINT:
- doRotateCameraTowardWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal(), pAction->getParameter(4)->getInt());
- return;
- case ScriptAction::RESET_CAMERA:
- doResetCamera(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal());
- return;
- case ScriptAction::MOVE_CAMERA_TO_SELECTION:
- doModCameraMoveToSelection();
- return;
- case ScriptAction::CAMERA_MOD_FREEZE_TIME:
- TheTacticalView->cameraModFreezeTime();
- return;
- case ScriptAction::CAMERA_MOD_FREEZE_ANGLE:
- TheTacticalView->cameraModFreezeAngle();
- return;
- case ScriptAction::CAMERA_MOD_SET_FINAL_ZOOM:
- TheTacticalView->cameraModFinalZoom(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal());
- return;
- case ScriptAction::CAMERA_MOD_SET_FINAL_PITCH:
- TheTacticalView->cameraModFinalPitch(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal());
- return;
- case ScriptAction::CAMERA_MOD_SET_FINAL_SPEED_MULTIPLIER:
- TheTacticalView->cameraModFinalTimeMultiplier(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::CAMERA_MOD_SET_ROLLING_AVERAGE:
- TheTacticalView->cameraModRollingAverage(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::SET_VISUAL_SPEED_MULTIPLIER:
- TheTacticalView->setTimeMultiplier(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::SUSPEND_BACKGROUND_SOUNDS:
- TheAudio->pauseAudio(AudioAffect_Sound);
- return;
- case ScriptAction::RESUME_BACKGROUND_SOUNDS:
- TheAudio->resumeAudio(AudioAffect_Sound);
- return;
- case ScriptAction::PLAY_SOUND_EFFECT_AT:
- doPlaySoundEffectAt(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SET_INFANTRY_LIGHTING_OVERRIDE:
- doSetInfantryLightingOverride(pAction->getParameter(0)->getReal());
- return;
- case ScriptAction::RESET_INFANTRY_LIGHTING_OVERRIDE:
- doSetInfantryLightingOverride(-1.0f);
- return;
- case ScriptAction::QUICKVICTORY:
- doQuickVictory();
- return;
- case ScriptAction::VICTORY:
- doVictory();
- return;
- case ScriptAction::DEFEAT:
- doDefeat();
- return;
- case ScriptAction::LOCALDEFEAT:
- doLocalDefeat();
- return;
- case ScriptAction::CREATE_OBJECT:
- {
- Coord3D pos;
- pAction->getParameter(2)->getCoord3D(&pos);
- doCreateObject( m_unnamedUnit, pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), &pos, pAction->getParameter(3)->getReal() );
- return;
- }
- case ScriptAction::TEAM_ATTACK_TEAM:
- doAttack( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::NAMED_ATTACK_NAMED:
- doNamedAttack( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::CREATE_NAMED_ON_TEAM_AT_WAYPOINT:
- createUnitOnTeamAt( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString(), pAction->getParameter(3)->getString());
- return;
- case ScriptAction::CREATE_UNNAMED_ON_TEAM_AT_WAYPOINT:
- createUnitOnTeamAt( AsciiString::TheEmptyString, pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- case ScriptAction::NAMED_APPLY_ATTACK_PRIORITY_SET:
- updateNamedAttackPrioritySet(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_APPLY_ATTACK_PRIORITY_SET:
- updateTeamAttackPrioritySet(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SET_BASE_CONSTRUCTION_SPEED:
- updateBaseConstructionSpeed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_SET_ATTITUDE:
- updateNamedSetAttitude(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::TEAM_SET_ATTITUDE:
- updateTeamSetAttitude(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_SET_REPULSOR:
- doNamedSetRepulsor(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::TEAM_SET_REPULSOR:
- doTeamSetRepulsor(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_ATTACK_AREA:
- doNamedAttackArea(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_ATTACK_TEAM:
- doNamedAttackTeam(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ATTACK_AREA:
- doTeamAttackArea(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ATTACK_NAMED:
- doTeamAttackNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_LOAD_TRANSPORTS:
- doLoadAllTransports(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_ENTER_NAMED:
- doNamedEnterNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ENTER_NAMED:
- doTeamEnterNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_EXIT_ALL:
- doNamedExitAll(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_EXIT_ALL:
- doTeamExitAll(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_SET_EVAC_LEFT_OR_RIGHT:
- doNamedSetGarrisonEvacDisposition(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_FOLLOW_WAYPOINTS:
- doNamedFollowWaypoints(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_GUARD:
- doNamedGuard(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_GUARD:
- doTeamGuard(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_GUARD_POSITION:
- doTeamGuardPosition(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_GUARD_OBJECT:
- doTeamGuardObject(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_GUARD_AREA:
- doTeamGuardArea(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_HUNT:
- doNamedHunt(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_HUNT:
- doTeamHunt(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_HUNT_WITH_COMMAND_BUTTON:
- doTeamHuntWithCommandButton(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_HUNT:
- doPlayerHunt(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_SELL_EVERYTHING:
- doPlayerSellEverything(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_DISABLE_BASE_CONSTRUCTION:
- doPlayerDisableBaseConstruction(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_DISABLE_FACTORIES:
- doPlayerDisableFactories(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_DISABLE_UNIT_CONSTRUCTION:
- doPlayerDisableUnitConstruction(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_ENABLE_BASE_CONSTRUCTION:
- doPlayerEnableBaseConstruction(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_ENABLE_FACTORIES:
- doPlayerEnableFactories(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::PLAYER_REPAIR_NAMED_STRUCTURE:
- doPlayerRepairStructure(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::PLAYER_ENABLE_UNIT_CONSTRUCTION:
- doPlayerEnableUnitConstruction(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::CAMERA_MOVE_HOME:
- doCameraMoveHome();
- return;
- case ScriptAction::BUILD_TEAM:
- doBuildTeam(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_DAMAGE:
- doNamedDamage(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_DELETE:
- doNamedDelete(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_DELETE:
- doTeamDelete(pAction->getParameter(0)->getString(), FALSE);
- return;
- case ScriptAction::TEAM_DELETE_LIVING:
- doTeamDelete(pAction->getParameter(0)->getString(), TRUE);
- return;
- case ScriptAction::TEAM_WANDER:
- doTeamWander(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_WANDER_IN_PLACE:
- doTeamWanderInPlace(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_INCREASE_PRIORITY:
- doTeamIncreasePriority(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_DECREASE_PRIORITY:
- doTeamDecreasePriority(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_PANIC:
- doTeamPanic(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_KILL:
- doNamedKill(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_KILL:
- doTeamKill(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_KILL:
- doPlayerKill(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::DISPLAY_TEXT:
- doDisplayText(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::DISPLAY_CINEMATIC_TEXT:
- doDisplayCinematicText(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(),
- pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::DEBUG_CRASH_BOX:
- #if defined(_DEBUG) || defined(_INTERNAL)
- {
- const char* MSG = "Your Script requested the following message be displayed:\n\n";
- const char* MSG2 = "\n\nTHIS IS NOT A BUG. DO NOT REPORT IT.";
- DEBUG_CRASH(("%s%s%s\n",MSG,pAction->getParameter(0)->getString().str(),MSG2));
- }
- #endif
- return;
- case ScriptAction::INGAME_POPUP_MESSAGE:
- doInGamePopupMessage(pAction->getParameter(0)->getString(),pAction->getParameter(1)->getInt(),
- pAction->getParameter(2)->getInt(), pAction->getParameter(3)->getInt(),
- pAction->getParameter(4)->getInt() );
- return;
- case ScriptAction::CAMEO_FLASH:
- doCameoFlash(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_FLASH:
- doNamedFlash(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), NULL);
- return;
- case ScriptAction::TEAM_FLASH:
- doTeamFlash(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), NULL);
- return;
- case ScriptAction::NAMED_FLASH_WHITE:
- {
- RGBColor c;
- c.red = c.green = c.blue = 1.0f;
- doNamedFlash(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), &c);
- }
- return;
- case ScriptAction::NAMED_CUSTOM_COLOR:
- {
- doNamedCustomColor(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- }
- return;
- case ScriptAction::TEAM_FLASH_WHITE:
- {
- RGBColor c;
- c.red = c.green = c.blue = 1.0f;
- doTeamFlash(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), &c);
- }
- return;
- case ScriptAction::MOVIE_PLAY_FULLSCREEN:
- doMoviePlayFullScreen(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MOVIE_PLAY_RADAR:
- doMoviePlayRadar(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::SOUND_PLAY_NAMED:
- doSoundPlayFromNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SPEECH_PLAY:
- doSpeechPlay(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::PLAYER_TRANSFER_OWNERSHIP_PLAYER:
- doPlayerTransferAssetsToPlayer(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_TRANSFER_OWNERSHIP_PLAYER:
- doNamedTransferAssetsToPlayer(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_EXCLUDE_FROM_SCORE_SCREEN:
- excludePlayerFromScoreScreen(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::ENABLE_SCORING:
- enableScoring(TRUE);
- return;
- case ScriptAction::DISABLE_SCORING:
- enableScoring(FALSE);
- return;
- case ScriptAction::PLAYER_RELATES_PLAYER:
- updatePlayerRelationTowardPlayer(pAction->getParameter(0)->getString(), pAction->getParameter(2)->getInt(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::RADAR_CREATE_EVENT:
- {
- Coord3D pos;
- pAction->getParameter(0)->getCoord3D(&pos);
- doRadarCreateEvent(&pos, pAction->getParameter(1)->getInt());
- return;
- }
- case ScriptAction::OBJECT_CREATE_RADAR_EVENT:
- doObjectRadarCreateEvent(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::TEAM_CREATE_RADAR_EVENT:
- doTeamRadarCreateEvent(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::RADAR_DISABLE:
- doRadarDisable();
- return;
- case ScriptAction::RADAR_ENABLE:
- doRadarEnable();
- return;
- case ScriptAction::NAMED_SET_STEALTH_ENABLED:
- doNamedEnableStealth(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::TEAM_SET_STEALTH_ENABLED:
- doTeamEnableStealth(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::NAMED_SET_UNMANNED_STATUS:
- doNamedSetUnmanned(pAction->getParameter(0)->getString() );
- return;
- case ScriptAction::TEAM_SET_UNMANNED_STATUS:
- doTeamSetUnmanned(pAction->getParameter(0)->getString() );
- return;
- case ScriptAction::NAMED_SET_BOOBYTRAPPED:
- doNamedSetBoobytrapped( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::TEAM_SET_BOOBYTRAPPED:
- doTeamSetBoobytrapped( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::MAP_REVEAL_AT_WAYPOINT:
- doRevealMapAtWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::MAP_SHROUD_AT_WAYPOINT:
- doShroudMapAtWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::MAP_REVEAL_ALL:
- doRevealMapEntire(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MAP_REVEAL_ALL_PERM:
- doRevealMapEntirePermanently(TRUE, pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MAP_REVEAL_ALL_UNDO_PERM:
- doRevealMapEntirePermanently(FALSE, pAction->getParameter(0)->getString());
- return;
- case ScriptAction::MAP_SHROUD_ALL:
- doShroudMapEntire(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_AVAILABLE_FOR_RECRUITMENT:
- doTeamAvailableForRecruitment(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::TEAM_COLLECT_NEARBY_FOR_TEAM:
- doCollectNearbyForTeam(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_MERGE_INTO_TEAM:
- doMergeTeamIntoTeam(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::IDLE_ALL_UNITS:
- doIdleAllPlayerUnits(AsciiString::TheEmptyString);
- return;
- case ScriptAction::RESUME_SUPPLY_TRUCKING:
- doResumeSupplyTruckingForIdleUnits(AsciiString::TheEmptyString);
- return;
- case ScriptAction::DISABLE_INPUT:
- doDisableInput();
- return;
- case ScriptAction::ENABLE_INPUT:
- doEnableInput();
- return;
- case ScriptAction::DISABLE_BORDER_SHROUD:
- doSetBorderShroud(FALSE);
- return;
- case ScriptAction::ENABLE_BORDER_SHROUD:
- doSetBorderShroud(TRUE);
- return;
- case ScriptAction::SOUND_AMBIENT_PAUSE:
- doAmbientSoundsPause(true);
- return;
- case ScriptAction::SOUND_AMBIENT_RESUME:
- doAmbientSoundsPause(false);
- return;
- case ScriptAction::MUSIC_SET_TRACK:
- doMusicTrackChange(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::TEAM_GARRISON_SPECIFIC_BUILDING:
- doTeamGarrisonSpecificBuilding(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::EXIT_SPECIFIC_BUILDING:
- doExitSpecificBuilding(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_GARRISON_NEAREST_BUILDING:
- doTeamGarrisonNearestBuilding(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_EXIT_ALL_BUILDINGS:
- doTeamExitAllBuildings(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_GARRISON_SPECIFIC_BUILDING:
- doUnitGarrisonSpecificBuilding(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_GARRISON_NEAREST_BUILDING:
- doUnitGarrisonNearestBuilding(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_EXIT_BUILDING:
- doUnitExitBuilding(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_GARRISON_ALL_BUILDINGS:
- doPlayerGarrisonAllBuildings(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_EXIT_ALL_BUILDINGS:
- doPlayerExitAllBuildings(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::CAMERA_LETTERBOX_BEGIN:
- doLetterBoxMode(true);
- return;
- case ScriptAction::CAMERA_LETTERBOX_END:
- doLetterBoxMode(false);
- return;
- case ScriptAction::CAMERA_BW_MODE_BEGIN:
- doBlackWhiteMode(true, pAction->getParameter(0) ? pAction->getParameter(0)->getInt() : 0);
- return;
- case ScriptAction::CAMERA_BW_MODE_END:
- doBlackWhiteMode(false, pAction->getParameter(0) ? pAction->getParameter(0)->getInt() : 0);
- return;
- case ScriptAction::DRAW_SKYBOX_BEGIN:
- doSkyBox(true);
- return;
- case ScriptAction::DRAW_SKYBOX_END:
- doSkyBox(false);
- return;
- case ScriptAction::SHOW_WEATHER:
- doWeather(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::CAMERA_MOTION_BLUR:
- doCameraMotionBlur(pAction->getParameter(0)->getInt(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::CAMERA_MOTION_BLUR_JUMP:
- doCameraMotionBlurJump(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::CAMERA_MOTION_BLUR_FOLLOW:
- TheTacticalView->setViewFilterMode((enum FilterModes)(FM_VIEW_MB_PAN_ALPHA+pAction->getParameter(0)->getInt()));
- TheTacticalView->setViewFilter(FT_VIEW_MOTION_BLUR_FILTER);
- return;
- case ScriptAction::CAMERA_MOTION_BLUR_END_FOLLOW:
- TheTacticalView->setViewFilterMode(FM_VIEW_MB_END_PAN_ALPHA);
- TheTacticalView->setViewFilter(FT_VIEW_MOTION_BLUR_FILTER);
- return;
- case ScriptAction::FREEZE_TIME:
- doFreezeTime();
- return;
- case ScriptAction::UNFREEZE_TIME:
- doUnfreezeTime();
- return;
- case ScriptAction::SHOW_MILITARY_CAPTION:
- doMilitaryCaption(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::CAMERA_SET_AUDIBLE_DISTANCE:
- doCameraSetAudibleDistance(pAction->getParameter(0)->getReal());
- return;
- case ScriptAction::SET_STOPPING_DISTANCE:
- doSetStoppingDistance(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::SET_FPS_LIMIT:
- if (!pAction->getParameter(0)->getInt())
- {
- TheGameEngine->setFramesPerSecondLimit(TheGlobalData->m_framesPerSecondLimit);
- }
- else
- {
- TheGameEngine->setFramesPerSecondLimit(pAction->getParameter(0)->getInt());
- }
- // Setting the fps limit doesn't do much good if we don't use it. jba.
- TheWritableGlobalData->m_useFpsLimit = true;
- return;
-
- case ScriptAction::DISABLE_SPECIAL_POWER_DISPLAY:
- doDisableSpecialPowerDisplay();
- return;
- case ScriptAction::ENABLE_SPECIAL_POWER_DISPLAY:
- doEnableSpecialPowerDisplay();
- return;
- case ScriptAction::NAMED_HIDE_SPECIAL_POWER_DISPLAY:
- doNamedHideSpecialPowerDisplay(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_SHOW_SPECIAL_POWER_DISPLAY:
- doNamedShowSpecialPowerDisplay(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::NAMED_SET_STOPPING_DISTANCE:
- doNamedSetStoppingDistance(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::NAMED_SET_HELD:
- doNamedSetHeld(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::MUSIC_SET_VOLUME:
- doAudioSetVolume(AudioAffect_Music, pAction->getParameter(0)->getReal());
- return;
- case ScriptAction::SOUND_SET_VOLUME:
- doAudioSetVolume((AudioAffect)(AudioAffect_Sound | AudioAffect_Sound3D), pAction->getParameter(0)->getReal());
- return;
- case ScriptAction::SPEECH_SET_VOLUME:
- doAudioSetVolume(AudioAffect_Speech, pAction->getParameter(0)->getReal());
- return;
- case ScriptAction::TEAM_TRANSFER_TO_PLAYER:
- doTransferTeamToPlayer(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_SET_MONEY:
- doSetMoney(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::PLAYER_GIVE_MONEY:
- doGiveMoney(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::DISPLAY_COUNTDOWN_TIMER:
- doDisplayCountdownTimer(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::HIDE_COUNTDOWN_TIMER:
- doHideCountdownTimer(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::DISPLAY_COUNTER:
- doDisplayCounter(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::HIDE_COUNTER:
- doHideCounter(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::DISABLE_COUNTDOWN_TIMER_DISPLAY:
- doDisableCountdownTimerDisplay();
- return;
- case ScriptAction::ENABLE_COUNTDOWN_TIMER_DISPLAY:
- doEnableCountdownTimerDisplay();
- return;
- case ScriptAction::NAMED_STOP_SPECIAL_POWER_COUNTDOWN:
- doNamedStopSpecialPowerCountdown(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), TRUE);
- return;
- case ScriptAction::NAMED_START_SPECIAL_POWER_COUNTDOWN:
- doNamedStopSpecialPowerCountdown(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), FALSE);
- return;
- case ScriptAction::NAMED_SET_SPECIAL_POWER_COUNTDOWN:
- doNamedSetSpecialPowerCountdown(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::NAMED_ADD_SPECIAL_POWER_COUNTDOWN:
- doNamedAddSpecialPowerCountdown(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::NAMED_FIRE_SPECIAL_POWER_AT_WAYPOINT:
- doNamedFireSpecialPowerAtWaypoint(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::SKIRMISH_FIRE_SPECIAL_POWER_AT_MOST_COST:
- doSkirmishFireSpecialPowerAtMostCost(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::NAMED_FIRE_SPECIAL_POWER_AT_NAMED:
- doNamedFireSpecialPowerAtNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::REFRESH_RADAR:
- doRadarRefresh();
- return;
-
- case ScriptAction::NAMED_STOP:
- doNamedStop(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_STOP:
- doTeamStop(pAction->getParameter(0)->getString(), FALSE);
- return;
- case ScriptAction::TEAM_STOP_AND_DISBAND:
- doTeamStop(pAction->getParameter(0)->getString(), TRUE);
- return;
- case ScriptAction::CAMERA_TETHER_NAMED:
- doCameraTetherNamed(pAction->getParameter(0)->getString(), (Bool)(pAction->getParameter(1)->getInt()), pAction->getParameter(2)->getReal());
- return;
- case ScriptAction::CAMERA_STOP_TETHER_NAMED:
- doCameraStopTetherNamed();
- return;
- case ScriptAction::CAMERA_SET_DEFAULT:
- doCameraSetDefault(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getReal());
- return;
- case ScriptAction::TEAM_SET_OVERRIDE_RELATION_TO_TEAM:
- doTeamSetOverrideRelationToTeam(pAction->getParameter(0)->getString(), // first team
- pAction->getParameter(1)->getString(), // second team
- pAction->getParameter(2)->getInt()); // relation (ENEMIES, etc)
- return;
- case ScriptAction::TEAM_REMOVE_OVERRIDE_RELATION_TO_TEAM:
- doTeamRemoveOverrideRelationToTeam(pAction->getParameter(0)->getString(), // first team
- pAction->getParameter(1)->getString()); // second team
- return;
- case ScriptAction::TEAM_REMOVE_ALL_OVERRIDE_RELATIONS:
- doTeamRemoveAllOverrideRelations(pAction->getParameter(0)->getString()); // first team
- return;
- case ScriptAction::TEAM_SET_OVERRIDE_RELATION_TO_PLAYER:
- doTeamSetOverrideRelationToPlayer(pAction->getParameter(0)->getString(), // first team
- pAction->getParameter(1)->getString(), // second player
- pAction->getParameter(2)->getInt()); // relation (ENEMIES, etc)
- return;
- case ScriptAction::TEAM_REMOVE_OVERRIDE_RELATION_TO_PLAYER:
- doTeamRemoveOverrideRelationToPlayer(pAction->getParameter(0)->getString(), // first team
- pAction->getParameter(1)->getString()); // second player
- return;
- case ScriptAction::PLAYER_SET_OVERRIDE_RELATION_TO_TEAM:
- doPlayerSetOverrideRelationToTeam(pAction->getParameter(0)->getString(), // first player
- pAction->getParameter(1)->getString(), // second team
- pAction->getParameter(2)->getInt()); // relation (ENEMIES, etc)
- return;
- case ScriptAction::PLAYER_REMOVE_OVERRIDE_RELATION_TO_TEAM:
- doPlayerRemoveOverrideRelationToTeam(pAction->getParameter(0)->getString(), // first player
- pAction->getParameter(1)->getString()); // second team
- return;
- case ScriptAction::NAMED_FIRE_WEAPON_FOLLOWING_WAYPOINT_PATH:
- doNamedFireWeaponFollowingWaypointPath(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::NAMED_USE_COMMANDBUTTON_ABILITY:
- doNamedUseCommandButtonAbility( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::NAMED_USE_COMMANDBUTTON_ABILITY_ON_NAMED:
- doNamedUseCommandButtonAbilityOnNamed( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
- case ScriptAction::NAMED_USE_COMMANDBUTTON_ABILITY_AT_WAYPOINT:
- doNamedUseCommandButtonAbilityAtWaypoint( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
-
- case ScriptAction::NAMED_USE_COMMANDBUTTON_ABILITY_USING_WAYPOINT_PATH:
- doNamedUseCommandButtonAbilityUsingWaypointPath( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
-
- case ScriptAction::TEAM_USE_COMMANDBUTTON_ABILITY:
- doTeamUseCommandButtonAbility( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString() );
- return;
- case ScriptAction::TEAM_USE_COMMANDBUTTON_ABILITY_ON_NAMED:
- doTeamUseCommandButtonAbilityOnNamed( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
- case ScriptAction::TEAM_USE_COMMANDBUTTON_ABILITY_AT_WAYPOINT:
- doTeamUseCommandButtonAbilityAtWaypoint( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString() );
- return;
-
- case ScriptAction::UNIT_EXECUTE_SEQUENTIAL_SCRIPT:
- doUnitStartSequentialScript(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), 0);
- return;
- case ScriptAction::UNIT_EXECUTE_SEQUENTIAL_SCRIPT_LOOPING:
- doUnitStartSequentialScript(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt() - 1);
- return;
- case ScriptAction::UNIT_STOP_SEQUENTIAL_SCRIPT:
- doUnitStopSequentialScript(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::TEAM_EXECUTE_SEQUENTIAL_SCRIPT:
- doTeamStartSequentialScript(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), 0);
- return;
- case ScriptAction::TEAM_EXECUTE_SEQUENTIAL_SCRIPT_LOOPING:
- doTeamStartSequentialScript(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt() - 1);
- return;
- case ScriptAction::TEAM_STOP_SEQUENTIAL_SCRIPT:
- doTeamStopSequentialScript(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::UNIT_GUARD_FOR_FRAMECOUNT:
- doUnitGuardForFramecount(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::UNIT_IDLE_FOR_FRAMECOUNT:
- doUnitIdleForFramecount(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
-
- case ScriptAction::TEAM_GUARD_FOR_FRAMECOUNT:
- doTeamIdleForFramecount(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
-
- case ScriptAction::TEAM_IDLE_FOR_FRAMECOUNT:
- doTeamIdleForFramecount(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::WATER_CHANGE_HEIGHT:
- doWaterChangeHeight(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::WATER_CHANGE_HEIGHT_OVER_TIME:
- doWaterChangeHeightOverTime( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(),
- pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getReal() );
- return;
- case ScriptAction::MAP_SWITCH_BORDER:
- doBorderSwitch(pAction->getParameter(0)->getInt());
- return;
-
- case ScriptAction::OBJECT_FORCE_SELECT:
- doForceObjectSelection(pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString(),
- pAction->getParameter(2)->getInt(),
- pAction->getParameter(3)->getString());
- return;
- case ScriptAction::UNIT_DESTROY_ALL_CONTAINED:
- doDestroyAllContained(pAction->getParameter(0)->getString(), 0);
- return;
- case ScriptAction::RADAR_FORCE_ENABLE:
- doRadarForceEnable();
- return;
- case ScriptAction::RADAR_REVERT_TO_NORMAL:
- doRadarRevertNormal();
- return;
- case ScriptAction::SCREEN_SHAKE:
- doScreenShake( (View::CameraShakeType)pAction->getParameter( 0 )->getInt() );
- return;
- case ScriptAction::TECHTREE_MODIFY_BUILDABILITY_OBJECT:
- doModifyBuildableStatus(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::SET_CAVE_INDEX:
- doSetCaveIndex(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::WAREHOUSE_SET_VALUE:
- doSetWarehouseValue(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::SOUND_DISABLE_TYPE:
- doSoundEnableType(pAction->getParameter(0)->getString(), false);
- return;
- case ScriptAction::SOUND_ENABLE_TYPE:
- doSoundEnableType(pAction->getParameter(0)->getString(), true);
- return;
- case ScriptAction::SOUND_ENABLE_ALL:
- doSoundEnableType(AsciiString::TheEmptyString, true);
- return;
-
- case ScriptAction::SOUND_REMOVE_ALL_DISABLED:
- doSoundRemoveAllDisabled();
- return;
- case ScriptAction::SOUND_REMOVE_TYPE:
- doSoundRemoveType(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::AUDIO_OVERRIDE_VOLUME_TYPE:
- doSoundOverrideVolume(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::AUDIO_RESTORE_VOLUME_TYPE:
- doSoundOverrideVolume(pAction->getParameter(0)->getString(), -100.0);
- return;
- case ScriptAction::AUDIO_RESTORE_VOLUME_ALL_TYPE:
- doSoundOverrideVolume(AsciiString::TheEmptyString, -100.0);
- return;
- case ScriptAction::NAMED_SET_TOPPLE_DIRECTION:
- {
- Coord3D dir;
- pAction->getParameter(1)->getCoord3D(&dir);
- doSetToppleDirection(pAction->getParameter(0)->getString(), &dir);
- return;
- }
- case ScriptAction::UNIT_MOVE_TOWARDS_NEAREST_OBJECT_TYPE:
- doMoveUnitTowardsNearest(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::TEAM_MOVE_TOWARDS_NEAREST_OBJECT_TYPE:
- doMoveTeamTowardsNearest(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::NAMED_RECEIVE_UPGRADE:
- doUnitReceiveUpgrade(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::SKIRMISH_ATTACK_NEAREST_GROUP_WITH_VALUE:
- doSkirmishAttackNearestGroupWithValue(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::SKIRMISH_PERFORM_COMMANDBUTTON_ON_MOST_VALUABLE_OBJECT:
- doSkirmishCommandButtonOnMostValuable(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getReal(), pAction->getParameter(3)->getInt());
- return;
- case ScriptAction::SKIRMISH_WAIT_FOR_COMMANDBUTTON_AVAILABLE_ALL:
- // We should never get here.
- DEBUG_CRASH(("\"[Skirmish] Wait for command button available - all\" should never be used outside of Sequential scripts. - jkmcd"));
- return;
- case ScriptAction::SKIRMISH_WAIT_FOR_COMMANDBUTTON_AVAILABLE_PARTIAL:
- // We should never get here.
- DEBUG_CRASH(("\"[Skirmish] Wait for command button available - partial\" should never be used outside of Sequential scripts. - jkmcd"));
- return;
- case ScriptAction::TEAM_WAIT_FOR_NOT_CONTAINED_ALL:
- // We should never get here.
- DEBUG_CRASH(("\"[Team] Wait for team no longer contained - all\" should never be used outside of Sequential scripts. - jkmcd"));
- return;
- case ScriptAction::TEAM_WAIT_FOR_NOT_CONTAINED_PARTIAL:
- // We should never get here.
- DEBUG_CRASH(("\"[Team] Wait for team no longer contained - partial\" should never be used outside of Sequential scripts. - jkmcd"));
- return;
- case ScriptAction::TEAM_SPIN_FOR_FRAMECOUNT:
- doTeamSpinForFramecount( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt() );
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NAMED:
- doTeamUseCommandButtonOnNamed(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_UNIT:
- doTeamUseCommandButtonOnNearestEnemy(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_GARRISONED_BUILDING:
- doTeamUseCommandButtonOnNearestGarrisonedBuilding(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_KINDOF:
- doTeamUseCommandButtonOnNearestKindof(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_BUILDING:
- doTeamUseCommandButtonOnNearestBuilding(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_BUILDING_CLASS:
- doTeamUseCommandButtonOnNearestBuildingClass(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_OBJECTTYPE:
- doTeamUseCommandButtonOnNearestObjectType(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::TEAM_PARTIAL_USE_COMMANDBUTTON:
- doTeamPartialUseCommandButton(pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::TEAM_CAPTURE_NEAREST_UNOWNED_FACTION_UNIT:
- doTeamCaptureNearestUnownedFactionUnit(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::PLAYER_CREATE_TEAM_FROM_CAPTURED_UNITS:
- doCreateTeamFromCapturedUnits(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_ADD_SKILLPOINTS:
- doPlayerAddSkillPoints(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::PLAYER_ADD_RANKLEVEL:
- doPlayerAddRankLevels(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::PLAYER_SET_RANKLEVEL:
- doPlayerSetRankLevel(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::PLAYER_SET_RANKLEVELLIMIT:
- doMapSetRankLevelLimit(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::PLAYER_GRANT_SCIENCE:
- doPlayerGrantScience(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_PURCHASE_SCIENCE:
- doPlayerPurchaseScience(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::PLAYER_SCIENCE_AVAILABILITY:
- doPlayerSetScienceAvailability(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString());
- return;
- case ScriptAction::TEAM_SET_EMOTICON:
- doTeamEmoticon( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getReal() );
- return;
- case ScriptAction::NAMED_SET_EMOTICON:
- doNamedEmoticon( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getReal() );
- return;
- case ScriptAction::OBJECTLIST_ADDOBJECTTYPE:
- doObjectTypeListMaintenance(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), TRUE);
- return;
- case ScriptAction::OBJECTLIST_REMOVEOBJECTTYPE:
- doObjectTypeListMaintenance(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), FALSE);
- return;
- case ScriptAction::MAP_REVEAL_PERMANENTLY_AT_WAYPOINT:
- doRevealMapAtWaypointPermanent(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal(), pAction->getParameter(2)->getString(), pAction->getParameter(3)->getString());
- return;
- case ScriptAction::MAP_UNDO_REVEAL_PERMANENTLY_AT_WAYPOINT:
- doUndoRevealMapAtWaypointPermanent(pAction->getParameter(0)->getString());
- return;
- case ScriptAction::EVA_SET_ENABLED_DISABLED:
- doEvaEnabledDisabled(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::OPTIONS_SET_OCCLUSION_MODE:
- doSetOcclusionMode(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::OPTIONS_SET_DRAWICON_UI_MODE:
- doSetDrawIconUIMode(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::CAMERA_ENABLE_SLAVE_MODE:
- {
- doC3CameraEnableSlaveMode
- (
- pAction->getParameter(0)->getString(),
- pAction->getParameter(1)->getString()
- );
- }
- return;
- case ScriptAction::CAMERA_DISABLE_SLAVE_MODE:
- {
- doC3CameraDisableSlaveMode();
- }
- return;
- case ScriptAction::CAMERA_ADD_SHAKER_AT: // WST 11.12.2002 (MBL)
- {
- doC3CameraShake
- (
- pAction->getParameter(0)->getString(), // Waypoint name
- pAction->getParameter(1)->getReal(), // Amplitude
- pAction->getParameter(2)->getReal(), // Duration in seconds
- pAction->getParameter(3)->getReal() // Radius
- );
- }
- return;
- case ScriptAction::OPTIONS_SET_PARTICLE_CAP_MODE:
- doSetDynamicLODMode(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::SCRIPTING_OVERRIDE_HULK_LIFETIME:
- doOverrideHulkLifetime( pAction->getParameter( 0 )->getReal() );
- return;
- case ScriptAction::NAMED_FACE_NAMED:
- doNamedFaceNamed( pAction->getParameter( 0 )->getString(), pAction->getParameter( 1 )->getString() );
- return;
- case ScriptAction::NAMED_FACE_WAYPOINT:
- doNamedFaceWaypoint( pAction->getParameter( 0 )->getString(), pAction->getParameter( 1 )->getString() );
- return;
- case ScriptAction::TEAM_FACE_NAMED:
- doTeamFaceNamed( pAction->getParameter( 0 )->getString(), pAction->getParameter( 1 )->getString() );
- return;
- case ScriptAction::TEAM_FACE_WAYPOINT:
- doTeamFaceWaypoint( pAction->getParameter( 0 )->getString(), pAction->getParameter( 1 )->getString() );
- return;
-
- case ScriptAction::UNIT_AFFECT_OBJECT_PANEL_FLAGS:
- doAffectObjectPanelFlagsUnit(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::TEAM_AFFECT_OBJECT_PANEL_FLAGS:
- doAffectObjectPanelFlagsTeam(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::PLAYER_SELECT_SKILLSET:
- doAffectPlayerSkillset(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::COMMANDBAR_REMOVE_BUTTON_OBJECTTYPE:
- doRemoveCommandBarButton(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString());
- return;
- case ScriptAction::COMMANDBAR_ADD_BUTTON_OBJECTTYPE_SLOT:
- doAddCommandBarButton(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getInt());
- return;
- case ScriptAction::UNIT_SPAWN_NAMED_LOCATION_ORIENTATION:
- {
- Coord3D pos;
- pAction->getParameter(3)->getCoord3D(&pos);
- doCreateObject( pAction->getParameter(0)->getString(), pAction->getParameter(1)->getString(), pAction->getParameter(2)->getString(), &pos, pAction->getParameter(4)->getReal() );
- return;
- }
-
- case ScriptAction::PLAYER_AFFECT_RECEIVING_EXPERIENCE:
- doAffectSkillPointsModifier(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getReal());
- return;
- case ScriptAction::TEAM_GUARD_SUPPLY_CENTER:
- doGuardSupplyCenter(pAction->getParameter(0)->getString(), pAction->getParameter(1)->getInt());
- return;
- case ScriptAction::OBJECT_ALLOW_BONUSES:
- doEnableOrDisableObjectDifficultyBonuses(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::TEAM_GUARD_IN_TUNNEL_NETWORK:
- doTeamGuardInTunnelNetwork(pAction->getParameter(0)->getString());
- return;
-
- case ScriptAction::RESIZE_VIEW_GUARDBAND:
- doResizeViewGuardband( pAction->getParameter(0)->getReal(), pAction->getParameter(1)->getReal() );
- return;
- case ScriptAction::DELETE_ALL_UNMANNED:
- deleteAllUnmanned();
- return;
- case ScriptAction::CHOOSE_VICTIM_ALWAYS_USES_NORMAL:
- doChooseVictimAlwaysUsesNormal(pAction->getParameter(0)->getInt());
- return;
- case ScriptAction::SET_TRAIN_HELD:
- doNamedSetTrainHeld( pAction->getParameter( 0 )->getString(), (Bool)pAction->getParameter( 1 )->getInt() );
- return;
- case ScriptAction::ENABLE_OBJECT_SOUND:
- doEnableObjectSound(pAction->getParameter(0)->getString(), true);
- return;
- case ScriptAction::DISABLE_OBJECT_SOUND:
- doEnableObjectSound(pAction->getParameter(0)->getString(), false);
- return;
- }
- }
|