ablmc2.cpp 193 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. //----------------------------------------------------------------------------------
  5. // Include Files
  6. #ifndef ABL_H
  7. #include "abl.h"
  8. #endif
  9. #ifndef MCLIB_H
  10. #include "mclib.h"
  11. #endif
  12. #ifndef MISSION_H
  13. #include "mission.h"
  14. #endif
  15. #ifndef MOVE_H
  16. #include "move.h"
  17. #endif
  18. #ifndef MOVEMGR_H
  19. #include "movemgr.h"
  20. #endif
  21. #ifndef GAMESOUND_H
  22. #include "gamesound.h"
  23. #endif
  24. #ifndef SOUNDS_H
  25. #include "sounds.h"
  26. #endif
  27. #ifndef COLLSN_H
  28. #include "collsn.h"
  29. #endif
  30. #ifndef CMPONENT_H
  31. #include "cmponent.h"
  32. #endif
  33. #ifndef OBJMGR_H
  34. #include "objmgr.h"
  35. #endif
  36. #ifndef MOVER_H
  37. #include "mover.h"
  38. #endif
  39. #ifndef MECH_H
  40. #include "mech.h"
  41. #endif
  42. #ifndef GVEHICL_H
  43. #include "gvehicl.h"
  44. #endif
  45. #ifndef CONTACT_H
  46. #include "contact.h"
  47. #endif
  48. #ifndef TEAM_H
  49. #include "team.h"
  50. #endif
  51. #ifndef COMNDR_H
  52. #include "comndr.h"
  53. #endif
  54. #ifndef GROUP_H
  55. #include "group.h"
  56. #endif
  57. #ifndef GAMECAM_H
  58. #include "gamecam.h"
  59. #endif
  60. #ifndef MULTPLYR_H
  61. #include "multplyr.h"
  62. #endif
  63. #ifndef WEAPONFX_H
  64. #include "weaponfx.h"
  65. #endif
  66. #ifndef TURRET_H
  67. #include "turret.h"
  68. #endif
  69. #ifndef GATE_H
  70. #include "gate.h"
  71. #endif
  72. #ifndef ARTLRY_H
  73. #include "artlry.h"
  74. #endif
  75. #ifndef GAMELOG_H
  76. #include "gamelog.h"
  77. #endif
  78. #ifndef MISSIONBEGIN_H
  79. #include "missionbegin.h"
  80. #endif
  81. #ifndef LOGISTICS_H
  82. #include "logistics.h"
  83. #endif
  84. MoverGroupPtr CurGroup = NULL;
  85. GameObjectPtr CurObject = NULL;
  86. long CurObjectClass = 0;
  87. MechWarriorPtr CurWarrior = NULL;
  88. GameObjectPtr CurContact = NULL;
  89. long CurAlarm;
  90. MoverPtr moverList[256];
  91. bool TacOrderOrigin = ORDER_ORIGIN_COMMANDER;
  92. long CurMultiplayCode = 0;
  93. long CurMultiplayParam = 0;
  94. extern float MaxVisualRadius;
  95. extern float WeaponRange[NUM_FIRERANGES];
  96. extern GameLog* BugLog;
  97. UserHeapPtr AblStackHeap = NULL;
  98. UserHeapPtr AblCodeHeap = NULL;
  99. UserHeapPtr AblSymbolHeap = NULL;
  100. extern bool GeneralAlarm;
  101. extern bool friendlyDestroyed;
  102. extern bool enemyDestroyed;
  103. extern bool invulnerableON; //Used for tutorials so mechs can take damage, but look like they are taking damage! Otherwise, I'd just use NOPAIN!!
  104. void DEBUGWINS_setGameObject (long debugObj, GameObjectPtr obj);
  105. void DEBUGWINS_print (char* s, long window);
  106. //*****************************************************************************
  107. // MISC AI
  108. //*****************************************************************************
  109. long getMoversWithinRadius (MoverPtr* moverList, Stuff::Vector3D center, float radius, long teamID, long commanderID, bool getEnemies, bool sortDescending, bool ignoreOrder) {
  110. static float sortValues[MAX_MOVERS];
  111. if (!Team::sortList) {
  112. Team::sortList = new SortList;
  113. if (!Team::sortList)
  114. Fatal(0, " Unable to create Team Contact sortList ");
  115. Team::sortList->init(MAX_CONTACTS_PER_SENSOR);
  116. }
  117. Team::sortList->clear(sortDescending);
  118. TeamPtr team = NULL;
  119. if (teamID > -1)
  120. team = Team::teams[teamID];
  121. long numValidMovers = 0;
  122. if (getEnemies) {
  123. for (long i = 0; i < ObjectManager->getNumMovers(); i++) {
  124. MoverPtr mover = ObjectManager->getMover(i);
  125. if (mover->getExists() && !mover->isDisabled() && mover->isEnemy(team))
  126. if (mover->numFunctionalWeapons > 0)
  127. if (mover->distanceFrom(center) < radius) {
  128. if (ignoreOrder || (mover->getPilot()->getCurTacOrder()->code == TACTICAL_ORDER_NONE)) {
  129. Team::sortList->setId(numValidMovers, mover->getHandle());
  130. Team::sortList->setValue(numValidMovers, mover->getThreatRating());
  131. numValidMovers++;
  132. }
  133. }
  134. }
  135. }
  136. else {
  137. if (commanderID == -1)
  138. for (long i = 0; i < team->rosterSize; i++) {
  139. MoverPtr mover = team->getMover(i);
  140. if (mover->getExists() && !mover->isDisabled() && (mover->numFunctionalWeapons > 0))
  141. if (mover->distanceFrom(center) < radius) {
  142. if (mover->getPilot()->getWillHelp()) {
  143. if (ignoreOrder || (mover->getPilot()->getCurTacOrder()->code == TACTICAL_ORDER_NONE)) {
  144. Team::sortList->setId(numValidMovers, mover->getHandle());
  145. Team::sortList->setValue(numValidMovers, mover->getThreatRating());
  146. numValidMovers++;
  147. }
  148. }
  149. }
  150. }
  151. else
  152. for (long i = 0; i < team->rosterSize; i++) {
  153. MoverPtr mover = team->getMover(i);
  154. if ((commanderID == mover->commanderId) && mover->getExists() && !mover->isDisabled() && (mover->numFunctionalWeapons > 0))
  155. if (mover->distanceFrom(center) < radius) {
  156. if (mover->getPilot()->getWillHelp()) {
  157. if (ignoreOrder || (mover->getPilot()->getCurTacOrder()->code == TACTICAL_ORDER_NONE)) {
  158. Team::sortList->setId(numValidMovers, mover->getHandle());
  159. Team::sortList->setValue(numValidMovers, mover->getThreatRating());
  160. numValidMovers++;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. if (numValidMovers > 0) {
  167. Team::sortList->sort(sortDescending);
  168. for (long i = 0; i < numValidMovers; i++)
  169. moverList[i] = (MoverPtr)ObjectManager->get(Team::sortList->getId(i));
  170. }
  171. return(numValidMovers);
  172. }
  173. //-----------------------------------------------------------------------------
  174. void calcAttackPlan (long numAttackers, GameObjectPtr* attackers, long numDefenders, GameObjectPtr* defenders) {
  175. if ((numDefenders == 0) || (numAttackers == 0))
  176. return;
  177. //------------------------------------------------------------------
  178. // This assumes the attackers and defenders lists are already sorted
  179. // in descending order...
  180. float attackRatio[MAX_MOVERS];
  181. long attackTotal[MAX_MOVERS];
  182. GameObjectPtr target[MAX_MOVERS];
  183. for (long i = 0; i < numDefenders; i++) {
  184. attackTotal[i] = 0;
  185. attackRatio[i] = 0.0;
  186. target[i] = NULL;
  187. }
  188. //-------------------------------------------------------------------------
  189. // Calc who they should attack, trying to spread the wealth, so to speak...
  190. for (long a = 0; a < numAttackers; a++) {
  191. long toughest = numDefenders - 1;
  192. for (long d = (numDefenders - 2); d > -1; d--) {
  193. if (attackRatio[d] < attackRatio[toughest])
  194. toughest = d;
  195. else if (attackRatio[d] == attackRatio[toughest]) {
  196. if (attackTotal[d] > attackTotal[toughest])
  197. toughest = d;
  198. }
  199. }
  200. attackTotal[toughest] += attackers[a]->getThreatRating();
  201. attackRatio[toughest] = attackTotal[toughest] / defenders[toughest]->getThreatRating();
  202. target[a] = defenders[toughest];
  203. }
  204. //---------------------------------------------
  205. // For now, let's let 'em know their targets...
  206. for (i = 0; i < numAttackers; i++)
  207. attackers[i]->getPilot()->triggerAlarm(PILOT_ALARM_ATTACK_ORDER, target[i]->getWatchID());
  208. }
  209. //-----------------------------------------------------------------------------
  210. GameObjectPtr calcBestTarget (MoverPtr attacker, long numAttackers, MoverPtr* attackers, long numDefenders, MoverPtr* defenders) {
  211. //------------------------------------------------------------------
  212. // This assumes the attackers and defenders lists are already sorted
  213. // in descending order...
  214. if (numDefenders == 0)
  215. return(NULL);
  216. float attackRatio[MAX_MOVERS];
  217. long attackTotal[MAX_MOVERS];
  218. GameObjectPtr target[MAX_MOVERS];
  219. for (long i = 0; i < numDefenders; i++) {
  220. attackTotal[i] = 0;
  221. attackRatio[i] = 0.0;
  222. target[i] = NULL;
  223. }
  224. //---------------------------------------------------------------
  225. // First, find out who everyone else in our group is attacking...
  226. for (long a = 0; a < numAttackers; a++) {
  227. GameObjectPtr target = attackers[a]->getPilot()->getCurrentTarget();
  228. for (long d = 0; d < numDefenders; d++)
  229. if (defenders[d] == target) {
  230. attackTotal[i] += attackers[a]->getThreatRating();
  231. break;
  232. }
  233. }
  234. for (long d = 0; d < numDefenders; d++)
  235. attackRatio[d] = attackTotal[d] / defenders[d]->getThreatRating();
  236. //----------------------------------------------
  237. // Now, find out who this pilot should attack...
  238. long bestTarget = numDefenders - 1;
  239. if (numDefenders > 1)
  240. for (d = (numDefenders - 2); d > -1; d--) {
  241. if (attackRatio[d] < attackRatio[bestTarget])
  242. bestTarget = d;
  243. else if (attackRatio[d] == attackRatio[bestTarget]) {
  244. if (attackTotal[d] > attackTotal[bestTarget])
  245. bestTarget = d;
  246. }
  247. }
  248. attackTotal[bestTarget] += attacker->getThreatRating();
  249. attackRatio[bestTarget] = attackTotal[bestTarget] / defenders[bestTarget]->getThreatRating();
  250. return(defenders[bestTarget]);
  251. }
  252. //*****************************************************************************
  253. inline signed int double2long(double _in) {
  254. _in+=6755399441055744.0;
  255. return(*(signed int*)&_in);
  256. }
  257. //-----------------------------------------------------------------------------
  258. inline bool isObjectId (long partId) {
  259. return(partId > MAX_UNIT_PART_ID);
  260. }
  261. //---------------------------------------------------------------------------
  262. inline bool isUnitId (long partId) {
  263. return((partId >= MIN_UNIT_PART_ID) && (partId <= MAX_UNIT_PART_ID));
  264. }
  265. //---------------------------------------------------------------------------
  266. inline bool isTeamId (long partId) {
  267. return((partId >= MIN_TEAM_PART_ID) && (partId <= MAX_TEAM_PART_ID));
  268. }
  269. //---------------------------------------------------------------------------
  270. GameObjectPtr getObject (long partId, bool existsOnly = false);
  271. inline GameObjectPtr getObject (long partId, bool existsOnly) {
  272. GameObjectPtr obj = NULL;
  273. if (partId == -1)
  274. obj = CurObject;
  275. else
  276. obj = ObjectManager->findByPartId(partId);
  277. if (existsOnly) {
  278. if (obj && obj->getExists())
  279. return(obj);
  280. return(NULL);
  281. }
  282. return(obj);
  283. }
  284. //---------------------------------------------------------------------------
  285. inline MechWarriorPtr getWarrior (long warriorIndex) {
  286. if (warriorIndex == -1)
  287. return(CurWarrior);
  288. else
  289. return(MechWarrior::warriorList[warriorIndex]);
  290. }
  291. //---------------------------------------------------------------------------
  292. long getMovers (long partId, MoverPtr* list, bool existsOnly = false);
  293. inline long getMovers (long partId, MoverPtr* list, bool existsOnly) {
  294. //---------------------------------------------------------------------
  295. // NOTE: It should be safe to assume that all objects here are movers,
  296. // since only movers may be members of a unit/team.
  297. // ALSO NOTE: If a group is referenced, we better be in a single-player
  298. // game (and it better be a computer-commander, which won't re-arrange
  299. // its groups)!
  300. long numObjects = 0;
  301. if ((partId >= OBJ_ID_FIRST_COMMANDER) && (partId <= OBJ_ID_LAST_COMMANDER))
  302. Fatal(3, " ABL.getMovers: bad id ");
  303. //numObjects = Commander::commanders[partId - OBJ_ID_FIRST_COMMANDER]->getRoster((GameObjectPtr*)list);
  304. else if ((partId >= OBJ_ID_FIRST_TEAM) && (partId <= OBJ_ID_LAST_TEAM)) {
  305. TeamPtr team = Team::teams[partId - OBJ_ID_FIRST_TEAM];
  306. if (team)
  307. numObjects = Team::teams[partId - OBJ_ID_FIRST_TEAM]->getRoster((GameObjectPtr*)list, existsOnly);
  308. }
  309. else {
  310. for (long i = 0; i < ObjectManager->getNumMovers(); i++) {
  311. MoverPtr mover = ObjectManager->getMover(i);
  312. if (mover && (mover->getSquadId() == partId))
  313. list[numObjects++] = mover;
  314. }
  315. }
  316. return(numObjects);
  317. }
  318. //*****************************************************************************
  319. void execGetId (void) {
  320. //-----------------------------------------------------
  321. //
  322. // GET ID function:
  323. //
  324. // Returns object id of current object.
  325. //
  326. // PARAMS: none
  327. //
  328. // RETURN: integer
  329. //
  330. //-----------------------------------------------------
  331. long partID = 0;
  332. if (CurObject)
  333. partID = CurObject->getPartId();
  334. ABLi_pushInteger(partID);
  335. }
  336. //***************************************************************************
  337. void execGetTime (void) {
  338. //-----------------------------------------------------
  339. //
  340. // GET TIME function:
  341. //
  342. // Returns current mission(scenario) time.
  343. //
  344. // PARAMS: none
  345. //
  346. // RETURN: real
  347. //
  348. //-----------------------------------------------------
  349. ABLi_pushReal(mission->actualTime);
  350. }
  351. //***************************************************************************
  352. void execGetTimeLeft (void) {
  353. //-----------------------------------------------------
  354. //
  355. // GET TIME function:
  356. //
  357. // Returns mission(scenario) time left.
  358. //
  359. // PARAMS: none
  360. //
  361. // RETURN: real
  362. //
  363. //-----------------------------------------------------
  364. if (mission->m_timeLimit > -1)
  365. if (mission->m_timeLimit - mission->actualTime > 0)
  366. ABLi_pushReal(mission->m_timeLimit - mission->actualTime);
  367. else
  368. ABLi_pushReal(0.0);
  369. else
  370. ABLi_pushReal(-1.0);
  371. }
  372. //*****************************************************************************
  373. void execSelectObject (void) {
  374. //-----------------------------------------------------
  375. //
  376. // SELECT OBJECT function:
  377. //
  378. // Sets the specified object as the Current Object.
  379. // It returns an error code if it fails, else it returns the
  380. // id of the previous current object.
  381. //
  382. // integer object id
  383. //
  384. // RETURN: integer object id or error code (-1 = not an object)
  385. //
  386. //-----------------------------------------------------
  387. long objectID = ABLi_peekInteger();
  388. //---------------------------------------
  389. // Remember what the current object is...
  390. long curObjectID = 0;
  391. if (CurObject)
  392. curObjectID = CurObject->getPartId();
  393. GameObjectPtr newObject = getObject(objectID);
  394. if (newObject) {
  395. CurObject = newObject;
  396. ABLi_pokeInteger(curObjectID);
  397. }
  398. else
  399. ABLi_pokeInteger(-1);
  400. }
  401. //***************************************************************************
  402. void execSelectWarrior (void) {
  403. //----------------------------------------------------------------------
  404. //
  405. // SELECT WARRIOR function:
  406. //
  407. // Sets the specified warrior as the Current Pilot. All pilot-assumed
  408. // ABL functions reference the Current Pilot(Warrior).
  409. // It returns an error code if it fails, else it returns the
  410. // warrior id of the previous current pilot.
  411. //
  412. // integer warrior id
  413. //
  414. // RETURN: integer warrior id or error code (-1 = not a pilot)
  415. //
  416. //----------------------------------------------------------------------
  417. long warriorIndex = ABLi_popInteger();
  418. //---------------------------------------
  419. // Remember who the current warrior is...
  420. long curWarriorIndex = 0;
  421. if (CurWarrior)
  422. curWarriorIndex = CurWarrior->getIndex();
  423. CurWarrior = getWarrior(warriorIndex);
  424. ABLi_pushInteger(curWarriorIndex);
  425. }
  426. //*****************************************************************************
  427. void execGetWarriorStatus (void) {
  428. //-----------------------------------------------------
  429. //
  430. // GET WARRIOR STATUS function:
  431. //
  432. // Returns the status of the warrior.
  433. //
  434. // PARAMS: integer warrior id
  435. //
  436. // RETURN: integer status
  437. //
  438. //-----------------------------------------------------
  439. long warriorId = ABLi_peekInteger();
  440. MechWarriorPtr warrior = getWarrior(warriorId);
  441. if (warrior)
  442. ABLi_pokeInteger(warrior->getStatus());
  443. else
  444. ABLi_pokeInteger(-1);
  445. }
  446. //*****************************************************************************
  447. void execGetContacts (void) {
  448. //-----------------------------------------------------
  449. //
  450. // GET CONTACTS function:
  451. //
  452. // Returns a sorted list of all criteria'd contacts for the pilot.
  453. //
  454. // PARAMS: integer[] contact list
  455. //
  456. // integer contact criteria
  457. //
  458. // integer sort criteria
  459. //
  460. // RETURN: integer result code
  461. //
  462. //-----------------------------------------------------
  463. long* contactList = ABLi_popIntegerPtr();
  464. long contactCriteria = ABLi_popInteger();
  465. long sortCriteria = ABLi_popInteger();
  466. long numContacts = CurObject->getContacts(contactList, contactCriteria, sortCriteria);
  467. ABLi_pushInteger(numContacts);
  468. for (long i = 0; i < numContacts; i++) {
  469. GameObjectPtr obj = ObjectManager->get(contactList[i]);
  470. Assert(obj != NULL, 0, " NULL contact");
  471. contactList[i] = obj->getPartId();
  472. }
  473. }
  474. //*****************************************************************************
  475. void execGetEnemyCount (void) {
  476. //-----------------------------------------------------
  477. //
  478. // GET ENEMY COUNT function:
  479. //
  480. // Returns number of sighted enemies.
  481. //
  482. // PARAMS: integer object id
  483. //
  484. // RETURN: integer result code
  485. //
  486. //-----------------------------------------------------
  487. long objectId = ABLi_popInteger();
  488. long result = -1;
  489. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  490. //--------------------------------------------
  491. // We have a group. Act accordingly.
  492. // Run through all objects fitting the group.
  493. if ((objectId >= OBJ_ID_FIRST_TEAM) && (objectId <= OBJ_ID_LAST_TEAM)) {
  494. TeamPtr team = Team::teams[objectId - OBJ_ID_FIRST_TEAM];
  495. if (team)
  496. result = SensorManager->getTeamSensor(team->getId())->numContacts;
  497. }
  498. }
  499. else {
  500. GameObjectPtr object = getObject(objectId);
  501. if (object) {
  502. if (object->isMover()) {
  503. if (object->getTeam())
  504. result = SensorManager->getTeamSensor(object->getTeamId())->numContacts;
  505. }
  506. else
  507. switch (object->getObjectClass()) {
  508. case BUILDING:
  509. case ARTILLERY:
  510. if (object->getTeamId() > -1)
  511. result = SensorManager->getTeamSensor(object->getTeamId())->numContacts;
  512. break;
  513. }
  514. }
  515. }
  516. ABLi_pushInteger(result);
  517. }
  518. //*****************************************************************************
  519. void execSelectContact (void) {
  520. //-----------------------------------------------------
  521. //
  522. // SELECT CONTACT function:
  523. //
  524. // Sets the specified contact as the Current Contact. All pilot
  525. // contact-related ABL functions reference the Current Contact.
  526. // The Current Pilot's contact lists are referenced.
  527. //
  528. // PARAMS: integer contact handle
  529. //
  530. // RETURN: integer error code (1 = not a contact)
  531. //
  532. //-----------------------------------------------------
  533. long type = ABLi_popInteger();
  534. long id = ABLi_popInteger();
  535. long code = -1;
  536. if (CurObject->isMover()) {
  537. MoverPtr me = (MoverPtr)CurObject;
  538. MoverPtr object = (MoverPtr)ObjectManager->findByPartId(id);
  539. //-------------------------------------------------------
  540. // Passed an object id, so select it if it's a contact...
  541. if (object && object->getTeam() && object->getContactStatus(me->getTeam()->getId(), true) != CONTACT_NONE) {
  542. CurContact = object;
  543. code = NO_ERR;
  544. }
  545. else
  546. code = 1;
  547. }
  548. ABLi_pushInteger(code);
  549. }
  550. //*****************************************************************************
  551. void execIsContact (void) {
  552. long objectId = ABLi_popInteger();
  553. long criteria = ABLi_popInteger();
  554. long select = ABLi_popInteger();
  555. long result = -1;
  556. if (CurObject->isMover() && CurObject->getTeam()) {
  557. GameObjectPtr object = getObject(objectId);
  558. if (object->isMover() && (SensorManager->getTeamSensor(CurObject->getTeamId())->meetsCriteria(CurObject, (MoverPtr)object, criteria))) {
  559. result = objectId;
  560. if (select)
  561. CurContact = object;
  562. }
  563. else
  564. result = 0;
  565. }
  566. ABLi_pushInteger(result);
  567. }
  568. //*****************************************************************************
  569. void execGetContactId (void) {
  570. //-----------------------------------------------------
  571. //
  572. // GET CONTACT ID function:
  573. //
  574. // Retrieves the current contact's object id number.
  575. //
  576. // PARAMS: none
  577. //
  578. // RETURN: integer contact's object id
  579. //
  580. //-----------------------------------------------------
  581. long result = 0;
  582. if (CurContact)
  583. result = CurContact->getPartId();
  584. ABLi_pushInteger(result);
  585. }
  586. //*****************************************************************************
  587. void execGetContactStatus (void) {
  588. //-----------------------------------------------------
  589. //
  590. // GET CONTACT STATUS function:
  591. //
  592. // Retrieves the contact status of the current contact.
  593. //
  594. // PARAMS: @integer is set to tag state, if any
  595. //
  596. // RETURN: integer contact's status
  597. //
  598. //-----------------------------------------------------
  599. long* contactTagged = ABLi_popIntegerPtr();
  600. *contactTagged = 0;
  601. long status = 0;
  602. if (CurContact && CurObject->isMover())
  603. status = ((MoverPtr)CurContact)->getContactStatus(CurObject->getTeamId(), true);
  604. ABLi_pushInteger(status);
  605. }
  606. //*****************************************************************************
  607. void execGetContactRelativePosition (void) {
  608. //-----------------------------------------------------
  609. //
  610. // GET CONTACT RELATIVE POSITION function:
  611. //
  612. // Retrieves the range and angle to the current contact.
  613. //
  614. // PARAMS: @real is set to the range (in meters) to contact
  615. //
  616. // @real is set to the angle (in degrees) to contact
  617. //
  618. // RETURN: integer error code
  619. //
  620. //-----------------------------------------------------
  621. float* range = ABLi_popRealPtr();
  622. float* angle = ABLi_popRealPtr();
  623. *range = -1.0;
  624. *angle = 0.0;
  625. long result = 1;
  626. if (CurContact && CurObject) {
  627. *range = CurObject->distanceFrom(CurContact->getPosition());
  628. *angle = CurObject->relFacingTo(CurContact->getPosition());
  629. result = NO_ERR;
  630. }
  631. ABLi_pushInteger(result);
  632. }
  633. //***************************************************************************
  634. void execSetTarget (void) {
  635. long attackerId = ABLi_popInteger();
  636. long targetId = ABLi_popInteger();
  637. GameObjectPtr target = getObject(targetId);
  638. if ((attackerId >= MIN_UNIT_PART_ID) && (attackerId <= MAX_UNIT_PART_ID)) {
  639. //--------------------------------------------
  640. // We have a group. Act accordingly.
  641. // Run through all objects fitting the group.
  642. long numObjects = getMovers(attackerId, moverList);
  643. for (long i = 0; i < numObjects; i++) {
  644. MechWarriorPtr pilot = moverList[i]->getPilot();
  645. if (pilot) {
  646. pilot->setCurrentTarget(target);
  647. pilot->getVehicle()->calcFireRanges();
  648. }
  649. }
  650. }
  651. else {
  652. GameObjectPtr attacker = getObject(attackerId);
  653. if (attacker) {
  654. MechWarriorPtr pilot = ((MoverPtr)attacker)->getPilot();
  655. if (pilot) {
  656. pilot->setCurrentTarget(target);
  657. pilot->getVehicle()->calcFireRanges();
  658. }
  659. }
  660. }
  661. }
  662. //*****************************************************************************
  663. void execGetTarget (void) {
  664. long objectId = ABLi_popInteger();
  665. long partID = 0;
  666. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  667. //--------------------------------------------
  668. // We have a group. Act accordingly.
  669. // Run through all objects fitting the group.
  670. }
  671. else {
  672. GameObjectPtr object = getObject(objectId);
  673. if (object && object->isMover()) {
  674. MechWarriorPtr pilot = ((MoverPtr)object)->getPilot();
  675. Assert(pilot != NULL, 0, " execHbGetTarget:No pilot in mover! ");
  676. GameObjectPtr target = pilot->getCurrentTarget();
  677. if (target)
  678. partID = target->getPartId();
  679. }
  680. }
  681. ABLi_pushInteger(partID);
  682. }
  683. //*****************************************************************************
  684. void execGetWeaponsReady (void) {
  685. long* weaponList = ABLi_popIntegerPtr();
  686. long listSize = ABLi_popInteger();
  687. long numWeapons = 0;
  688. if (CurObject->isMover())
  689. numWeapons = ((MoverPtr)CurObject)->getWeaponsReady(weaponList, listSize);
  690. ABLi_pushInteger(numWeapons);
  691. }
  692. //*****************************************************************************
  693. void execGetWeaponsLocked (void) {
  694. long* weaponList = ABLi_popIntegerPtr();
  695. long listSize = ABLi_popInteger();
  696. long numWeapons = 0;
  697. if (CurObject->isMover())
  698. numWeapons = ((MoverPtr)CurObject)->getWeaponsLocked(weaponList, listSize);
  699. ABLi_pushInteger(numWeapons);
  700. }
  701. //*****************************************************************************
  702. void execGetWeaponsInRange (void) {
  703. long* weaponList = ABLi_popIntegerPtr();
  704. long listSize = ABLi_popInteger();
  705. GameObjectPtr target = CurWarrior->getCurrentTarget();
  706. long numWeapons = 0;
  707. if (CurObject->isMover() && target)
  708. numWeapons = ((MoverPtr)CurObject)->getWeaponsInRange(weaponList, listSize, CurObject->distanceFrom(target->getPosition()));
  709. ABLi_pushInteger(numWeapons);
  710. }
  711. //*****************************************************************************
  712. void execGetWeaponShots (void) {
  713. long weaponIndex = ABLi_popInteger();
  714. long numShots = 0;
  715. if (CurObject->isMover())
  716. numShots = ((MoverPtr)CurObject)->getWeaponShots(weaponIndex);
  717. ABLi_pushInteger(numShots);
  718. }
  719. //*****************************************************************************
  720. void execGetWeaponRanges (void) {
  721. //-----------------------------------------------------
  722. //
  723. // GET WEAPON RANGES function:
  724. //
  725. // Returns the range in meters for the object's shortest,
  726. // optimal and longest weapon ranges.
  727. //
  728. // PARAMS: integer object id
  729. //
  730. // real[3] list to store weapon ranges
  731. //
  732. // RETURN: none
  733. //
  734. //-----------------------------------------------------
  735. long objectId = ABLi_popInteger();
  736. float* rangeList = ABLi_popRealPtr();
  737. GameObjectPtr object = getObject(objectId);
  738. if (object && object->isMover()) {
  739. rangeList[0] = ((MoverPtr)object)->getMinFireRange();
  740. rangeList[1] = ((MoverPtr)object)->getOptimalFireRange();
  741. rangeList[2] = ((MoverPtr)object)->getMaxFireRange();
  742. }
  743. else
  744. rangeList[0] = rangeList[1] = rangeList[2] = 0.0;
  745. }
  746. //*****************************************************************************
  747. void execGetObjectPosition (void) {
  748. long objectId = ABLi_popInteger();
  749. float* coordList = ABLi_popRealPtr();
  750. coordList[0] = 0.0;
  751. coordList[1] = 0.0;
  752. coordList[2] = 0.0;
  753. GameObjectPtr obj = getObject(objectId);
  754. if (obj) {
  755. Stuff::Vector3D pos = obj->getPosition();
  756. coordList[0] = pos.x;
  757. coordList[1] = pos.y;
  758. coordList[2] = pos.z;
  759. }
  760. }
  761. //*****************************************************************************
  762. void execGetIntegerMemory (void) {
  763. //-----------------------------------------------------
  764. //
  765. // GET MEMORY INTEGER function:
  766. //
  767. // Returns current integer value in memory cell of pilot.
  768. //
  769. // PARAMS: integer
  770. //
  771. // RETURN: integer
  772. //
  773. //-----------------------------------------------------
  774. long memIndex = ABLi_peekInteger();
  775. ABLi_pokeInteger(CurWarrior->getIntegerMemory(memIndex));
  776. }
  777. //*****************************************************************************
  778. void execGetRealMemory (void) {
  779. //-----------------------------------------------------
  780. //
  781. // GET MEMORY REAL function:
  782. //
  783. // Returns current real value in memory cell of pilot.
  784. //
  785. // PARAMS: integer
  786. //
  787. // RETURN: real
  788. //
  789. //-----------------------------------------------------
  790. long memIndex = ABLi_peekInteger();
  791. ABLi_pokeReal(CurWarrior->getRealMemory(memIndex));
  792. }
  793. //*****************************************************************************
  794. void execGetAlarmTriggers (void) {
  795. //-----------------------------------------------------
  796. //
  797. // GET ALARM TRIGGERS function:
  798. //
  799. // Returns number of triggers for the current combat event handler.
  800. // It also fills the list with all of the trigger ids for this
  801. // frame(call).
  802. //
  803. // PARAMS: integer[]
  804. //
  805. // RETURN: integer
  806. //
  807. //-----------------------------------------------------
  808. long* triggerList = ABLi_popIntegerPtr();
  809. ABLi_pushInteger(CurWarrior->getEventHistory(CurAlarm, triggerList));
  810. }
  811. //*****************************************************************************
  812. void execGetChallenger (void) {
  813. //-----------------------------------------------------
  814. //
  815. // GET CHALLENGER function:
  816. //
  817. // Returns the challenger for the specified object.
  818. //
  819. // PARAMS: integer object id
  820. //
  821. // RETURN: integer challenger object id
  822. //
  823. //-----------------------------------------------------
  824. long objectId = ABLi_popInteger();
  825. long challengerPartID = 0;
  826. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  827. //--------------------------------------------
  828. // We have a group. Act accordingly.
  829. // Run through all objects fitting the group.
  830. }
  831. else {
  832. GameObjectPtr object = getObject(objectId);
  833. if (object) {
  834. if (object->isMover()) {
  835. GameObjectPtr challenger = ((MoverPtr)object)->getChallenger();
  836. if (challenger)
  837. challengerPartID = challenger->getPartId();
  838. }
  839. }
  840. }
  841. ABLi_pushInteger(challengerPartID);
  842. }
  843. //*****************************************************************************
  844. void execGetTimeWithoutOrders (void) {
  845. //-----------------------------------------------------
  846. //
  847. // GET TIME WITHOUT ORDERS function:
  848. //
  849. // Returns the current pilot's time (in secs) without orders.
  850. //
  851. // PARAMS: none
  852. //
  853. // RETURN: real time (in seconds)
  854. //
  855. //-----------------------------------------------------
  856. ABLi_pushReal(0.0);
  857. if (CurWarrior) {
  858. float lastTime = CurWarrior->getTimeOfLastOrders();
  859. if (lastTime >= 0.0)
  860. ABLi_pokeReal(scenarioTime - lastTime);
  861. }
  862. }
  863. //*****************************************************************************
  864. void execGetFireRanges (void) {
  865. //-----------------------------------------------------
  866. //
  867. // GET FIRE RANGES function:
  868. //
  869. // Retrieves the current settings for SHORT, MEDIUM and LONG range,
  870. // as well as MAX WEAPON range
  871. //
  872. // PARAMS: @real[4] sets the game's current ranges (meters)
  873. //
  874. // RETURN: none
  875. //
  876. //-----------------------------------------------------
  877. float* ranges = ABLi_popRealPtr();
  878. ranges[0] = WeaponRange[FIRERANGE_SHORT];
  879. ranges[1] = WeaponRange[FIRERANGE_MEDIUM];
  880. ranges[2] = WeaponRange[FIRERANGE_LONG];
  881. ranges[3] = 250.0; //No one should use this in MC2!
  882. }
  883. //*****************************************************************************
  884. void execGetAttackers (void) {
  885. //-----------------------------------------------------
  886. //
  887. // GET ATTACKERS function:
  888. //
  889. // Retrieves all objects that have attacked current pilot
  890. // in the last x seconds.
  891. //
  892. // PARAMS: @integer[] attacker list (make it big!)
  893. //
  894. // real seconds
  895. //
  896. // RETURN: integer num attackers
  897. //
  898. //-----------------------------------------------------
  899. long* attackers = ABLi_popIntegerPtr();
  900. float seconds = ABLi_popReal();
  901. long numAttackers = 0;
  902. if (CurWarrior)
  903. numAttackers = CurWarrior->getAttackers((unsigned long*)attackers, seconds);
  904. ABLi_pushInteger(numAttackers);
  905. }
  906. //*****************************************************************************
  907. void execGetAttackerInfo (void) {
  908. //-----------------------------------------------------
  909. //
  910. // GET ATTACKER INFO function:
  911. //
  912. // If the object has attacked the current pilot, it returns the #
  913. // of seconds since the last attack (FUTURE: may return # of hits,
  914. // damage done, etc. thru params). If the object never attacked
  915. // 'em, returns -1.0.
  916. //
  917. // PARAMS: integer attacker id
  918. //
  919. // RETURN: real seconds since last attack
  920. //
  921. //-----------------------------------------------------
  922. unsigned long attackerId = ABLi_popInteger();
  923. float timeSince = 1000000.0;
  924. if ((attackerId >= MIN_UNIT_PART_ID) && (attackerId <= MAX_UNIT_PART_ID)) {
  925. //--------------------------------------------
  926. // We have a group. Act accordingly.
  927. // Run through all objects fitting the group.
  928. }
  929. else {
  930. if (CurWarrior) {
  931. AttackerRecPtr attackerRec = CurWarrior->getAttackerInfo(attackerId);
  932. if (attackerRec)
  933. timeSince = scenarioTime - attackerRec->lastTime;
  934. }
  935. }
  936. ABLi_pushReal(timeSince);
  937. }
  938. //*****************************************************************************
  939. void execSetChallenger (void) {
  940. //-----------------------------------------------------
  941. //
  942. // SET CHALLENGER function:
  943. //
  944. // Sets the challenger for the specified object.
  945. //
  946. // PARAMS: integer object1
  947. //
  948. // integer object2 (challenger)
  949. //
  950. // RETURN: integer error code
  951. //
  952. //-----------------------------------------------------
  953. long victimId = ABLi_popInteger();
  954. long challengerId = ABLi_popInteger();
  955. long result = NO_ERR;
  956. if ((challengerId >= MIN_UNIT_PART_ID) && (challengerId <= MAX_UNIT_PART_ID)) {
  957. //--------------------------------------------
  958. // We have a group. Act accordingly.
  959. // Run through all objects fitting the group.
  960. result = -1;
  961. }
  962. else {
  963. GameObjectPtr challenger = getObject(challengerId);
  964. GameObjectPtr victim = getObject(victimId);
  965. if (victim && victim->isMover())
  966. ((MoverPtr)victim)->setChallenger(challenger);
  967. else
  968. result = -2;
  969. }
  970. ABLi_pushInteger(result);
  971. }
  972. //*****************************************************************************
  973. void execSetIntegerMemory (void) {
  974. long memIndex = ABLi_popInteger();
  975. long memValue = ABLi_popInteger();
  976. CurWarrior->setIntegerMemory(memIndex, memValue);
  977. }
  978. //***************************************************************************
  979. void execSetRealMemory (void) {
  980. long memIndex = ABLi_popInteger();
  981. float memValue = ABLi_popReal();
  982. CurWarrior->setRealMemory(memIndex, memValue);
  983. }
  984. //*****************************************************************************
  985. void execHasMoveGoal (void) {
  986. bool result = false;
  987. if (CurWarrior)
  988. result = (CurWarrior->getMoveNewGoal() && CurWarrior->hasMoveGoal());
  989. ABLi_pushBoolean(result);
  990. }
  991. //*****************************************************************************
  992. void execHasMovePath (void) {
  993. bool result = false;
  994. if (CurWarrior)
  995. result = (CurWarrior->getMovePath() && !CurWarrior->getMoveNewGoal());
  996. ABLi_pushBoolean(result);
  997. }
  998. //*****************************************************************************
  999. void execSortWeapons (void) {
  1000. long* weaponList = ABLi_popIntegerPtr();
  1001. long listSize = ABLi_popInteger();
  1002. long sortType = ABLi_popInteger();
  1003. long valueList[50];
  1004. if (CurObject && CurObject->isMover())
  1005. ((MoverPtr)CurObject)->sortWeapons(weaponList, valueList, listSize, sortType, true);
  1006. }
  1007. //*****************************************************************************
  1008. void execGetVisualRange (void) {
  1009. //-----------------------------------------------------
  1010. //
  1011. // GET VISUAL RANGE function:
  1012. //
  1013. // Returns visual range of the indicated object (taking into
  1014. // account the infamous Beagle Probe).
  1015. //
  1016. // PARAMS: integer object id
  1017. //
  1018. // RETURN: real range in meters
  1019. //
  1020. //-----------------------------------------------------
  1021. long objectId = ABLi_popInteger();
  1022. float range = 0.0;
  1023. GameObjectPtr object = NULL;
  1024. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1025. //--------------------------------------------
  1026. // We have a group. Act accordingly.
  1027. // Run through all objects fitting the group.
  1028. range = -1;
  1029. }
  1030. else {
  1031. object = getObject(objectId);
  1032. if (object && object->isMover())
  1033. range = ((MoverPtr)object)->getVisualRange();
  1034. }
  1035. ABLi_pushReal(range);
  1036. }
  1037. //*****************************************************************************
  1038. void execGetUnitMates (void) {
  1039. //-----------------------------------------------------
  1040. //
  1041. // GET UNIT MATES function:
  1042. //
  1043. // Returns number and list of unit mates of the specified object.
  1044. //
  1045. // PARAMS: integer object (unit) id
  1046. //
  1047. // integer[] object list
  1048. //
  1049. // RETURN: integer num objects in unit
  1050. //
  1051. //-----------------------------------------------------
  1052. long objectId = ABLi_popInteger();
  1053. long* mateList = ABLi_popIntegerPtr();
  1054. long numObjs = 0;
  1055. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1056. //--------------------------------------------
  1057. // We have a group. Act accordingly.
  1058. long numObjects = getMovers(objectId, moverList);
  1059. for (long i = 0; i < numObjects; i++)
  1060. mateList[i] = moverList[i]->getPartId();
  1061. numObjs = numObjects;
  1062. }
  1063. else {
  1064. GameObjectPtr object = getObject(objectId);
  1065. if (object && object->isMover()) {
  1066. MoverGroupPtr group = ((MoverPtr)object)->getGroup();
  1067. if (group) {
  1068. long numObjects = group->getMovers(moverList);
  1069. for (long i = 0; i < numObjects; i++)
  1070. mateList[i] = moverList[i]->getPartId();
  1071. numObjs = numObjects;
  1072. }
  1073. }
  1074. }
  1075. ABLi_pushInteger(numObjs);
  1076. }
  1077. //*****************************************************************************
  1078. void execGetTacOrder(void) {
  1079. //-----------------------------------------------------
  1080. //
  1081. // GET TACORDER:
  1082. //
  1083. // Retrieves the current tactical order for the specified object.
  1084. // Also sets the order time and order parameters, which are passed
  1085. // as call-by-ref parameters.
  1086. //
  1087. // PARAMS: integer object id
  1088. //
  1089. // @real time order was given
  1090. //
  1091. // integer[] order parameters (size of list varies by order)
  1092. //
  1093. // RETURN: integer tac order code
  1094. //
  1095. //-----------------------------------------------------
  1096. long objectId = ABLi_popInteger();
  1097. float* time = ABLi_popRealPtr();
  1098. long* paramList = ABLi_popIntegerPtr();
  1099. long code = 0;
  1100. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1101. //--------------------------------------------
  1102. // We have a group. Act accordingly.
  1103. // Run through all objects fitting the group.
  1104. }
  1105. else {
  1106. GameObjectPtr object = getObject(objectId);
  1107. if (object && object->isMover()) {
  1108. MechWarriorPtr pilot = ((MoverPtr)object)->getPilot();
  1109. if (pilot) {
  1110. code = pilot->getCurTacOrder()->getParamData(time, paramList);
  1111. GameObjectPtr goalObj = NULL;
  1112. Stuff::Vector3D goalLoc;
  1113. float goalRange = 0.0;
  1114. paramList[17] = pilot->getMainGoal(goalObj, goalLoc, goalRange);
  1115. paramList[18] = goalObj ? goalObj->getPartId() : 0;
  1116. }
  1117. }
  1118. }
  1119. ABLi_pushInteger(code);
  1120. }
  1121. //*****************************************************************************
  1122. void execGetLastTacOrder(void) {
  1123. //-----------------------------------------------------
  1124. //
  1125. // GET LAST TACORDER:
  1126. //
  1127. // Retrieves the last tactical order for the specified object.
  1128. // Also sets the order time and order parameters, which are passed
  1129. // as call-by-ref parameters.
  1130. //
  1131. // PARAMS: integer object id
  1132. //
  1133. // @real time order was given
  1134. //
  1135. // integer[] order parameters (size of list varies by order)
  1136. //
  1137. // RETURN: integer tac order code
  1138. //
  1139. //-----------------------------------------------------
  1140. long objectId = ABLi_popInteger();
  1141. float* time = ABLi_popRealPtr();
  1142. long* paramList = ABLi_popIntegerPtr();
  1143. long code = 0;
  1144. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1145. //--------------------------------------------
  1146. // We have a group. Act accordingly.
  1147. // Run through all objects fitting the group.
  1148. }
  1149. else {
  1150. GameObjectPtr object = getObject(objectId);
  1151. if (object && object->isMover()) {
  1152. MechWarriorPtr pilot = ((MoverPtr)object)->getPilot();
  1153. if (pilot)
  1154. code = pilot->getLastTacOrder()->getParamData(time, paramList);
  1155. }
  1156. }
  1157. ABLi_pushInteger(code);
  1158. }
  1159. //*****************************************************************************
  1160. void execGetObjects (void) {
  1161. //-----------------------------------------------------
  1162. //
  1163. // GET OBJECTS function:
  1164. //
  1165. // Returns number and list of unit mates of the specified object.
  1166. //
  1167. // PARAMS: integer object criteria
  1168. //
  1169. // integer[] object list
  1170. //
  1171. // RETURN: integer num objects in unit
  1172. //
  1173. //-----------------------------------------------------
  1174. long criteria = ABLi_popInteger();
  1175. long* objList = ABLi_popIntegerPtr();
  1176. long numObjects = 0;
  1177. switch (criteria) {
  1178. case 0: {
  1179. // MOVERS
  1180. long listSize = ObjectManager->getNumMovers();
  1181. for (long i = 0; i < listSize; i++) {
  1182. MoverPtr mover = ObjectManager->getMover(i);
  1183. if (mover && mover->getExists())
  1184. objList[numObjects++] = mover->getPartId();
  1185. }
  1186. }
  1187. break;
  1188. case 1: {
  1189. // TERRAIN OBJECTS
  1190. long listSize = ObjectManager->getNumTerrainObjects();
  1191. for (long i = 0; i < listSize; i++) {
  1192. TerrainObjectPtr terObj = ObjectManager->getTerrainObject(i);
  1193. if (terObj) {
  1194. //long row, col;
  1195. //((GameObjectPtr)terObj)->getCellPosition(row, col);
  1196. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1197. //Assert(partID == terObj->getPartId(), partID, "ugh");
  1198. objList[numObjects++] = terObj->getPartId();
  1199. }
  1200. }
  1201. }
  1202. break;
  1203. case 2: {
  1204. // BUILDINGS
  1205. long listSize = ObjectManager->getNumBuildings();
  1206. for (long i = 0; i < listSize; i++) {
  1207. BuildingPtr building = ObjectManager->getBuilding(i);
  1208. if (building) {
  1209. //long row, col;
  1210. //((GameObjectPtr)building)->getCellPosition(row, col);
  1211. //long calcPartID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1212. //long partID = building->getPartId();
  1213. //Assert(partID == calcPartID, partID, "ugh");
  1214. objList[numObjects++] = building->getPartId();
  1215. }
  1216. }
  1217. }
  1218. break;
  1219. case 3: {
  1220. // TURRETS
  1221. long listSize = ObjectManager->getNumTurrets();
  1222. for (long i = 0; i < listSize; i++) {
  1223. TurretPtr turret = ObjectManager->getTurret(i);
  1224. if (turret) {
  1225. //long row, col;
  1226. //((GameObjectPtr)turret)->getCellPosition(row, col);
  1227. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1228. //Assert(partID == turret->getPartId(), partID, "ugh");
  1229. objList[numObjects++] = turret->getPartId();
  1230. }
  1231. }
  1232. }
  1233. break;
  1234. case 4: {
  1235. // GATES
  1236. long listSize = ObjectManager->getNumGates();
  1237. for (long i = 0; i < listSize; i++) {
  1238. GatePtr gate = ObjectManager->getGate(i);
  1239. if (gate) {
  1240. //long row, col;
  1241. //((GameObjectPtr)gate)->getCellPosition(row, col);
  1242. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1243. //Assert(partID == gate->getPartId(), partID, "ugh");
  1244. objList[numObjects++] = gate->getPartId();
  1245. }
  1246. }
  1247. }
  1248. break;
  1249. case 5: {
  1250. // ALL TERRAIN OBJECTS, including buildings, turrets and gates
  1251. long listSize = ObjectManager->getNumTerrainObjects();
  1252. for (long i = 0; i < listSize; i++) {
  1253. TerrainObjectPtr terObj = ObjectManager->getTerrainObject(i);
  1254. if (terObj) {
  1255. //long row, col;
  1256. //((GameObjectPtr)terObj)->getCellPosition(row, col);
  1257. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1258. //Assert(partID == terObj->getPartId(), partID, "ugh");
  1259. objList[numObjects++] = terObj->getPartId();
  1260. }
  1261. }
  1262. listSize = ObjectManager->getNumBuildings();
  1263. for (i = 0; i < listSize; i++) {
  1264. BuildingPtr building = ObjectManager->getBuilding(i);
  1265. if (building) {
  1266. //long row, col;
  1267. //((GameObjectPtr)building)->getCellPosition(row, col);
  1268. //long calcPartID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1269. //long partID = building->getPartId();
  1270. //Assert(partID == calcPartID, partID, "ugh");
  1271. objList[numObjects++] = building->getPartId();
  1272. }
  1273. }
  1274. listSize = ObjectManager->getNumTurrets();
  1275. for (i = 0; i < listSize; i++) {
  1276. TurretPtr turret = ObjectManager->getTurret(i);
  1277. if (turret) {
  1278. //long row, col;
  1279. //((GameObjectPtr)turret)->getCellPosition(row, col);
  1280. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1281. //Assert(partID == turret->getPartId(), partID, "ugh");
  1282. objList[numObjects++] = turret->getPartId();
  1283. }
  1284. }
  1285. listSize = ObjectManager->getNumGates();
  1286. for (i = 0; i < listSize; i++) {
  1287. GatePtr gate = ObjectManager->getGate(i);
  1288. if (gate) {
  1289. //long row, col;
  1290. //((GameObjectPtr)gate)->getCellPosition(row, col);
  1291. //long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  1292. //Assert(partID == gate->getPartId(), partID, "ugh");
  1293. objList[numObjects++] = gate->getPartId();
  1294. }
  1295. }
  1296. }
  1297. break;
  1298. }
  1299. ABLi_pushInteger(numObjects);
  1300. }
  1301. //*****************************************************************************
  1302. void execOrderWait (void) {
  1303. float seconds = ABLi_popReal();
  1304. bool clearLastTarget = ABLi_peekBoolean();
  1305. if (ABLi_getSkipOrder()) {
  1306. ABLi_pokeInteger(1);
  1307. return;
  1308. }
  1309. long result = TACORDER_FAILURE;
  1310. result = CurWarrior->orderWait(false, ORDER_ORIGIN_COMMANDER, double2long(seconds), clearLastTarget);
  1311. ABLi_pokeInteger(result);
  1312. }
  1313. //*****************************************************************************
  1314. void execOrderMoveTo (void) {
  1315. //-----------------------------------------------------
  1316. //
  1317. // MOVE TO POINT tactical order:
  1318. //
  1319. // Set tactical order to move to specified location, using the
  1320. // current attitude orders and other move factors. Returns tacorder
  1321. // result code.
  1322. //
  1323. // PARAMS: real[3] location
  1324. //
  1325. // boolean run
  1326. //
  1327. // RETURN: integer
  1328. //
  1329. //-----------------------------------------------------
  1330. float* coordList = ABLi_popRealPtr();
  1331. bool run = ABLi_popBoolean();
  1332. if (ABLi_getSkipOrder()) {
  1333. ABLi_pushInteger(1);
  1334. return;
  1335. }
  1336. long result = TACORDER_FAILURE;
  1337. Stuff::Vector3D location;
  1338. location.x = coordList[0];
  1339. location.y = coordList[1];
  1340. location.z = coordList[2];
  1341. unsigned long params = TACORDER_PARAM_NONE;
  1342. if (run)
  1343. params |= TACORDER_PARAM_RUN;
  1344. result = CurWarrior->orderMoveToPoint(false, true, ORDER_ORIGIN_COMMANDER, location, -1, params);
  1345. ABLi_pushInteger(result);
  1346. }
  1347. //*****************************************************************************
  1348. void execOrderMoveToObject (void) {
  1349. //-----------------------------------------------------
  1350. //
  1351. // MOVE TO OBJECT tactical order:
  1352. //
  1353. // Set tactical order to move to specified object, using the given
  1354. // movement parameters (stealth, etc.). Returns error code.
  1355. //
  1356. // PARAMS: integer contact id
  1357. //
  1358. // boolean run
  1359. //
  1360. // RETURN: integer error code
  1361. //
  1362. //-----------------------------------------------------
  1363. unsigned long objectId = ABLi_popInteger();
  1364. bool run = ABLi_popBoolean();
  1365. if (ABLi_getSkipOrder()) {
  1366. ABLi_pushInteger(1);
  1367. return;
  1368. }
  1369. long result = 1;
  1370. GameObjectPtr object = NULL;
  1371. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1372. //--------------------------------------------
  1373. // We have a group. Act accordingly.
  1374. // Run through all objects fitting the group.
  1375. result = 1;
  1376. }
  1377. else {
  1378. object = getObject(objectId);
  1379. if (object)
  1380. result = CurWarrior->orderMoveToObject(false, true, ORDER_ORIGIN_COMMANDER, object, -1, -1, run);
  1381. }
  1382. ABLi_pushInteger(result);
  1383. }
  1384. //*****************************************************************************
  1385. void execOrderMoveToContact (void) {
  1386. //-----------------------------------------------------
  1387. //
  1388. // MOVE TO CONTACT tactical order:
  1389. //
  1390. // Set tactical order to move to specified contact, using the given
  1391. // movement parameters (stealth, etc.). Returns error code.
  1392. //
  1393. // PARAMS: boolean run
  1394. //
  1395. // RETURN: integer error code
  1396. //
  1397. //-----------------------------------------------------
  1398. bool run = ABLi_popBoolean();
  1399. if (ABLi_getSkipOrder()) {
  1400. ABLi_pushInteger(1);
  1401. return;
  1402. }
  1403. long result = TACORDER_FAILURE;
  1404. //---------------------------------------------------------------
  1405. // First, get the contact's object ID and its current location...
  1406. if (CurContact) {
  1407. //------------------------------------------------------------
  1408. // Now, set up the tactical order, and pass it to the pilot...
  1409. result = CurWarrior->orderMoveToObject(false, true, ORDER_ORIGIN_COMMANDER, CurContact, -1, -1, run);
  1410. }
  1411. ABLi_pushInteger(result);
  1412. }
  1413. //*****************************************************************************
  1414. void execOrderPowerDown (void) {
  1415. //-----------------------------------------------------
  1416. //
  1417. // ORDER POWER DOWN function:
  1418. //
  1419. // Set tactical order to power down.
  1420. // Returns tacorder result code.
  1421. //
  1422. // PARAMS: NONE
  1423. //
  1424. // RETURN: integer
  1425. //
  1426. //-----------------------------------------------------
  1427. if (ABLi_getSkipOrder()) {
  1428. ABLi_pushInteger(1);
  1429. return;
  1430. }
  1431. ABLi_pushInteger(CurWarrior->orderPowerDown(false, TacOrderOrigin));
  1432. }
  1433. //*****************************************************************************
  1434. void execOrderPowerUp (void) {
  1435. //-----------------------------------------------------
  1436. //
  1437. // ORDER POWER UP function:
  1438. //
  1439. // Set tactical order to power up.
  1440. // Returns tacorder result code.
  1441. //
  1442. // PARAMS: NONE
  1443. //
  1444. // RETURN: integer
  1445. //
  1446. //-----------------------------------------------------
  1447. if (ABLi_getSkipOrder()) {
  1448. ABLi_pushInteger(1);
  1449. return;
  1450. }
  1451. ABLi_pushInteger(CurWarrior->orderPowerUp(false, TacOrderOrigin));
  1452. }
  1453. //*****************************************************************************
  1454. void execOrderAttackObject (void) {
  1455. //-----------------------------------------------------
  1456. //
  1457. // ORDER ATTACK OBJECT tactical order:
  1458. //
  1459. // Set tactical order to direct all weapons fire at the specified
  1460. // object. Returns an error code.
  1461. //
  1462. // PARAMS: integer object id
  1463. //
  1464. // integer attack type (0 = none, 1 = destroy, 2 = disable)
  1465. //
  1466. // integer method (0 = ranged, 1 = dfa, 2 = ramming)
  1467. //
  1468. // integer range (0 = short, 1 = medium, 2 = long)
  1469. //
  1470. // integer pursue (0 = False, 1 = True)
  1471. //
  1472. // RETURN: integer error code
  1473. //
  1474. //-----------------------------------------------------
  1475. unsigned long objectId = ABLi_popInteger();
  1476. long attackType = ABLi_popInteger();
  1477. long attackMethod = ABLi_popInteger();
  1478. long attackRange = ABLi_popInteger();
  1479. long pursue = ABLi_popInteger();
  1480. long result = 1;
  1481. if (!ABLi_getSkipOrder()) {
  1482. unsigned long params = TACORDER_PARAM_NONE;
  1483. if (pursue)
  1484. params |= TACORDER_PARAM_PURSUE;
  1485. GameObjectPtr object = NULL;
  1486. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1487. //--------------------------------------------
  1488. // We have a group. Act accordingly.
  1489. // Run through all objects fitting the group.
  1490. }
  1491. else {
  1492. if (objectId > 0)
  1493. object = ObjectManager->findByPartId(objectId);
  1494. result = CurWarrior->orderAttackObject(false, ORDER_ORIGIN_COMMANDER, object, attackType, attackMethod, attackRange, -1, -1, params);
  1495. }
  1496. }
  1497. ABLi_pushInteger(result);
  1498. }
  1499. //*****************************************************************************
  1500. void execOrderAttackContact (void) {
  1501. //-----------------------------------------------------
  1502. //
  1503. // ORDER ATTACK CONTACT tactical order:
  1504. //
  1505. // Set tactical order to direct all weapons fire at the current
  1506. // contact. Returns an error code.
  1507. //
  1508. // PARAMS: integer attack type (0 = none, 1 = destroy, 2 = disable)
  1509. //
  1510. // integer range (0 = short, 1 = medium, 2 = long)
  1511. //
  1512. // integer method (0 = ranged, 1 = dfa, 2 = ramming)
  1513. //
  1514. // integer pursue (0 = False, 1 = True)
  1515. //
  1516. // RETURN: integer error code
  1517. //
  1518. //-----------------------------------------------------
  1519. long attackType = ABLi_popInteger();
  1520. long attackMethod = ABLi_popInteger();
  1521. long attackRange = ABLi_popInteger();
  1522. long pursue = ABLi_popInteger();
  1523. long result = 1;
  1524. if (!ABLi_getSkipOrder()) {
  1525. unsigned long params = TACORDER_PARAM_NONE;
  1526. if (pursue)
  1527. params |= TACORDER_PARAM_PURSUE;
  1528. result = -2;
  1529. if (CurContact)
  1530. result = CurWarrior->orderAttackObject(false, ORDER_ORIGIN_COMMANDER, CurContact, attackType, attackMethod, attackRange, -1, -1, params);
  1531. }
  1532. ABLi_pushInteger(result);
  1533. }
  1534. //*****************************************************************************
  1535. void execOrderWithdraw(void) {
  1536. //Makes the object(s) passed in withdraw
  1537. //
  1538. // PARAMS: NONE
  1539. //
  1540. // Returns: integer (result)
  1541. ABLi_pushInteger(1);
  1542. if (!ABLi_getSkipOrder()) {
  1543. Stuff::Vector3D location;
  1544. location.Zero();
  1545. ABLi_pushInteger(0);
  1546. if (CurWarrior)
  1547. CurWarrior->orderWithdraw(false, ORDER_ORIGIN_COMMANDER, location);
  1548. else
  1549. ABLi_pokeInteger(-2);
  1550. }
  1551. }
  1552. //*****************************************************************************
  1553. void execObjectInWithdrawal(void) {
  1554. //Checks the object(s) passed in to see if they are withdrawing
  1555. //
  1556. // PARAMS: integer
  1557. //
  1558. // Returns: integer (result)
  1559. long objectId1 = ABLi_popInteger();
  1560. long result = 1;
  1561. GameObjectPtr object1 = NULL;
  1562. if ((objectId1 >= MIN_UNIT_PART_ID) && (objectId1 <= MAX_UNIT_PART_ID)) {
  1563. //--------------------------------------------
  1564. // We have a group. Act accordingly.
  1565. // Run through all objects fitting the group.
  1566. long numObjects = getMovers(objectId1, moverList);
  1567. for (long i = 0; i < numObjects; i++) {
  1568. if (!moverList[i]->isWithdrawing()) {
  1569. result = 0;
  1570. break;
  1571. }
  1572. }
  1573. }
  1574. else {
  1575. object1 = getObject(objectId1);
  1576. if (object1 && !object1->isWithdrawing())
  1577. result = 0;
  1578. }
  1579. ABLi_pushInteger(result);
  1580. }
  1581. //*****************************************************************************
  1582. void execDamageObject (void) {
  1583. //----------------------------------------------------------------------
  1584. //
  1585. // DAMAGE OBJECT function:
  1586. //
  1587. // Directly damages an object as if it were a weapon shot.
  1588. // Returns error code.
  1589. //
  1590. // PARAMS: integer target object id
  1591. //
  1592. // integer attacker object id
  1593. //
  1594. // integer weapon master component id
  1595. //
  1596. // real damage points
  1597. //
  1598. // integer hit location
  1599. //
  1600. // real hit roll
  1601. //
  1602. // real entry angle
  1603. //
  1604. // RETURN: integer error code (always returns 0, for now)
  1605. //
  1606. // -1 = bad target
  1607. //
  1608. // -2 = bad attacker
  1609. //
  1610. //----------------------------------------------------------------------
  1611. long targetId = ABLi_popInteger();
  1612. long attackerId = ABLi_popInteger();
  1613. long weaponMasterId = ABLi_popInteger();
  1614. float damage = ABLi_popReal();
  1615. long hitLocation = ABLi_popInteger();
  1616. float hitRoll = ABLi_popReal();
  1617. float entryAngle = ABLi_peekReal();
  1618. GameObjectPtr attacker = getObject(attackerId);
  1619. ABLi_pokeInteger(-1);
  1620. if (attacker) {
  1621. if ((targetId >= MIN_UNIT_PART_ID) && (targetId <= MAX_UNIT_PART_ID)) {
  1622. //--------------------------------------------
  1623. // We have a group. Act accordingly.
  1624. long numObjects = getMovers(targetId, moverList, true);
  1625. WeaponShotInfo shotInfo;
  1626. shotInfo.init(attacker->getWatchID(), weaponMasterId, damage, hitLocation, entryAngle);
  1627. if (MPlayer) {
  1628. if (MPlayer->isServer()) {
  1629. for (long i = 0; i < numObjects; i++) {
  1630. moverList[i]->handleWeaponHit(&shotInfo, true);
  1631. }
  1632. }
  1633. }
  1634. else
  1635. for (long i = 0; i < numObjects; i++)
  1636. moverList[i]->handleWeaponHit(&shotInfo);
  1637. ABLi_pokeInteger(numObjects);
  1638. }
  1639. else {
  1640. GameObjectPtr target = getObject(targetId, true);
  1641. if (target) {
  1642. WeaponShotInfo shotInfo;
  1643. shotInfo.init(attacker->getWatchID(), weaponMasterId, damage, hitLocation, entryAngle);
  1644. if (MPlayer) {
  1645. if (MPlayer->isServer()) {
  1646. target->handleWeaponHit(&shotInfo, true);
  1647. }
  1648. }
  1649. else
  1650. target->handleWeaponHit(&shotInfo);
  1651. ABLi_pokeInteger(1);
  1652. }
  1653. else
  1654. ABLi_pokeInteger(-2);
  1655. }
  1656. }
  1657. }
  1658. //*****************************************************************************
  1659. void execSetAttackRadius (void) {
  1660. //-----------------------------------------------------
  1661. //
  1662. // SET ATTACK RADIUS tactical order:
  1663. //
  1664. // Sets the range at which the pilot will break off attack from its
  1665. // last target. Returns previous attack radius.
  1666. //
  1667. // PARAMS: real attack radius in meters
  1668. //
  1669. // RETURN: real previous attack radius
  1670. //
  1671. //-----------------------------------------------------
  1672. float radius = ABLi_peekReal();
  1673. ABLi_pokeReal(CurWarrior->getAttackRadius());
  1674. CurWarrior->setAttackRadius(radius);
  1675. }
  1676. //*****************************************************************************
  1677. void execObjectChangeSides (void) {
  1678. //Object Change Side Function.
  1679. //
  1680. // PARAMS: integer, integer
  1681. //
  1682. // Returns: nothing!
  1683. long objectId = ABLi_popInteger();
  1684. long newObjectSide = ABLi_popInteger();
  1685. GameObjectPtr object = NULL;
  1686. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1687. //--------------------------------------------
  1688. // We have a group. Act accordingly.
  1689. // Run through all objects fitting the group.
  1690. Fatal(0, " Cannot ABL:ObjectChangeSides for Mover Units ");
  1691. }
  1692. else {
  1693. object = getObject(objectId);
  1694. if (object)
  1695. object->setTeam(Team::teams[newObjectSide]);
  1696. }
  1697. }
  1698. //*****************************************************************************
  1699. void execDistanceToObject (void) {
  1700. //Distance to Object From Object Function.
  1701. //
  1702. // PARAMS: integer, integer
  1703. //
  1704. // Returns: (real) distance in meters
  1705. long objectId1 = ABLi_popInteger();
  1706. long objectId2 = ABLi_peekInteger();
  1707. ABLi_pokeReal(-1.0);
  1708. GameObjectPtr object2 = getObject(objectId2);
  1709. if (object2) {
  1710. Stuff::Vector3D position2 = object2->getPosition();
  1711. if ((objectId1 >= MIN_UNIT_PART_ID) && (objectId1 <= MAX_UNIT_PART_ID)) {
  1712. //--------------------------------------------
  1713. // We have a group. Act accordingly.
  1714. // Run through all objects fitting the group.
  1715. float minDistance = 3.4E38f;
  1716. float distance = 3.4E38f;
  1717. long numObjects = getMovers(objectId1, moverList);
  1718. for (long i = 0; i < numObjects; i++) {
  1719. MoverPtr mover = moverList[i];
  1720. if (!mover->getExistsAndAwake())
  1721. continue;
  1722. Stuff::Vector3D position1 = mover->getPosition();
  1723. position2.z = position1.z;
  1724. Stuff::Vector3D resultVector;
  1725. resultVector.Subtract(position2, position1);
  1726. distance = resultVector.GetLength();
  1727. if (distance < minDistance)
  1728. minDistance = distance;
  1729. }
  1730. if (minDistance < 3.4E38)
  1731. ABLi_pokeReal(minDistance * metersPerWorldUnit);
  1732. }
  1733. else {
  1734. GameObjectPtr object1 = getObject(objectId1);
  1735. if (object1) {
  1736. Stuff::Vector3D position1 = object1->getPosition();
  1737. position2.z = position1.z;
  1738. Stuff::Vector3D resultVector;
  1739. resultVector.Subtract(position2, position1);
  1740. ABLi_pokeReal(resultVector.GetLength() * metersPerWorldUnit);
  1741. }
  1742. }
  1743. }
  1744. }
  1745. //***************************************************************************
  1746. void execDistanceToPosition (void) {
  1747. //Distance to Object From Position Function.
  1748. //
  1749. // PARAMS: integer, real[3]
  1750. //
  1751. // Returns: (real) distance in meters
  1752. long objectId = ABLi_popInteger();
  1753. float* coordList = ABLi_popRealPtr();
  1754. ABLi_pushReal(-1.0);
  1755. //---------------------------------------
  1756. // For now, we only care about x and y...
  1757. Stuff::Vector3D position2;
  1758. position2.Zero();
  1759. if (!_isnan(coordList[0]))
  1760. position2.x = coordList[0];
  1761. if (!_isnan(coordList[1]))
  1762. position2.y = coordList[1];
  1763. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1764. //--------------------------------------------
  1765. // We have a group. Act accordingly.
  1766. // Run through all objects fitting the group.
  1767. long numObjects = getMovers(objectId, moverList);
  1768. float minDistance = 3.4E38f;
  1769. float distance = 3.4E38f;
  1770. for (long i = 0; i < numObjects; i++) {
  1771. MoverPtr mover = moverList[i];
  1772. if (!mover->getExistsAndAwake())
  1773. continue;
  1774. Stuff::Vector3D position1 = mover->getPosition();
  1775. position2.z = position1.z;
  1776. Stuff::Vector3D resultVector;
  1777. resultVector.Subtract(position2, position1);
  1778. distance = resultVector.GetLength();
  1779. if (distance < minDistance)
  1780. minDistance = distance;
  1781. }
  1782. if (minDistance < 3.4E38)
  1783. ABLi_pokeReal(minDistance * metersPerWorldUnit);
  1784. }
  1785. else {
  1786. GameObjectPtr obj = getObject(objectId);
  1787. if (obj) {
  1788. Stuff::Vector3D position1 = obj->getPosition();
  1789. position2.z = position1.z;
  1790. Stuff::Vector3D resultVector;
  1791. resultVector.Subtract(position2, position1);
  1792. ABLi_pokeReal(resultVector.GetLength() * metersPerWorldUnit);
  1793. }
  1794. }
  1795. }
  1796. //*****************************************************************************
  1797. void execObjectSuicide (void) {
  1798. //Cause object to destroy itself Function.
  1799. //
  1800. // PARAMS: integer
  1801. //
  1802. // Returns: nothing
  1803. //-----------------
  1804. long objectId = ABLi_popInteger();
  1805. GameObjectPtr object1 = NULL;
  1806. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1807. //--------------------------------------------
  1808. // We have a group. Act accordingly.
  1809. // Run through all objects fitting the group.
  1810. long numObjects = getMovers(objectId, moverList);
  1811. for (long i = 0; i < numObjects; i++)
  1812. moverList[i]->setExists(false);
  1813. }
  1814. else {
  1815. object1 = getObject(objectId);
  1816. if (object1)
  1817. object1->setExists(false);
  1818. }
  1819. }
  1820. //***************************************************************************
  1821. void execObjectCreate (void) {
  1822. //Cause object to create itself Function.
  1823. //
  1824. // PARAMS: integer
  1825. //
  1826. // Returns: id of object created
  1827. long objectId = ABLi_popInteger();
  1828. long result = 0;
  1829. GameObjectPtr object = getObject(objectId);
  1830. if (object && !object->getExists()) {
  1831. object->setExists(true);
  1832. for (long i = 0; i < Team::numTeams; i++)
  1833. SensorManager->getTeamSensor(i)->scanBattlefield();
  1834. result = objectId;
  1835. }
  1836. ABLi_pushInteger(result);
  1837. }
  1838. //***************************************************************************
  1839. void execObjectExists (void) {
  1840. //test if object exists Function.
  1841. //
  1842. // PARAMS: integer
  1843. //
  1844. // Returns: integer
  1845. long objectId = ABLi_peekInteger();
  1846. ABLi_pokeInteger(0);
  1847. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1848. //--------------------------------------------
  1849. // We have a group. Act accordingly.
  1850. // Run through all objects fitting the group.
  1851. long numObjs = getMovers(objectId, moverList);
  1852. long i = 0;
  1853. while ((i < numObjs) && !moverList[i]->getExists())
  1854. i++;
  1855. ABLi_pokeInteger(i < numObjs);
  1856. }
  1857. else {
  1858. GameObjectPtr obj = getObject(objectId);
  1859. if (obj && obj->getExists())
  1860. ABLi_pokeInteger(1);
  1861. }
  1862. }
  1863. //***************************************************************************
  1864. void execObjectStatus (void) {
  1865. //returns object's status.
  1866. //
  1867. // PARAMS: integer
  1868. //
  1869. // Returns: integer
  1870. long objectId = ABLi_popInteger();
  1871. long result = -1;
  1872. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1873. //-------------------------------------------------------
  1874. // We have a group. Act accordingly.
  1875. // No Group Check of actual status, return -1.
  1876. // If any unit member is still alive, then the unit is...
  1877. bool disabled = true;
  1878. long numObjects = getMovers(objectId, moverList);
  1879. for (long i = 0; i < numObjects; i++) {
  1880. long status = moverList[i]->getStatus();
  1881. if ((status != OBJECT_STATUS_DESTROYED) && (status != OBJECT_STATUS_DISABLED)) {
  1882. MechWarriorPtr pilot = moverList[i]->getPilot();
  1883. if (pilot && (pilot->getStatus() != WARRIOR_STATUS_WITHDRAWN)) {
  1884. disabled = false;
  1885. break;
  1886. }
  1887. }
  1888. }
  1889. if (disabled)
  1890. result = OBJECT_STATUS_DISABLED;
  1891. else
  1892. result = OBJECT_STATUS_NORMAL;
  1893. }
  1894. else {
  1895. GameObjectPtr obj = getObject(objectId);
  1896. if (obj)
  1897. result = obj->getStatus();
  1898. }
  1899. ABLi_pushInteger(result);
  1900. }
  1901. //*****************************************************************************
  1902. void execObjectStatusCount (void) {
  1903. //return object status count for an object, unit or team.
  1904. //
  1905. // PARAMS: integer partId
  1906. //
  1907. // integer[9] tally list
  1908. //
  1909. // Returns: NONE
  1910. long objectId = ABLi_popInteger();
  1911. long* tallyList = ABLi_popIntegerPtr();
  1912. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1913. //--------------------------------------------
  1914. // We have a group. Act accordingly.
  1915. // No Group Check of actual status, return -1.
  1916. if ((objectId >= PlayerLance0) && (objectId < PlayerLance0 + MAX_MOVERGROUPS))
  1917. //Fatal(0, " ABL.objectStatusCount: bad id ");
  1918. Commander::commanders[0]->getGroup(objectId - PlayerLance0)->statusCount(tallyList);
  1919. else if ((objectId >= AlliedLance0) && (objectId < AlliedLance0 + MAX_MOVERGROUPS))
  1920. //Fatal(0, " ABL.objectStatusCount: bad id ");
  1921. Commander::commanders[2]->getGroup(objectId - AlliedLance0)->statusCount(tallyList);
  1922. else if ((objectId >= ClanStar0) && (objectId < ClanStar0 + MAX_MOVERGROUPS))
  1923. //Fatal(0, " ABL.objectStatusCount: bad id ");
  1924. Commander::commanders[1]->getGroup(objectId - ClanStar0)->statusCount(tallyList);
  1925. else if ((objectId >= OBJ_ID_FIRST_TEAM) && (objectId <= OBJ_ID_LAST_TEAM)) {
  1926. TeamPtr team = Team::teams[objectId - OBJ_ID_FIRST_TEAM];
  1927. if (team)
  1928. team->statusCount(tallyList);
  1929. }
  1930. }
  1931. else {
  1932. GameObjectPtr object1 = getObject(objectId);
  1933. if (object1)
  1934. tallyList[object1->getStatus()]++;
  1935. }
  1936. }
  1937. //*****************************************************************************
  1938. void execObjectVisible (void) {
  1939. //test if object2 is visible from object1
  1940. //
  1941. // PARAMS: integer, integer
  1942. //
  1943. // Returns: integer
  1944. long objectId1 = ABLi_popInteger();
  1945. long objectId2 = ABLi_popInteger();
  1946. GameObjectPtr object1 = NULL;
  1947. GameObjectPtr object2 = getObject(objectId2);
  1948. long result = 0;
  1949. if (object2) {
  1950. if ((objectId1 >= MIN_UNIT_PART_ID) && (objectId1 <= MAX_UNIT_PART_ID)) {
  1951. //--------------------------------------------
  1952. // We have a group. Act accordingly.
  1953. // Run through all objects fitting the group.
  1954. // Can anyone in the group see the object?
  1955. long numObjects = getMovers(objectId1, moverList);
  1956. for (long i = 0; i < numObjects; i++)
  1957. if (object1->lineOfSight(moverList[i])) {
  1958. result = 1;
  1959. break;
  1960. }
  1961. }
  1962. else {
  1963. object1 = getObject(objectId1);
  1964. if (object1)
  1965. result = object1->lineOfSight(object2);
  1966. }
  1967. }
  1968. ABLi_pushInteger(result);
  1969. }
  1970. //*****************************************************************************
  1971. void execObjectTeam (void) {
  1972. //return what side object plays for Function.
  1973. //
  1974. // PARAMS: integer
  1975. //
  1976. // Returns: integer
  1977. long objectId = ABLi_popInteger();
  1978. long result = -1;
  1979. GameObjectPtr object = getObject(objectId);
  1980. if (object)
  1981. result = MIN_TEAM_PART_ID + object->getTeamId();
  1982. ABLi_pushInteger(result);
  1983. }
  1984. //*****************************************************************************
  1985. void execObjectCommander (void) {
  1986. long objectId = ABLi_peekInteger();
  1987. ABLi_pokeInteger(-1);
  1988. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  1989. //-----------------------------------
  1990. // We have a group. Act accordingly.
  1991. }
  1992. else {
  1993. GameObjectPtr obj = getObject(objectId);
  1994. if (obj)
  1995. ABLi_pokeInteger(obj->getCommanderId());
  1996. }
  1997. }
  1998. //*****************************************************************************
  1999. void execObjectClass(void) {
  2000. //return what object class the obj is.
  2001. //
  2002. // PARAMS: integer
  2003. //
  2004. // Returns: integer
  2005. long objectId = ABLi_popInteger();
  2006. long result = -1;
  2007. GameObjectPtr object = getObject(objectId);
  2008. if (object)
  2009. result = object->getObjectClass();
  2010. ABLi_pushInteger(result);
  2011. }
  2012. //*****************************************************************************
  2013. void execSetTimer (void) {
  2014. //Creates a timer which counts down from time passed in
  2015. //
  2016. // PARAMS: integer, real
  2017. //
  2018. // Returns: integer (ID of timer created)
  2019. short timerNumber = ABLi_popInteger();
  2020. float duration = ABLi_popReal();
  2021. if (timerNumber < SCENARIO_TIMER_1 || timerNumber > SCENARIO_TIMER_8)
  2022. timerNumber = 0;
  2023. else {
  2024. TimerPtr timer = timerManager->getTimer(timerNumber);
  2025. Assert(timer != NULL, timerNumber, " ABL.execHbSetTimer: NULL timer ");
  2026. timer->setTimer(duration);
  2027. }
  2028. ABLi_pushInteger(timerNumber);
  2029. }
  2030. //*****************************************************************************
  2031. void execCheckTimer (void) {
  2032. //Checks a timer created and return time left
  2033. //
  2034. // PARAMS: integer
  2035. //
  2036. // Returns: real (time left)
  2037. short timerNumber = ABLi_popInteger();
  2038. float timeLeft = 0.0;
  2039. if ((timerNumber >= 0) && (timerNumber < MAX_TIMERS)) {
  2040. TimerPtr timer = timerManager->getTimer(timerNumber);
  2041. Assert(timer != NULL, timerNumber, " ABL.execHbSetTimer: NULL timer ");
  2042. timeLeft = timer->getCurrentTime();
  2043. }
  2044. if (timeLeft < 0.0f)
  2045. timeLeft = 0.0f;
  2046. ABLi_pushReal(timeLeft);
  2047. }
  2048. //*****************************************************************************
  2049. void execEndTimer (void) {
  2050. //sets time to zero and destroys timer.
  2051. //
  2052. // PARAMS: integer
  2053. //
  2054. // Returns: nothing
  2055. long timerID = ABLi_popInteger();
  2056. // NOT REALLY NECESSARY ANYMORE--since the timers have no callback, they just
  2057. // keep counting down... no harm...
  2058. #if 0
  2059. if ((timerId < SCENARIOTIMER1) || (timerId > SCENARIOTIMER8))
  2060. timerId = 0;
  2061. else
  2062. application->RemoveTimer(application,timerId);
  2063. #endif
  2064. }
  2065. //*****************************************************************************
  2066. void execSetObjectiveTimer (void) {
  2067. //Sets timer of objective passed in.
  2068. //
  2069. // PARAMS: integer, real
  2070. //
  2071. // Returns: integer (result)
  2072. long objectiveNum = ABLi_popInteger();
  2073. float duration = ABLi_popReal();
  2074. ABLi_pushInteger(mission->setObjectiveTimer(objectiveNum, duration));
  2075. }
  2076. //*****************************************************************************
  2077. void execCheckObjectiveTimer (void) {
  2078. //Checks an objective timer passed in and returns time left
  2079. //
  2080. // PARAMS: integer
  2081. //
  2082. // Returns: real (time left)
  2083. long objectiveNum = ABLi_popInteger();
  2084. ABLi_pushReal(mission->checkObjectiveTimer(objectiveNum));
  2085. }
  2086. //*****************************************************************************
  2087. void execSetObjectiveStatus (void) {
  2088. //Sets status of objective passed in.
  2089. //
  2090. // PARAMS: integer, integer
  2091. //
  2092. // Returns: integer (result)
  2093. long objectiveNum = ABLi_popInteger();
  2094. long status = ABLi_popInteger();
  2095. ABLi_pushInteger(mission->setObjectiveStatus(objectiveNum,status));
  2096. }
  2097. //*****************************************************************************
  2098. void execCheckObjectiveStatus (void) {
  2099. //Checks an objective status passed in and returns it
  2100. //
  2101. // PARAMS: integer
  2102. //
  2103. // Returns: integer (status)
  2104. long objectiveNum = ABLi_popInteger();
  2105. ABLi_pushInteger(mission->checkObjectiveStatus(objectiveNum));
  2106. }
  2107. //*****************************************************************************
  2108. void execSetObjectiveType (void) {
  2109. //Sets type of objective passed in.
  2110. //
  2111. // PARAMS: integer, integer
  2112. //
  2113. // Returns: integer (result)
  2114. long objectiveNum = ABLi_popInteger();
  2115. long type = ABLi_popInteger();
  2116. ABLi_pushInteger(mission->setObjectiveType(objectiveNum,type));
  2117. }
  2118. //*****************************************************************************
  2119. void execCheckObjectiveType (void) {
  2120. //Checks an objective type passed in and returns it
  2121. //
  2122. // PARAMS: integer
  2123. //
  2124. // Returns: integer (status)
  2125. long objectiveNum = ABLi_popInteger();
  2126. ABLi_pushInteger(mission->checkObjectiveType(objectiveNum));
  2127. }
  2128. //*****************************************************************************
  2129. void execPlayDigitalMusic (void) {
  2130. //Starts playback of Digital music
  2131. //
  2132. // PARAMS: integer
  2133. //
  2134. // Returns: integer (result)
  2135. long soundNum = ABLi_popInteger();
  2136. if (soundSystem)
  2137. soundSystem->playABLDigitalMusic(soundNum);
  2138. ABLi_pushInteger(0);
  2139. }
  2140. //***************************************************************************
  2141. void execStopMusic(void) {
  2142. //Stops playback of Digitalmusic
  2143. //
  2144. // PARAMS: None
  2145. //
  2146. // Returns: None
  2147. if (soundSystem)
  2148. soundSystem->stopABLMusic();
  2149. }
  2150. //*****************************************************************************
  2151. void execPlaySoundEffect(void) {
  2152. //Starts playback of Digital sound effect
  2153. //
  2154. // PARAMS: integer, real
  2155. //
  2156. // Returns: integer (result)
  2157. long soundNum = ABLi_popInteger();
  2158. if (soundSystem)
  2159. soundSystem->playABLSFX(soundNum);
  2160. ABLi_pushInteger(0);
  2161. }
  2162. //*****************************************************************************
  2163. void execPlayVideo(void) {
  2164. //Starts playback of video sequence
  2165. //
  2166. // PARAMS: integer, real
  2167. //
  2168. // Returns: integer (result)
  2169. char* fileName = ABLi_popCharPtr();
  2170. mission->missionInterface->playMovie(fileName);
  2171. ABLi_pushInteger(0);
  2172. }
  2173. //*****************************************************************************
  2174. void execSetRadio (void) {
  2175. //-----------------------------------------------------
  2176. //
  2177. // SET RADIO function:
  2178. //
  2179. // Turns the radio(s) on or off.
  2180. //
  2181. // PARAMS: integer warrior id
  2182. //
  2183. // integer FALSE = off, TRUE= on
  2184. //
  2185. // RETURN: none
  2186. //
  2187. //-----------------------------------------------------
  2188. long warriorIndex = ABLi_popInteger();
  2189. bool radioSetting = ABLi_popBoolean();
  2190. MechWarriorPtr pilot = getWarrior(warriorIndex);
  2191. if (pilot && pilot->getRadio()) {
  2192. if (radioSetting)
  2193. pilot->getRadio()->turnOn();
  2194. else
  2195. pilot->getRadio()->turnOff();
  2196. }
  2197. }
  2198. //*****************************************************************************
  2199. void execPlaySpeech (void) {
  2200. //Starts playback of Digital speech
  2201. //
  2202. // PARAMS: integer, integer
  2203. //
  2204. // Returns: integer (result)
  2205. long warriorIndex = ABLi_popInteger();
  2206. long message = ABLi_popInteger();
  2207. MechWarriorPtr pilot = getWarrior(warriorIndex);
  2208. if (pilot)
  2209. pilot->radioMessage(message, true);
  2210. ABLi_pushInteger(0);
  2211. }
  2212. //*****************************************************************************
  2213. void execPlayBetty (void) {
  2214. //Starts playback of betty message
  2215. //
  2216. // PARAMS: integer
  2217. //
  2218. // Returns: integer (result)
  2219. //-----------------------------------------------
  2220. // Get the ID of the pilot whose speech this is
  2221. long messageIndex = ABLi_popInteger();
  2222. long result = soundSystem->playBettySample(messageIndex);
  2223. ABLi_pushInteger(result);
  2224. }
  2225. //*****************************************************************************
  2226. void execGetMissionWon (void)
  2227. {
  2228. if (Mission::terminationResult != -1)
  2229. {
  2230. ABLi_pushBoolean(Mission::terminationResult >= mis_PLAYER_WIN_SMALL);
  2231. }
  2232. else
  2233. {
  2234. ABLi_pushBoolean(false);
  2235. }
  2236. }
  2237. //*****************************************************************************
  2238. void execGetMissionLost (void)
  2239. {
  2240. ABLi_pushBoolean((Mission::terminationResult == mis_PLAYER_LOST_BIG) ||
  2241. (Mission::terminationResult == mis_PLAYER_LOST_SMALL));
  2242. }
  2243. //*****************************************************************************
  2244. void execGetObjectiveSuccess (void)
  2245. {
  2246. ABLi_pushBoolean(mission->checkObjectiveSuccess());
  2247. }
  2248. //*****************************************************************************
  2249. void execGetObjectiveFailed (void)
  2250. {
  2251. ABLi_pushBoolean(mission->checkObjectiveFailed());
  2252. }
  2253. //*****************************************************************************
  2254. void execGetEnemyDestroyed (void)
  2255. {
  2256. ABLi_pushBoolean(enemyDestroyed);
  2257. enemyDestroyed = false;
  2258. }
  2259. //*****************************************************************************
  2260. void execGetFriendlyDestroyed (void)
  2261. {
  2262. ABLi_pushBoolean(friendlyDestroyed);
  2263. friendlyDestroyed = false;
  2264. }
  2265. //*****************************************************************************
  2266. void execPlayerInCombat (void)
  2267. {
  2268. ABLi_pushBoolean(MechWarrior::anyPlayerInCombat());
  2269. }
  2270. //*****************************************************************************
  2271. void execGetSensorsActive (void)
  2272. {
  2273. ABLi_pushBoolean(SensorSystemManager::enemyInLOS);
  2274. }
  2275. //*****************************************************************************
  2276. void execGetCurrentMusicId (void)
  2277. {
  2278. ABLi_pushInteger(soundSystem->getCurrentMusicId());
  2279. }
  2280. void execGetMissionTuneId (void)
  2281. {
  2282. ABLi_pushInteger(mission->getMissionTuneId());
  2283. }
  2284. //*****************************************************************************
  2285. void execSetObjectActive(void) {
  2286. //Turns on/off the AI for the object(s) passed in
  2287. //
  2288. // PARAMS: integer object id
  2289. //
  2290. // boolean true = on, false = off
  2291. //
  2292. // Returns: integer (result)
  2293. long objectId1 = ABLi_popInteger();
  2294. bool active = ABLi_peekBoolean();
  2295. //------------------------------------------------
  2296. // Code to make this work goes here
  2297. GameObjectPtr object1 = NULL;
  2298. long numActivated = 0;
  2299. if ((objectId1 >= MIN_UNIT_PART_ID) && (objectId1 <= MAX_UNIT_PART_ID)) {
  2300. //--------------------------------------------
  2301. // We have a group. Act accordingly.
  2302. // Run through all objects fitting the group.
  2303. long numObjects = getMovers(objectId1, moverList);
  2304. for (long i = 0; i < numObjects; i++)
  2305. if (moverList[i]->getAwake() != active) {
  2306. object1->setAwake(active);
  2307. #ifdef USE_IFACE
  2308. theInterface->ActivateMech(moverList[i]->getPartId());
  2309. #endif
  2310. numActivated++;
  2311. }
  2312. }
  2313. else {
  2314. object1 = getObject(objectId1);
  2315. if (object1 && (object1->getAwake() != active)) {
  2316. object1->setAwake(active);
  2317. #ifdef USE_IFACE
  2318. theInterface->ActivateMech(object1->getPartId());
  2319. #endif
  2320. numActivated++;
  2321. }
  2322. }
  2323. ABLi_pokeInteger(numActivated);
  2324. }
  2325. //*****************************************************************************
  2326. void execObjectTypeID (void) {
  2327. //Returns the objectTypeId for the ObjectNum passed in
  2328. //
  2329. // PARAMS: integer
  2330. //
  2331. // Returns: integer (result)
  2332. long objectId1 = ABLi_popInteger();
  2333. long partID = -1;
  2334. //---------------------------------
  2335. // Code to make this work goes here
  2336. GameObjectPtr object1 = getObject(objectId1);
  2337. if (object1)
  2338. partID = object1->getObjectType()->whatAmI();
  2339. ABLi_pushInteger(partID);
  2340. }
  2341. //*****************************************************************************
  2342. void execGetTerrainObjectPartID (void) {
  2343. //Returns the object PartID for a terrain Object
  2344. //
  2345. // PARAMS: integer, integer
  2346. //
  2347. // Returns: integer (result)
  2348. long row = ABLi_popInteger();
  2349. long col = ABLi_popInteger();
  2350. long partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + col;
  2351. pushInteger(partID);
  2352. }
  2353. //*****************************************************************************
  2354. void execGetWeaponAmmo (void) {
  2355. //Returns number of rounds left based on objectId and weaponId
  2356. //
  2357. // PARAMS: integer, integer
  2358. //
  2359. // Returns: integer (result)
  2360. long objectNum = ABLi_popInteger();
  2361. long weaponNum = ABLi_popInteger();
  2362. //------------------------------------------------
  2363. // Code to make this work goes here
  2364. GameObjectPtr object1 = getObject(objectNum);
  2365. if (object1 && object1->isMover())
  2366. ABLi_pushInteger(((MoverPtr)object1)->getWeaponShots(weaponNum));
  2367. else
  2368. ABLi_pushInteger(-1);
  2369. }
  2370. //*****************************************************************************
  2371. void execInArea (void) {
  2372. //returns TRUE if object/unit/team inside area.
  2373. //
  2374. // PARAMS: integer object/unit/team id
  2375. //
  2376. // real[3] center of area
  2377. //
  2378. // real radius of area
  2379. //
  2380. // integer min number to pass (-1 = ALL must be in)
  2381. //
  2382. // RETURN: boolean yes or no?
  2383. long objectId = ABLi_popInteger();
  2384. float* areaCenter = ABLi_popRealPtr();
  2385. float areaRadius = ABLi_popReal();
  2386. long minIn = ABLi_peekInteger();
  2387. Stuff::Vector3D center;
  2388. center.x = areaCenter[0];
  2389. center.y = areaCenter[1];
  2390. center.z = areaCenter[2];
  2391. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  2392. //--------------------------------------------
  2393. // We have a group. Act accordingly.
  2394. long numObjects = getMovers(objectId, moverList);
  2395. if (minIn == -1) {
  2396. ABLi_pokeInteger(1);
  2397. long numAlive = 0;
  2398. for (long i = 0; i < numObjects; i++) {
  2399. GameObjectPtr obj = moverList[i];
  2400. if (!obj->isDisabled()) {
  2401. numAlive++;
  2402. if (obj->getExists() && obj->getAwake()) {
  2403. if (obj->distanceFrom(center) > areaRadius) {
  2404. ABLi_pokeInteger(0);
  2405. break;
  2406. }
  2407. }
  2408. }
  2409. }
  2410. if (numAlive == 0)
  2411. ABLi_pokeInteger(0);
  2412. }
  2413. else {
  2414. ABLi_pokeInteger(0);
  2415. long numIn = 0;
  2416. for (long i = 0; i < numObjects; i++) {
  2417. MoverPtr mover = moverList[i];
  2418. if (mover->getExists() && mover->getAwake() && !mover->isDisabled() && !mover->isDestroyed())
  2419. if (mover->distanceFrom(center) <= areaRadius) {
  2420. if (++numIn == minIn) {
  2421. ABLi_pokeInteger(1);
  2422. break;
  2423. }
  2424. }
  2425. }
  2426. }
  2427. }
  2428. else {
  2429. ABLi_pokeInteger(1);
  2430. if (minIn != 0) {
  2431. ABLi_pokeInteger(0);
  2432. GameObjectPtr obj = getObject(objectId);
  2433. if (obj && obj->getExists() && obj->getAwake() && !obj->isDisabled() && !obj->isDestroyed()) {
  2434. if (obj->distanceFrom(center) <= areaRadius)
  2435. ABLi_pokeInteger(1);
  2436. }
  2437. }
  2438. }
  2439. }
  2440. //*****************************************************************************
  2441. void execObjectRemove (void) {
  2442. //---------------------------------------------------------------------
  2443. //
  2444. // Object Remove
  2445. //
  2446. // Remove the object from the game (COMPLETELY removes).
  2447. // Currently only works for Movers.
  2448. //
  2449. // PARAMS: integer object id
  2450. //
  2451. // RETURN: integer result (0 = success)
  2452. //
  2453. //---------------------------------------------------------------------
  2454. long objectId = ABLi_popInteger();
  2455. GameObjectPtr object = getObject(objectId);
  2456. if (object) {
  2457. if (object->isMover()) {
  2458. //-------------------------------------------------------------
  2459. // If the object we're removing is the CurObject, then we can't
  2460. // do it until after we finish this object's update!
  2461. // So, we'll just set the removed flag, and then check it
  2462. // at the end of the update.
  2463. if (object == CurObject)
  2464. CurObject->setFlag(OBJECT_FLAG_REMOVED, true);
  2465. else
  2466. mission->removeMover((MoverPtr)object);
  2467. ABLi_pushInteger(0);
  2468. }
  2469. else
  2470. ABLi_pushInteger(1);
  2471. }
  2472. }
  2473. //*****************************************************************************
  2474. void execCreateInfantry (void) {
  2475. long teamID = ABLi_popInteger();
  2476. long commanderID = ABLi_popInteger();
  2477. float* worldPos = ABLi_popRealPtr();
  2478. long buildingPartID = ABLi_popInteger();
  2479. MoverInitData moverData;
  2480. memset(&moverData, 0, sizeof(MoverInitData));
  2481. strcpy(moverData.pilotFileName, "pmw00080");
  2482. strcpy(moverData.brainFileName, "infantry001");
  2483. strcpy(moverData.csvFileName, "PM101100");
  2484. moverData.objNumber = 53;
  2485. moverData.rosterIndex = 255;
  2486. moverData.controlType = 2;
  2487. moverData.controlDataType = 0;
  2488. moverData.variant = 0;
  2489. moverData.position.x = worldPos[0];
  2490. moverData.position.y = worldPos[1];
  2491. moverData.position.z = 0.0;
  2492. moverData.rotation = 0.0;
  2493. moverData.teamID = teamID;
  2494. moverData.commanderID = commanderID;
  2495. moverData.gestureID = 2;
  2496. moverData.active = true;
  2497. moverData.exists = true;
  2498. moverData.icon = 0;
  2499. moverData.capturable = false;
  2500. long infantryHandle = mission->addMover(&moverData);
  2501. MoverPtr infantry = (MoverPtr)ObjectManager->get(infantryHandle);
  2502. if (infantry)
  2503. infantry->getPilot()->setIntegerMemory(0, buildingPartID);
  2504. ABLi_pushInteger(0);
  2505. }
  2506. //*****************************************************************************
  2507. void execGetSensorsWorking (void) {
  2508. //Returns whether or not sensors are operative for object passed in
  2509. //
  2510. // PARAMS: integer
  2511. //
  2512. // Returns: integer (result)
  2513. long objectNum = ABLi_popInteger();
  2514. long result = -1;
  2515. GameObjectPtr object1 = getObject(objectNum);
  2516. if (object1 && object1->isMover() && ((MoverPtr)object1)->sensorSystem)
  2517. result = ((MoverPtr)object1)->sensorSystem->enabled();
  2518. ABLi_pushInteger(result);
  2519. }
  2520. //*****************************************************************************
  2521. void execGetCurrentBRValue (void) {
  2522. //Returns the current BR value for the object passed in.
  2523. //
  2524. // PARAMS: integer
  2525. //
  2526. // Returns: integer (result)
  2527. long objectNum = ABLi_popInteger();
  2528. long result = -1;
  2529. //------------------------------------------------
  2530. // Code to make this work goes here
  2531. GameObjectPtr object1 = getObject(objectNum);
  2532. if (object1)
  2533. result = object1->getCurCV();
  2534. ABLi_pushInteger(result);
  2535. }
  2536. //*****************************************************************************
  2537. void execSetCurrentBRValue (void) {
  2538. //Sets the current BR value for the object passed in.
  2539. //
  2540. // PARAMS: integer, integer
  2541. //
  2542. // Returns: None
  2543. long objectNum = tos->integer;
  2544. long newBRValue = tos->integer;
  2545. //------------------------------------------------
  2546. // Code to make this work goes here
  2547. GameObjectPtr object1 = getObject(objectNum);
  2548. if (object1)
  2549. object1->setCurCV(newBRValue);
  2550. }
  2551. //*****************************************************************************
  2552. void execGetArmorPts (void) {
  2553. //Returns the current number of armor points remaining on the object passed in
  2554. //
  2555. // PARAMS: integer
  2556. //
  2557. // Returns: integer (result)
  2558. long objectNum = ABLi_peekInteger();
  2559. //---------------------------------
  2560. // Code to make this work goes here
  2561. GameObjectPtr obj = getObject(objectNum);
  2562. long armorPts = 0;
  2563. ABLi_pokeInteger(0);
  2564. if (obj && obj->isMover()) {
  2565. MoverPtr mover = (MoverPtr)obj;
  2566. for (long i = 0; i < mover->numArmorLocations; i++)
  2567. armorPts += mover->armor[i].curArmor;
  2568. ABLi_pokeInteger(armorPts);
  2569. }
  2570. }
  2571. //*****************************************************************************
  2572. void execGetMaxArmor (void) {
  2573. //Returns the max number of armor points on the object passed in
  2574. //
  2575. // PARAMS: integer
  2576. //
  2577. // Returns: integer (result)
  2578. long objectNum = ABLi_peekInteger();
  2579. //---------------------------------
  2580. // Code to make this work goes here
  2581. ABLi_pokeInteger(0);
  2582. GameObjectPtr obj = getObject(objectNum);
  2583. long armorPts = 0;
  2584. if (obj && obj->isMover()) {
  2585. MoverPtr mover = (MoverPtr)obj;
  2586. for (long i = 0; i < mover->numArmorLocations; i++)
  2587. armorPts += mover->armor[i].maxArmor;
  2588. ABLi_pokeInteger(armorPts);
  2589. }
  2590. }
  2591. //*****************************************************************************
  2592. void execGetPilotID (void) {
  2593. //Returns the pilot ID of the driver of the object passed in.
  2594. //
  2595. // PARAMS: integer
  2596. //
  2597. // Returns: integer (result)
  2598. long objectNum = ABLi_peekInteger();
  2599. //---------------------------------
  2600. // Code to make this work goes here
  2601. GameObjectPtr obj = getObject(objectNum);
  2602. ABLi_pokeInteger(-1);
  2603. if (obj) {
  2604. MechWarriorPtr pilot = obj->getPilot();
  2605. if (pilot)
  2606. ABLi_pokeInteger(pilot->getIndex());
  2607. }
  2608. }
  2609. //*****************************************************************************
  2610. void execGetPilotWounds (void) {
  2611. //Returns number of wounds pilot of vehicle has sustained.
  2612. //
  2613. // PARAMS: integer
  2614. //
  2615. // Returns: real (result)
  2616. long objectNum = ABLi_peekInteger();
  2617. //---------------------------------
  2618. // Code to make this work goes here
  2619. GameObjectPtr obj = getObject(objectNum);
  2620. ABLi_pokeReal(0.0);
  2621. if (obj) {
  2622. MechWarriorPtr pilot = obj->getPilot();
  2623. if (pilot)
  2624. ABLi_pokeReal(pilot->getWounds());
  2625. }
  2626. }
  2627. //*****************************************************************************
  2628. void execSetPilotWounds (void) {
  2629. //Returns number of wounds pilot of vehicle has sustained.
  2630. //
  2631. // PARAMS: integer
  2632. //
  2633. // Returns: real (result)
  2634. long objectNum = ABLi_popInteger();
  2635. long wounds = ABLi_popInteger();
  2636. //------------------------------------------------
  2637. // Code to make this work goes here
  2638. if (wounds > 6)
  2639. wounds = 6;
  2640. GameObjectPtr obj = getObject(objectNum);
  2641. if (obj) {
  2642. MechWarriorPtr pilot = obj->getPilot();
  2643. if (pilot)
  2644. pilot->setWounds(wounds);
  2645. }
  2646. }
  2647. //*****************************************************************************
  2648. void execGetObjectActive (void) {
  2649. //Checks to see if the object(s) passed in are active
  2650. //
  2651. // PARAMS: integer, real
  2652. //
  2653. // Returns: integer (result)
  2654. long objectId = ABLi_popInteger();
  2655. long result = 0;
  2656. GameObjectPtr object1 = NULL;
  2657. if ((objectId >= MIN_UNIT_PART_ID) && (objectId <= MAX_UNIT_PART_ID)) {
  2658. //--------------------------------------------
  2659. // We have a group. Act accordingly.
  2660. // Run through all objects fitting the group.
  2661. long numObjects = getMovers(objectId, moverList);
  2662. long numAwake = 0;
  2663. for (long i = 0; i < numObjects; i++)
  2664. if (moverList[i]->getAwake())
  2665. numAwake++;
  2666. result = numAwake;
  2667. }
  2668. else {
  2669. object1 = getObject(objectId);
  2670. if (object1 && object1->getAwake())
  2671. result = 1;
  2672. }
  2673. ABLi_pushInteger(result);
  2674. }
  2675. //***************************************************************************
  2676. void execGetObjectDamage (void) {
  2677. //Returns the damage level of the object passed in
  2678. //
  2679. // PARAMS: integer
  2680. //
  2681. // Returns: integer (result)
  2682. long objectNum = ABLi_peekInteger();
  2683. //------------------------------------------------
  2684. // Code to make this work goes here
  2685. ABLi_pokeInteger(0);
  2686. GameObjectPtr obj = getObject(objectNum);
  2687. if (obj && obj->isTerrainObject()) {
  2688. float dmgLevel = obj->getDamageLevel();
  2689. //Assert(dmgLevel > 0.0, (long)dmgLevel, " ABL.execHbGetObjDamage: ZERO damageLevel ");
  2690. float dmgResult = 100.0;
  2691. if (dmgLevel > 0.0)
  2692. dmgResult = floor((obj->getDamage() / dmgLevel) * 100.0);
  2693. ABLi_pokeInteger((long)dmgResult);
  2694. }
  2695. }
  2696. //***************************************************************************
  2697. void execGetObjectDmgPts (void) {
  2698. //Returns the damage points of the object passed in
  2699. //
  2700. // PARAMS: integer
  2701. //
  2702. // Returns: integer (result)
  2703. long objectNum = ABLi_peekInteger();
  2704. //------------------------------------------------
  2705. // Code to make this work goes here
  2706. ABLi_pokeInteger(0);
  2707. GameObjectPtr obj = getObject(objectNum);
  2708. if (obj && obj->isTerrainObject()) {
  2709. long dmgResult = (long)obj->getDamage();
  2710. ABLi_pokeInteger(dmgResult);
  2711. }
  2712. }
  2713. //***************************************************************************
  2714. void execGetObjectMaxDmg (void) {
  2715. //Returns the damage level of the object passed in
  2716. //
  2717. // PARAMS: integer
  2718. //
  2719. // Returns: integer (result)
  2720. long objectNum = ABLi_peekInteger();
  2721. //------------------------------------------------
  2722. // Code to make this work goes here
  2723. ABLi_pokeInteger(0);
  2724. GameObjectPtr obj = getObject(objectNum);
  2725. if (obj) {
  2726. float damage = obj->getDamage();
  2727. ABLi_pokeInteger((long)damage);
  2728. }
  2729. }
  2730. //***************************************************************************
  2731. void execSetObjectDamage (void) {
  2732. //Sets the damage level of the object passed in
  2733. //Note that the damage can only be given, not taken away!
  2734. //
  2735. // PARAMS: integer, integer
  2736. //
  2737. // Returns: none
  2738. long objectNum = ABLi_popInteger();
  2739. long dmgPercentage = ABLi_popInteger();
  2740. if (dmgPercentage > 100)
  2741. dmgPercentage = 100;
  2742. //---------------------------------
  2743. // Code to make this work goes here
  2744. GameObjectPtr obj = getObject(objectNum);
  2745. if (obj && (dmgPercentage > 0)) {
  2746. float maxDmg = obj->getDamageLevel();
  2747. float curDmg = obj->getDamage();
  2748. float dmgPoints = ((float)dmgPercentage / 100.0) * maxDmg - curDmg;
  2749. dmgPoints += 1.0f; //One to be sure.
  2750. if (dmgPoints > 0.0)
  2751. {
  2752. WeaponShotInfo shot;
  2753. shot.init(NULL, -1, dmgPoints, 0, 0);
  2754. if (MPlayer)
  2755. {
  2756. if (MPlayer->isServer())
  2757. {
  2758. obj->handleWeaponHit(&shot, true);
  2759. }
  2760. }
  2761. else
  2762. obj->handleWeaponHit(&shot);
  2763. }
  2764. }
  2765. }
  2766. //*****************************************************************************
  2767. void execGetGlobalValue (void) {
  2768. //Gets the value stored in global variable specified by passed in number.
  2769. //
  2770. // PARAMS: integer
  2771. //
  2772. // Returns: real (result)
  2773. long variableNum = ABLi_peekInteger();
  2774. //------------------------------------------------
  2775. // Code to make this work goes here
  2776. ABLi_pokeReal(0.0);
  2777. if ((variableNum >= 0) && (variableNum < MAX_GLOBAL_MISSION_VALUES))
  2778. ABLi_pokeReal(globalMissionValues[variableNum]);
  2779. }
  2780. //***************************************************************************
  2781. void execSetGlobalValue (void) {
  2782. //Sets the value stored in global variable specified by passed in number.
  2783. //
  2784. // PARAMS: integer, real
  2785. //
  2786. // Returns: nothing
  2787. long variableNum = ABLi_popInteger();
  2788. float value = ABLi_popReal();
  2789. //------------------------------------------------
  2790. // Code to make this work goes here
  2791. if ((variableNum >= 0) && (variableNum < MAX_GLOBAL_MISSION_VALUES))
  2792. globalMissionValues[variableNum] = value;
  2793. }
  2794. //***************************************************************************
  2795. void execSetObjectivePos (void) {
  2796. //Sets the position for objective passed in.
  2797. //
  2798. // PARAMS: integer, real, real, real
  2799. //
  2800. // Returns: nothing
  2801. long variableNum = ABLi_popInteger();
  2802. float X = ABLi_popReal();
  2803. float Y = ABLi_popReal();
  2804. float Z = ABLi_popReal();
  2805. mission->setObjectivePos(variableNum, X, Y, Z);
  2806. }
  2807. //*****************************************************************************
  2808. void execSetSensorRange (void) {
  2809. //-----------------------------------------------------
  2810. //
  2811. // SET SENSOR RANGE function:
  2812. //
  2813. // Sets the sensor range of the object.
  2814. //
  2815. // PARAMS: integer object id
  2816. //
  2817. // real range
  2818. //
  2819. // RETURN: NONE
  2820. //
  2821. //-----------------------------------------------------
  2822. long objectId = ABLi_popInteger();
  2823. float range = ABLi_popReal();
  2824. GameObjectPtr obj = getObject(objectId);
  2825. if (obj)
  2826. obj->setSensorRange(range);
  2827. }
  2828. //***************************************************************************
  2829. void execSetTonnage (void) {
  2830. //-----------------------------------------------------
  2831. //
  2832. // SET TONNAGE function:
  2833. //
  2834. // Sets the tonnage of the object.
  2835. //
  2836. // PARAMS: integer object id
  2837. //
  2838. // real tons
  2839. //
  2840. // RETURN: nothing
  2841. //
  2842. //-----------------------------------------------------
  2843. long objectId = ABLi_popInteger();
  2844. float tonnage = ABLi_popReal();
  2845. GameObjectPtr object = getObject(objectId);
  2846. if (object)
  2847. object->setTonnage(tonnage);
  2848. }
  2849. //*****************************************************************************
  2850. void execSetExplosionDamage (void) {
  2851. //-----------------------------------------------------
  2852. //
  2853. // SET Explosion Damage function:
  2854. //
  2855. // Sets the Explosion Damage of the object.
  2856. //
  2857. // PARAMS: integer object id
  2858. //
  2859. // real points of damage
  2860. //
  2861. // RETURN: nothing
  2862. //
  2863. //-----------------------------------------------------
  2864. long objectId = ABLi_popInteger();
  2865. float dmg = ABLi_popReal();
  2866. GameObjectPtr obj = getObject(objectId);
  2867. if (obj)
  2868. obj->setExplDmg(dmg);
  2869. }
  2870. //*****************************************************************************
  2871. void execSetExplosionRadius (void) {
  2872. //-----------------------------------------------------
  2873. //
  2874. // SET Explosion Radius function:
  2875. //
  2876. // Sets the explosion radius of the object.
  2877. //
  2878. // PARAMS: integer object id
  2879. //
  2880. // real radius (in Meters)
  2881. //
  2882. // RETURN: nothing
  2883. //
  2884. //-----------------------------------------------------
  2885. long objectId = ABLi_popInteger();
  2886. float radius = ABLi_popReal();
  2887. GameObjectPtr obj = getObject(objectId);
  2888. if (obj)
  2889. obj->setExplRad(radius);
  2890. }
  2891. //*****************************************************************************
  2892. void execSetSalvage (void) {
  2893. //-----------------------------------------------------
  2894. //
  2895. // SET Salvage function:
  2896. //
  2897. // Sets the salvage for a building object.
  2898. //
  2899. // PARAMS: integer object id
  2900. //
  2901. // integer MasterComponentID of salvage
  2902. //
  2903. // integer Number of these components
  2904. //
  2905. // RETURN: BOOLEAN True if function succeeds
  2906. //
  2907. //-----------------------------------------------------
  2908. //long objectId =
  2909. ABLi_popInteger();
  2910. //long component =
  2911. ABLi_popInteger();
  2912. //long itemCount = ABLi_peekInteger();
  2913. ABLi_pokeInteger(0);
  2914. #ifdef USE_SALVAGE
  2915. GameObjectPtr obj = getObject(objectId);
  2916. if (obj) {
  2917. SalvageItemPtr tmpSalvage = object->getSalvage();
  2918. SalvageItemPtr newSalvage = new SalvageItem;
  2919. if (newSalvage) {
  2920. ABLi_pokeInteger(1);
  2921. newSalvage->itemID = component;
  2922. newSalvage->numItems = itemCount;
  2923. while (tmpSalvage && tmpSalvage->next)
  2924. tmpSalvage = tmpSalvage->next;
  2925. if (object->getSalvage())
  2926. tmpSalvage->next = newSalvage;
  2927. else
  2928. object->setSalvage(newSalvage);
  2929. }
  2930. }
  2931. #endif
  2932. }
  2933. //*****************************************************************************
  2934. void execSetSalvageStatus (void){
  2935. //-----------------------------------------------------
  2936. //
  2937. // SET Salvage function:
  2938. //
  2939. // Sets a mover on or off the salvage list
  2940. //
  2941. // PARAMS: integer object id
  2942. //
  2943. // BOOLEAN TRUE = on list, FALSE = off
  2944. //
  2945. // RETURN: BOOLEAN True if function succeeds
  2946. //
  2947. //-----------------------------------------------------
  2948. //long objectId =
  2949. ABLi_popInteger();
  2950. //bool on = ABLi_peekBoolean();
  2951. ABLi_pokeBoolean(false);
  2952. #ifdef USE_SALVAGE
  2953. GameObjectPtr obj = getObject(objectId);
  2954. if (obj && TACMAP && (object->isMover() || object->isBuilding())) {
  2955. if (on)
  2956. ABLi_pokeBoolean(TACMAP->AddSalvage(object));
  2957. else
  2958. ABLi_pokeBoolean(TACMAP->RemoveSalvage(object));
  2959. }
  2960. #endif
  2961. }
  2962. //*****************************************************************************
  2963. void execSetAnimation (void) {
  2964. //-----------------------------------------------------
  2965. //
  2966. // SET Animation function:
  2967. //
  2968. // Sets the salvage for a building object. (Say what?! --jm)
  2969. // ALL RIGHT, ALLRIGHT!!!! Sets the animation State and subState. -fs
  2970. //
  2971. // PARAMS: integer object id
  2972. //
  2973. // integer Animation State
  2974. //
  2975. // integer Animation Sub State
  2976. //
  2977. // RETURN: Nothing
  2978. //
  2979. //-----------------------------------------------------
  2980. long objectId = ABLi_popInteger();
  2981. //long newState =
  2982. ABLi_popInteger();
  2983. //long newSubState =
  2984. ABLi_popInteger();
  2985. GameObjectPtr obj = getObject(objectId);
  2986. if (obj && obj->isBuilding()) {
  2987. #ifdef USE_BUILDING_APPR
  2988. ((BuildingPtr)building)->setAnimState(newState, newSubState);
  2989. #endif
  2990. }
  2991. }
  2992. //*****************************************************************************
  2993. void execSetRevealed (void) {
  2994. //Reveals terrain around point a distance out.
  2995. //
  2996. // PARAMS: integer, real, real[2]
  2997. //
  2998. // Returns: nothing
  2999. long teamID = ABLi_popInteger();
  3000. float distance = ABLi_popReal();
  3001. float* coordList = ABLi_popRealPtr();
  3002. Stuff::Vector3D position2;
  3003. position2.x = coordList[0];
  3004. position2.y = coordList[1];
  3005. position2.z = 0.0;
  3006. if (teamID > -1)
  3007. land->markRadiusSeen(position2,distance,teamID);
  3008. //------------------------------------------------------------------
  3009. // This is sloppy, and we need a better way to update their scans...
  3010. for (long i = 0; i < Team::numTeams; i++)
  3011. SensorManager->getTeamSensor(i)->scanBattlefield();
  3012. }
  3013. //*****************************************************************************
  3014. void execGetSalvage (void) {
  3015. //-----------------------------------------------------
  3016. //
  3017. // GET Salvage function:
  3018. //
  3019. // Returns two list of itemIds and quantities of salvage in an object
  3020. //
  3021. // PARAMS: integer building ID
  3022. //
  3023. // integer number of item in array
  3024. //
  3025. // integer[] item list
  3026. //
  3027. // integer[] quantity list
  3028. //
  3029. // RETURN: none
  3030. //
  3031. //-----------------------------------------------------
  3032. long objectId = ABLi_popInteger();
  3033. long itemCount = ABLi_popInteger();
  3034. long* items = ABLi_popIntegerPtr();
  3035. long* quantities = ABLi_popIntegerPtr();
  3036. for (long i = 0; i < itemCount; i++) {
  3037. items[i] = -1;
  3038. quantities[i] = -1;
  3039. }
  3040. GameObjectPtr obj = getObject(objectId);
  3041. if (obj) {
  3042. #ifdef USE_SALVAGE
  3043. SalvageItemPtr tmpSalvage = object->getSalvage();
  3044. while (tmpSalvage && itemCount > 0)
  3045. {
  3046. *tmpItems = tmpSalvage->itemID;
  3047. *tmpQuantities = tmpSalvage->numItems;
  3048. tmpItems++;
  3049. tmpQuantities++;
  3050. tmpSalvage = tmpSalvage->next;
  3051. itemCount--;
  3052. }
  3053. #endif
  3054. }
  3055. }
  3056. //*****************************************************************************
  3057. void execOrderRefit (void) {
  3058. //-----------------------------------------------------
  3059. //
  3060. // Refit function:
  3061. //
  3062. // Current Object starts refiting mover
  3063. //
  3064. // PARAMS: integer mover ID
  3065. //
  3066. // integer order params
  3067. //
  3068. // RETURN: none
  3069. //
  3070. //-----------------------------------------------------
  3071. long refiteeId = ABLi_popInteger();
  3072. long params = ABLi_popInteger();
  3073. if (CurObject) {
  3074. MechWarriorPtr pilot = CurObject->getPilot();
  3075. if (pilot) {
  3076. GameObjectPtr refitee = getObject(refiteeId);
  3077. if (refitee && refitee->getObjectClass() == BATTLEMECH)
  3078. pilot->orderRefit(ORDER_ORIGIN_COMMANDER, refitee, params);
  3079. }
  3080. }
  3081. }
  3082. //*****************************************************************************
  3083. void execSetCaptured (void) {
  3084. //-----------------------------------------------------
  3085. //
  3086. // Set Captured function:
  3087. //
  3088. // Sets an objects captured flag to TRUE, and starts the capture display
  3089. //
  3090. // PARAMS: integer building ID
  3091. //
  3092. //-----------------------------------------------------
  3093. long objectId = ABLi_popInteger();
  3094. GameObjectPtr object = getObject(objectId);
  3095. if (object)
  3096. object->setCaptured(true);
  3097. }
  3098. //*****************************************************************************
  3099. void execOrderCapture (void) {
  3100. //-----------------------------------------------------
  3101. //
  3102. // Capture Object function:
  3103. //
  3104. // Sets CurObject to capture object specified by target ID
  3105. //
  3106. // PARAMS: integer target ID
  3107. //
  3108. // integer order params
  3109. //
  3110. // RETURN: NONE
  3111. //
  3112. //-----------------------------------------------------
  3113. long targetId = ABLi_popInteger();
  3114. long params = ABLi_popInteger();
  3115. GameObjectPtr target = NULL;
  3116. if (CurObject && CurObject->isMover())
  3117. target = getObject(targetId);
  3118. if (target)
  3119. CurObject->getPilot()->orderCapture(ORDER_ORIGIN_COMMANDER, target, -1, params);
  3120. }
  3121. //*****************************************************************************
  3122. void execSetCapturable (void) {
  3123. //-----------------------------------------------------
  3124. //
  3125. // Set Capturable function:
  3126. //
  3127. // Sets an objects captureabl flag to captureable.
  3128. //
  3129. // PARAMS: integer building ID
  3130. //
  3131. // boolean captureable
  3132. //
  3133. //-----------------------------------------------------
  3134. long objectId = ABLi_popInteger();
  3135. //bool captureable =
  3136. ABLi_popBoolean();
  3137. GameObjectPtr obj = getObject(objectId);
  3138. if (obj) {
  3139. if (MPlayer)
  3140. obj->clearCaptured();
  3141. if (obj->isBuilding() || (obj->getObjectClass() == GROUNDVEHICLE))
  3142. obj->setFlag(OBJECT_FLAG_CAPTURABLE, true);
  3143. }
  3144. }
  3145. //*****************************************************************************
  3146. void execIsCaptured (void) {
  3147. //-----------------------------------------------------
  3148. //
  3149. // Is Captured function:
  3150. //
  3151. // Returns the number of captured object in the group
  3152. // (0 or 1 if called for a separate object)
  3153. //
  3154. // PARAMS: integer object ID
  3155. //
  3156. // RETURN: integer
  3157. //
  3158. //-----------------------------------------------------
  3159. long objectId = ABLi_peekInteger();
  3160. long numCaptured = 0;
  3161. if (isUnitId(objectId)) {
  3162. //--------------------------------------------
  3163. // We have a group. Act accordingly.
  3164. long numObjects = getMovers(objectId, moverList);
  3165. for (long i = 0; i < numObjects; i++)
  3166. if (moverList[i]->isCaptured())
  3167. numCaptured++;
  3168. }
  3169. else {
  3170. GameObjectPtr obj = getObject(objectId);
  3171. if (obj && obj->isCaptured())
  3172. numCaptured++;
  3173. }
  3174. ABLi_pokeInteger(numCaptured);
  3175. }
  3176. //*****************************************************************************
  3177. void execIsCapturable (void) {
  3178. //-----------------------------------------------------
  3179. //
  3180. // Is Capturable function:
  3181. //
  3182. // Returns whether or not an object is capturable
  3183. //
  3184. // PARAMS: integer object ID
  3185. //
  3186. // integer capturing team ID
  3187. //
  3188. // RETURN: BOOL
  3189. //
  3190. //-----------------------------------------------------
  3191. long objectId = ABLi_popInteger();
  3192. long capturingTeamID = ABLi_popInteger();
  3193. ABLi_pushBoolean(false);
  3194. GameObjectPtr obj = getObject(objectId);
  3195. if (capturingTeamID == -2) {
  3196. if (obj && obj->getFlag(OBJECT_FLAG_CAPTURABLE) && !obj->isDestroyed())
  3197. ABLi_pokeBoolean(true);
  3198. }
  3199. else {
  3200. if (obj && obj->isCaptureable(capturingTeamID))
  3201. ABLi_pokeBoolean(true);
  3202. }
  3203. }
  3204. //*****************************************************************************
  3205. void execWasEverCapturable (void) {
  3206. //-----------------------------------------------------
  3207. //
  3208. // Was Ever Is Capturable function:
  3209. //
  3210. // Returns whether or not object was ever capturable
  3211. // (regardless of whether it's dead, currently captured, etc.)
  3212. // Only applies to vehicles!
  3213. //
  3214. // PARAMS: integer object ID
  3215. //
  3216. // RETURN: BOOL
  3217. //
  3218. //-----------------------------------------------------
  3219. long objectId = ABLi_peekInteger();
  3220. GameObjectPtr obj = getObject(objectId);
  3221. ABLi_pokeBoolean(false);
  3222. if (obj && obj->getFlag(OBJECT_FLAG_CAPTURABLE))
  3223. ABLi_pokeBoolean(true);
  3224. }
  3225. //*****************************************************************************
  3226. void execSetBuildingName (void) {
  3227. //-----------------------------------------------------
  3228. //
  3229. // SetBuildingName Function:
  3230. //
  3231. // Sets a building's name
  3232. //
  3233. // PARAMS: integer building ID
  3234. //
  3235. // integer name Resource ID
  3236. //
  3237. //-----------------------------------------------------
  3238. long objectId = ABLi_popInteger();
  3239. //long newName =
  3240. ABLi_popInteger();
  3241. GameObjectPtr obj = getObject(objectId);
  3242. if (obj) {
  3243. #ifdef USE_RESOURCE_STRINGS
  3244. char tmpString[255];
  3245. cLoadString(thisInstance,newName+languageOffset,tmpString,254);
  3246. obj->setName(tmpString);
  3247. #endif
  3248. }
  3249. }
  3250. //*****************************************************************************
  3251. void execCallStrike (void) {
  3252. //-----------------------------------------------------
  3253. //
  3254. // CallStrike function:
  3255. //
  3256. // calls an air or artillery strike at the specified location
  3257. //
  3258. // PARAMS: integer strike type (248 = big arty, 249 = sm arty, 250 sensor arty,
  3259. // 507 = big air strike, 508 = sm air, 509 = sensor air
  3260. //
  3261. // integer id of target object
  3262. //
  3263. // real x coord of strike
  3264. //
  3265. // real y coord of strike
  3266. //
  3267. // real z coord of strike
  3268. //
  3269. // bool clan (is this coming from the clan?)
  3270. //
  3271. // RETURN: nothing
  3272. //
  3273. //-----------------------------------------------------
  3274. //---------------------------------------------------------------------
  3275. // Since artillery strikes are commander(player) based, not team based,
  3276. // & current missions are coded to assume team based, we'll just
  3277. // fatal if we're not in a campaign mission. Then, we can decide if
  3278. // it's worth re-coding ABL scripts (since we'll have to change the
  3279. // parameters for this call to specify the player that's calling the
  3280. // strike)...
  3281. if (MPlayer)
  3282. Fatal(0, " ABL: Calling ArtilleryStrike in Multiplayer game ");
  3283. long strikeType = ABLi_popInteger();
  3284. long targetId = ABLi_popInteger();
  3285. Stuff::Vector3D strikeLoc;
  3286. strikeLoc.x = ABLi_popReal();
  3287. strikeLoc.y = ABLi_popReal();
  3288. strikeLoc.z = ABLi_popReal();
  3289. bool clanStrike = ABLi_popBoolean();
  3290. GameObjectPtr target = getObject(targetId);
  3291. if (target)
  3292. IfaceCallStrike(strikeType, NULL, target, false);
  3293. else {
  3294. strikeLoc.z = land->getTerrainElevation(strikeLoc);
  3295. IfaceCallStrike(strikeType, &strikeLoc, NULL, false, clanStrike);
  3296. }
  3297. }
  3298. //*****************************************************************************
  3299. void execCallStrikeEx (void) {
  3300. //-----------------------------------------------------
  3301. //
  3302. // CallStrikeEx function:
  3303. //
  3304. // calls an air or artillery strike at the specified location delayed by time
  3305. //
  3306. // PARAMS: integer strike type (248 = big arty, 249 = sm arty, 250 sensor arty,
  3307. // 507 = big air strike, 508 = sm air, 509 = sensor air
  3308. //
  3309. // integer id of target object
  3310. //
  3311. // real x coord of strike
  3312. //
  3313. // real y coord of strike
  3314. //
  3315. // real z coord of strike
  3316. //
  3317. // bool clan (is this coming from the clan?)
  3318. //
  3319. // real time to impact
  3320. //
  3321. // RETURN: nothing
  3322. //
  3323. //-----------------------------------------------------
  3324. //---------------------------------------------------------------------
  3325. // Since artillery strikes are commander(player) based, not team based,
  3326. // & current missions are coded to assume team based, we'll just
  3327. // fatal if we're not in a campaign mission. Then, we can decide if
  3328. // it's worth re-coding ABL scripts (since we'll have to change the
  3329. // parameters for this call to specify the player that's calling the
  3330. // strike)...
  3331. if (MPlayer)
  3332. Fatal(0, " ABL: Calling ArtilleryStrike in Multiplayer game ");
  3333. long strikeType = ABLi_popInteger();
  3334. long targetId = ABLi_popInteger();
  3335. Stuff::Vector3D strikeLoc;
  3336. strikeLoc.x = ABLi_popReal();
  3337. strikeLoc.y = ABLi_popReal();
  3338. strikeLoc.z = ABLi_popReal();
  3339. bool clanStrike = ABLi_popBoolean();
  3340. float timeToImpact = ABLi_popReal();
  3341. if (timeToImpact < 0.0)
  3342. timeToImpact = 0.0;
  3343. GameObjectPtr target = getObject(targetId);
  3344. if (target)
  3345. IfaceCallStrike(strikeType, NULL, target, false, clanStrike, timeToImpact);
  3346. else {
  3347. strikeLoc.z = land->getTerrainElevation(strikeLoc);
  3348. IfaceCallStrike(strikeType, &strikeLoc, NULL, false, clanStrike, timeToImpact);
  3349. }
  3350. }
  3351. //*****************************************************************************
  3352. void execOrderLoadElementals (void) {
  3353. //-----------------------------------------------------
  3354. //
  3355. // LoadElementals function: tells elementals of selected group to load into specified carrier
  3356. //
  3357. // PARAMS: integer carrier id
  3358. //
  3359. // RETURN: nothing
  3360. //
  3361. //-----------------------------------------------------
  3362. //long carrierId =
  3363. ABLi_popInteger();
  3364. #ifdef USE_ELEMENTALS
  3365. GameObjectPtr carrior = NULL;
  3366. if (CurObject && CurObject->getObjectClass() == ELEMENTAL)
  3367. carrier = getObject(carrierID);
  3368. if (carrier && carrier->getObjectClass() == GROUNDVEHICLE && ((GroundVehiclePtr) carrier)->elementalCarrier)
  3369. CurObject->getPilot()->orderLoadIntoCarrier(ORDER_ORIGIN_COMMANDER, carrier);
  3370. #endif
  3371. }
  3372. //*****************************************************************************
  3373. void execOrderDeployElementals (void) {
  3374. //-----------------------------------------------------
  3375. //
  3376. // CallStrike function: tells elemental carrier to deploy any loaded elementals
  3377. //
  3378. // PARAMS: real[3] coord of deployment location
  3379. //
  3380. // integer misc. order params (set to 0, typically)
  3381. //
  3382. // RETURN: nothing
  3383. //
  3384. //-----------------------------------------------------
  3385. //long params =
  3386. ABLi_popInteger();
  3387. #ifdef USE_ELEMENTALS
  3388. if (CurObject && CurObject->getObjectClass() == GROUNDVEHICLE && ((GroundVehiclePtr) CurObject)->elementalCarrier)
  3389. CurObject->getPilot()->orderDeployElementals(ORDER_ORIGIN_COMMANDER, params);
  3390. #endif
  3391. }
  3392. //***************************************************************************
  3393. void execAddPrisoner (void) {
  3394. //-----------------------------------------------------
  3395. //
  3396. // AddPrisoner function: adds specified prisoner to specified building
  3397. //
  3398. // PARAMS: integer building id
  3399. //
  3400. // integer prisoner id
  3401. //
  3402. // RETURN: 0 if successful
  3403. //
  3404. //-----------------------------------------------------
  3405. //long prisonId =
  3406. ABLi_popInteger();
  3407. //long prisonerId = ABLi_peekInteger();
  3408. //GameObjectPtr prison = getObject(prisonId);
  3409. ABLi_pokeInteger(-1);
  3410. #ifdef USE_PRISONS
  3411. if (prison && prison->isBuilding() && mission)
  3412. {
  3413. for (i=1; i<=scenario->getNumWarriors(); i++)
  3414. {
  3415. prisoner = scenario->getWarrior(i);
  3416. if (prisoner && prisoner->getIndex() == prisonerID)
  3417. break;
  3418. prisoner = NULL;
  3419. }
  3420. if (prisoner)
  3421. {
  3422. if (prison->getObjectClass() == BUILDING)
  3423. {
  3424. BuildingPtr bPrison = (BuildingPtr) prison;
  3425. for (i=0; i<MAX_PRISONERS; i++)
  3426. if (bPrison->prisoners[i] == NULL)
  3427. {
  3428. bPrison->prisoners[i] = prisoner;
  3429. result = 0;
  3430. }
  3431. }
  3432. if (prison->getObjectClass() == TREEBUILDING)
  3433. {
  3434. TreeBuildingPtr tPrison = (TreeBuildingPtr) prison;
  3435. for (i=0; i<MAX_PRISONERS; i++)
  3436. if (tPrison->prisoners[i] == NULL)
  3437. {
  3438. tPrison->prisoners[i] = prisoner;
  3439. result = 0;
  3440. }
  3441. }
  3442. }
  3443. }
  3444. #endif
  3445. }
  3446. //*****************************************************************************
  3447. void execLockGateOpen (void) {
  3448. //-----------------------------------------------------
  3449. //
  3450. // LockGateOpen function: Forces a gate to be Open Forever
  3451. //
  3452. // PARAMS: integer gate id
  3453. //
  3454. // RETURN: none
  3455. //
  3456. //-----------------------------------------------------
  3457. //long gateID =
  3458. ABLi_popInteger();
  3459. #ifdef USE_GATES
  3460. GameObjectPtr obj = getObject(gateID);
  3461. if (obj && obj->getObjectClass() == GATE)
  3462. ((GatePtr) obj)->setLockedOpen();
  3463. #endif
  3464. }
  3465. //***************************************************************************
  3466. void execLockGateClosed (void) {
  3467. //-----------------------------------------------------
  3468. //
  3469. // LockGateOpen function: Forces a gate to be Closed Forever
  3470. //
  3471. // PARAMS: integer gate id
  3472. //
  3473. // RETURN: none
  3474. //
  3475. //-----------------------------------------------------
  3476. //long gateID =
  3477. ABLi_popInteger();
  3478. #ifdef USE_GATES
  3479. GameObjectPtr obj = getObject(gateID);
  3480. if (obj && obj->getObjectClass() == GATE)
  3481. ((GatePtr) obj)->setLockedClose();
  3482. #endif
  3483. }
  3484. //*****************************************************************************
  3485. void execReleaseGateLock (void) {
  3486. //-----------------------------------------------------
  3487. //
  3488. // LockGateOpen function: Releases any lock on a gate.
  3489. //
  3490. // PARAMS: integer gate id
  3491. //
  3492. // RETURN: none
  3493. //
  3494. //-----------------------------------------------------
  3495. //long gateID =
  3496. ABLi_popInteger();
  3497. #ifdef USE_GATES
  3498. GameObjectPtr obj = getObject(gateID);
  3499. if (obj && obj->getObjectClass() == GATE)
  3500. ((GatePtr) obj)->releaseLocks();
  3501. #endif
  3502. }
  3503. //*****************************************************************************
  3504. void execIsGateOpen (void) {
  3505. //-----------------------------------------------------
  3506. //
  3507. // IsGateOpen function:
  3508. //
  3509. // Returns whether or not a gate is open
  3510. //
  3511. // PARAMS: integer object ID
  3512. //
  3513. // RETURN: BOOL Open
  3514. //
  3515. //-----------------------------------------------------
  3516. //long objectId = ABLi_peekInteger();
  3517. ABLi_pokeBoolean(false);
  3518. #ifdef USE_GATES
  3519. GameObjectPtr obj = getObject(objectId);
  3520. if (obj && (obj->getObjectClass() == GATE)) {
  3521. ABLi_pokeBoolean(((GatePtr)object)->opened);
  3522. #endif
  3523. }
  3524. //*****************************************************************************
  3525. void execGetRelativePositionToPoint (void) {
  3526. //-----------------------------------------------------
  3527. //
  3528. // Get Relative Position To Point function:
  3529. //
  3530. // Calcs a position relative to the given point
  3531. //
  3532. // PARAMS: real[3] point
  3533. //
  3534. // real angle (-180 <= angle <= 180.0, + is left, - is right)
  3535. //
  3536. // real distance (in meters)
  3537. //
  3538. // integer flags
  3539. //
  3540. // real[3] new point
  3541. //
  3542. // RETURN: NONE
  3543. //
  3544. //-----------------------------------------------------
  3545. float* pos = ABLi_popRealPtr();
  3546. float angle = ABLi_popReal();
  3547. float distance = ABLi_popReal();
  3548. long flags = ABLi_popInteger();
  3549. float* relPos = ABLi_popRealPtr();
  3550. Stuff::Vector3D curPos;
  3551. curPos.x = pos[0];
  3552. curPos.y = pos[1];
  3553. curPos.z = 0;
  3554. Stuff::Vector3D newPos;
  3555. newPos = relativePositionToPoint(curPos, angle, distance, flags);
  3556. relPos[0] = newPos.x;
  3557. relPos[1] = newPos.y;
  3558. relPos[2] = newPos.z;
  3559. }
  3560. //*****************************************************************************
  3561. void execGetRelativePositionToObject (void) {
  3562. //----------------------------------------------------------------------
  3563. //
  3564. // Get Relative Position To Object function:
  3565. //
  3566. // Calcs a position relative to the given object
  3567. //
  3568. // PARAMS: integer object id
  3569. //
  3570. // real angle (-180 <= angle <= 180.0, + is left, - is right)
  3571. //
  3572. // real distance (in meters)
  3573. //
  3574. // integer flags
  3575. //
  3576. // real[3] new point
  3577. //
  3578. // RETURN: NONE
  3579. //
  3580. //----------------------------------------------------------------------
  3581. long objectId = ABLi_popInteger();
  3582. float angle = ABLi_popReal();
  3583. float distance = ABLi_popReal();
  3584. long flags = ABLi_popInteger();
  3585. float* relPos = ABLi_popRealPtr();
  3586. GameObjectPtr object = getObject(objectId);
  3587. if (object) {
  3588. Stuff::Vector3D newPos;
  3589. newPos = ((MoverPtr)object)->relativePosition(angle, distance, flags);
  3590. relPos[0] = newPos.x;
  3591. relPos[1] = newPos.y;
  3592. relPos[2] = newPos.z;
  3593. }
  3594. }
  3595. //*****************************************************************************
  3596. void execGetUnitStatus (void) {
  3597. //Returns the current state of the health bar in percent format from 0 to 100
  3598. //
  3599. // PARAMS: integer
  3600. //
  3601. // Returns: real (result)
  3602. long objectNum = ABLi_popInteger();
  3603. //---------------------------------
  3604. // Code to make this work goes here
  3605. GameObjectPtr obj = getObject(objectNum);
  3606. ABLi_pushReal(0.0);
  3607. if (obj)
  3608. ABLi_pokeReal(obj->getStatusRating() * 100.0);
  3609. }
  3610. //*****************************************************************************
  3611. void execRepair (void) {
  3612. //-----------------------------------------------------
  3613. //
  3614. // Repair function:
  3615. //
  3616. // Repairs armor and internals. Currently only works on mechs
  3617. //
  3618. // PARAMS: integer object id
  3619. //
  3620. // real points (of armor or structure) to repair
  3621. //
  3622. // RETURN: NONE
  3623. //
  3624. //-----------------------------------------------------
  3625. long objectId = ABLi_popInteger();
  3626. float points = ABLi_popReal();
  3627. GameObjectPtr repairTarget = getObject(objectId);
  3628. if (repairTarget && (repairTarget->getObjectClass() == BATTLEMECH)) {
  3629. BattleMechPtr mech = (BattleMechPtr) repairTarget;
  3630. for (long i = 0; i < mech->numBodyLocations; i++) {
  3631. float diff = (float)mech->body[i].maxInternalStructure - mech->body[i].curInternalStructure;
  3632. if (mech->body[i].damageState == IS_DAMAGE_DESTROYED) // can't repair it if it ain't there!
  3633. continue;
  3634. if (diff > 0) {
  3635. if (diff < points) {
  3636. points -= diff;
  3637. mech->body[i].curInternalStructure = mech->body[i].maxInternalStructure;
  3638. }
  3639. else {
  3640. mech->body[i].curInternalStructure += points;
  3641. points = 0;
  3642. break;
  3643. }
  3644. }
  3645. }
  3646. for (i = 0; i < mech->numArmorLocations; i++) {
  3647. float diff = (float) mech->armor[i].maxArmor - mech->armor[i].curArmor;
  3648. if (i < mech->numBodyLocations) {
  3649. if (mech->body[i].damageState == IS_DAMAGE_DESTROYED) // can't repair it if it ain't there!
  3650. continue;
  3651. }
  3652. else { // for back armor, be sure you're looking at the front...
  3653. if (mech->body[i - mech->numBodyLocations + 1].damageState == IS_DAMAGE_DESTROYED) // can't repair it if it ain't there!
  3654. continue;
  3655. }
  3656. if (diff > 0) {
  3657. if (diff < points) {
  3658. points -= diff;
  3659. mech->armor[i].curArmor= mech->armor[i].maxArmor;
  3660. }
  3661. else {
  3662. mech->armor[i].curArmor += points;
  3663. points = 0;
  3664. break;
  3665. }
  3666. }
  3667. }
  3668. }
  3669. }
  3670. //*****************************************************************************
  3671. void execGetFixed (void) {
  3672. //-----------------------------------------------------
  3673. //
  3674. // Get Fixed function:
  3675. //
  3676. // Sends mech or vehicle to appropriate repair bay
  3677. // returns error code if call is illegal
  3678. //
  3679. // PARAMS: integer mech or vehicle (fixee) to repair id
  3680. //
  3681. // integer repair bay id
  3682. //
  3683. // integer parameters
  3684. //
  3685. // RETURN: integer error code
  3686. //
  3687. // -1 unknown error
  3688. // * 1 bay is out of repair points (probably means the bay is destroyed)
  3689. // * 2 wrong kind of bay (either sending a vehicle to a mech bay, or mech to vehicle bay)
  3690. // * 3 bay is already repairing this fixee
  3691. // * 4 bay is repairing something else
  3692. // * 5 fixee is being repaired by something else (either another bay or a refit vehicle)
  3693. // * 6 fixee doesn't need repair
  3694. // * 7 illegal fixee object (either there's no object with that ID, or the object isn't a mech or a vehicle)
  3695. // * 8 illegal bay object (either there's no object with that ID, or the object is not a repair bay)
  3696. // * 9 alignment mismatch (bay and fixee are on different sides.)
  3697. // * is checked by -fs on 5/5/97
  3698. //-----------------------------------------------------
  3699. long fixeeId = ABLi_popInteger();
  3700. long bayId = ABLi_popInteger();
  3701. long params = ABLi_popInteger();
  3702. BuildingPtr bay = NULL;
  3703. GameObjectPtr obj = getObject(bayId);
  3704. if (obj && obj->isBuilding() && obj->getFlag(OBJECT_FLAG_CANREFIT))
  3705. bay = (BuildingPtr)obj;
  3706. long result = 8;
  3707. if (bay) {
  3708. result = 1;
  3709. if (bay->getRefitPoints() > 0.0) {
  3710. result = 7;
  3711. obj = getObject(fixeeId);
  3712. if (obj && ((obj->getObjectClass() == BATTLEMECH) || (obj->getObjectClass() == GROUNDVEHICLE))) {
  3713. result = 9;
  3714. if (obj->getTeam() && bay->isFriendly(obj->getTeam())) {
  3715. GameObjectPtr refitBuddy = ObjectManager->getByWatchID(bay->refitBuddyWID);
  3716. if (refitBuddy) {
  3717. if (refitBuddy == obj)
  3718. result = 3;
  3719. else
  3720. result = 4;
  3721. }
  3722. else if (obj->getObjectClass() == BATTLEMECH) {
  3723. BattleMechPtr mech = (BattleMechPtr)obj;
  3724. result = 2;
  3725. if (bay->getFlag(OBJECT_FLAG_MECHBAY)) {
  3726. result = 5;
  3727. refitBuddy = ObjectManager->getByWatchID(mech->refitBuddyWID);
  3728. if (!refitBuddy) {
  3729. result = 6;
  3730. if (mech->needsRefit()) {
  3731. if (mech->getPilot()->orderGetFixed(ORDER_ORIGIN_COMMANDER, bay, params) == NO_ERR)
  3732. result = 0;
  3733. else
  3734. result = -1;
  3735. }
  3736. }
  3737. }
  3738. }
  3739. else {
  3740. GroundVehiclePtr vehicle = (GroundVehiclePtr)obj;
  3741. result = 2;
  3742. if (bay->getFlag(OBJECT_FLAG_MECHBAY)) {
  3743. result = 5;
  3744. refitBuddy = ObjectManager->getByWatchID(vehicle->refitBuddyWID);
  3745. if (!refitBuddy) {
  3746. result = 6;
  3747. if (vehicle->needsRefit()) {
  3748. if (vehicle->getPilot()->orderGetFixed(ORDER_ORIGIN_COMMANDER, bay, params) == NO_ERR)
  3749. result = 0;
  3750. else
  3751. result = -1;
  3752. }
  3753. }
  3754. }
  3755. }
  3756. }
  3757. }
  3758. }
  3759. }
  3760. ABLi_pushInteger(result);
  3761. }
  3762. //***************************************************************************
  3763. void execGetRepairState (void) {
  3764. //Returns the percentage of repairable armor and IS points of the objectId passed in
  3765. //
  3766. // PARAMS: integer
  3767. //
  3768. // Returns: integer (result)
  3769. long objectId = ABLi_peekInteger();
  3770. ABLi_pokeInteger(0);
  3771. long max = 0;
  3772. long cur = 0.0;
  3773. GameObjectPtr object = getObject(objectId);
  3774. if (object && object->isMover()) {
  3775. MoverPtr mover = (MoverPtr) object;
  3776. for (long i = 0; i < mover->numBodyLocations; i++) {
  3777. // can't repair it if it ain't there, so don't report it if destroyed...
  3778. if (mover->body[i].damageState == IS_DAMAGE_DESTROYED)
  3779. continue;
  3780. max += mover->body[i].maxInternalStructure;
  3781. cur += mover->body[i].curInternalStructure;
  3782. }
  3783. for (i = 0; i < mover->numArmorLocations; i++) {
  3784. if (i < mover->numBodyLocations) {
  3785. if (mover->body[i].damageState == IS_DAMAGE_DESTROYED) // can't repair it if it ain't there!
  3786. continue;
  3787. }
  3788. else {
  3789. // for back armor, be sure you're looking at the front...
  3790. if (mover->body[i - mover->numBodyLocations + 1].damageState == IS_DAMAGE_DESTROYED) // can't repair it if it ain't there!
  3791. continue;
  3792. }
  3793. max += mover->armor[i].maxArmor;
  3794. cur += mover->armor[i].curArmor;
  3795. }
  3796. }
  3797. // make it a percentage...
  3798. cur *= 100;
  3799. ABLi_pokeInteger(cur / max);
  3800. }
  3801. //*****************************************************************************
  3802. void execIsTeamTargeting (void) {
  3803. //-----------------------------------------------------
  3804. //
  3805. // Is Team Targeting function:
  3806. //
  3807. // Returns whether anyone of the specified team is currently
  3808. // targeting the specified target with the possible exception
  3809. // of the one team member (which may be set to 0, if desired).
  3810. //
  3811. // PARAMS: integer team id
  3812. //
  3813. // integer target id
  3814. //
  3815. // integer except id (may be 0)
  3816. //
  3817. // RETURN: boolean yes or no
  3818. //
  3819. //-----------------------------------------------------
  3820. long teamId = ABLi_popInteger();
  3821. long targetId = ABLi_popInteger();
  3822. long exceptId = ABLi_popInteger();
  3823. bool targeting = false;
  3824. if ((teamId >= OBJ_ID_FIRST_TEAM) && (teamId <= OBJ_ID_LAST_TEAM)) {
  3825. TeamPtr team = Team::teams[teamId - OBJ_ID_FIRST_TEAM];
  3826. if (team)
  3827. targeting = team->isTargeting(targetId, exceptId);
  3828. }
  3829. else if (teamId == 0) {
  3830. GameObjectPtr target = ObjectManager->get(targetId);
  3831. if (target)
  3832. targeting = (target->getNumAttackers() > 0);
  3833. }
  3834. ABLi_pushBoolean(targeting);
  3835. }
  3836. //*****************************************************************************
  3837. void execIsTeamCapturing (void) {
  3838. //-----------------------------------------------------
  3839. //
  3840. // Is Team Capturing function:
  3841. //
  3842. // Returns whether anyone of the specified team is currently
  3843. // capturing the specified target with the possible exception
  3844. // of the one team member (which may be set to 0, if desired).
  3845. //
  3846. // PARAMS: integer team id
  3847. //
  3848. // integer target id
  3849. //
  3850. // RETURN: boolean yes or no
  3851. //
  3852. //-----------------------------------------------------
  3853. long teamId = ABLi_popInteger();
  3854. long targetId = ABLi_popInteger();
  3855. long exceptId = ABLi_popInteger();
  3856. bool targeting = false;
  3857. GameObjectPtr target = getObject(targetId);
  3858. unsigned long targetWID = target ? target->getWatchID(false) : 0;
  3859. if (targetWID) {
  3860. if ((teamId >= OBJ_ID_FIRST_TEAM) && (teamId <= OBJ_ID_LAST_TEAM)) {
  3861. TeamPtr team = Team::teams[teamId - OBJ_ID_FIRST_TEAM];
  3862. if (team)
  3863. targeting = ObjectManager->isTeamCapturing(team, targetWID);
  3864. }
  3865. else if (teamId == 0) {
  3866. targeting = ObjectManager->isTeamCapturing(NULL, targetWID);
  3867. }
  3868. }
  3869. ABLi_pushBoolean(targeting);
  3870. }
  3871. //*****************************************************************************
  3872. void execSendMessage (void) {
  3873. CurMultiplayCode = ABLi_popInteger();
  3874. CurMultiplayParam = ABLi_popInteger();
  3875. if (MPlayer && MPlayer->isServer()) {
  3876. //------------------------------------
  3877. // We must be server if we got here...
  3878. MPlayer->addMissionScriptMessageChunk(CurMultiplayCode, CurMultiplayParam);
  3879. #ifdef DEBUG_MISSION_SCRIPT
  3880. if (NumMissionScriptMessages == MAX_MISSION_MSGS) {
  3881. DebugMissionScriptMessages();
  3882. Assert(false, NumMissionScriptMessages, " Way too many Mission Script Messages! ");
  3883. }
  3884. MissionScriptMessageLog[NumMissionScriptMessages][0] = execLineNumber;
  3885. MissionScriptMessageLog[NumMissionScriptMessages][1] = CurMultiplayCode;
  3886. MissionScriptMessageLog[NumMissionScriptMessages][2] = CurMultiplayParam;
  3887. NumMissionScriptMessages++;
  3888. #endif
  3889. }
  3890. }
  3891. //*****************************************************************************
  3892. void execGetMessage (void) {
  3893. long* messageParam = ABLi_peekIntegerPtr();
  3894. *messageParam = CurMultiplayParam;
  3895. ABLi_pokeInteger(CurMultiplayCode);
  3896. }
  3897. //*****************************************************************************
  3898. void execGetHomeTeam (void) {
  3899. //-----------------------------------------------------
  3900. //
  3901. // Get HomeTeam function:
  3902. //
  3903. // Returns id for home team: 500 = IS, 501 = CLAN, 502 = ALLIED
  3904. //
  3905. // PARAMS: NONE
  3906. //
  3907. // RETURN: integer hometeam id
  3908. //
  3909. //-----------------------------------------------------
  3910. ABLi_pushInteger(Team::home->getId() + MIN_TEAM_PART_ID);
  3911. }
  3912. //***************************************************************************
  3913. void execIsServer (void) {
  3914. //-----------------------------------------------------
  3915. //
  3916. // Is Server function:
  3917. //
  3918. // Returns TRUE if I'm the server in a multi-player game.
  3919. //
  3920. // PARAMS: NONE
  3921. //
  3922. // RETURN: boolean TRUE = yes I am:)
  3923. //
  3924. //-----------------------------------------------------
  3925. if (MPlayer && MPlayer->isServer())
  3926. pushInteger(1);
  3927. else
  3928. pushInteger(0);
  3929. }
  3930. //*****************************************************************************
  3931. void execCalcPartID (void) {
  3932. long objectClass = ABLi_popInteger();
  3933. long param1 = ABLi_popInteger();
  3934. long param2 = ABLi_popInteger();
  3935. long param3 = ABLi_popInteger();
  3936. long partId = ObjectManager->calcPartId(objectClass, param1, param2, param3);
  3937. ABLi_pushInteger(partId);
  3938. }
  3939. //*****************************************************************************
  3940. void execSetDebugString (void) {
  3941. long objectId = ABLi_popInteger();
  3942. long stringNum = ABLi_popInteger();
  3943. char* debugString = ABLi_popCharPtr();
  3944. GameObjectPtr obj = getObject(objectId);
  3945. if (obj) {
  3946. MechWarriorPtr pilot = obj->getPilot();
  3947. if (pilot)
  3948. pilot->setDebugString(stringNum, debugString);
  3949. }
  3950. #if 0
  3951. ABLi_popInteger();
  3952. ABLi_popInteger();
  3953. ABLi_popCharPtr();
  3954. #endif
  3955. }
  3956. //*****************************************************************************
  3957. void execBreak (void) {
  3958. if (ABLi_getCurrentState()) {
  3959. DEBUGWINS_print("BREAK", 0);
  3960. }
  3961. }
  3962. //*****************************************************************************
  3963. void execPathExists (void) {
  3964. //-----------------------------------------------------
  3965. //
  3966. // PATH EXISTS function:
  3967. //
  3968. // Returns number and list of objects of the specified object type.
  3969. //
  3970. // PARAMS: integer mover id. if set to 0, assumes a mech-type
  3971. //
  3972. // integer startCellRow
  3973. //
  3974. // integer startCellCol
  3975. //
  3976. // integer goalCellRow
  3977. //
  3978. // integer goalCellCol
  3979. //
  3980. // RETURN: integer answer: 0 = no, else number of areas in
  3981. // LR path
  3982. //
  3983. //-----------------------------------------------------
  3984. long moverID = ABLi_popInteger();
  3985. long startRow = ABLi_popInteger();
  3986. long startCol = ABLi_popInteger();
  3987. long goalRow = ABLi_popInteger();
  3988. long goalCol = ABLi_popInteger();
  3989. //-------------------------------------------------
  3990. // For now, assumes we mean the ground level (0)...
  3991. long startArea = GlobalMoveMap[0]->calcArea(startRow, startCol);
  3992. long goalArea = GlobalMoveMap[0]->calcArea(goalRow, goalCol);
  3993. long confidence;
  3994. long areaPathCost = GlobalMoveMap[0]->getPathCost(startArea, goalArea, false, confidence, true);
  3995. ABLi_pushInteger(areaPathCost);
  3996. }
  3997. //*****************************************************************************
  3998. void execConvertCoords (void) {
  3999. long convertType = ABLi_popInteger();
  4000. float* worldPos = ABLi_popRealPtr();
  4001. long* cellPos = ABLi_popIntegerPtr();
  4002. ABLi_pushInteger(0);
  4003. if (convertType == 0) {
  4004. // world to cell
  4005. Stuff::Vector3D worldP;
  4006. worldP.x = worldPos[0];
  4007. worldP.y = worldPos[1];
  4008. worldP.z = worldPos[2];
  4009. land->worldToCell(worldP, cellPos[0], cellPos[1]);
  4010. }
  4011. else {
  4012. // cell to world
  4013. Stuff::Vector3D worldP;
  4014. land->cellToWorld(cellPos[0], cellPos[1], worldP);
  4015. worldPos[0] = worldP.x;
  4016. worldPos[1] = worldP.y;
  4017. worldPos[2] = 0.0;
  4018. }
  4019. }
  4020. //*****************************************************************************
  4021. void execCoreMoveTo (void) {
  4022. float* location = ABLi_popRealPtr();
  4023. unsigned long params = (unsigned long)ABLi_popInteger();
  4024. if (ABLi_getSkipOrder()) {
  4025. ABLi_pushInteger(1);
  4026. return;
  4027. }
  4028. if (_isnan(location[0]) || _isnan(location[1]))
  4029. {
  4030. STOP(("Move to order location is Not a Number in Brain %s. Check patrol path array indices!",CurWarrior->getBrainString()));
  4031. }
  4032. long result = 0;
  4033. if (CurWarrior)
  4034. {
  4035. Stuff::Vector3D loc(location[0], location[1], 0.0);
  4036. result = CurWarrior->coreMoveTo(loc, params);
  4037. }
  4038. ABLi_pushInteger(result);
  4039. }
  4040. //*****************************************************************************
  4041. void execCoreMoveToObject (void) {
  4042. long objectID = ABLi_popInteger();
  4043. unsigned long params = (unsigned long)ABLi_popInteger();
  4044. if (ABLi_getSkipOrder()) {
  4045. ABLi_pushInteger(1);
  4046. return;
  4047. }
  4048. GameObjectPtr target = getObject(objectID);
  4049. long result = 0;
  4050. if (CurWarrior)
  4051. result = CurWarrior->coreMoveToObject(target, params);
  4052. ABLi_pushInteger(result);
  4053. }
  4054. //*****************************************************************************
  4055. void execCorePower (void) {
  4056. bool up = ABLi_popBoolean();
  4057. if (ABLi_getSkipOrder()) {
  4058. ABLi_pushInteger(1);
  4059. return;
  4060. }
  4061. long result = 0;
  4062. if (CurWarrior)
  4063. result = CurWarrior->corePower(up);
  4064. ABLi_pushInteger(result);
  4065. }
  4066. //*****************************************************************************
  4067. void execCoreAttack (void) {
  4068. long objectID = ABLi_popInteger();
  4069. unsigned long params = (unsigned long)ABLi_popInteger();
  4070. if (ABLi_getSkipOrder()) {
  4071. ABLi_pushInteger(1);
  4072. return;
  4073. }
  4074. GameObjectPtr target = getObject(objectID);
  4075. long result = 0;
  4076. if (CurWarrior)
  4077. result = CurWarrior->coreAttack(target, params);
  4078. ABLi_pushInteger(result);
  4079. }
  4080. //*****************************************************************************
  4081. void execCoreCapture (void) {
  4082. long objectID = ABLi_popInteger();
  4083. unsigned long params = (unsigned long)ABLi_popInteger();
  4084. if (ABLi_getSkipOrder()) {
  4085. ABLi_pushInteger(1);
  4086. return;
  4087. }
  4088. long targetID = 0;
  4089. GameObjectPtr obj = getObject(objectID);
  4090. if (CurWarrior && ((objectID == 0) || obj))
  4091. targetID = CurWarrior->coreCapture((objectID == 0) ? NULL : obj, params);
  4092. ABLi_pushInteger(targetID);
  4093. }
  4094. //*****************************************************************************
  4095. void execCoreScan (void) {
  4096. long objectID = ABLi_popInteger();
  4097. unsigned long params = (unsigned long)ABLi_popInteger();
  4098. if (ABLi_getSkipOrder()) {
  4099. ABLi_pushInteger(1);
  4100. return;
  4101. }
  4102. long targetID = 0;
  4103. GameObjectPtr obj = getObject(objectID);
  4104. if (CurWarrior && ((objectID == 0) || obj))
  4105. targetID = CurWarrior->coreScan((objectID == 0) ? NULL : obj, params);
  4106. ABLi_pushInteger(targetID);
  4107. }
  4108. //*****************************************************************************
  4109. void execCoreControl (void) {
  4110. long objectID = ABLi_popInteger();
  4111. unsigned long params = (unsigned long)ABLi_popInteger();
  4112. if (ABLi_getSkipOrder()) {
  4113. ABLi_pushInteger(1);
  4114. return;
  4115. }
  4116. long targetID = 0;
  4117. GameObjectPtr obj = getObject(objectID);
  4118. if (CurWarrior && ((objectID == 0) || obj))
  4119. targetID = CurWarrior->coreControl((objectID == 0) ? NULL : obj, params);
  4120. ABLi_pushInteger(targetID);
  4121. }
  4122. //*****************************************************************************
  4123. void execCoreEject (void) {
  4124. if (ABLi_getSkipOrder()) {
  4125. ABLi_pushInteger(1);
  4126. return;
  4127. }
  4128. long result = 0;
  4129. if (CurWarrior)
  4130. result = CurWarrior->coreEject();
  4131. ABLi_pushInteger(result);
  4132. }
  4133. //*****************************************************************************
  4134. void execSetPilotState (void) {
  4135. //-----------------------------------------------------
  4136. //
  4137. // SetPilotState: Sets the current pilot's brain state.
  4138. //
  4139. // PARAMS: integer new state ID
  4140. //
  4141. // RETURN: integer previous state ID
  4142. //
  4143. //-----------------------------------------------------
  4144. unsigned long newStateHandle = ABLi_popInteger();
  4145. long curStateHandle = ABLi_getCurrentState();
  4146. if (curStateHandle > 0) {
  4147. ABLi_transState(newStateHandle);
  4148. ABLi_pushInteger(curStateHandle);
  4149. }
  4150. else {
  4151. ABLi_resetOrders();
  4152. long prevState = CurWarrior->setBrainState(newStateHandle);
  4153. ABLi_pushInteger(prevState);
  4154. }
  4155. }
  4156. //*****************************************************************************
  4157. void execGetPilotState (void) {
  4158. //-----------------------------------------------------
  4159. //
  4160. // GetPilotState: Gets the current pilot's brain state.
  4161. //
  4162. // PARAMS: NONE
  4163. //
  4164. // RETURN: integer current state ID
  4165. //
  4166. //-----------------------------------------------------
  4167. ABLi_pushInteger(CurWarrior->getBrainState());
  4168. }
  4169. //*****************************************************************************
  4170. void execGetNextPilotEvent (void) {
  4171. //-----------------------------------------------------
  4172. //
  4173. // GetNextPilotEvent: Removes & returns the next queued pilot event.
  4174. // Any params for the event are put into the
  4175. // integer array passed in.
  4176. //
  4177. // PARAMS: @integer[3] parameter list
  4178. //
  4179. // RETURN: integer event ID
  4180. //
  4181. //-----------------------------------------------------
  4182. long* paramList = ABLi_popIntegerPtr();
  4183. long eventID = CurWarrior->getNextEventHistory(paramList);
  4184. ABLi_pushInteger(eventID);
  4185. }
  4186. //*****************************************************************************
  4187. void execSetTargetPriority (void) {
  4188. //-----------------------------------------------------
  4189. //
  4190. // SetTargetPriority: Sets the target priority specified for the
  4191. // current pilot.
  4192. //
  4193. // PARAMS: integer target priority index (0 thru ?)
  4194. //
  4195. // integer target priority type
  4196. //
  4197. // integer param 1
  4198. //
  4199. // integer param 2
  4200. //
  4201. // integer param 3
  4202. //
  4203. // RETURN: integer error code (0 = OK)
  4204. //
  4205. //-----------------------------------------------------
  4206. long index = ABLi_popInteger();
  4207. long type = ABLi_popInteger();
  4208. long param1 = ABLi_popInteger();
  4209. long param2 = ABLi_popInteger();
  4210. long param3 = ABLi_popInteger();
  4211. long err = CurWarrior->setTargetPriority(index, type, param1, param2, param3);
  4212. ABLi_pushInteger(err);
  4213. }
  4214. //*****************************************************************************
  4215. void execSetDebugWindow (void) {
  4216. //-----------------------------------------------------
  4217. //
  4218. // SetDebugWindow: Sets the game object for the specified debug window.
  4219. //
  4220. // PARAMS: integer debug window id (0 thru 3)
  4221. //
  4222. // integer object id
  4223. //
  4224. // RETURN: integer object id, if set. Else 0.
  4225. //
  4226. //-----------------------------------------------------
  4227. long windowIndex = ABLi_popInteger();
  4228. long objectID = ABLi_popInteger();
  4229. GameObjectPtr obj = getObject(objectID);
  4230. if (obj)
  4231. DEBUGWINS_setGameObject(windowIndex, obj);
  4232. else
  4233. objectID = 0;
  4234. ABLi_pushInteger(objectID);
  4235. }
  4236. //*****************************************************************************
  4237. void execSetMovieMode (void)
  4238. {
  4239. //-----------------------------------------------------
  4240. //
  4241. // SetMovieMode
  4242. //
  4243. // Changes game to movie playback mode. GUI disappears, Commands not allowed, Letterbox
  4244. //
  4245. // PARAMS: NONE
  4246. //
  4247. // RETURN: NONE
  4248. //
  4249. //-----------------------------------------------------
  4250. if (eye)
  4251. eye->setMovieMode();
  4252. }
  4253. //*****************************************************************************
  4254. void execEndMovieMode (void)
  4255. {
  4256. //-----------------------------------------------------
  4257. //
  4258. // EndMovieMode
  4259. //
  4260. // Changes game to play mode. GUI reappears, Commands allowed, no Letterbox
  4261. //
  4262. // PARAMS: NONE
  4263. //
  4264. // RETURN: NONE
  4265. //
  4266. //-----------------------------------------------------
  4267. if (eye)
  4268. eye->endMovieMode();
  4269. }
  4270. //*****************************************************************************
  4271. void execGetGeneralAlarm (void)
  4272. {
  4273. //-----------------------------------------------------
  4274. //
  4275. // GetGeneralAlarm
  4276. //
  4277. // Returns value of GeneralAlarm set by Perimeter alarms in game
  4278. //
  4279. // PARAMS: NONE
  4280. //
  4281. // RETURN: Integer
  4282. //
  4283. //-----------------------------------------------------
  4284. ABLi_pushInteger(GeneralAlarm);
  4285. }
  4286. //*****************************************************************************
  4287. void execSetGeneralAlarm (void)
  4288. {
  4289. //-----------------------------------------------------
  4290. //
  4291. // SetGeneralAlarm
  4292. //
  4293. // sets value of GeneralAlarm for Perimeter alarms in game
  4294. //
  4295. // PARAMS: Integer
  4296. //
  4297. // RETURN: NONE
  4298. //
  4299. //-----------------------------------------------------
  4300. GeneralAlarm = (ABLi_popInteger() != 0);
  4301. }
  4302. //*****************************************************************************
  4303. void execFadeToColor (void)
  4304. {
  4305. //-----------------------------------------------------
  4306. //
  4307. // FadeToColor
  4308. //
  4309. // Fades entire screen to color read in by the time read in.
  4310. //
  4311. // PARAMS: NONE
  4312. //
  4313. // RETURN: NONE
  4314. //
  4315. //-----------------------------------------------------
  4316. DWORD fadeColor = ABLi_popInteger();
  4317. DWORD fadeTime = ABLi_popReal();
  4318. if (eye)
  4319. eye->fadeToColor(fadeColor,fadeTime);
  4320. }
  4321. //*****************************************************************************
  4322. void execForceMovieEnd (void)
  4323. {
  4324. //-----------------------------------------------------
  4325. //
  4326. // ForceMovieEnd
  4327. //
  4328. // Checks if the player has requested the movie to end. If so, the script should endMovieMode immediately!!
  4329. //
  4330. // PARAMS: None
  4331. //
  4332. // RETURN: 1 if user asked movie to end. Zero otherwise
  4333. //
  4334. //-----------------------------------------------------
  4335. DWORD result = 0;
  4336. if (eye && eye->forceMovieEnd)
  4337. result = 1;
  4338. ABLi_pushInteger(result);
  4339. }
  4340. //*****************************************************************************
  4341. void execGetCameraPosition (void) {
  4342. //-----------------------------------------------------
  4343. //
  4344. // GetCameraPosition
  4345. //
  4346. // Sets the value passed in to the camera position.
  4347. //
  4348. // PARAMS: real[3] camPos
  4349. //
  4350. // RETURN: NONE
  4351. //
  4352. //-----------------------------------------------------
  4353. float* camPos = ABLi_popRealPtr();
  4354. Stuff::Vector3D result(0.0,0.0,0.0);
  4355. if (eye)
  4356. result = eye->getPosition();
  4357. camPos[0] = result.x;
  4358. camPos[1] = result.y;
  4359. camPos[2] = result.z;
  4360. }
  4361. //*****************************************************************************
  4362. void execSetCameraPosition(void) {
  4363. //-----------------------------------------------------
  4364. //
  4365. // SetCameraPosition
  4366. //
  4367. // Sets the camera position to the value passed in.
  4368. //
  4369. // PARAMS: real[3] camPos
  4370. //
  4371. // RETURN: NONE
  4372. //
  4373. //-----------------------------------------------------
  4374. float* camPos = ABLi_popRealPtr();
  4375. Stuff::Vector3D result(0.0,0.0,0.0);
  4376. result.x = camPos[0];
  4377. result.y = camPos[1];
  4378. result.z = camPos[2];
  4379. if (eye)
  4380. eye->setPosition(result,false);
  4381. }
  4382. //*****************************************************************************
  4383. void execSetCameraGoalPosition (void) {
  4384. //-----------------------------------------------------
  4385. //
  4386. // SetCameraGoalPosition
  4387. //
  4388. // Sets the camera position to the value passed in.
  4389. //
  4390. // PARAMS: real[3] camPos
  4391. // real time
  4392. //
  4393. // RETURN: NONE
  4394. //
  4395. //-----------------------------------------------------
  4396. float* camPos = ABLi_popRealPtr();
  4397. float time = ABLi_popReal();
  4398. Stuff::Vector3D result(0.0,0.0,0.0);
  4399. result.x = camPos[0];
  4400. result.y = camPos[1];
  4401. result.z = camPos[2];
  4402. if (eye) {
  4403. eye->setGoalPosition(result);
  4404. eye->setGoalPosTime(time);
  4405. }
  4406. }
  4407. //*****************************************************************************
  4408. void execGetCameraGoalPosition (void) {
  4409. //-----------------------------------------------------
  4410. //
  4411. // GetCameraGoalPosition
  4412. //
  4413. // Gets the camera position to the value passed in.
  4414. //
  4415. // PARAMS: real[3] camPos
  4416. //
  4417. // RETURN: NONE
  4418. //
  4419. //-----------------------------------------------------
  4420. float* camPos = ABLi_popRealPtr();
  4421. Stuff::Vector3D result(0.0,0.0,0.0);
  4422. if (eye)
  4423. result = eye->getGoalPosition();
  4424. camPos[0] = result.x;
  4425. camPos[1] = result.y;
  4426. camPos[2] = result.z;
  4427. }
  4428. //*****************************************************************************
  4429. void execGetCameraRotation (void) {
  4430. //-----------------------------------------------------
  4431. //
  4432. // GetCameraRotation
  4433. //
  4434. // Sets the value passed in to the camera Rotation.
  4435. //
  4436. // PARAMS: real[3] camRot
  4437. //
  4438. // RETURN: NONE
  4439. //
  4440. //-----------------------------------------------------
  4441. float* camRot = ABLi_popRealPtr();
  4442. Stuff::Vector3D result(0.0,0.0,0.0);
  4443. if (eye)
  4444. result = eye->getRotation();
  4445. camRot[0] = result.x;
  4446. camRot[1] = result.y;
  4447. camRot[2] = result.z;
  4448. }
  4449. //*****************************************************************************
  4450. void execSetCameraRotation (void) {
  4451. //-----------------------------------------------------
  4452. //
  4453. // SetCameraRotation
  4454. //
  4455. // Sets the value passed in to be the camera Rotation.
  4456. //
  4457. // PARAMS: real[3] camRot
  4458. //
  4459. // RETURN: NONE
  4460. //
  4461. //-----------------------------------------------------
  4462. float* camRot = ABLi_popRealPtr();
  4463. Stuff::Vector3D result(0.0,0.0,0.0);
  4464. result.x = camRot[0];
  4465. result.y = camRot[1];
  4466. result.z = camRot[2];
  4467. if (eye)
  4468. eye->setRotation(result);
  4469. }
  4470. //*****************************************************************************
  4471. void execSetCameraGoalRotation (void) {
  4472. //-----------------------------------------------------
  4473. //
  4474. // SetCameraGoalRotation
  4475. //
  4476. // Sets the camera Rotation to the value passed in.
  4477. //
  4478. // PARAMS: real[3] camRot
  4479. // real time
  4480. //
  4481. // RETURN: NONE
  4482. //
  4483. //-----------------------------------------------------
  4484. float* camRot = ABLi_popRealPtr();
  4485. float time = ABLi_popReal();
  4486. Stuff::Vector3D result(0.0,0.0,0.0);
  4487. result.x = camRot[0];
  4488. result.y = camRot[1];
  4489. result.z = camRot[2];
  4490. if (eye) {
  4491. eye->setGoalRotation(result);
  4492. eye->setGoalRotTime(time);
  4493. }
  4494. }
  4495. //*****************************************************************************
  4496. void execGetCameraGoalRotation (void) {
  4497. //-----------------------------------------------------
  4498. //
  4499. // GetCameraGoalRotation
  4500. //
  4501. // Gets the camera Rotation into the value passed in.
  4502. //
  4503. // PARAMS: real[3] camRot
  4504. //
  4505. // RETURN: NONE
  4506. //
  4507. //-----------------------------------------------------
  4508. float* camRot = ABLi_popRealPtr();
  4509. Stuff::Vector3D result(0.0,0.0,0.0);
  4510. if (eye)
  4511. result = eye->getGoalRotation();
  4512. camRot[0] = result.x;
  4513. camRot[1] = result.y;
  4514. camRot[2] = result.z;
  4515. }
  4516. //*****************************************************************************
  4517. void execGetCameraZoom (void) {
  4518. //-----------------------------------------------------
  4519. //
  4520. // GetCameraZoom
  4521. //
  4522. // Gets the camera FOV into the value passed in.
  4523. //
  4524. // PARAMS: real camFOV
  4525. //
  4526. // RETURN: NONE
  4527. //
  4528. //-----------------------------------------------------
  4529. float result = 0.0;
  4530. if (eye)
  4531. result = eye->getFieldOfView();
  4532. ABLi_pushReal(result);
  4533. }
  4534. //*****************************************************************************
  4535. void execSetCameraZoom (void) {
  4536. //-----------------------------------------------------
  4537. //
  4538. // SetCameraZoom
  4539. //
  4540. // Sets the camera FOV to the value passed in.
  4541. //
  4542. // PARAMS: real camFOV
  4543. //
  4544. // RETURN: NONE
  4545. //
  4546. //-----------------------------------------------------
  4547. float camFOV = ABLi_popReal();
  4548. if (eye)
  4549. eye->setFieldOfView(camFOV);
  4550. }
  4551. //*****************************************************************************
  4552. void execGetCameraGoalZoom (void) {
  4553. //-----------------------------------------------------
  4554. //
  4555. // GetCameraGoalZoom
  4556. //
  4557. // Gets the camera FOV into the value passed in.
  4558. //
  4559. // PARAMS: real camFOV
  4560. //
  4561. // RETURN: NONE
  4562. //
  4563. //-----------------------------------------------------
  4564. float result = 0.0;
  4565. if (eye)
  4566. result = eye->getFieldOfViewGoal();
  4567. ABLi_pushReal(result);
  4568. }
  4569. //*****************************************************************************
  4570. void execSetCameraGoalZoom (void) {
  4571. //-----------------------------------------------------
  4572. //
  4573. // SetCameraGoalZoom
  4574. //
  4575. // Sets the camera FOV to the value passed in.
  4576. //
  4577. // PARAMS: real camFOV
  4578. //
  4579. // RETURN: NONE
  4580. //
  4581. //-----------------------------------------------------
  4582. float camFOV = ABLi_popReal();
  4583. float time = ABLi_popReal();
  4584. if (eye)
  4585. eye->setFieldOfViewGoal(camFOV, time);
  4586. }
  4587. //*****************************************************************************
  4588. void execSetCameraVelocity (void) {
  4589. //-----------------------------------------------------
  4590. //
  4591. // SetCameraVelocity
  4592. //
  4593. // Sets the camera velocity to the value passed in.
  4594. //
  4595. // PARAMS: real[3] camVel
  4596. //
  4597. // RETURN: NONE
  4598. //
  4599. //-----------------------------------------------------
  4600. float* camVel = ABLi_popRealPtr();
  4601. Stuff::Vector3D result(0.0,0.0,0.0);
  4602. result.x = camVel[0];
  4603. result.y = camVel[1];
  4604. result.z = camVel[2];
  4605. if (eye)
  4606. eye->setVelocity(result);
  4607. }
  4608. //*****************************************************************************
  4609. void execGetCameraVelocity (void) {
  4610. //-----------------------------------------------------
  4611. //
  4612. // GetCameraVelocity
  4613. //
  4614. // gets the camera velocity into the value passed in.
  4615. //
  4616. // PARAMS: real[3] camVel
  4617. //
  4618. // RETURN: NONE
  4619. //
  4620. //-----------------------------------------------------
  4621. float* camVel = ABLi_popRealPtr();
  4622. Stuff::Vector3D result(0.0,0.0,0.0);
  4623. if (eye)
  4624. result = eye->getVelocity();
  4625. camVel[0] = result.x;
  4626. camVel[1] = result.y;
  4627. camVel[2] = result.z;
  4628. }
  4629. //*****************************************************************************
  4630. void execSetCameraGoalVelocity (void) {
  4631. //-----------------------------------------------------
  4632. //
  4633. // SetCameraGoalVelocity
  4634. //
  4635. // Sets the camera Velocity Goal to the value passed in.
  4636. //
  4637. // PARAMS: real[3] camVel
  4638. // real time
  4639. //
  4640. // RETURN: NONE
  4641. //
  4642. //-----------------------------------------------------
  4643. float* camVel = ABLi_popRealPtr();
  4644. float time = ABLi_popReal();
  4645. Stuff::Vector3D result(0.0,0.0,0.0);
  4646. result.x = camVel[0];
  4647. result.y = camVel[1];
  4648. result.z = camVel[2];
  4649. if (eye) {
  4650. eye->setGoalVelocity(result);
  4651. eye->setGoalVelTime(time);
  4652. }
  4653. }
  4654. //*****************************************************************************
  4655. void execGetCameraGoalVelocity (void) {
  4656. //-----------------------------------------------------
  4657. //
  4658. // GetCameraGoalVelocity
  4659. //
  4660. // Sets the camera Velocity Goal into the value passed in.
  4661. //
  4662. // PARAMS: real[3] camVel
  4663. // real time
  4664. //
  4665. // RETURN: NONE
  4666. //
  4667. //-----------------------------------------------------
  4668. float* camVel = ABLi_popRealPtr();
  4669. Stuff::Vector3D result(0.0,0.0,0.0);
  4670. if (eye)
  4671. result = eye->getGoalVelocity();
  4672. camVel[0] = result.x;
  4673. camVel[1] = result.y;
  4674. camVel[2] = result.z;
  4675. }
  4676. //*****************************************************************************
  4677. void execSetCameraLookObject (void) {
  4678. //-----------------------------------------------------
  4679. //
  4680. // SetCameraLookObject
  4681. //
  4682. // Sets the camera Look Object
  4683. //
  4684. // PARAMS: long objectId
  4685. //
  4686. // RETURN: NONE
  4687. //
  4688. //-----------------------------------------------------
  4689. long objectId = ABLi_popInteger();
  4690. if (eye)
  4691. eye->setCameraTargetId(objectId);
  4692. }
  4693. //*****************************************************************************
  4694. void execGetCameraLookObject (void) {
  4695. //-----------------------------------------------------
  4696. //
  4697. // GetCameraGetLookObject
  4698. //
  4699. // Gets the camera FOV into the value passed in.
  4700. //
  4701. // PARAMS: NONE
  4702. //
  4703. // RETURN: Integer
  4704. //
  4705. //-----------------------------------------------------
  4706. long result = 0;
  4707. if (eye)
  4708. result = eye->getCameraTargetId();
  4709. ABLi_pushInteger(result);
  4710. }
  4711. //*****************************************************************************
  4712. void execGetCameraFrameLength (void) {
  4713. //-----------------------------------------------------
  4714. //
  4715. // GetCameraFrameLength
  4716. //
  4717. // Gets the Last Frame's Length
  4718. //
  4719. // PARAMS: NONE
  4720. //
  4721. // RETURN: real
  4722. //
  4723. //-----------------------------------------------------
  4724. ABLi_pushReal(frameLength);
  4725. }
  4726. //*****************************************************************************
  4727. void execAnimationCallout (void)
  4728. {
  4729. // Takes an integer for button num, bool for if its a button, bool for if it should press it, real for time to get there, integer for num flashes.
  4730. //
  4731. // Returns a bool. True if the animation played, false if an animation is running.
  4732. //
  4733. long buttonId = ABLi_popInteger();
  4734. bool isButton = ABLi_popBoolean();
  4735. bool isPressed = ABLi_popBoolean();
  4736. float timeToScroll = ABLi_popReal();
  4737. long numFlashes = ABLi_popInteger();
  4738. bool result = mission->missionInterface->startAnimation(buttonId,isButton,isPressed,timeToScroll,numFlashes);
  4739. ABLi_pushBoolean(result);
  4740. }
  4741. static char tutorialMessages[MAX_CHAT_COUNT][1024];
  4742. static unsigned char currentMessage = 0;
  4743. //*****************************************************************************
  4744. void execTutorialText (void)
  4745. {
  4746. //Takes an integer for TextID to send.
  4747. //
  4748. // returns nothing.
  4749. //
  4750. long textId = ABLi_popInteger();
  4751. cLoadString(textId,tutorialMessages[currentMessage],1023);
  4752. mission->missionInterface->setTutorialText(tutorialMessages[currentMessage]);
  4753. currentMessage++;
  4754. if (currentMessage >= MAX_CHAT_COUNT)
  4755. currentMessage = 0;
  4756. }
  4757. //*****************************************************************************
  4758. void execGUIIsAOEStyle (void)
  4759. {
  4760. //Takes NOTHING
  4761. //
  4762. // Returns state of GUI.
  4763. ABLi_pushBoolean(mission->missionInterface->isAOEStyle());
  4764. }
  4765. //*****************************************************************************
  4766. void execSetInvulnerable (void)
  4767. {
  4768. //Takes a bool and sets local team invulnerability to the flag passed in.
  4769. //
  4770. // Returns NOTHING.
  4771. bool invulnerableFlag = ABLi_popBoolean();
  4772. invulnerableON = invulnerableFlag;
  4773. }
  4774. //*****************************************************************************
  4775. void execFreezeGUI (void)
  4776. {
  4777. //Takes a bool and turns mouse input on or off based on flag passed in.
  4778. //
  4779. // Returns NOTHING.
  4780. bool guiFlag = ABLi_popBoolean();
  4781. mission->missionInterface->freezeGUI(guiFlag);
  4782. }
  4783. //*****************************************************************************
  4784. void execLogisticsScreenId (void)
  4785. {
  4786. //Takes NOTHING
  4787. //
  4788. //Returns ID of logistics Screen we are IN. Returns -1 if not in logistics or missionBegin is NULL!
  4789. //singlePlayerScreens[0][1] = pMissionSelectionScreen; ID 1
  4790. //singlePlayerScreens[1][1] = pBriefingScreen; ID 11
  4791. //singlePlayerScreens[2][1] = pMechBayScreen; ID 21
  4792. //singlePlayerScreens[3][1] = pPilotSelectionScreen; ID 31
  4793. //singlePlayerScreens[2][0] = pPurchaseMechScreen; ID 20
  4794. //singlePlayerScreens[2][2] = pMechLabScreen; ID 22
  4795. //singlePlayerScreens[4][1] = pLoadScreen; ID 41
  4796. if (logistics && logistics->getMissionBegin())
  4797. {
  4798. ABLi_pushInteger(logistics->getMissionBegin()->getCurrentScreenId());
  4799. }
  4800. else
  4801. {
  4802. ABLi_pushInteger(-1);
  4803. }
  4804. }
  4805. //*****************************************************************************
  4806. void execLogisticsAnimationCallout (void)
  4807. {
  4808. // Takes an integer for button num, real for time to get there, integer for num flashes.
  4809. //
  4810. // Returns a bool. True if the animation played, false if an animation is running.
  4811. //
  4812. long buttonId = ABLi_popInteger();
  4813. bool isButton = ABLi_popBoolean();
  4814. float timeToScroll = ABLi_popReal();
  4815. long numFlashes = ABLi_popInteger();
  4816. if (logistics && logistics->getMissionBegin())
  4817. {
  4818. bool result = logistics->getMissionBegin()->startAnimation(buttonId,isButton,timeToScroll,numFlashes);
  4819. ABLi_pushBoolean(result);
  4820. }
  4821. else
  4822. {
  4823. ABLi_pushBoolean(false);
  4824. }
  4825. }
  4826. //*****************************************************************************
  4827. void execLogisticsInCallout (void)
  4828. {
  4829. //takes NOTHING
  4830. //
  4831. // Returns a bool. True if we are currently animating the mouse to the button area OR no logistics, false if not animating
  4832. if (logistics && logistics->getMissionBegin())
  4833. {
  4834. ABLi_pushBoolean(logistics->getMissionBegin()->isInCalloutAnimation());
  4835. }
  4836. else
  4837. {
  4838. ABLi_pushBoolean(true);
  4839. }
  4840. }
  4841. //*****************************************************************************
  4842. void execInCallout (void)
  4843. {
  4844. //takes NOTHING
  4845. //
  4846. // Returns a bool. True if we are currently animating the mouse to the button area OR no logistics, false if not animating
  4847. if (mission && mission->missionInterface)
  4848. {
  4849. ABLi_pushBoolean(mission->missionInterface->isInCalloutAnimation());
  4850. }
  4851. else
  4852. {
  4853. ABLi_pushBoolean(true);
  4854. }
  4855. }
  4856. //*****************************************************************************
  4857. void execIsPlayingVoiceOver(void)
  4858. {
  4859. //Takes NOTHING
  4860. //
  4861. // Returns a bool, true if voiceover channel is active, false if not.
  4862. ABLi_pushBoolean(soundSystem->isPlayingVoiceOver());
  4863. }
  4864. //*****************************************************************************
  4865. void execStopVoiceOver(void)
  4866. {
  4867. //Takes NOTHING
  4868. //
  4869. // Returns a NOTHING
  4870. soundSystem->stopSupportSample();
  4871. }
  4872. //*****************************************************************************
  4873. void execGetLogisticsTime(void)
  4874. {
  4875. //Takes NOTHING
  4876. //
  4877. // Returns a bool, true if voiceover channel is active, false if not.
  4878. ABLi_pushReal(timeGetTime());
  4879. }
  4880. //*****************************************************************************
  4881. void execRequestHelp (void) {
  4882. //--------------------------------------------------
  4883. // Defender is the CurPilot (calling this function).
  4884. long enemyPartID = ABLi_popInteger();
  4885. float* friendlyCenter = ABLi_popRealPtr();
  4886. float friendlyRadius = ABLi_popReal();
  4887. float* enemyCenter = ABLi_popRealPtr();
  4888. float enemyRadius = ABLi_popReal();
  4889. long priority = ABLi_popInteger();
  4890. if (CurWarrior->getTeam()) {
  4891. Stuff::Vector3D friendlyPos;
  4892. friendlyPos.x = friendlyCenter[0];
  4893. friendlyPos.y = friendlyCenter[1];
  4894. friendlyPos.z = 0.0;
  4895. MoverPtr friendlies[MAX_MOVERS];
  4896. long commanderID = -1;
  4897. if (MPlayer || (CurWarrior->getTeam() == Team::home))
  4898. commanderID = CurWarrior->getCommander()->getId();
  4899. long numFriendlies = getMoversWithinRadius(friendlies, friendlyPos, friendlyRadius, CurWarrior->getTeam()->getId(), commanderID, false, true, priority > 0);
  4900. GameObjectPtr enemy = ObjectManager->findByPartId(enemyPartID);
  4901. if (enemy && enemy->getTeam() && (enemy->getTeam() != CurWarrior->getTeam())) {
  4902. Stuff::Vector3D enemyPos;
  4903. enemyPos.x = enemyCenter[0];
  4904. enemyPos.y = enemyCenter[1];
  4905. enemyPos.z = 0.0;
  4906. MoverPtr enemies[MAX_MOVERS];
  4907. long numEnemies = getMoversWithinRadius(enemies, enemyPos, enemyRadius, enemy->getTeamId(), -1, false, true, true);
  4908. calcAttackPlan(numFriendlies, (GameObjectPtr*)friendlies, numEnemies, (GameObjectPtr*)enemies);
  4909. }
  4910. }
  4911. ABLi_pushReal(0.0);
  4912. }
  4913. //*****************************************************************************
  4914. void execRequestTarget (void) {
  4915. float* center = ABLi_popRealPtr();
  4916. float radius = ABLi_popReal();
  4917. if (CurWarrior->getTeam()) {
  4918. Stuff::Vector3D friendlyPos;
  4919. friendlyPos.x = center[0];
  4920. friendlyPos.y = center[1];
  4921. friendlyPos.z = 0.0;
  4922. MoverPtr friendlies[MAX_MOVERS];
  4923. MoverPtr enemies[MAX_MOVERS];
  4924. long commanderID = -1;
  4925. if (MPlayer || (CurWarrior->getTeam() == Team::home))
  4926. commanderID = CurWarrior->getCommander()->getId();
  4927. long numFriendlies = getMoversWithinRadius(friendlies, friendlyPos, radius, CurWarrior->getTeam()->getId(), commanderID, false, true, true);
  4928. long numEnemies = getMoversWithinRadius(enemies, friendlyPos, radius, CurWarrior->getTeam()->getId(), -1,true, true, true);
  4929. GameObjectPtr bestTarget = NULL;
  4930. if (numEnemies > 0)
  4931. bestTarget = calcBestTarget(CurWarrior->getVehicle(), numFriendlies, friendlies, numEnemies, enemies);
  4932. if (bestTarget)
  4933. ABLi_pushInteger(bestTarget->getPartId());
  4934. else
  4935. ABLi_pushInteger(0);
  4936. }
  4937. }
  4938. //*****************************************************************************
  4939. #define MAX_SHELTERS 10
  4940. void execRequestShelter (void) {
  4941. float range = ABLi_popIntegerReal();
  4942. long numValidBuildings = 0;
  4943. BuildingPtr validBuildings[MAX_SHELTERS];
  4944. long numBuildings = ObjectManager->getNumBuildings();
  4945. for (long i = 0; i < numBuildings; i++) {
  4946. BuildingPtr building = ObjectManager->getBuilding(i);
  4947. if (CurObject->distanceFrom(building->getPosition()) < range) {
  4948. validBuildings[numValidBuildings++] = building;
  4949. if (numValidBuildings == MAX_SHELTERS)
  4950. break;
  4951. }
  4952. }
  4953. if (numValidBuildings > 0) {
  4954. long buildingIndex = RandomNumber(numValidBuildings);
  4955. ABLi_pushInteger(validBuildings[buildingIndex]->getPartId());
  4956. }
  4957. else
  4958. ABLi_pushInteger(0);
  4959. }
  4960. //*****************************************************************************
  4961. void execMCPrint (void) {
  4962. ABLStackItem value;
  4963. ABLi_popAnything(&value);
  4964. char s[256];
  4965. switch (value.type) {
  4966. case ABL_STACKITEM_CHAR:
  4967. sprintf(s, "char=%c", value.data.character);
  4968. DEBUGWINS_print(s, 0);
  4969. break;
  4970. case ABL_STACKITEM_INTEGER:
  4971. sprintf(s, "int=%d", value.data.integer);
  4972. DEBUGWINS_print(s, 0);
  4973. break;
  4974. case ABL_STACKITEM_REAL:
  4975. sprintf(s, "real=%.2f", value.data.real);
  4976. DEBUGWINS_print(s, 0);
  4977. break;
  4978. case ABL_STACKITEM_BOOLEAN:
  4979. sprintf(s, "bool=%s", value.data.boolean ? "true" : "false");
  4980. DEBUGWINS_print(s, 0);
  4981. break;
  4982. case ABL_STACKITEM_CHAR_PTR:
  4983. sprintf(s, "char*=%s", (char*)value.data.characterPtr);
  4984. DEBUGWINS_print(s, 0);
  4985. break;
  4986. case ABL_STACKITEM_INTEGER_PTR:
  4987. sprintf(s, "int*=%d,%d,%d", value.data.integerPtr[0], value.data.integerPtr[1], value.data.integerPtr[2]);
  4988. DEBUGWINS_print(s, 0);
  4989. break;
  4990. case ABL_STACKITEM_REAL_PTR:
  4991. sprintf(s, "real*=%.2f,%.2f,%.2f", value.data.realPtr[0], value.data.realPtr[1], value.data.realPtr[2]);
  4992. DEBUGWINS_print(s, 0);
  4993. break;
  4994. case ABL_STACKITEM_BOOLEAN_PTR:
  4995. sprintf(s, "bool*=%d,%d,%d", value.data.booleanPtr[0], value.data.booleanPtr[1], value.data.booleanPtr[2]);
  4996. DEBUGWINS_print(s, 0);
  4997. break;
  4998. }
  4999. }
  5000. //*****************************************************************************
  5001. void execGetMissionStatus (void) {
  5002. ABLi_pushInteger(mission->getStatus());
  5003. }
  5004. //*****************************************************************************
  5005. void execAddTriggerArea (void) {
  5006. long ULrow = ABLi_popInteger();
  5007. long ULcol = ABLi_popInteger();
  5008. long LRrow = ABLi_popInteger();
  5009. long LRcol = ABLi_popInteger();
  5010. long type = ABLi_popInteger();
  5011. long param = ABLi_popInteger();
  5012. long handle = Mover::triggerAreaMgr->add(ULrow, ULcol, LRrow, LRcol, type, param);
  5013. if (handle == 0)
  5014. Fatal(0, " Too many Trigger Areas ");
  5015. ABLi_pushInteger(handle);
  5016. }
  5017. //*****************************************************************************
  5018. void execIsTriggerAreaHit (void) {
  5019. long handle = ABLi_popInteger();
  5020. ABLi_pushBoolean(Mover::triggerAreaMgr->isHit(handle));
  5021. }
  5022. //*****************************************************************************
  5023. void execResetTriggerArea (void) {
  5024. long handle = ABLi_popInteger();
  5025. Mover::triggerAreaMgr->reset(handle);
  5026. }
  5027. //*****************************************************************************
  5028. void execRemoveTriggerArea (void) {
  5029. long handle = ABLi_popInteger();
  5030. Mover::triggerAreaMgr->remove(handle);
  5031. }
  5032. //*****************************************************************************
  5033. void execGetWeapons (void) {
  5034. long* weaponList = ABLi_popIntegerPtr();
  5035. long infoType = ABLi_popInteger();
  5036. long numWpns = 0;
  5037. if (CurObject->isMover()) {
  5038. MoverPtr mover = (MoverPtr)CurObject;
  5039. switch (infoType) {
  5040. case 0: {
  5041. for (long curWeapon = mover->numOther; curWeapon < (mover->numOther + mover->numWeapons); curWeapon++)
  5042. weaponList[numWpns++] = mover->inventory[curWeapon].masterID;
  5043. }
  5044. break;
  5045. case 1: {
  5046. for (long curWeapon = mover->numOther; curWeapon < (mover->numOther + mover->numWeapons); curWeapon++) {
  5047. if (!mover->inventory[curWeapon].disabled && (mover->getWeaponShots(curWeapon) > 0))
  5048. weaponList[numWpns++] = mover->inventory[curWeapon].masterID;
  5049. }
  5050. #ifdef BUGLOG
  5051. if ((numWpns != mover->numFunctionalWeapons) && BugLog) {
  5052. char s[50];
  5053. sprintf(s, "[%.2f] ablmc2.execGetWeapons: numWpns != numFunctionalWeapons (%05d)%s", scenarioTime, mover->getPartId(), mover->getName());
  5054. BugLog->write(s);
  5055. BugLog->write(" ");
  5056. }
  5057. #endif
  5058. }
  5059. break;
  5060. }
  5061. }
  5062. ABLi_pushInteger(numWpns);
  5063. }
  5064. //*****************************************************************************
  5065. void execGetWeaponsStatus (void) {
  5066. long* weaponList = ABLi_popIntegerPtr();
  5067. long status = 0;
  5068. if (CurObject && CurObject->isMover()) {
  5069. MoverPtr mover = (MoverPtr)CurObject;
  5070. status = mover->getPilot()->getWeaponsStatus(weaponList);
  5071. }
  5072. ABLi_pushInteger(status);
  5073. }
  5074. //*****************************************************************************
  5075. void execSetMoveArea (void) {
  5076. float* center = ABLi_popRealPtr();
  5077. float radius = ABLi_popReal();
  5078. if (CurObject->isMover()) {
  5079. Stuff::Vector3D loc;
  5080. loc.x = center[0];
  5081. loc.y = center[1];
  5082. loc.z = land->getTerrainElevation(loc);
  5083. ((MoverPtr)CurObject)->moveCenter = loc;
  5084. ((MoverPtr)CurObject)->moveRadius = radius;
  5085. }
  5086. }
  5087. //*****************************************************************************
  5088. void execClearTacOrder (void) {
  5089. if (CurObject)
  5090. CurObject->getPilot()->clearCurTacOrder();
  5091. }
  5092. //*****************************************************************************
  5093. void execPlayWave (void) {
  5094. char* fileName = ABLi_popCharPtr();
  5095. long type = ABLi_popInteger();
  5096. soundSystem->playSupportSample(-1, fileName);
  5097. ABLi_pushInteger(0);
  5098. }
  5099. //*****************************************************************************
  5100. void execSetWillHelp (void) {
  5101. bool willHelp = ABLi_popBoolean();
  5102. bool wasHelping = CurWarrior->getWillHelp();
  5103. CurWarrior->setWillHelp(willHelp);
  5104. ABLi_pushInteger(wasHelping);
  5105. }
  5106. //*****************************************************************************
  5107. void execGetLastScan (void) {
  5108. GameObjectPtr lastScanTarget = ObjectManager->getByWatchID(CurWarrior->getCoreScanTargetWID());
  5109. long lastScanTargetID = 0;
  5110. if (lastScanTarget)
  5111. lastScanTargetID = lastScanTarget->getPartId();
  5112. ABLi_pushInteger(lastScanTargetID);
  5113. }
  5114. //*****************************************************************************
  5115. void execGetMapInfo (void) {
  5116. long* mapInfo = ABLi_popIntegerPtr();
  5117. mapInfo[0] = GameMap->getHeight();
  5118. mapInfo[1] = GameMap->getWidth();
  5119. }
  5120. //*****************************************************************************
  5121. void execIsOffMap (void) {
  5122. float* worldPos = ABLi_popRealPtr();
  5123. Stuff::Vector3D pos;
  5124. pos.x = worldPos[0];
  5125. pos.y = worldPos[1];
  5126. if (pos.x > 999000) {
  5127. if (CurObject)
  5128. pos = CurObject->getPosition();
  5129. else {
  5130. ABLi_pushBoolean(false);
  5131. return;
  5132. }
  5133. }
  5134. long row, col;
  5135. land->worldToCell(pos, row, col);
  5136. ABLi_pushBoolean(GameMap->getOffMap(row, col) ? true : false);
  5137. }
  5138. //*****************************************************************************
  5139. void execSetGoalPlanning (void) {
  5140. bool setting = ABLi_popBoolean();
  5141. bool oldSetting = false;
  5142. if (CurObject) {
  5143. oldSetting = ((MoverPtr)CurObject)->getPilot()->getUseGoalPlan();
  5144. ((MoverPtr)CurObject)->getPilot()->setUseGoalPlan(setting);
  5145. if (oldSetting != setting)
  5146. ((MoverPtr)CurObject)->getPilot()->setMainGoal(GOAL_ACTION_NONE, NULL, NULL, -1.0);
  5147. }
  5148. ABLi_pushBoolean(oldSetting);
  5149. }
  5150. //*****************************************************************************
  5151. void execSetEject (void) {
  5152. bool setting = ABLi_popBoolean();
  5153. bool oldSetting = false;
  5154. if (CurObject) {
  5155. oldSetting = ((MoverPtr)CurObject)->getPilot()->getEscapesThruEjection();
  5156. ((MoverPtr)CurObject)->getPilot()->setEscapesThruEjection(setting);
  5157. }
  5158. ABLi_pushBoolean(oldSetting);
  5159. }
  5160. //*****************************************************************************
  5161. void execSetKeepMoving (void) {
  5162. bool setting = ABLi_popBoolean();
  5163. bool oldSetting = false;
  5164. if (CurObject) {
  5165. oldSetting = ((MoverPtr)CurObject)->getPilot()->getKeepMoving();
  5166. ((MoverPtr)CurObject)->getPilot()->setKeepMoving(setting);
  5167. }
  5168. ABLi_pushBoolean(oldSetting);
  5169. }
  5170. //*****************************************************************************
  5171. void* ablSystemMallocCallback (unsigned long memSize) {
  5172. return(systemHeap->Malloc(memSize));
  5173. }
  5174. //-----------------------------------------------------------------------------
  5175. void* ablStackMallocCallback (unsigned long memSize) {
  5176. if (!AblSymbolHeap)
  5177. Fatal(0, " ablSymbolMallocCallback: NULL heap ");
  5178. return(AblStackHeap->Malloc(memSize));
  5179. }
  5180. //-----------------------------------------------------------------------------
  5181. void* ablCodeMallocCallback (unsigned long memSize) {
  5182. if (!AblCodeHeap)
  5183. Fatal(0, " ablCodeFreeCallback: NULL heap ");
  5184. return(AblCodeHeap->Malloc(memSize));
  5185. }
  5186. //-----------------------------------------------------------------------------
  5187. void* ablSymbolMallocCallback (unsigned long memSize) {
  5188. if (!AblSymbolHeap)
  5189. Fatal(0, " ablSymbolMallocCallback: NULL heap ");
  5190. return(AblSymbolHeap->Malloc(memSize));
  5191. }
  5192. //-----------------------------------------------------------------------------
  5193. void ablSystemFreeCallback (void* memBlock) {
  5194. systemHeap->Free(memBlock);
  5195. }
  5196. //-----------------------------------------------------------------------------
  5197. void ablStackFreeCallback (void* memBlock) {
  5198. if (!AblStackHeap)
  5199. Fatal(0, " ablStackFreeCallback: NULL heap ");
  5200. AblStackHeap->Free(memBlock);
  5201. }
  5202. //-----------------------------------------------------------------------------
  5203. void ablCodeFreeCallback (void* memBlock) {
  5204. if (!AblCodeHeap)
  5205. Fatal(0, " ablCodeFreeCallback: NULL heap ");
  5206. AblCodeHeap->Free(memBlock);
  5207. }
  5208. //-----------------------------------------------------------------------------
  5209. void ablSymbolFreeCallback (void* memBlock) {
  5210. if (!AblSymbolHeap)
  5211. Fatal(0, " ablSymbolFreeCallback: NULL heap ");
  5212. AblSymbolHeap->Free(memBlock);
  5213. }
  5214. //*****************************************************************************
  5215. long ablFileCreateCB (void** file, char* fName) {
  5216. *file = new File;
  5217. if (*file == NULL)
  5218. Fatal(0, " unable to create ABL file");
  5219. if (((FilePtr)*file)->create(fName) != NO_ERR) {
  5220. char s[256];
  5221. sprintf(s, " ABL.ablFileOpenCB: unable to create file [%s] ", fName);
  5222. Fatal(0, s);
  5223. }
  5224. return(NO_ERR);
  5225. }
  5226. //-----------------------------------------------------------------------------
  5227. long ablFileOpenCB (void** file, char* fName) {
  5228. *file = new File;
  5229. if (*file == NULL)
  5230. Fatal(0, " unable to create ABL file");
  5231. //Filenames MUST be all lowercase or Hash won't find 'em!
  5232. CharLower(fName);
  5233. if (((FilePtr)*file)->open(fName) != NO_ERR)
  5234. STOP((" unable to open ABL File %s",fName));
  5235. return(NO_ERR);
  5236. }
  5237. //-----------------------------------------------------------------------------
  5238. long ablFileCloseCB (void** file) {
  5239. ((FilePtr)*file)->close();
  5240. delete (FilePtr)*file;
  5241. *file = NULL;
  5242. return(0);
  5243. }
  5244. //-----------------------------------------------------------------------------
  5245. bool ablFileEofCB (void* file) {
  5246. return(((FilePtr)file)->eof());
  5247. }
  5248. //-----------------------------------------------------------------------------
  5249. long ablFileReadCB (void* file, unsigned char* buffer, long length) {
  5250. return(((FilePtr)file)->read(buffer, length));
  5251. }
  5252. //-----------------------------------------------------------------------------
  5253. long ablFileReadLongCB (void* file) {
  5254. return(((FilePtr)file)->readLong());
  5255. }
  5256. //-----------------------------------------------------------------------------
  5257. long ablFileReadStringCB (void* file, unsigned char* buffer) {
  5258. return(((FilePtr)file)->readString(buffer));
  5259. }
  5260. //-----------------------------------------------------------------------------
  5261. long ablFileReadLineExCB (void* file, unsigned char* buffer, long maxLength) {
  5262. return(((FilePtr)file)->readLineEx(buffer, maxLength));
  5263. }
  5264. //-----------------------------------------------------------------------------
  5265. long ablFileWriteCB (void* file, unsigned char* buffer, long length) {
  5266. return(((FilePtr)file)->write(buffer, length));
  5267. }
  5268. //-----------------------------------------------------------------------------
  5269. long ablFileWriteByteCB (void* file, unsigned char byte) {
  5270. return(((FilePtr)file)->writeByte(byte));
  5271. }
  5272. //-----------------------------------------------------------------------------
  5273. long ablFileWriteLongCB (void* file, long value) {
  5274. return(((FilePtr)file)->writeLong(value));
  5275. }
  5276. //-----------------------------------------------------------------------------
  5277. long ablFileWriteStringCB (void* file, char* buffer) {
  5278. return(((FilePtr)file)->writeString(buffer));
  5279. }
  5280. //*****************************************************************************
  5281. void ablDebuggerPrintCallback (char* s) {
  5282. //ABLDebuggerOut->print(s);
  5283. char msg[1024];
  5284. sprintf(msg, "%s\n", s);
  5285. SPEW((0,msg));
  5286. }
  5287. //*****************************************************************************
  5288. void ablDebugPrintCallback (char* s) {
  5289. DEBUGWINS_print(s, 0);
  5290. }
  5291. //*****************************************************************************
  5292. void ablSeedRandom (unsigned long seed) {
  5293. gos_srand(seed);
  5294. }
  5295. //*****************************************************************************
  5296. void ablFatalCallback (long code, char* s) {
  5297. STOP((s));
  5298. }
  5299. //*****************************************************************************
  5300. extern GameObjectPtr LastCoreAttackTarget;
  5301. void ablEndlessStateCallback (UserFile* log) {
  5302. char s[256];
  5303. sprintf(s, "Mover = %s (%d)", CurWarrior->getVehicle()->getName(), CurWarrior->getVehicle()->getPartId());
  5304. log->write(s);
  5305. sprintf(s, " Status = %d", CurWarrior->getVehicle()->getStatus());
  5306. log->write(s);
  5307. sprintf(s, " NumWeapons = %d", CurWarrior->getVehicle()->numWeapons);
  5308. log->write(s);
  5309. sprintf(s, " NumFunctionalWeapons = %d", CurWarrior->getVehicle()->numFunctionalWeapons);
  5310. log->write(s);
  5311. sprintf(s, " TacOrder = ");
  5312. CurWarrior->getCurTacOrder()->debugString(CurWarrior, &s[16]);
  5313. log->write(s);
  5314. log->write(" ");
  5315. if (LastCoreAttackTarget) {
  5316. sprintf(s, "Target = %s (%d)", LastCoreAttackTarget->getName(), LastCoreAttackTarget->getPartId());
  5317. log->write(s);
  5318. Stuff::Vector3D pos;
  5319. pos = LastCoreAttackTarget->getPosition();
  5320. sprintf(s, "Target Position = (%.3f, %.3f, %.3f) [%d, %d]",
  5321. pos.x, pos.y, pos.z,
  5322. LastCoreAttackTarget->cellPositionRow,
  5323. LastCoreAttackTarget->cellPositionCol);
  5324. log->write(s);
  5325. sprintf(s, " Status = %d", LastCoreAttackTarget->getStatus());
  5326. log->write(s);
  5327. if (LastCoreAttackTarget->isMover()) {
  5328. MoverPtr mover = (MoverPtr)LastCoreAttackTarget;
  5329. sprintf(s, " NumWeapons = %d", mover->numWeapons);
  5330. log->write(s);
  5331. sprintf(s, " NumFunctionalWeapons = %d", mover->numFunctionalWeapons);
  5332. log->write(s);
  5333. sprintf(s, " TacOrder = ");
  5334. mover->getPilot()->getCurTacOrder()->debugString(CurWarrior, &s[16]);
  5335. log->write(s);
  5336. }
  5337. }
  5338. else {
  5339. sprintf(s, "Target = NULL");
  5340. log->write(s);
  5341. }
  5342. }
  5343. //*****************************************************************************
  5344. void initABL (void) {
  5345. AblSymbolHeap = new UserHeap;
  5346. long heapErr = AblSymbolHeap->init(767999);
  5347. if (heapErr != NO_ERR)
  5348. ABL_Fatal(0, "ABLi_init: unable to create ABL symbol table heap");
  5349. AblStackHeap = new UserHeap;
  5350. heapErr = AblStackHeap->init(511999);
  5351. if (heapErr != NO_ERR)
  5352. ABL_Fatal(0, "ABLi_init: unable to create ABL stack heap");
  5353. AblCodeHeap = new UserHeap;
  5354. heapErr = AblCodeHeap->init(307199);
  5355. if (heapErr != NO_ERR)
  5356. ABL_Fatal(0, "ABLi_init: unable to create ABL code heap");
  5357. ABLi_init(20479, //AblRunTimeStackSize,
  5358. 102400, //AblMaxCodeBlockSize,
  5359. 200, //AblMaxRegisteredModules,
  5360. 100, //AblMaxStaticVariables,
  5361. ablSystemMallocCallback,
  5362. ablStackMallocCallback,
  5363. ablCodeMallocCallback,
  5364. ablSymbolMallocCallback,
  5365. ablSystemFreeCallback,
  5366. ablStackFreeCallback,
  5367. ablCodeFreeCallback,
  5368. ablSymbolFreeCallback,
  5369. ablFileCreateCB,
  5370. ablFileOpenCB,
  5371. ablFileCloseCB,
  5372. ablFileEofCB,
  5373. ablFileReadCB,
  5374. ablFileReadLongCB,
  5375. ablFileReadStringCB,
  5376. ablFileReadLineExCB,
  5377. ablFileWriteCB,
  5378. ablFileWriteByteCB,
  5379. ablFileWriteLongCB,
  5380. ablFileWriteStringCB,
  5381. ablDebuggerPrintCallback,
  5382. ablFatalCallback,
  5383. true,
  5384. false);
  5385. ABLi_setDebugPrintCallback(ablDebugPrintCallback);
  5386. ABLi_setRandomCallbacks(ablSeedRandom, RandomNumber);
  5387. ABLi_setEndlessStateCallback(ablEndlessStateCallback);
  5388. ABLi_addFunction("getid", false, NULL, "i", execGetId);
  5389. ABLi_addFunction("gettime", false, NULL, "r", execGetTime);
  5390. ABLi_addFunction("gettimeleft", false, NULL, "r", execGetTimeLeft);
  5391. ABLi_addFunction("selectobject", false, "i", "i", execSelectObject);
  5392. //ABLi_addFunction("selectunit", false, "i", "i", execSelectUnit);
  5393. ABLi_addFunction("selectwarrior", false, "i", "i", execSelectWarrior);
  5394. ABLi_addFunction("getwarriorstatus", false, "i", "i", execGetWarriorStatus);
  5395. ABLi_addFunction("getcontacts", false, "Iii", "i", execGetContacts);
  5396. ABLi_addFunction("getenemycount", false, "i", "i", execGetEnemyCount);
  5397. ABLi_addFunction("selectcontact", false, "ii", "i", execSelectContact);
  5398. ABLi_addFunction("getcontactid", false, NULL, "i", execGetContactId);
  5399. ABLi_addFunction("iscontact", false, "iii", "i", execIsContact);
  5400. ABLi_addFunction("getcontactstatus", false, "I", "i", execGetContactStatus);
  5401. ABLi_addFunction("getcontactrelativeposition", false, "rr", "i", execGetContactRelativePosition);
  5402. ABLi_addFunction("settarget", false, "ii", NULL, execSetTarget);
  5403. ABLi_addFunction("gettarget", false, "i", "i", execGetTarget);
  5404. ABLi_addFunction("getweaponsready", false, "Ii", "i", execGetWeaponsReady);
  5405. ABLi_addFunction("getweaponslocked", false, "Ii", "i", execGetWeaponsLocked);
  5406. ABLi_addFunction("getweaponsinrange", false, "Ii", "i", execGetWeaponsInRange);
  5407. ABLi_addFunction("getweaponshots", false, "i", "i", execGetWeaponShots);
  5408. ABLi_addFunction("getweaponranges", false, "iR", NULL, execGetWeaponRanges);
  5409. ABLi_addFunction("getobjectposition", false, "iR", NULL, execGetObjectPosition);
  5410. ABLi_addFunction("getintegermemory", false, "i", "i", execGetIntegerMemory);
  5411. ABLi_addFunction("getrealmemory", false, "i", "r", execGetRealMemory);
  5412. ABLi_addFunction("getalarmtriggers", false, "I", "i", execGetAlarmTriggers);
  5413. ABLi_addFunction("getchallenger", false, "i", "i", execGetChallenger);
  5414. ABLi_addFunction("gettimewithoutorders", false, NULL, "r", execGetTimeWithoutOrders);
  5415. ABLi_addFunction("getfireranges", false, "R", NULL, execGetFireRanges);
  5416. ABLi_addFunction("getattackers", false, "Ir", "i", execGetAttackers);
  5417. ABLi_addFunction("getattackerinfo", false, "i", "r", execGetAttackerInfo);
  5418. ABLi_addFunction("setchallenger", false, "ii", "i", execSetChallenger);
  5419. ABLi_addFunction("setintegermemory", false, "ii", NULL, execSetIntegerMemory);
  5420. ABLi_addFunction("setrealmemory", false, "ir", NULL, execSetRealMemory);
  5421. ABLi_addFunction("hasmovegoal", false, NULL, "b", execHasMoveGoal);
  5422. ABLi_addFunction("hasmovepath", false, NULL, "b", execHasMovePath);
  5423. ABLi_addFunction("sortweapons", false, "Ii", "i", execSortWeapons);
  5424. ABLi_addFunction("getvisualrange", false, "i", "r", execGetVisualRange);
  5425. ABLi_addFunction("getunitmates", false, "iI", "i", execGetUnitMates);
  5426. ABLi_addFunction("gettacorder", false, "irI", "i", execGetTacOrder);
  5427. ABLi_addFunction("getlasttacorder", false, "irI", "i", execGetLastTacOrder);
  5428. ABLi_addFunction("getobjects", false, "iI", "i", execGetObjects);
  5429. ABLi_addFunction("orderwait", false, "rb", "i", execOrderWait);
  5430. ABLi_addFunction("ordermoveto", false, "Rb", "i", execOrderMoveTo);
  5431. ABLi_addFunction("ordermovetoobject", false, "ib", "i", execOrderMoveToObject);
  5432. ABLi_addFunction("ordermovetocontact", false, "b", "i", execOrderMoveToContact);
  5433. ABLi_addFunction("orderpowerdown", false, NULL, "i", execOrderPowerDown);
  5434. ABLi_addFunction("orderpowerup", false, NULL, "i", execOrderPowerUp);
  5435. ABLi_addFunction("orderattackobject", false, "iiiib", "i", execOrderAttackObject);
  5436. ABLi_addFunction("orderattackcontact", false, "iiib", "i", execOrderAttackContact);
  5437. ABLi_addFunction("orderwithdraw", false, NULL, "i", execOrderWithdraw);
  5438. ABLi_addFunction("objectinwithdrawal", false, "i", "i", execObjectInWithdrawal);
  5439. ABLi_addFunction("damageobject", false, "iiirirr", "i", execDamageObject);
  5440. ABLi_addFunction("setattackradius", false, "r", "r", execSetAttackRadius);
  5441. ABLi_addFunction("objectchangesides", false, "ii", NULL, execObjectChangeSides);
  5442. ABLi_addFunction("distancetoobject", false, "ii", "r", execDistanceToObject);
  5443. ABLi_addFunction("distancetoposition", false, "iR", "r", execDistanceToPosition);
  5444. ABLi_addFunction("objectsuicide", false, "i", NULL, execObjectSuicide);
  5445. ABLi_addFunction("objectcreate", false, "i", "i", execObjectCreate);
  5446. ABLi_addFunction("objectexists", false, "i", "i", execObjectExists);
  5447. ABLi_addFunction("objectstatus", false, "i", "i", execObjectStatus);
  5448. ABLi_addFunction("objectstatuscount", false, "iI", NULL, execObjectStatusCount);
  5449. ABLi_addFunction("objectvisible", false, "ii", "i", execObjectVisible);
  5450. ABLi_addFunction("objectside", false, "i", "i", execObjectTeam);
  5451. ABLi_addFunction("objectcommander", false, "i", "i", execObjectCommander);
  5452. ABLi_addFunction("objectclass", false, "i", "i", execObjectClass);
  5453. ABLi_addFunction("settimer", false, "i*", "i", execSetTimer);
  5454. ABLi_addFunction("checktimer", false, "i", "r", execCheckTimer);
  5455. ABLi_addFunction("endtimer", false, "i", NULL, execEndTimer);
  5456. // ABLi_addFunction("setobjectivetimer", false, "i*", "i", execSetObjectiveTimer);
  5457. // ABLi_addFunction("checkobjectivetimer", false, "i", "r", execCheckObjectiveTimer);
  5458. ABLi_addFunction("setobjectivestatus", false, "ii", "i", execSetObjectiveStatus);
  5459. ABLi_addFunction("checkobjectivestatus", false, "i", "i", execCheckObjectiveStatus);
  5460. // ABLi_addFunction("setobjectivetype", false, "ii", "i", execSetObjectiveType);
  5461. // ABLi_addFunction("checkobjectivetype", false, "i", "i", execCheckObjectiveType);
  5462. ABLi_addFunction("playdigitalmusic", false, "i", "i", execPlayDigitalMusic);
  5463. ABLi_addFunction("stopmusic", false, NULL, "i", execStopMusic);
  5464. ABLi_addFunction("playsoundeffect", false, "i", "i", execPlaySoundEffect);
  5465. ABLi_addFunction("playvideo", false, "C", "i", execPlayVideo);
  5466. ABLi_addFunction("setradio", false, "ib", "i", execSetRadio);
  5467. ABLi_addFunction("playspeech", false, "ii", "i", execPlaySpeech);
  5468. ABLi_addFunction("playbetty", false, "i", "i", execPlayBetty);
  5469. ABLi_addFunction("setobjectactive", false, "ib", "i", execSetObjectActive);
  5470. ABLi_addFunction("objecttypeid", false, "i", "i", execObjectTypeID);
  5471. ABLi_addFunction("getterrainobjectpartid", false, "ii", "i", execGetTerrainObjectPartID);
  5472. ABLi_addFunction("objectremove", false, "i", "i", execObjectRemove);
  5473. ABLi_addFunction("inarea", false, "iRri", "b", execInArea);
  5474. ABLi_addFunction("createinfantry", false, "Ri", "i", execCreateInfantry);
  5475. ABLi_addFunction("getsensorsworking", false, "i", "i", execGetSensorsWorking);
  5476. ABLi_addFunction("getcurrentbrvalue", false, "i", "i", execGetCurrentBRValue);
  5477. ABLi_addFunction("setcurrentbrvalue", false, "ii", NULL, execSetCurrentBRValue);
  5478. ABLi_addFunction("getarmorpts", false, "i", "i", execGetArmorPts);
  5479. ABLi_addFunction("getmaxarmor", false, "i", "i", execGetMaxArmor);
  5480. ABLi_addFunction("getpilotid", false, "i", "i", execGetPilotID);
  5481. ABLi_addFunction("getpilotwounds", false, "i", "r", execGetPilotWounds);
  5482. ABLi_addFunction("setpilotwounds", false, "ii", NULL, execSetPilotWounds);
  5483. ABLi_addFunction("getobjectactive", false, "i", "i", execGetObjectActive);
  5484. ABLi_addFunction("getobjectdamage", false, "i", "i", execGetObjectDamage);
  5485. ABLi_addFunction("getobjectdmgpts", false, "i", "i", execGetObjectDmgPts);
  5486. ABLi_addFunction("getobjectmaxdmg", false, "i", "i", execGetObjectMaxDmg);
  5487. ABLi_addFunction("setobjectdamage", false, "ii", "i", execSetObjectDamage);
  5488. ABLi_addFunction("getglobalvalue", false, "i", "r", execGetGlobalValue);
  5489. ABLi_addFunction("setglobalvalue", false, "i*", NULL, execSetGlobalValue);
  5490. ABLi_addFunction("setobjectivepos", false, "i***", NULL, execSetObjectivePos);
  5491. ABLi_addFunction("setsensorrange", false, "ir", NULL, execSetSensorRange);
  5492. ABLi_addFunction("settonnage", false, "ir", NULL, execSetTonnage);
  5493. ABLi_addFunction("setexplosiondamage", false, "ir", NULL, execSetExplosionDamage);
  5494. ABLi_addFunction("setexplosionradius", false, "ir", NULL, execSetExplosionRadius);
  5495. ABLi_addFunction("setsalvage", false, "iii", "b", execSetSalvage);
  5496. ABLi_addFunction("setsalvagestatus", false, "ib", "b", execSetSalvageStatus);
  5497. ABLi_addFunction("setanimation", false, "iii", NULL, execSetAnimation);
  5498. ABLi_addFunction("setrevealed", false, "i*R", NULL, execSetRevealed);
  5499. ABLi_addFunction("getsalvage", false, "iiII", NULL, execGetSalvage);
  5500. ABLi_addFunction("orderrefit", false, "ii", NULL, execOrderRefit);
  5501. ABLi_addFunction("setcaptured", false, "i", NULL, execSetCaptured);
  5502. ABLi_addFunction("ordercapture", false, "ii", NULL, execOrderCapture);
  5503. ABLi_addFunction("setcapturable", false, "ib", NULL, execSetCapturable);
  5504. ABLi_addFunction("iscaptured", false, "i", "i", execIsCaptured);
  5505. ABLi_addFunction("iscapturable", false, "ii", "b", execIsCapturable);
  5506. ABLi_addFunction("wasevercapturable", false, "i", "b", execWasEverCapturable);
  5507. ABLi_addFunction("setbuildingname", false, "ii", NULL, execSetBuildingName);
  5508. ABLi_addFunction("callstrike", false, "iirrrb", NULL, execCallStrike);
  5509. ABLi_addFunction("callstrikeex", false, "iirrrbr", NULL, execCallStrikeEx);
  5510. ABLi_addFunction("orderloadelementals", false, "i", NULL, execOrderLoadElementals);
  5511. ABLi_addFunction("orderdeployelementals", false, "i", NULL, execOrderDeployElementals);
  5512. ABLi_addFunction("addprisoner", false, "ii", "i", execAddPrisoner);
  5513. ABLi_addFunction("lockgateopen", false, "i", NULL, execLockGateOpen);
  5514. ABLi_addFunction("lockgateclosed", false, "i", NULL, execLockGateClosed);
  5515. ABLi_addFunction("releasegatelock", false, "i", NULL, execReleaseGateLock);
  5516. ABLi_addFunction("isgateopen", false, "i", "b", execIsGateOpen);
  5517. ABLi_addFunction("getrelativepositiontopoint", false, "RrriR", NULL, execGetRelativePositionToPoint);
  5518. ABLi_addFunction("getrelativepositiontoobject", false, "irriR", NULL, execGetRelativePositionToObject);
  5519. ABLi_addFunction("getunitstatus", false, "i", "r", execGetUnitStatus);
  5520. ABLi_addFunction("repair", false, "ir", NULL, execRepair);
  5521. ABLi_addFunction("getfixed", false, "iii", "i", execGetFixed);
  5522. ABLi_addFunction("getrepairstate", false, "i", "i", execGetRepairState);
  5523. ABLi_addFunction("isteamtargeting", false, "iii", "b", execIsTeamTargeting);
  5524. ABLi_addFunction("isteamcapturing", false, "iii", "b", execIsTeamCapturing);
  5525. ABLi_addFunction("sendmessage", false, "ii", NULL, execSendMessage);
  5526. ABLi_addFunction("getmessage", false, "i", "i", execGetMessage);
  5527. ABLi_addFunction("gethometeam", false, NULL, "i", execGetHomeTeam);
  5528. // ABLi_addFunction("getstrikes", false, "ii", "i", execGetStrikes);
  5529. // ABLi_addFunction("setstrikes", false, "iii", NULL, execSetStrikes);
  5530. // ABLi_addFunction("addstrikes", false, "iii", NULL, execAddStrikes);
  5531. ABLi_addFunction("isserver", false, NULL, "b", execIsServer);
  5532. ABLi_addFunction("calcpartid", false, "iiii", "i", execCalcPartID);
  5533. ABLi_addFunction("setdebugstring", false, "iiC", NULL, execSetDebugString);
  5534. ABLi_addFunction("break", false, NULL, NULL, execBreak);
  5535. ABLi_addFunction("pathexists", false, "iiiii", "i", execPathExists);
  5536. ABLi_addFunction("convertcoords", false, "iRI", "i", execConvertCoords);
  5537. ABLi_addFunction("newmoveto", true, "Ri", "i", execCoreMoveTo);
  5538. ABLi_addFunction("newmovetoobject", true, "ii", "i", execCoreMoveToObject);
  5539. ABLi_addFunction("newpower", true, "b", "i", execCorePower);
  5540. ABLi_addFunction("newattack", true, "ii", "i", execCoreAttack);
  5541. ABLi_addFunction("newcapture", true, "ii", "i", execCoreCapture);
  5542. ABLi_addFunction("newscan", true, "ii", "i", execCoreScan);
  5543. ABLi_addFunction("newcontrol", true, "ii", "i", execCoreControl);
  5544. ABLi_addFunction("coremoveto", true, "Ri", "i", execCoreMoveTo);
  5545. ABLi_addFunction("coremovetoobject", true, "ii", "i", execCoreMoveToObject);
  5546. ABLi_addFunction("corepower", true, "b", "i", execCorePower);
  5547. ABLi_addFunction("coreattack", true, "ii", "i", execCoreAttack);
  5548. ABLi_addFunction("corecapture", true, "ii", "i", execCoreCapture);
  5549. ABLi_addFunction("corescan", true, "ii", "i", execCoreScan);
  5550. ABLi_addFunction("corecontrol", true, "ii", "i", execCoreControl);
  5551. ABLi_addFunction("coreeject", true, NULL, "i", execCoreEject);
  5552. ABLi_addFunction("setpilotstate", false, "i", "i", execSetPilotState);
  5553. ABLi_addFunction("getpilotstate", false, NULL, "i", execGetPilotState);
  5554. ABLi_addFunction("getnextpilotevent", false, "I", "i", execGetNextPilotEvent);
  5555. ABLi_addFunction("settargetpriority", false, "iiiii", "i", execSetTargetPriority);
  5556. ABLi_addFunction("setdebugwindow", false, "ii", "i", execSetDebugWindow);
  5557. ABLi_addFunction("setmoviemode", false, NULL, NULL, execSetMovieMode);
  5558. ABLi_addFunction("endmoviemode", false, NULL, NULL, execEndMovieMode);
  5559. ABLi_addFunction("fadetocolor", false, "ir", NULL, execFadeToColor);
  5560. ABLi_addFunction("forcemovieend", false, NULL, "i", execForceMovieEnd);
  5561. ABLi_addFunction("getcameraposition", false, "R", NULL, execGetCameraPosition);
  5562. ABLi_addFunction("setcameraposition", false, "R", NULL, execSetCameraPosition);
  5563. ABLi_addFunction("setcameragoalposition", false, "Rr", NULL, execSetCameraGoalPosition);
  5564. ABLi_addFunction("getcameragoalposition", false, "R", NULL, execGetCameraGoalPosition);
  5565. ABLi_addFunction("getcamerarotation", false, "R", NULL, execGetCameraRotation);
  5566. ABLi_addFunction("setcamerarotation", false, "R", NULL, execSetCameraRotation);
  5567. ABLi_addFunction("setcameragoalrotation", false, "Rr", NULL, execSetCameraGoalRotation);
  5568. ABLi_addFunction("getcameragoalrotation", false, "R", NULL, execGetCameraGoalRotation);
  5569. ABLi_addFunction("getcamerazoom", false, NULL, "r", execGetCameraZoom);
  5570. ABLi_addFunction("setcamerazoom", false, "r", NULL, execSetCameraZoom);
  5571. ABLi_addFunction("getcameragoalzoom", false, NULL, "r", execGetCameraGoalZoom);
  5572. ABLi_addFunction("setcameragoalzoom", false, "rr", NULL, execSetCameraGoalZoom);
  5573. ABLi_addFunction("setcameravelocity", false, "R", NULL, execSetCameraVelocity);
  5574. ABLi_addFunction("getcameravelocity", false, "R", NULL, execGetCameraVelocity);
  5575. ABLi_addFunction("setcameragoalvelocity", false, "Rr", NULL, execSetCameraGoalVelocity);
  5576. ABLi_addFunction("getcameragoalvelocity", false, "R", NULL, execGetCameraGoalVelocity);
  5577. ABLi_addFunction("setcameralookobject", false, "i", NULL, execSetCameraLookObject);
  5578. ABLi_addFunction("getcameralookobject", false, NULL, "i", execGetCameraLookObject);
  5579. ABLi_addFunction("getcameraframelength", false, NULL, "r", execGetCameraFrameLength);
  5580. ABLi_addFunction("getmissionwon", false, NULL, "b", execGetMissionWon);
  5581. ABLi_addFunction("getmissionlost", false, NULL, "b", execGetMissionLost);
  5582. ABLi_addFunction("getobjectivesuccess", false, NULL, "b", execGetObjectiveSuccess);
  5583. ABLi_addFunction("getobjectivefailed", false, NULL, "b", execGetObjectiveFailed);
  5584. ABLi_addFunction("getenemydestroyed", false, NULL, "b", execGetEnemyDestroyed);
  5585. ABLi_addFunction("getfriendlydestroyed", false, NULL, "b", execGetFriendlyDestroyed);
  5586. ABLi_addFunction("getplayerincombat", false, NULL, "b", execPlayerInCombat);
  5587. ABLi_addFunction("getsensorsactive", false, NULL, "b", execGetSensorsActive);
  5588. ABLi_addFunction("getcurrentmusicid", false, NULL, "i", execGetCurrentMusicId);
  5589. ABLi_addFunction("getmissiontune", false, NULL, "i", execGetMissionTuneId);
  5590. ABLi_addFunction("requesthelp", false, "iRrRri", "r", execRequestHelp);
  5591. ABLi_addFunction("requesttarget", false, "Rr", "i", execRequestTarget);
  5592. ABLi_addFunction("requestshelter", false, "*", "i", execRequestShelter);
  5593. ABLi_addFunction("mcprint", false, "?", NULL, execMCPrint);
  5594. ABLi_addFunction("getmissionstatus", false, NULL, "i", execGetMissionStatus);
  5595. ABLi_addFunction("addtriggerarea", false, "iiiiii", "i", execAddTriggerArea);
  5596. ABLi_addFunction("istriggerareahit", false, "i", "b", execIsTriggerAreaHit);
  5597. ABLi_addFunction("resettriggerarea", false, "i", NULL, execResetTriggerArea);
  5598. ABLi_addFunction("removetriggerarea", false, "i", NULL, execRemoveTriggerArea);
  5599. ABLi_addFunction("getweapons", false, "Ii", "i", execGetWeapons);
  5600. ABLi_addFunction("setmovearea", false, "Rr", NULL, execSetMoveArea);
  5601. ABLi_addFunction("getweaponsstatus", false, "I", "i", execGetWeaponsStatus);
  5602. ABLi_addFunction("cleartacorder", false, NULL, NULL, execClearTacOrder);
  5603. ABLi_addFunction("playwave", false, "Ci", "i", execPlayWave);
  5604. ABLi_addFunction("objectteam", false, "i", "i", execObjectTeam);
  5605. ABLi_addFunction("setwillhelp", false, "b", "b", execSetWillHelp);
  5606. ABLi_addFunction("getlastscan", false, NULL, "i", execGetLastScan);
  5607. ABLi_addFunction("getmapinfo", false, "I", NULL, execGetMapInfo);
  5608. ABLi_addFunction("getgeneralalarm", false, NULL, "i", execGetGeneralAlarm);
  5609. ABLi_addFunction("setgeneralalarm", false, "i", NULL, execSetGeneralAlarm);
  5610. ABLi_addFunction("isoffmap", false, "R", "b", execIsOffMap);
  5611. ABLi_addFunction("setgoalplanning", false, "b", "b", execSetGoalPlanning);
  5612. ABLi_addFunction("seteject", false, "b", "b", execSetEject);
  5613. ABLi_addFunction("setkeepmoving", false, "b", "b", execSetKeepMoving);
  5614. //Tutorial Functions
  5615. ABLi_addFunction("animationcallout", false, "ibbri", "b", execAnimationCallout);
  5616. ABLi_addFunction("tutorialtext", false, "i", NULL, execTutorialText);
  5617. ABLi_addFunction("guiisaoe", false, NULL, "b", execGUIIsAOEStyle);
  5618. ABLi_addFunction("logisticsscreenid", false, NULL, "i", execLogisticsScreenId);
  5619. ABLi_addFunction("logisticsanimationcallout", false, "ibri", "b", execLogisticsAnimationCallout);
  5620. ABLi_addFunction("logisticsincallout", false, NULL, "b", execLogisticsInCallout);
  5621. ABLi_addFunction("isplayingvoiceover", false, NULL, "b", execIsPlayingVoiceOver);
  5622. ABLi_addFunction("getlogisticstime", false, NULL, "r", execGetLogisticsTime);
  5623. ABLi_addFunction("stopvoiceover", false, NULL, NULL, execStopVoiceOver);
  5624. ABLi_addFunction("incallout", false, NULL, "b", execInCallout);
  5625. ABLi_addFunction("setinvulnerable", false, "b", NULL, execSetInvulnerable);
  5626. ABLi_addFunction("freezegui", false, "b", NULL, execFreezeGUI);
  5627. //static long Godzilla = 120;
  5628. //static long GodzillaList[5] = {10, 20, 30, 40, 50};
  5629. //ABLi_registerInteger("godzilla", &Godzilla);
  5630. //ABLi_registerInteger("godzillalist", &GodzillaList, 5);
  5631. }
  5632. //*****************************************************************************
  5633. void closeABL (void) {
  5634. ABLi_close();
  5635. if (AblSymbolHeap) {
  5636. delete AblSymbolHeap;
  5637. AblSymbolHeap = NULL;
  5638. }
  5639. if (AblStackHeap) {
  5640. delete AblStackHeap;
  5641. AblStackHeap = NULL;
  5642. }
  5643. if (AblCodeHeap) {
  5644. delete AblCodeHeap;
  5645. AblCodeHeap = NULL;
  5646. }
  5647. }
  5648. //*****************************************************************************