| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150 |
- /*
- ** Command & Conquer Red Alert(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /* $Header: /CounterStrike/INFANTRY.CPP 2 3/03/97 10:35p Joe_bostic $ */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : INFANTRY.CPP *
- * *
- * Programmer : Joe L. Bostic *
- * *
- * Start Date : August 15, 1994 *
- * *
- * Last Update : October 28, 1996 [JLB] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * InfantryClass::AI -- Handles the infantry non-graphic related AI processing. *
- * InfantryClass::Active_Click_With -- Handles action when clicking with infantry soldier. *
- * InfantryClass::Assign_Destination -- Gives the infantry a movement destination. *
- * InfantryClass::Assign_Target -- Gives the infantry a combat target. *
- * InfantryClass::Can_Enter_Cell -- Determines if the infantry can enter the cell specified. *
- * InfantryClass::Can_Fire -- Can the infantry fire its weapon? *
- * InfantryClass::Class_Of -- Returns the class reference for this object. *
- * InfantryClass::Clear_Occupy_Bit -- Clears occupy bit and given cell *
- * InfantryClass::Debug_Dump -- Displays debug information about infantry unit. *
- * InfantryClass::Detach -- Removes the specified target from targeting computer. *
- * InfantryClass::Do_Action -- Launches the infantry into an animation sequence. *
- * InfantryClass::Doing_AI -- Handles the animation AI processing. *
- * InfantryClass::Draw_It -- Draws a unit object. *
- * InfantryClass::Edge_Of_World_AI -- Detects when infantry has left the map. *
- * InfantryClass::Enter_Idle_Mode -- The infantry unit enters idle mode by this routine. *
- * InfantryClass::Fear_AI -- Process any fear related affects on this infantry. *
- * InfantryClass::Fire_At -- Fires projectile from infantry unit. *
- * InfantryClass::Firing_AI -- Handles firing and combat AI for the infantry. *
- * InfantryClass::Full_Name -- Fetches the full name of the infantry unit. *
- * InfantryClass::Get_Image_Data -- Fetches the image data for this infantry unit. *
- * InfantryClass::Greatest_Threat -- Determines greatest threat (target) for infantry unit. *
- * InfantryClass::InfantryClass -- The constructor for infantry objects. *
- * InfantryClass::Init -- Initialize the infantry object system. *
- * InfantryClass::Is_Ready_To_Random_Anima -- Checks to see if it is ready to perform an idle*
- * InfantryClass::Limbo -- Performs cleanup operations needed when limboing. *
- * InfantryClass::Mission_Attack -- Intercept attack mission for special handling. *
- * InfantryClass::Movement_AI -- This routine handles all infantry movement logic. *
- * InfantryClass::Overlap_List -- The list of cells that the infantry overlaps, but doesn't o*
- * InfantryClass::Paradrop -- Handles paradropping infantry. *
- * InfantryClass::Per_Cell_Process -- Handles special operations that occur once per cell. *
- * InfantryClass::Random_Animate -- Randomly animate the infantry (maybe) *
- * InfantryClass::Read_INI -- Reads units from scenario INI file. *
- * InfantryClass::Response_Attack -- Plays infantry audio response to attack order. *
- * InfantryClass::Response_Move -- Plays infantry response to movement order. *
- * InfantryClass::Response_Select -- Plays infantry audio response due to being selected. *
- * InfantryClass::Scatter -- Causes the infantry to scatter to nearby cell. *
- * InfantryClass::Set_Occupy_Bit -- Sets the occupy bit cell and bit pos *
- * InfantryClass::Set_Primary_Facing -- Change infantry primary facing -- always and instantl*
- * InfantryClass::Shape_Number -- Fetch the shape number for this infantry. *
- * InfantryClass::Start_Driver -- Handles giving immediate destination and move orders. *
- * InfantryClass::Stop_Driver -- Stops the infantry from moving any further. *
- * InfantryClass::Take_Damage -- Applies damage to the infantry unit. *
- * InfantryClass::Unlimbo -- Unlimbo infantry unit in legal sub-location. *
- * InfantryClass::What_Action -- Determines what action to perform for the cell specified. *
- * InfantryClass::What_Action -- Infantry units might be able to capture -- check. *
- * InfantryClass::Write_INI -- Store the infantry to the INI database. *
- * InfantryClass::operator delete -- Returns the infantry object back to the free pool *
- * InfantryClass::operator new -- Allocates an infantry object from the free pool. *
- * InfantryClass::~InfantryClass -- Default destructor for infantry units. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- int const InfantryClass::HumanShape[32] = {0,0,7,7,7,7,6,6,6,6,5,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,1,1,1,1,1,0};
- /***************************************************************************
- ** This is the array of constant data associated with infantry maneuvers. It
- ** specifies the frame rate as well as if the animation can be aborted.
- */
- // interruptible, mobile, randomstart, rate
- DoStruct const InfantryClass::MasterDoControls[DO_COUNT] = {
- {true, false, false, 0}, // DO_STAND_READY
- {true, false, false, 0}, // DO_STAND_GUARD
- {true, false, false, 0}, // DO_PRONE
- {true, true, true, 2}, // DO_WALK
- {true, false, false, 1}, // DO_FIRE_WEAPON
- {false, true, false, 2}, // DO_LIE_DOWN
- {true, true, true, 2}, // DO_CRAWL
- {false, false, false, 3}, // DO_GET_UP
- {true, false, false, 1}, // DO_FIRE_PRONE
- {true, false, false, 2}, // DO_IDLE1
- {true, false, false, 2}, // DO_IDLE2
- {false, false, false, 2}, // DO_GUN_DEATH
- {false, false, false, 2}, // DO_EXPLOSION_DEATH
- {false, false, false, 2}, // DO_EXPLOSION2_DEATH
- {false, false, false, 2}, // DO_GRENADE_DEATH
- {false, false, false, 2}, // DO_FIRE_DEATH
- {false, false, false, 2}, // DO_GESTURE1
- {false, false, false, 2}, // DO_SALUTE1
- {false, false, false, 2}, // DO_GESTURE2
- {false, false, false, 2}, // DO_SALUTE2
- {false, false, false, 2}, // DO_DOG_MAUL
- };
- #ifdef CHEAT_KEYS
- /***********************************************************************************************
- * InfantryClass::Debug_Dump -- Displays debug information about infantry unit. *
- * *
- * This routine is used by the debug version to display pertinent information about the *
- * infantry unit. *
- * *
- * INPUT: mono -- The monochrome screen to display the debug information to. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Debug_Dump(MonoClass * mono) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- mono->Set_Cursor(0, 0);
- mono->Print(Text_String(TXT_DEBUG_INFANTRY));
- mono->Set_Cursor(1, 11);mono->Printf("%3d", Doing);
- mono->Set_Cursor(8, 11);mono->Printf("%3d", Fear);
- mono->Fill_Attrib(66, 13, 12, 1, IsTechnician ? MonoClass::INVERSE : MonoClass::NORMAL);
- mono->Fill_Attrib(66, 14, 12, 1, IsStoked ? MonoClass::INVERSE : MonoClass::NORMAL);
- mono->Fill_Attrib(66, 15, 12, 1, IsProne ? MonoClass::INVERSE : MonoClass::NORMAL);
- FootClass::Debug_Dump(mono);
- }
- #endif
- /***********************************************************************************************
- * InfantryClass::InfantryClass -- The constructor for infantry objects. *
- * *
- * This is the constructor used when creating an infantry unit. All values are required *
- * except for facing and position. If these are absent, then the infantry is created in *
- * a state of limbo -- not placed upon the map. *
- * *
- * INPUT: see below... *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- InfantryClass::InfantryClass(InfantryType classid, HousesType house) :
- FootClass(RTTI_INFANTRY, Infantry.ID(this), house),
- Class(InfantryTypes.Ptr((int)classid)),
- Doing(DO_NOTHING),
- Comment(0),
- IsTechnician(false),
- IsStoked(false),
- IsProne(false),
- IsZoneCheat(false),
- WasSelected(false),
- Fear(FEAR_NONE)
- {
- House->Tracking_Add(this);
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- IsCloakable = Class->IsCloakable;
- #endif
- /*
- ** For two shooters, clear out the second shot flag -- it will be set the first time
- ** the object fires. For non two shooters, set the flag since it will never be cleared
- ** and the second shot flag tells the system that normal rearm times apply -- this is
- ** what is desired for non two shooters.
- */
- if (Class->Is_Two_Shooter()) {
- IsSecondShot = false;
- } else {
- IsSecondShot = true;
- }
- Strength = Class->MaxStrength;
- /*
- ** Civilians carry much less ammo than soldiers do.
- */
- Ammo = Class->MaxAmmo;
- }
- /***********************************************************************************************
- * InfantryClass::~InfantryClass -- Default destructor for infantry units. *
- * *
- * This is the default destructor for infantry type units. It will put the infantry into *
- * a limbo state if it isn't already in that state and the game is still active. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/10/1995 JLB : Created. *
- *=============================================================================================*/
- InfantryClass::~InfantryClass(void)
- {
- if (GameActive && Class.Is_Valid()) {
- /*
- ** Remove this member from any team it may be associated with. This must occur at the
- ** top most level of the inheritance hierarchy because it may call virtual functions.
- */
- if (Team.Is_Valid()) {
- Team->Remove(this);
- Team = NULL;
- }
- House->Tracking_Remove(this);
- Limbo();
- }
- ID = -1;
- }
- /***********************************************************************************************
- * InfantryClass::operator new -- Allocates an infantry object from the free pool. *
- * *
- * This will allocate an infantry object from the infantry object free pool. If there is *
- * no available slot, then NULL is returned. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with a pointer to the allocated infantry object or NULL if none could be *
- * allocated. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- void * InfantryClass::operator new(size_t)
- {
- void * ptr = Infantry.Allocate();
- if (ptr != NULL) {
- ((InfantryClass *)ptr)->IsActive = true;
- }
- return(ptr);
- }
- /***********************************************************************************************
- * InfantryClass::operator delete -- Returns the infantry object back to the free pool *
- * *
- * This routine is used return an infantry object back to the system. *
- * *
- * INPUT: ptr -- Pointer to the infantry object to delete. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::operator delete(void * ptr)
- {
- if (ptr != NULL) {
- ((InfantryClass *)ptr)->IsActive = false;
- }
- Infantry.Free((InfantryClass *)ptr);
- }
- /***********************************************************************************************
- * InfantryClass::Take_Damage -- Applies damage to the infantry unit. *
- * *
- * This routine applies the damage specified to the infantry object. It is possible that *
- * this routine will DESTROY the infantry unit in the process. *
- * *
- * INPUT: damage -- The damage points to inflict. *
- * *
- * distance -- The distance from the damage center point to the object's center point.*
- * *
- * warhead -- The warhead type that is inflicting the damage. *
- * *
- * source -- Who is responsible for inflicting the damage. *
- * *
- * OUTPUT: bool; Was the infantry unit destroyed by this damage? *
- * *
- * WARNINGS: Since the infantry unit could be destroyed by this routine, be sure to check *
- * for this in the code that follows the call to Take_Damage(). *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- * 11/22/1994 JLB : Shares base damage handler for techno objects. *
- * 03/31/1995 JLB : Revenge factor. *
- *=============================================================================================*/
- ResultType InfantryClass::Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source, int forced)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- ResultType res = RESULT_NONE;
- /*
- ** Prone infantry take only half damage, but never below one damage point.
- */
- if (IsProne && damage > 0) {
- damage = damage * Rule.ProneDamageBias;
- }
- /*
- ** If we're taking damage from a dog, we have to decide if we're the
- ** target of the dog. Dogs don't spill collateral damage onto anyone
- ** else, so if we're the target of a valid dog, take full damage, but if
- ** we're not the target, or the dog doesn't exist, then take no damage.
- */
- if (source != NULL && source->What_Am_I() == RTTI_INFANTRY && ((InfantryClass *)source)->Class->IsDog) {
- if (source->TarCom == As_Target()) {
- damage = Strength;
- } else {
- damage = 0;
- }
- }
- res = FootClass::Take_Damage(damage, distance, warhead, source, forced);
- /*
- ** hack for dog: if you're hit by a dog, and you're the target, your
- ** damage gets upped to max.
- */
- if (res == RESULT_NONE) return(res);
- if (res == RESULT_DESTROYED) {
- if (*this == INFANTRY_TANYA) {
- IsTanyaDead = true;
- }
- Death_Announcement(source);
- Stop_Driver();
- Stun();
- Mission = MISSION_NONE;
- Assign_Mission(MISSION_GUARD);
- Commence();
- VocType sound;
- VocType altsound;
- sound = Sim_Random_Pick(VOC_SCREAM1, VOC_SCREAM11);
- altsound = VOC_YELL1;
- if (*this == INFANTRY_TANYA) {
- sound = altsound = VOC_TANYA_DIE;
- }
- if (Class->IsDog) {
- sound = altsound = VOC_DOG_HURT;
- }
- /*
- ** The type of warhead determines the animation the infantry
- ** will perform when killed.
- */
- bool delthis = false;
- TARGET us = As_Target();
- switch (WarheadTypeClass::As_Pointer(warhead)->InfantryDeath) {
- default:
- case 0:
- delthis = true;
- break;
- case 1:
- Sound_Effect(sound, Coord);
- Do_Action(DO_GUN_DEATH, true);
- break;
- case 2:
- Sound_Effect(sound, Coord);
- Do_Action(DO_EXPLOSION_DEATH, true);
- break;
- case 3:
- Sound_Effect(sound, Coord);
- Do_Action(DO_GRENADE_DEATH, true);
- break;
- case 4:
- Sound_Effect(altsound, Coord);
- Do_Action(DO_FIRE_DEATH, true);
- break;
- case 5:
- Sound_Effect(sound, Coord);
- AnimType anim = ANIM_ELECT_DIE;
- if (Class->IsDog) anim = ANIM_DOG_ELECT_DIE;
- new AnimClass(anim, Coord);
- delthis = true;
- break;
- }
- if (delthis) {
- delete this;
- }
- return(res);
- }
- /*
- ** When infantry gets hit, it gets scared.
- */
- if (res != RESULT_DESTROYED) {
- COORDINATE source_coord = (source) ? source->Coord : NULL;
- /*
- ** If an engineer is damaged and it is just sitting there, then tell it
- ** to go do something since it will definitely die if it doesn't.
- */
- if (!House->IsHuman && *this == INFANTRY_RENOVATOR && (Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA)) {
- Assign_Mission(MISSION_HUNT);
- }
- if (source != NULL) {
- Scatter(source_coord);
- }
- if (source != NULL && Fear < FEAR_SCARED) {
- if (Class->IsFraidyCat) {
- Fear = FEAR_PANIC;
- } else {
- Fear = FEAR_SCARED;
- }
- } else {
- /*
- ** Increase the fear of the infantry by a bit. The fear increases more
- ** quickly if the infantry is damaged.
- */
- int morefear = FEAR_ANXIOUS;
- if (Health_Ratio() > Rule.ConditionRed) morefear /= 2;
- if (Health_Ratio() > Rule.ConditionYellow) morefear /= 2;
- Fear = FearType(min((int)Fear + morefear, FEAR_MAXIMUM));
- }
- }
- return(res);
- }
- /***********************************************************************************************
- * InfantryClass::Shape_Number -- Fetch the shape number for this infantry. *
- * *
- * This will determine the shape number to use for this infantry soldier. The shape number *
- * is relative to the shape file associated with this infantry unit. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the shape number for this infantry object to be used when drawing. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- int InfantryClass::Shape_Number(void) const
- {
- /*
- ** Fetch the shape pointer to use for the infantry. This is controlled by what
- ** choreograph sequence the infantry is performing, it's facing, and whether it
- ** is prone.
- */
- DoType doit = Doing;
- if (doit == DO_NOTHING) doit = DO_STAND_READY;
- /*
- ** The infantry shape is always modulo the number of animation frames
- ** of the action stage that the infantry is doing.
- */
- int shapenum = Fetch_Stage() % max(Class->DoControls[doit].Count, 1);
- /*
- ** If facing makes a difference, then the shape number will be incremented
- ** by the facing accordingly.
- */
- if (Class->DoControls[doit].Jump) {
- shapenum += HumanShape[Dir_To_32(PrimaryFacing.Current())] * Class->DoControls[doit].Jump;
- }
- /*
- ** Finally, the shape number is biased according to the starting frame number for
- ** that action in the infantry shape file.
- */
- shapenum += Class->DoControls[doit].Frame;
- /*
- ** Return with the final infantry shape number.
- */
- return(shapenum);
- }
- /***********************************************************************************************
- * InfantryClass::Draw_It -- Draws a unit object. *
- * *
- * This routine is the one that actually draws a unit object. It displays the unit *
- * according to its current state flags and centered at the location specified. *
- * *
- * INPUT: x,y -- The X and Y coordinate of where to draw the unit. *
- * *
- * window -- The clipping window to use. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 06/20/1994 JLB : Created. *
- * 06/27/1994 JLB : Takes a window parameter. *
- * 08/15/1994 JLB : Converted to infantry support. *
- * 08/14/1996 JLB : Simplified. *
- *=============================================================================================*/
- void InfantryClass::Draw_It(int x, int y, WindowNumberType window) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Verify the legality of the unit class by seeing if there is shape imagery for it. If
- ** there is no shape image, then it certainly can't be drawn -- bail.
- */
- void const * shapefile = Get_Image_Data();
- if (shapefile == NULL) return;
- y += 4;
- x -= 2;
- /*
- ** Actually draw the root body of the unit.
- */
- Techno_Draw_Object(shapefile, Shape_Number(), x, y, window);
- FootClass::Draw_It(x, y, window);
- }
- /***********************************************************************************************
- * InfantryClass::Per_Cell_Process -- Handles special operations that occur once per cell. *
- * *
- * This routine will handle any special operations that need to be performed once each *
- * cell travelled. This includes radioing a transport that it is now clear and the *
- * transport is free to leave. *
- * *
- * INPUT: why -- Specifies the circumstances under which this routine was called. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- * 03/01/1995 JLB : Capture building options. *
- * 05/31/1995 JLB : Capture is always successful now. *
- *=============================================================================================*/
- void InfantryClass::Per_Cell_Process(PCPType why)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- BStart(BENCH_PCP);
- CellClass * cellptr = &Map[Coord];
- if (why == PCP_END) {
- /*
- ** If the infantry unit is entering a cell that contains the building it is trying to
- ** capture, then capture it.
- */
- if (Mission == MISSION_CAPTURE) {
- TechnoClass * tech = cellptr->Cell_Building();
- if (tech == NULL) tech = cellptr->Cell_Techno();
- if (tech != NULL && (tech->As_Target() == NavCom || tech->As_Target() == TarCom)) {
- if (*this == INFANTRY_RENOVATOR) {
- /*
- ** An engineer will either mega-repair a friendly or allied
- ** building or it will damage/capture an enemy building. Whether
- ** it damages or captures depends on how badly damaged the
- ** enemy building is.
- */
- #ifdef FIXIT_ENGINEER_CAPTURE
- if (House->Is_Ally(tech)) {
- #else
- if (tech->House->Is_Ally(House)) {
- #endif
- tech->Renovate();
- } else {
- bool iscapturable = false;
- if (tech->What_Am_I() == RTTI_BUILDING) {
- iscapturable = ((BuildingClass *)tech)->Class->IsCaptureable;
- }
- #ifdef FIXIT_ENGINEER // checked - ajw 9/28/98
- if (tech->Health_Ratio() <= EngineerCaptureLevel && iscapturable) {
- #else
- if (tech->Health_Ratio() <= Rule.ConditionRed && iscapturable) {
- #endif
- if (tech->Trigger.Is_Valid()) {
- tech->Trigger->Spring(TEVENT_PLAYER_ENTERED, this);
- }
- tech->House->IsThieved = true;
- tech->Captured(House);
- } else {
- #ifdef FIXIT_ENGINEER // checked - ajw 9/28/98
- int damage = min( (tech->Techno_Type_Class()->MaxStrength) * EngineerDamage, tech->Strength-1);
- #else
- int damage = min( (tech->Techno_Type_Class()->MaxStrength) / 3, tech->Strength-1);
- #endif
- tech->Take_Damage(damage, 0, WARHEAD_HE, this, true);
- }
- BEnd(BENCH_PCP);
- delete this;
- return;
- }
- } else {
- if (*this != INFANTRY_SPY && tech->Trigger.Is_Valid()) {
- tech->Trigger->Spring(TEVENT_PLAYER_ENTERED, this);
- }
- if (*this == INFANTRY_SPY) {
- int housespy = (1 << (House->Class->House));
- // tech->House->IsSpied = true;
- if (tech->Trigger.Is_Valid()) {
- tech->Trigger->Spring(TEVENT_SPIED, this);
- }
- if (IsOwnedByPlayer) Speak(VOX_BUILDING_INFILTRATED);
- tech->Mark(MARK_OVERLAP_UP);
- tech->SpiedBy |= housespy;
- tech->Mark(MARK_OVERLAP_DOWN);
- if (tech->What_Am_I() == RTTI_BUILDING) {
- StructType build = *(BuildingClass *)tech;
- if (build == STRUCT_RADAR /* || build == STRUCT_EYE */ ) {
- tech->House->RadarSpied |= housespy;
- }
- // If they're spying on a sub pen, give 'em a sonar pulse
- if (build == STRUCT_SUB_PEN) {
- House->SuperWeapon[SPC_SONAR_PULSE].Enable(false, true, false);
- if (IsOwnedByPlayer) {
- Map.Add(RTTI_SPECIAL, SPC_SONAR_PULSE);
- Map.Column[1].Flag_To_Redraw();
- }
- }
- }
- } else {
- if (*this == INFANTRY_THIEF) { // Thief just raided a storage facility
- tech->House->IsThieved = true;
- if (tech->What_Am_I() == RTTI_BUILDING) {
- BuildingClass * bldg = (BuildingClass *)tech;
- if (bldg->Class->Capacity) {
- /*
- ** If we just raided a storage facility (refinery or silo)
- ** then give the thief up to half the capacity of the
- ** storage facility.
- */
- if (IsOwnedByPlayer || bldg->IsOwnedByPlayer) Speak(VOX_MONEY_STOLEN);
- #ifdef OBSOLETE
- long capacity = bldg->Class->Capacity * 256;
- capacity /= (bldg->House->Tiberium+1);
- int bldgcap = bldg->Class->Capacity;
- long cash = (bldgcap * 256) / (capacity+1);
- if (cash > (bldgcap / 2)) cash = bldgcap / 2;
- #else
- long cash = bldg->House->Available_Money() / 2;
- #endif
- bldg->House->Spend_Money(cash);
- House->Refund_Money(cash);
- }
- }
- }
- }
- }
- BEnd(BENCH_PCP);
- delete this;
- return;
- } else {
- #ifdef OBSOLETE
- // are we trying to repair a bridge?
- if (Is_Target_Cell(TarCom) ) {
- CELL cell = Coord_Cell(Coord);
- if (cell == ::As_Cell(NavCom)) {
- TemplateType tt = cellptr->TType;
- int icon = cellptr->TIcon;
- int w = TemplateTypeClass::As_Reference(cellptr->TType).Width;
- int h = TemplateTypeClass::As_Reference(cellptr->TType).Height;
- cell -= icon % w;
- cell -= MAP_CELL_W * (icon / w);
- if (tt == TEMPLATE_BRIDGE1D || tt == TEMPLATE_BRIDGE2D) {
- new TemplateClass(TemplateType(cellptr->TType-1), cell);
- Map.Zone_Reset(MZONEF_ALL);
- delete this;
- return;
- } else {
- // Trying to repair multi-segment bridge. Look for the
- // start tile, then fix it, and determine the direction to
- // go in and repair it all that way.
- TemplateType newtt = TEMPLATE_BRIDGE_1A;
- int xmov = -1; // coords to move to for next template
- int ymov = 2;
- bool valid = false;
- switch (tt) {
- case TEMPLATE_BRIDGE_1B:
- case TEMPLATE_BRIDGE_1C:
- valid = true;
- break;
- case TEMPLATE_BRIDGE_2B:
- case TEMPLATE_BRIDGE_2C:
- newtt = TEMPLATE_BRIDGE_2A;
- xmov = 2;
- ymov = -1;
- valid = true;
- break;
- case TEMPLATE_BRIDGE_3C:
- case TEMPLATE_BRIDGE_3D:
- newtt = TEMPLATE_BRIDGE_3A;
- valid = true;
- break;
- case TEMPLATE_BRIDGE_3E:
- newtt = TEMPLATE_BRIDGE_3A;
- xmov = 2;
- ymov = -1;
- valid = true;
- break;
- }
- // Did we find a valid repairable bridge piece?
- if (valid) {
- bool doing = true;
- while (doing) {
- new TemplateClass(TemplateType(newtt), cell);
- cell += (MAP_CELL_W * ymov) + xmov;
- if (xmov < 0) {
- xmov = -1;
- ymov = 1;
- } else {
- xmov = 1;
- ymov = -1;
- }
- cellptr = &Map[cell];
- tt = cellptr->TType;
- if ((tt >= TEMPLATE_BRIDGE_3B && tt <= TEMPLATE_BRIDGE_3F) ||
- tt == TEMPLATE_BRIDGE_1B || tt == TEMPLATE_BRIDGE_1C ||
- tt == TEMPLATE_BRIDGE_2B || tt == TEMPLATE_BRIDGE_2C ) {
- if (tt >= TEMPLATE_BRIDGE_3B) {
- newtt = TEMPLATE_BRIDGE_3A;
- } else {
- if (tt < TEMPLATE_BRIDGE_2A) {
- newtt = TEMPLATE_BRIDGE_1A;
- } else {
- newtt = TEMPLATE_BRIDGE_2A;
- }
- }
- icon = cellptr->TIcon;
- w = TemplateTypeClass::As_Reference(cellptr->TType).Width;
- h = TemplateTypeClass::As_Reference(cellptr->TType).Height;
- cell -= icon % w;
- cell -= MAP_CELL_W * (icon / w);
- } else {
- doing = false;
- }
- }
- Map.Zone_Reset(MZONEF_ALL);
- delete this;
- return;
- }
- }
- }
- } else {
- #endif
- if (!Target_Legal(NavCom)) {
- Enter_Idle_Mode();
- if (Map[Coord].Cell_Building()) {
- Scatter(0, true);
- }
- }
- #ifdef OBSOLETE
- }
- #endif
- }
- }
- /*
- ** Infantry entering a transport vehicle will break radio contact
- ** at attach itself to the transporter.
- */
- TechnoClass * techno = Contact_With_Whom();
- if (Mission == MISSION_ENTER && techno != NULL && Coord_Cell(Coord) == Coord_Cell(techno->Coord) && techno == As_Techno(NavCom)) {
- if (Transmit_Message(RADIO_IM_IN) == RADIO_ATTACH) {
- Limbo();
- techno->Attach(this);
- }
- BEnd(BENCH_PCP);
- return;
- }
- /*
- ** If the infantry unit is entering a cell that contains the building it is trying to
- ** sabotage, then sabotage it.
- */
- if (Mission == MISSION_SABOTAGE) {
- BuildingClass * building = cellptr->Cell_Building();
- if (building != NULL && building->As_Target() == NavCom) {
- if (!building->IronCurtainCountDown && building->Mission != MISSION_DECONSTRUCTION) {
- building->IsGoingToBlow = true;
- building->Clicked_As_Target((Rule.C4Delay * TICKS_PER_MINUTE) / 2);
- building->CountDown = Rule.C4Delay * TICKS_PER_MINUTE;
- building->WhomToRepay = As_Target();
- }
- NavCom = TARGET_NONE;
- Do_Uncloak();
- Arm = Rearm_Delay(true);
- Scatter(building->Center_Coord(), true, true); // RUN AWAY!
- BEnd(BENCH_PCP);
- return;
- } else {
- if (::As_Target(Coord_Cell(Center_Coord())) == NavCom) {
- Explosion_Damage(Coord, Rule.BridgeStrength, this, WARHEAD_HE);
- Stop_Driver();
- Scatter(Adjacent_Cell(Coord, PrimaryFacing), true, true);
- Assign_Mission(MISSION_MOVE);
- CELL cell = Coord_Cell(Center_Coord());
- CellClass * cellptr = &Map[cell];
- if (!Target_Legal(NavCom) || Map[As_Cell(NavCom)].Land_Type() == LAND_WATER) {
- Mark(MARK_DOWN); // Needed only so that Tanya will get destroyed by the explosion.
- }
- Explosion_Damage(Coord, Rule.BridgeStrength, NULL, WARHEAD_HE);
- Explosion_Damage(Coord, Rule.BridgeStrength, NULL, WARHEAD_HE);
- if (!IsActive) {
- BEnd(BENCH_PCP);
- return;
- }
- Mark(MARK_DOWN);
- }
- }
- }
- /*
- ** If this unit is on a teather, then cut it at this time so that
- ** the "parent" unit is free to proceed. Note that the parent
- ** unit might actually be a building.
- */
- if (IsTethered) {
- Transmit_Message(RADIO_UNLOADED);
- if (House->ActLike == HOUSE_USSR || House->ActLike == HOUSE_UKRAINE) {
- Do_Action(DO_GESTURE1);
- } else {
- Do_Action(DO_GESTURE2);
- }
- /*
- ** Special voice play.
- */
- if (*this == INFANTRY_TANYA) {
- Sound_Effect(VOC_TANYA_LAUGH, Coord);
- }
- /*
- ** If the cell is now full of infantry, tell them all to scatter
- ** in order to make room for more.
- */
- if ((cellptr->Flag.Composite & 0x01F) == 0x01F) {
- cellptr->Incoming(0, true, true);
- // cellptr->Incoming(0, true);
- }
- }
- /*
- ** When the infantry reaches the center of the cell, it may begin a new mission.
- */
- if (MissionQueue == MISSION_NONE && !Target_Legal(NavCom) && !Target_Legal(TarCom) && !In_Radio_Contact()) {
- Enter_Idle_Mode();
- }
- Commence();
- /*
- ** If entering a cell with a land mine in it, blow up the mine.
- */
- BuildingClass * bldng = cellptr->Cell_Building();
- if (bldng != NULL && *bldng == STRUCT_APMINE) {
- /*
- ** Show the animation and get rid of the land mine
- */
- COORDINATE blcoord = bldng->Center_Coord();
- new AnimClass(Combat_Anim(Rule.APMineDamage, WARHEAD_HE, cellptr->Land_Type()), blcoord);
- delete bldng;
- int damage;
- for (int index = 0; index < Infantry.Count(); index++) {
- InfantryClass * obj = Infantry.Ptr(index);
- if (obj != NULL && !obj->IsInLimbo) {
- int dist = ::Distance(obj->Coord, blcoord);
- if (dist <= 0xC0) {
- damage = Rule.APMineDamage;
- obj->Take_Damage(damage, 0, WARHEAD_HE);
- }
- }
- }
- if (!IsActive) {
- BEnd(BENCH_PCP);
- return;
- }
- }
- Look(true);
- #if 1
- /*
- ** If after all is said and done, the unit finishes its move on an impassable cell, then
- ** it must presume that it is in the case of a unit driving onto a bridge that blows up
- ** before the unit completes it's move. In such a case the unit should have been destroyed
- ** anyway, so blow it up now.
- */
- LandType land = Map[Coord].Land_Type();
- if (!IsDriving && !Class->IsBomber && (land == LAND_ROCK || land == LAND_WATER || land == LAND_RIVER)) {
- int damage = Strength;
- Take_Damage(damage, 0, WARHEAD_AP, NULL, true);
- return;
- }
- #endif
- }
- if (IsActive) {
- FootClass::Per_Cell_Process(why);
- }
- BEnd(BENCH_PCP);
- }
- /***********************************************************************************************
- * InfantryClass::Detach -- Removes the specified target from targeting computer. *
- * *
- * This is a support routine that removes the target specified from any targeting or *
- * navigation computers. When a target is destroyed or removed from the game system, *
- * the target must be removed from any tracking systems of the other units. This routine *
- * handles removal for infantry units. *
- * *
- * INPUT: target -- The target to remove from the infantry unit's tracking systems. *
- * *
- * all -- Is the target going away for good as opposed to just cloaking/hiding? *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Detach(TARGET target, bool all)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (TarCom == target) {
- Mark(MARK_OVERLAP_UP);
- IsFiring = false;
- Mark(MARK_OVERLAP_DOWN);
- }
- FootClass::Detach(target, all);
- }
- /***********************************************************************************************
- * InfantryClass::Init -- Initialize the infantry object system. *
- * *
- * This routine will force the infantry object system into its empty initial state. It *
- * is called when the scenario needs to be cleared in preparation for a scenario load. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Init(void)
- {
- Infantry.Free_All();
- }
- /***********************************************************************************************
- * InfantryClass::Assign_Destination -- Gives the infantry a movement destination. *
- * *
- * This routine updates the infantry's navigation computer so that the infantry will *
- * travel to the destination target specified. *
- * *
- * INPUT: target -- The target to have the infantry unit move to. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Assign_Destination(TARGET target)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Special flag so that infantry will start heading in the right direction immediately.
- */
- if (IsDriving && !IsFormationMove && Target_Legal(target) && Map[Center_Coord()].Is_Clear_To_Move(Class->Speed, true, false)) {
- Stop_Driver();
- }
- /*
- ** When telling an infantry soldier to move to a location twice, then this
- ** means that movement is more important than safety. Get up and run!
- */
- if (House->IsHuman && Target_Legal(target) && NavCom == target && IsProne && !Class->IsFraidyCat && !Class->IsDog) {
- Do_Action(DO_GET_UP);
- }
- /*
- ** If telling a dog to attack a human, start the dog running
- */
- TechnoClass * tech = As_Techno(target);
- /*
- ** Handle entry logic here.
- */
- if (Mission == MISSION_ENTER || MissionQueue == MISSION_ENTER) {
- /*
- ** If not already in radio contact (presumed with the transport), then
- ** either try to establish contact if allowed, or just move close and
- ** wait until radio contact can be established.
- */
- if (!In_Radio_Contact()) {
- TechnoClass * techno = As_Techno(target);
- if (techno != NULL) {
- /*
- ** Determine if the transport is already in radio contact. If so, then just move
- ** toward the transport and try to establish contact at a later time.
- */
- if (techno->In_Radio_Contact()) {
- // TCTCTC -- call for an update from the transport to get a good rendezvous position.
- ArchiveTarget = target;
- } else {
- if (Transmit_Message(RADIO_HELLO, techno) == RADIO_ROGER) {
- if (Transmit_Message(RADIO_DOCKING) != RADIO_ROGER) {
- Transmit_Message(RADIO_OVER_OUT);
- } else {
- //BG: keep retransmitted navcom from radio-move-here.
- return;
- }
- }
- }
- }
- } else {
- Path[0] = FACING_NONE;
- }
- } else {
- Path[0] = FACING_NONE;
- }
- FootClass::Assign_Destination(target);
- }
- /***********************************************************************************************
- * InfantryClass::Assign_Target -- Gives the infantry a combat target. *
- * *
- * This routine will update the infantry's targeting computer so that it will try to *
- * attack the target specified. This might result in it moving to be within range and thus *
- * also cause adjustment of the navigation computer. *
- * *
- * INPUT: target -- The target that this infantry should attack. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- * 06/30/1995 JLB : Tries to capture target if possible. *
- *=============================================================================================*/
- void InfantryClass::Assign_Target(TARGET target)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- Path[0] = FACING_NONE;
- if (Class->IsDog) {
- if (::As_Object(target) && ::As_Object(target)->What_Am_I() != RTTI_INFANTRY) {
- target = TARGET_NONE;
- }
- }
- FootClass::Assign_Target(target);
- /*
- ** If this is an infantry that can only capture, then also assign its destination to the
- ** target specified.
- */
- if (!Target_Legal(NavCom) && Class->IsCapture && !Is_Weapon_Equipped()) {
- BuildingClass const * building = As_Building(target);
- if (building != NULL && building->Class->IsCaptureable) {
- Assign_Destination(target);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::AI -- Handles the infantry non-graphic related AI processing. *
- * *
- * This routine is used to handle the non-graphic AI processing the infantry requires. *
- * Call this routine ONCE per game frame. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/08/1994 JLB : Created. *
- * 08/14/1996 JLB : Simplified. *
- *=============================================================================================*/
- void InfantryClass::AI(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- FootClass::AI();
- if (!IsActive) {
- return;
- }
- if (IsUnloading) Mark(MARK_CHANGE_REDRAW);
- /*
- ** Infantry that are not on the ground should always be redrawn. Such is
- ** the case when they are parachuting to the ground.
- */
- if (In_Which_Layer() != LAYER_GROUND) {
- Mark(MARK_CHANGE);
- }
- /*
- ** Special hack to make sure that if this infantry is in firing animation, but the
- ** stage class isn't set, then abort the firing flag.
- */
- if (IsFiring && Fetch_Rate() == 0) {
- Mark(MARK_OVERLAP_UP);
- IsFiring = false;
- Do_Action(DO_STAND_READY);
- Mark(MARK_OVERLAP_DOWN);
- }
- /*
- ** Delete this unit if it finds itself off the edge of the map and it is in
- ** guard or other static mission mode.
- */
- if (Edge_Of_World_AI()) {
- return;
- }
- /*
- ** Act on new orders if the unit is at a good position to do so.
- */
- if (!IsFiring && !IsFalling && !IsDriving && (Doing == DO_NOTHING || MasterDoControls[Doing].Interrupt)) {
- if (Mission == MISSION_NONE && MissionQueue == MISSION_NONE) Enter_Idle_Mode();
- Commence();
- }
- /*
- ** Special hack to make sure the dog never attacks a cell.
- */
- if (Class->IsDog && Target_Legal(TarCom) && Is_Target_Cell(TarCom)) {
- Assign_Target(TARGET_NONE);
- }
- /*
- ** Handle any infantry fear logic or related actions.
- */
- Fear_AI();
- /*
- ** Special victory dance action.
- */
- if (!Target_Legal(NavCom) && !IsProne && IsStoked && Comment == 0) {
- IsStoked = false;
- Do_Action(Percent_Chance(50) ? DO_GESTURE1 : DO_GESTURE2);
- }
- /*
- ** Determine if this infantry unit should fire off an
- ** attack or not.
- */
- Firing_AI();
- /*
- ** Handle the completion of the animation sequence.
- */
- Doing_AI();
- /*
- ** Perform movement operations at this time.
- */
- Movement_AI();
- }
- /***********************************************************************************************
- * InfantryClass::Can_Enter_Cell -- Determines if the infantry can enter the cell specified. *
- * *
- * This routine is used to examine the cell specified and determine if the infantry is *
- * allowed to enter it. It is used by the path finding algorithm. *
- * *
- * INPUT: cell -- The cell to examine. *
- * *
- * OUTPUT: Returns the type of blockage in the cell. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- MoveType InfantryClass::Can_Enter_Cell(CELL cell, FacingType ) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** If we are moving into an illegal cell, then we can't do that.
- */
- if ((unsigned)cell >= MAP_CELL_TOTAL) return(MOVE_NO);
- /*
- ** If moving off the edge of the map, then consider that an illegal move.
- */
- if (!ScenarioInit && !Map.In_Radar(cell) && !Is_Allowed_To_Leave_Map()) {
- return(MOVE_NO);
- }
- CellClass * cellptr = &Map[cell];
- /*
- ** Walls are considered impassable for infantry UNLESS the wall has a hole
- ** in it.
- */
- if (cellptr->Overlay != OVERLAY_NONE) {
- OverlayTypeClass const & otype = OverlayTypeClass::As_Reference(cellptr->Overlay);
- if (otype.IsCrate && !((Session.Type == GAME_NORMAL) ? House->IsPlayerControl : House->IsHuman) && Session.Type == GAME_NORMAL) {
- return(MOVE_NO);
- }
- if (otype.IsWall) {
- if ((cellptr->OverlayData / 16) != otype.DamageLevels) {
- /*
- ** If the wall can be destroyed, then return this fact instead of
- ** a complete failure to enter.
- */
- if (Is_Weapon_Equipped() && Class->PrimaryWeapon->Is_Wall_Destroyer()) {
- return(MOVE_DESTROYABLE);
- }
- return(MOVE_NO);
- }
- }
- }
- /*
- ** Loop through all of the objects in the square setting a bit
- ** for how they affect movement.
- */
- MoveType retval = MOVE_OK;
- ObjectClass * obj = cellptr->Cell_Occupier();
- while (obj != NULL) {
- if (obj != this) {
- /*
- ** Always allow movement if the cell is the object to be captured or sabotaged.
- */
- if (((Mission == MISSION_ENTER && In_Radio_Contact()) || Mission == MISSION_CAPTURE || Mission == MISSION_SABOTAGE) &&
- (obj->As_Target() == NavCom || obj->As_Target() == TarCom)) {
- return(MOVE_OK);
- }
- /*
- ** Guard area should not allow the guarding unit to enter the cell with the
- ** guarded unit.
- */
- if (Mission == MISSION_GUARD_AREA && ArchiveTarget == obj->As_Target() && Is_Target_Unit(ArchiveTarget)) {
- return(MOVE_NO);
- }
- /*
- ** If object is a land mine, allow movement
- */
- if (obj->What_Am_I() == RTTI_BUILDING) {
- if ((*(BuildingClass *)obj) == STRUCT_AVMINE) {
- obj = obj->Next;
- continue;
- } else {
- if (!Rule.IsMineAware || !((BuildingClass *)obj)->House->Is_Ally(House)) {
- if ((*(BuildingClass *)obj) == STRUCT_APMINE) {
- obj = obj->Next;
- continue;
- }
- }
- }
- }
- /*
- ** Special case check so that a landed aircraft that is in radio contact, will not block
- ** a capture attempt. It is presumed that this case happens when a helicopter is landed
- ** at a helipad.
- */
- // if ((Mission != MISSION_CAPTURE && Mission != MISSION_SABOTAGE) || obj->What_Am_I() != RTTI_AIRCRAFT || !((AircraftClass *)obj)->In_Radio_Contact()) {
- /*
- ** Special check to always allow entry into the building that this infantry
- ** is trying to capture.
- */
- // if (obj->What_Am_I() == RTTI_BUILDING || obj->What_Am_I() == RTTI_AIRCRAFT || obj->What_Am_I() == RTTI_UNIT) {
- // if ((Mission == MISSION_CAPTURE || Mission == MISSION_SABOTAGE) && (obj->As_Target() == NavCom || obj->As_Target() == TarCom)) {
- // return(MOVE_OK);
- // }
- // }
- /*
- ** Special check to always allow entry into the building that this infantry
- ** is trying to capture.
- */
- if (Mission == MISSION_ENTER && obj->As_Target() == NavCom && IsTethered) {
- return(MOVE_OK);
- }
- /*
- ** Allied objects block movement using different rules than for enemy
- ** objects.
- */
- if (House->Is_Ally(obj) || ScenarioInit) {
- switch (obj->What_Am_I()) {
- /*
- ** A unit blocks as either a moving blockage or a stationary temp blockage.
- ** This depends on whether the unit is currently moving or not.
- */
- case RTTI_UNIT:
- if (((UnitClass *)obj)->IsDriving || Target_Legal(((UnitClass *)obj)->NavCom)) {
- if (retval < MOVE_MOVING_BLOCK) retval = MOVE_MOVING_BLOCK;
- } else {
- if (retval < MOVE_TEMP) retval = MOVE_TEMP;
- }
- break;
- /*
- ** Aircraft and buildings always block movement. If for some reason there is an
- ** allied terrain object, that blocks movement as well.
- */
- case RTTI_TERRAIN:
- case RTTI_AIRCRAFT:
- case RTTI_BUILDING:
- return(MOVE_NO);
- default:
- break;
- }
- } else {
- /*
- ** Cloaked enemy objects are not considered if this is a Find_Path()
- ** call.
- */
- if (!obj->Is_Techno() || ((TechnoClass *)obj)->Cloak != CLOAKED) {
- /*
- ** Any non-allied blockage is considered impassible if the infantry
- ** is not equipped with a weapon.
- */
- if (Combat_Damage() <= 0) return(MOVE_NO);
- /*
- ** Some kinds of terrain are considered destroyable if the infantry is equipped
- ** with the weapon that can destroy it. Otherwise, the terrain is considered
- ** impassable.
- */
- switch (obj->What_Am_I()) {
- case RTTI_TERRAIN:
- #ifdef OBSOLETE
- if (((TerrainClass *)obj)->Class->Armor == ARMOR_WOOD &&
- Class->PrimaryWeapon->WarheadPtr->IsWoodDestroyer) {
- if (retval < MOVE_DESTROYABLE) retval = MOVE_DESTROYABLE;
- } else {
- return(MOVE_NO);
- }
- break;
- #else
- return(MOVE_NO);
- #endif
- case RTTI_INFANTRY:
- if ( *(InfantryClass *)obj == INFANTRY_SPY && !Class->IsDog) {
- retval = MOVE_TEMP;
- break;
- }
- // otherwise, fall thru.
- default:
- if (retval < MOVE_DESTROYABLE) retval = MOVE_DESTROYABLE;
- break;
- }
- } else {
- if (retval < MOVE_CLOAK) retval = MOVE_CLOAK;
- }
- }
- // }
- }
- /*
- ** Move to next object in chain.
- */
- obj = obj->Next;
- }
- /*
- ** If foot soldiers cannot travel on the cell -- consider it impassable.
- */
- if (retval == MOVE_OK && !IsTethered && Ground[cellptr->Land_Type()].Cost[SPEED_FOOT] == 0) {
- #ifdef OBSOLETE
- /*
- ** Special case - if it's an engineer, and the cell under consideration
- ** is his NavCom, and his mission is mission_capture, then he's most
- ** likely moving to his final destination to repair a bridge, so we
- ** should let him.
- */
- if (*this == INFANTRY_RENOVATOR && Is_Target_Cell(TarCom) && (cell == ::As_Cell(NavCom)) && (cellptr->TType == TEMPLATE_BRIDGE1D || cellptr->TType == TEMPLATE_BRIDGE2D || (cellptr->TType >= TEMPLATE_BRIDGE_1C && cellptr->TType <= TEMPLATE_BRIDGE_3E) ) ) {
- return(MOVE_OK);
- }
- #endif
- return(MOVE_NO);
- }
- /*
- ** if a unit has the cell reserved then we just can't go in there.
- */
- if (retval == MOVE_OK && cellptr->Flag.Occupy.Vehicle) {
- return(MOVE_NO);
- }
- /*
- ** if a block of infantry has the cell reserved then there are two
- ** possibilities...
- */
- if (cellptr->InfType != HOUSE_NONE) {
- if (House->Is_Ally(cellptr->InfType)) {
- if ((cellptr->Flag.Composite & 0x1F) == 0x1f) {
- if (retval < MOVE_MOVING_BLOCK) retval = MOVE_MOVING_BLOCK;
- }
- } else {
- if (Combat_Damage() > 0) {
- if (retval < MOVE_DESTROYABLE) {
- retval = MOVE_DESTROYABLE;
- }
- } else {
- return(MOVE_NO);
- }
- }
- }
- /*
- ** If it is still ok to move the infantry, then perform the last check
- ** to see if the cell is already full of infantry.
- */
- if (retval == MOVE_OK && (cellptr->Flag.Composite & 0x1F) == 0x1F) {
- return(MOVE_NO);
- }
- /*
- ** Return with the most severe reason why this cell would be impassable.
- */
- return(retval);
- }
- /***********************************************************************************************
- * InfantryClass::Overlap_List -- The list of cells that the infantry overlaps, but doesn't occ*
- * *
- * This is a rendering support routine that will return a pointer to a list of cell offsets *
- * that specify the cells the infantry unit is currently overlapping (graphic wise) but *
- * is not considered to occupy. This list is used to update the map display. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns a pointer to an offset list for cells that the unit overlaps but doesn't *
- * occupy. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- #ifdef PARTIAL
- short const * InfantryClass::Overlap_List(bool redraw) const
- #else
- short const * InfantryClass::Overlap_List(bool ) const
- #endif
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (Class->IsDog) {
- return(Coord_Spillage_List(Coord, 24 + (Doing == DO_DOG_MAUL ? 40 : 0) + (Doing >= DO_GUN_DEATH && Doing <= DO_FIRE_DEATH ? 40 : 0) ));
- } else {
- /*
- ** The default infantry rectangle will be as large as the largest shape the infantry
- ** can be.
- */
- #ifdef PARTIAL
- Rect rect(-16, -24, 32, 36);
- /*
- ** If this is for a visual change redraw, then the overlap list will be based
- ** on the actual dimensions of the shape data. If the dimensions have already
- ** been calculated then use them, otherwise, use the default large rectangle
- ** previously created.
- */
- if (Height == 0 && !IsSelected && redraw && Class->DimensionData != NULL) {
- int shapenum = Shape_Number();
- if (!Class->DimensionData[shapenum].Is_Valid()) {
- Class->DimensionData[shapenum] = Shape_Dimensions(Get_Image_Data(), shapenum);
- }
- rect = Class->DimensionData[shapenum];
- rect.Y += 4;
- rect.X -= 2;
- }
- return(Coord_Spillage_List(Coord, rect, true));
- #else
- static Rect rect(-16, -24, 32, 36);
- return(Coord_Spillage_List(Coord, rect, true));
- #endif
- // return(Coord_Spillage_List(Coord, 24 /*+ ((Doing > DO_WALK || IsSelected)?12:0)*/ ));
- }
- }
- /***********************************************************************************************
- * InfantryClass::Can_Fire -- Can the infantry fire its weapon? *
- * *
- * Determines if the infantry unit can fire on the target. If it can't fire, then the *
- * reason why is returned. *
- * *
- * INPUT: target -- The target to determine if the infantry can fire upon. *
- * *
- * OUTPUT: Returns the fire error type that indicates if the infantry can fire and if it *
- * can't, why not. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- * 06/27/1995 JLB : Flame thrower can fire while prone now. *
- *=============================================================================================*/
- FireErrorType InfantryClass::Can_Fire(TARGET target, int which) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Don't allow firing if the infantry is still firing on previous target.
- */
- // if (IsFiring) return(FIRE_REARM);
- /*
- ** If a medic is shooting at a healed target, let's declare the target
- ** illegal so he won't be constantly healing healed infantrymen.
- */
- if (Combat_Damage() < 0) {
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- TechnoClass * targ = As_Techno(target);
- #else
- InfantryClass * targ = As_Infantry(target);
- #endif
- if (targ == NULL || targ->Health_Ratio() >= Rule.ConditionGreen) {
- return(FIRE_ILLEGAL);
- }
- }
- /*
- ** If this unit cannot fire while moving, then bail.
- */
- if (IsDriving || (Target_Legal(NavCom) && Doing != DO_NOTHING && !MasterDoControls[Doing].Interrupt)) {
- return(FIRE_MOVING);
- }
- return(FootClass::Can_Fire(target, which));
- }
- /***********************************************************************************************
- * InfantryClass::Enter_Idle_Mode -- The infantry unit enters idle mode by this routine. *
- * *
- * Use this routine when the infantry unit as accomplished its task and needs to find *
- * something to do. The default behavior is to enter some idle state such as guarding. *
- * *
- * INPUT: initial -- Is this called when the unit just leaves a factory or is initially *
- * or is initially placed on the map? *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Enter_Idle_Mode(bool )
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- MissionType order = MISSION_GUARD;
- if (Target_Legal(TarCom)) {
- order = MISSION_ATTACK;
- if (Mission == MISSION_SABOTAGE) {
- order = MISSION_SABOTAGE;
- }
- if (Mission == MISSION_CAPTURE) {
- order = MISSION_CAPTURE;
- }
- } else {
- Handle_Navigation_List();
- if (Target_Legal(NavCom)) {
- order = MISSION_MOVE;
- if (Mission == MISSION_CAPTURE) {
- order = MISSION_CAPTURE;
- }
- if (Mission == MISSION_SABOTAGE) {
- order = MISSION_SABOTAGE;
- }
- } else {
- if (Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA || MissionControl[Mission].IsZombie || MissionControl[Mission].IsParalyzed) {
- return;
- }
- if (Class->IsDog) {
- if (House->IsHuman || Team.Is_Valid()) {
- order = MISSION_GUARD;
- } else {
- order = MISSION_GUARD_AREA;
- ArchiveTarget = ::As_Target(Coord_Cell(Center_Coord()));
- }
- } else {
- if (House->IsHuman || Team.Is_Valid()) {
- order = MISSION_GUARD;
- } else {
- if (House->IQ < Rule.IQGuardArea) {
- order = MISSION_GUARD;
- } else {
- if (Is_Weapon_Equipped()) {
- order = MISSION_GUARD_AREA;
- } else {
- order = MISSION_GUARD;
- }
- }
- }
- }
- }
- }
- Assign_Mission(order);
- }
- /***********************************************************************************************
- * InfantryClass::Random_Animate -- Randomly animate the infantry (maybe) *
- * *
- * This routine is the random animator initiator for infantry units. This routine should *
- * be called regularly. On occasion, it will cause the infantry to go into an idle *
- * animation. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/01/1994 JLB : Created. *
- * 12/13/1994 JLB : Does random facing change. *
- * 07/02/1995 JLB : Nikoomba special effects. *
- *=============================================================================================*/
- bool InfantryClass::Random_Animate(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (Is_Ready_To_Random_Animate()) {
- IdleTimer = Random_Pick(Rule.RandomAnimateTime * (TICKS_PER_MINUTE/2), Rule.RandomAnimateTime * (TICKS_PER_MINUTE*2));
- /*
- ** Scared infantry will always follow the golden rule of civilians;
- ** "When in darkness or in doubt, run in circles, scream, and shout!"
- */
- if (Class->IsFraidyCat && !House->IsHuman && Fear > FEAR_ANXIOUS) {
- Scatter(NULL, true);
- return(true);
- }
- switch (Random_Pick(0, 10)) {
- case 0:
- if (Class->IsDog) {
- Do_Action(DO_IDLE1);
- }
- break;
- case 1:
- Do_Action(DO_SALUTE1);
- break;
- case 2:
- Do_Action(DO_SALUTE2);
- break;
- case 3:
- Do_Action(DO_GESTURE1);
- break;
- case 4:
- Do_Action(DO_GESTURE2);
- break;
- case 5:
- Do_Action(DO_IDLE1);
- break;
- case 6:
- Mark(MARK_CHANGE_REDRAW);
- PrimaryFacing.Set(Facing_Dir(Random_Pick(FACING_N, FACING_NW)));
- Mark(MARK_CHANGE_REDRAW);
- break;
- case 7:
- Do_Action(DO_IDLE2);
- Mark(MARK_CHANGE_REDRAW);
- PrimaryFacing.Set(Facing_Dir(Random_Pick(FACING_N, FACING_NW)));
- Mark(MARK_CHANGE_REDRAW);
- if (!IsSelected && IsOwnedByPlayer && *this == INFANTRY_TANYA && Sim_Random_Pick(0, 2) == 0) {
- Sound_Effect(VOC_TANYA_SHAKE, Coord);
- }
- break;
- /*
- ** On occasion, civilian types will wander about.
- */
- case 8:
- Mark(MARK_CHANGE_REDRAW);
- PrimaryFacing.Set(Facing_Dir(Random_Pick(FACING_N, FACING_NW)));
- Mark(MARK_CHANGE_REDRAW);
- if (!House->IsHuman && Class->IsFraidyCat) {
- Scatter(NULL, true);
- }
- break;
- case 9:
- case 10:
- Mark(MARK_CHANGE_REDRAW);
- PrimaryFacing.Set(Facing_Dir(Random_Pick(FACING_N, FACING_NW)));
- Mark(MARK_CHANGE_REDRAW);
- }
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * InfantryClass::Scatter -- Causes the infantry to scatter to nearby cell. *
- * *
- * This routine is used when the infantry should scatter to a nearby cell. Scattering *
- * occurs as an occasional consequence of being fired upon. It is one of the features *
- * that makes infantry so "charming". *
- * *
- * INPUT: threat -- The coordinate source of the threat that is causing the infantry to *
- * scatter. If the threat isn't from a particular direction, then this *
- * parameter will be NULL. *
- * *
- * forced -- The threat is real and a serious effort to scatter should be made. *
- * *
- * nokidding-- The scatter should affect the player's infantry even if it otherwise *
- * wouldn't have. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/24/1994 JLB : Created. *
- * 12/12/1994 JLB : Flame thrower infantry always scatter. *
- * 08/02/1996 JLB : Added the nokidding parameter *
- *=============================================================================================*/
- void InfantryClass::Scatter(COORDINATE threat, bool forced, bool nokidding)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** A unit that is in the process of going somewhere will never scatter.
- */
- if (IsDriving) forced = false;
- /*
- ** Certain missions prevent scattering regardless of whether it would be
- ** a good idea or not.
- */
- if (!MissionControl[Mission].IsScatter && !forced) return;
- /*
- ** If the infantry is currently engaged in legitimate combat, then don't
- ** scatter unless forced to.
- */
- if (!Class->IsFraidyCat && Target_Legal(TarCom) && !forced) return;
- /*
- ** Don't scatter if performing an action that can't be interrupted.
- */
- if (Doing != DO_NOTHING && !MasterDoControls[Doing].Interrupt) return;
- /*
- ** For human players, don't scatter the infantry, if the special
- ** flag has not been enabled that allows infantry scatter.
- */
- if (!Rule.IsScatter && !nokidding && House->IsHuman && !forced && !Team.Is_Valid()) return;
- if (forced || Class->IsFraidyCat /*|| !(Random_Pick(1, 4) == 1)*/) {
- FacingType toface;
- if (threat) {
- toface = Dir_Facing(Direction8(threat, Coord));
- toface = toface + FacingType(Random_Pick(0, 4)-2);
- } else {
- COORDINATE coord = Coord_Fraction(Center_Coord());
- if (coord != 0x00800080L) {
- toface = Dir_Facing((DirType)Desired_Facing8(0x0080, 0x0080, Coord_X(coord), Coord_Y(coord)));
- } else {
- toface = Dir_Facing(PrimaryFacing.Current());
- }
- toface = toface + FacingType(Random_Pick(0, 4)-2);
- }
- CELL newcell = 0;
- CELL altcell = 0;
- for (FacingType face = FACING_N; face < FACING_COUNT; face++) {
- FacingType newface = toface + face;
- newcell = Adjacent_Cell(Coord_Cell(Coord), newface);
- if (Map.In_Radar(newcell) && Can_Enter_Cell(newcell) == MOVE_OK) {
- if (altcell == 0) altcell = newcell;
- if (!Map[newcell].Is_Bridge_Here()) break;
- // Assign_Mission(MISSION_MOVE);
- // Assign_Destination(::As_Target(newcell));
- }
- }
- if (face == FACING_COUNT) {
- newcell = 0;
- }
- if (newcell == 0) {
- newcell = altcell;
- }
- if (newcell != 0) {
- Assign_Mission(MISSION_MOVE);
- Assign_Destination(::As_Target(newcell));
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Do_Action -- Launches the infantry into an animation sequence. *
- * *
- * This starts the infantry into a choreographed animation sequence. These sequences can *
- * be as simple as standing up or lying down, but can also be complex, such as dying or *
- * performing some idle animation. *
- * *
- * INPUT: todo -- The choreographed sequence to start. *
- * *
- * force -- Force starting this animation even if the current animation is flagged *
- * as uninterruptible. This is necessary for death animations. *
- * *
- * OUTPUT: bool; Was the animation started? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/24/1994 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Do_Action(DoType todo, bool force)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (todo == DO_NOTHING || Class->DoControls[todo].Count == 0) {
- return(false);
- }
- if (*this == INFANTRY_SPY && todo >= DO_GESTURE1) {
- todo = (DoType)(DO_IDLE1 + Random_Pick(0,1));
- }
- if (todo != Doing && (Doing == DO_NOTHING || force || MasterDoControls[Doing].Interrupt)) {
- Mark(MARK_OVERLAP_UP);
- Doing = todo;
- Mark(MARK_OVERLAP_DOWN);
- if (todo == DO_IDLE1 || todo == DO_IDLE2) {
- Set_Rate(Options.Normalize_Delay(MasterDoControls[Doing].Rate));
- } else {
- Set_Rate(MasterDoControls[Doing].Rate);
- }
- Set_Stage(0);
- /*
- ** Kludge to make sure that if infantry is in the dying animation, it isn't still
- ** moving as well.
- */
- if (Strength == 0) {
- Stop_Driver();
- }
- /*
- ** Since the animation sequence might be interrupted. Set any flags
- ** necessary so that if interrupted, the affect on the infantry is
- ** still accomplished.
- */
- switch (todo) {
- case DO_LIE_DOWN:
- IsProne = true;
- break;
- case DO_GET_UP:
- IsProne = false;
- break;
- default:
- break;
- }
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * InfantryClass::Stop_Driver -- Stops the infantry from moving any further. *
- * *
- * This is used to stop the infantry from animating in movement. This function will stop *
- * the infantry moving and revert it to either a prone or standing. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: bool; Was the driving stopped? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/24/1994 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Stop_Driver(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (Head_To_Coord()) {
- /*
- ** Remove the "reservation" bit in the destination location.
- */
- Clear_Occupy_Bit(Head_To_Coord());
- }
- /*
- ** Set the occupation bit at the current location.
- */
- Set_Occupy_Bit(Coord);
- if (Class->IsDog) {
- Do_Action(DO_STAND_READY);
- } else {
- if (IsProne) {
- Do_Action(DO_PRONE);
- } else {
- Do_Action(DO_STAND_READY);
- }
- }
- if (Can_Enter_Cell(Coord_Cell(Coord)) == MOVE_OK) {
- IsZoneCheat = false;
- } else {
- IsZoneCheat = true;
- }
- return(FootClass::Stop_Driver());
- }
- /***********************************************************************************************
- * InfantryClass::Start_Driver -- Handles giving immediate destination and move orders. *
- * *
- * Use this routine to being the infantry moving toward the destination specified. The *
- * destination is first checked to see if there is a free spot available. Then the infantry *
- * reserves that spot and begins movement toward it. *
- * *
- * INPUT: headto -- The coordinate location desired for the infantry to head to. *
- * *
- * OUTPUT: bool; Was the infantry successfully started on its journey? Failure may be because *
- * the specified destination could not contain the infantry unit. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 12/21/1994 JLB : Created. *
- * 05/14/1995 JLB : Tries to move to closest spot possible. *
- * 05/15/1995 JLB : Uses closest spot if moving onto transport. *
- *=============================================================================================*/
- bool InfantryClass::Start_Driver(COORDINATE & headto)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- COORDINATE old = headto;
- /*
- ** Convert the head to coordinate to a legal sub-position location.
- */
- headto = Map[headto].Closest_Free_Spot(Coord_Move(headto, Direction(headto)+DIR_S, 0x007C));
- if (!headto && Can_Enter_Cell(Coord_Cell(old)) == MOVE_OK) {
- headto = Map[old].Closest_Free_Spot(Coord_Move(old, Direction(headto)+DIR_S, 0x0080), true);
- }
- /*
- ** If the infantry started moving, then fixup the occupation bits.
- */
- if (headto && FootClass::Start_Driver(headto)) {
- if (!IsActive) return(false);
- /*
- ** Remove the occupation bit from the infantry's current location.
- */
- Clear_Occupy_Bit(Coord);
- /*
- ** Set the occupation bit for the new headto location.
- */
- Set_Occupy_Bit(headto);
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * InfantryClass::Limbo -- Performs cleanup operations needed when limboing. *
- * *
- * This routine will clean up the infantry occupation bits (as necessary) as well as stop *
- * the infantry movement process when it gets limboed. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: bool; Was the infantry unit limboed? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 12/22/1994 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Limbo(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (!IsInLimbo) {
- Stop_Driver();
- Clear_Occupy_Bit(Coord);
- }
- return(FootClass::Limbo());
- }
- /***********************************************************************************************
- * InfantryClass::Fire_At -- Fires projectile from infantry unit. *
- * *
- * Use this routine when the infantry unit wishes to fire a projectile. This routine *
- * will launch the projectile and perform any other necessary infantry specific operations. *
- * *
- * INPUT: target -- The target of the attack. *
- * *
- * which -- Which weapon to use for firing. 0=primary, 1=secondary. *
- * *
- * OUTPUT: Returns with pointer to the projectile launched. If none could be launched, then *
- * NULL is returned. If there is already the maximum bullet objects in play, then *
- * this could happen. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 12/26/1994 JLB : Created. *
- *=============================================================================================*/
- BulletClass * InfantryClass::Fire_At(TARGET target, int which)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- Mark(MARK_OVERLAP_UP);
- IsFiring = false;
- Mark(MARK_OVERLAP_DOWN);
- BulletClass * bullet = FootClass::Fire_At(target, which);
- if (bullet != NULL && !IsInLimbo) {
- /*
- ** For fraidycat infantry that run out of ammo, always go into
- ** a maximum fear state at that time.
- */
- if (Class->IsFraidyCat && !Ammo) {
- Fear = FEAR_MAXIMUM;
- if (Mission == MISSION_ATTACK || Mission == MISSION_HUNT) {
- Assign_Mission(MISSION_GUARD);
- }
- }
- }
- return(bullet);
- }
- /***********************************************************************************************
- * InfantryClass::Unlimbo -- Unlimbo infantry unit in legal sub-location. *
- * *
- * This will attempt to unlimbo the infantry unit at the designated coordinate, but will *
- * ensure that the coordinate is a legal subposition. *
- * *
- * INPUT: coord -- The coordinate to unlimbo the infantry at. *
- * *
- * facing -- The desired initial facing for the infantry unit. *
- * *
- * strength -- The desired initial strength for the infantry unit. *
- * *
- * mission -- The desired initial mission for the infantry unit. *
- * *
- * OUTPUT: bool; Was the infantry unlimboed successfully? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 12/26/1994 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Unlimbo(COORDINATE coord, DirType facing)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Make sure that the infantry start in a legal position on the map.
- */
- coord = Map[coord].Closest_Free_Spot(coord, ScenarioInit);
- if (coord == NULL) {
- return(false);
- }
- if (FootClass::Unlimbo(coord, facing)) {
- /*
- ** Ensure that the owning house knows about the
- ** new object.
- */
- House->IScan |= (1L << Class->Type);
- House->ActiveIScan |= (1L << Class->Type);
- /*
- ** If there is no sight range, then this object isn't discovered by the player unless
- ** it actually appears in a cell mapped by the player.
- */
- if (Class->SightRange == 0) {
- IsDiscoveredByPlayer = false;
- }
- Set_Occupy_Bit(coord);
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * InfantryClass::Greatest_Threat -- Determines greatest threat (target) for infantry unit. *
- * *
- * This routine intercepts the Greatest_Threat request and adds the appropriate target *
- * types to search for. For regular infantry, this consists of all the ground types. For *
- * rocket launching infantry, this also includes aircraft. *
- * *
- * INPUT: threat -- The basic threat control value. *
- * *
- * OUTPUT: Returns with the best target for this infantry unit to attack. If no suitable *
- * target could be found, then TARGET_NONE is returned. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/01/1995 JLB : Created. *
- * 09/28/1995 JLB : Engineers try to recapture buildings first. *
- *=============================================================================================*/
- TARGET InfantryClass::Greatest_Threat(ThreatType threat) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Engineers consider only buildings that can be captured as being a threat. All others
- ** are ignored. If there is a building that needs to be recaptured and it is nearby
- ** then automatically head toward it to recapture it.
- */
- if (!House->IsHuman && Class->IsCapture && !Is_Weapon_Equipped()) {
- if (House->ToCapture != TARGET_NONE && Distance(House->ToCapture) < 0x0F00) {
- return(House->ToCapture);
- }
- threat = threat | THREAT_CAPTURE;
- }
- if (!Is_Weapon_Equipped()) {
- if (!Class->IsCapture && *this != INFANTRY_RENOVATOR && *this != INFANTRY_SPY && *this != INFANTRY_THIEF) {
- return(TARGET_NONE);
- }
- }
- /*
- ** Special hack to make Tanya not auto-fire if controlled by a
- ** human player.
- */
- if (*this == INFANTRY_TANYA && House->IsHuman) {
- return(TARGET_NONE);
- }
- if (Class->PrimaryWeapon != NULL) {
- threat = threat | Class->PrimaryWeapon->Allowed_Threats();
- }
- if (Class->SecondaryWeapon != NULL) {
- threat = threat | Class->SecondaryWeapon->Allowed_Threats();
- }
- /*
- ** Organic weapon types don't consider anything but infantry to be a threat. Such
- ** weapon types would be the dog jaw and the medic first aid kit.
- */
- if (Is_Weapon_Equipped() && Class->PrimaryWeapon->WarheadPtr->IsOrganic) {
- threat = threat & ~(THREAT_BUILDINGS|THREAT_VEHICLES|THREAT_BOATS|THREAT_AIR);
- }
- /*
- ** Human controlled infantry don't automatically fire upon buildings.
- */
- if (Is_Weapon_Equipped() && House->IsHuman) {
- threat = threat & ~THREAT_BUILDINGS;
- }
- /*
- ** If this is a bomber type, then allow buildings to be considered a threat.
- */
- if (Class->IsBomber && !House->IsHuman) {
- threat = threat | THREAT_BUILDINGS;
- }
- /*
- ** Special hack: if it's a thief, then the only possible objects to
- ** consider are tiberium-processing objects (silos & refineries).
- */
- if (*this == INFANTRY_THIEF) {
- threat = threat | THREAT_CAPTURE | THREAT_TIBERIUM;
- // threat = (ThreatType)(THREAT_CAPTURE | THREAT_TIBERIUM);
- }
- return(FootClass::Greatest_Threat(threat));
- }
- /***********************************************************************************************
- * InfantryClass::Response_Select -- Plays infantry audio response due to being selected. *
- * *
- * This routine handles playing an audio response as a result of the player selecting the *
- * infantry unit. This occurs prior to giving it an order and may not be followed by any *
- * order at all. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/01/1995 JLB : Created. *
- * 05/05/1995 JLB : Rambo response types added. *
- *=============================================================================================*/
- void InfantryClass::Response_Select(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (!AllowVoice) return;
- if (Class->IsCivilian && *this != INFANTRY_EINSTEIN) {
- VocType response = VOC_NONE;
- if (Class->IsFemale) {
- response = VOC_GIRL_YEAH;
- } else {
- response = VOC_GUY_YEAH;
- }
- Sound_Effect(response, fixed(1), ID+1);
- } else {
- static VocType _eng_response[] = {VOC_ENG_YES,VOC_ENG_ENG};
- static VocType _ein_response[] = {VOC_E_AH};
- static VocType _dog_response[] = {VOC_DOG_YES};
- static VocType _spy_response[] = {VOC_SPY_COMMANDER,VOC_SPY_YESSIR};
- static VocType _medic_response[] = {VOC_MED_REPORTING,VOC_MED_YESSIR};
- static VocType _tanya_response[] = {VOC_TANYA_YEA,VOC_TANYA_YES,VOC_TANYA_WHATS};
- static VocType _thief_response[] = {VOC_THIEF_YEA,VOC_THIEF_WHAT};
- static VocType _default_response[] = {VOC_ACKNOWL,VOC_REPORT,VOC_REPORT,VOC_YESSIR,VOC_YESSIR,VOC_READY,VOC_AWAIT};
- static VocType _stavros[] = {VOC_STAVCMDR,VOC_STAVYES};
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- static VocType _mechanic_response[] = {VOC_MECHHOWDY1,VOC_MECHHUH1,VOC_MECHLAFF1};
- static VocType _shock_response[] = {VOC_STYES1,VOC_STJUMP1,VOC_STJUICE1};
- #endif
- int size = 0;
- VocType * response = NULL;
- HousesType house = PlayerPtr->ActLike;
- switch (Class->Type) {
- case INFANTRY_GENERAL:
- if (house != HOUSE_USSR && house != HOUSE_BAD) {
- response = _stavros;
- size = ARRAY_SIZE(_stavros);
- } else {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- house = HOUSE_USSR;
- break;
- case INFANTRY_DOG:
- response = _dog_response;
- size = ARRAY_SIZE(_dog_response);
- break;
- case INFANTRY_EINSTEIN:
- response = _ein_response;
- size = ARRAY_SIZE(_ein_response);
- break;
- case INFANTRY_SPY:
- response = _spy_response;
- size = ARRAY_SIZE(_spy_response);
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- if(house == HOUSE_USSR) {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- #endif
- break;
- case INFANTRY_MEDIC:
- response = _medic_response;
- size = ARRAY_SIZE(_medic_response);
- break;
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- case INFANTRY_MECHANIC:
- response = _mechanic_response;
- size = ARRAY_SIZE(_mechanic_response);
- break;
- case INFANTRY_SHOCK:
- response = _shock_response;
- size = ARRAY_SIZE(_shock_response);
- break;
- #endif
- case INFANTRY_TANYA:
- response = _tanya_response;
- size = ARRAY_SIZE(_tanya_response);
- break;
- case INFANTRY_THIEF:
- response = _thief_response;
- size = ARRAY_SIZE(_thief_response);
- break;
- case INFANTRY_RENOVATOR:
- response = _eng_response;
- size = ARRAY_SIZE(_eng_response);
- break;
- default:
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- break;
- }
- if (response != NULL) {
- Sound_Effect(response[Sim_Random_Pick(0, size-1)], fixed(1), ID+1, 0, house);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Response_Move -- Plays infantry response to movement order. *
- * *
- * When the infantry is given the order to move, this routine handles the audio response *
- * generated by the infantry unit. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/01/1995 JLB : Created. *
- * 05/05/1995 JLB : Rambo response types added. *
- *=============================================================================================*/
- void InfantryClass::Response_Move(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (!AllowVoice) return;
- if (Class->IsCivilian && *this != INFANTRY_EINSTEIN) {
- VocType response;
- if (Class->IsFemale) {
- response = VOC_GIRL_OKAY;
- } else {
- response = VOC_GUY_OKAY;
- }
- Sound_Effect(response, fixed(1), ID+1);
- } else {
- static VocType _eng_response[] = {VOC_ENG_AFFIRM,VOC_ENG_AFFIRM};
- static VocType _ein_response[] = {VOC_E_OK,VOC_E_YES};
- static VocType _dog_response[] = {VOC_DOG_BARK};
- static VocType _spy_response[] = {VOC_SPY_ONWAY,VOC_SPY_KING,VOC_SPY_INDEED};
- static VocType _medic_response[] = {VOC_MED_AFFIRM,VOC_MED_MOVEOUT};
- #ifdef ENGLISH
- static VocType _tanya_response[] = {VOC_TANYA_THERE,VOC_TANYA_ROCK};
- #else
- static VocType _tanya_response[] = {VOC_TANYA_THERE,VOC_TANYA_GIVE};
- #endif
- static VocType _thief_response[] = {VOC_THIEF_MOVEOUT,VOC_THIEF_OKAY,VOC_THIEF_AFFIRM};
- static VocType _default_response[] = {VOC_ROGER,VOC_RIGHT_AWAY,VOC_UGOTIT,VOC_AFFIRM,VOC_AFFIRM};
- static VocType _stavros[] = {VOC_STAVMOV,VOC_STAVCRSE};
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- static VocType _mechanic[] = {VOC_MECHYES1,VOC_MECHRISE1,VOC_MECHHEAR1,VOC_MECHBOSS1};
- static VocType _shock[] = {VOC_STPOWER1,VOC_STDANCE1,VOC_STCHRGE1};
- #endif
- int size = 0;
- VocType * response = NULL;
- HousesType house = PlayerPtr->ActLike;
- switch (Class->Type) {
- case INFANTRY_GENERAL:
- if (house != HOUSE_USSR && house != HOUSE_BAD) {
- response = _stavros;
- size = ARRAY_SIZE(_stavros);
- } else {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- house = HOUSE_USSR;
- break;
- case INFANTRY_DOG:
- response = _dog_response;
- size = ARRAY_SIZE(_dog_response);
- break;
- case INFANTRY_EINSTEIN:
- response = _ein_response;
- size = ARRAY_SIZE(_ein_response);
- break;
- case INFANTRY_RENOVATOR:
- response = _eng_response;
- size = ARRAY_SIZE(_eng_response);
- break;
- case INFANTRY_SPY:
- response = _spy_response;
- size = ARRAY_SIZE(_spy_response);
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- if(house == HOUSE_USSR) {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- #endif
- break;
- case INFANTRY_MEDIC:
- response = _medic_response;
- size = ARRAY_SIZE(_medic_response);
- break;
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- case INFANTRY_MECHANIC:
- response = _mechanic;
- size = ARRAY_SIZE(_mechanic);
- break;
- case INFANTRY_SHOCK:
- response = _shock;
- size = ARRAY_SIZE(_shock);
- break;
- #endif
- case INFANTRY_TANYA:
- response = _tanya_response;
- size = ARRAY_SIZE(_tanya_response);
- break;
- case INFANTRY_THIEF:
- response = _thief_response;
- size = ARRAY_SIZE(_thief_response);
- break;
- default:
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- break;
- }
- if (response != NULL) {
- Sound_Effect(response[Sim_Random_Pick(0, size-1)], fixed(1), ID+1, 0, house);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Response_Attack -- Plays infantry audio response to attack order. *
- * *
- * When the player gives an infantry unit the order to attack, this routine handles *
- * the audio response by that unit. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/01/1995 JLB : Created. *
- * 05/05/1995 JLB : Rambo response types added. *
- *=============================================================================================*/
- void InfantryClass::Response_Attack(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (!AllowVoice) return;
- if (Class->IsCivilian && *this != INFANTRY_EINSTEIN) {
- VocType response;
- if (Class->IsFemale) {
- response = VOC_GIRL_OKAY;
- } else {
- response = VOC_GUY_OKAY;
- }
- Sound_Effect(response, fixed(1), ID+1);
- } else {
- static VocType _eng_response[] = {VOC_ENG_AFFIRM,VOC_ENG_AFFIRM};
- static VocType _dog_response[] = {VOC_DOG_GROWL2};
- static VocType _ein_response[] = {VOC_E_OK,VOC_E_YES};
- static VocType _spy_response[] = {VOC_SPY_ONWAY,VOC_SPY_KING,VOC_SPY_INDEED};
- static VocType _medic_response[] = {VOC_MED_AFFIRM,VOC_MED_MOVEOUT};
- #ifdef ENGLISH
- static VocType _tanya_response[] = {VOC_TANYA_CHEW,VOC_TANYA_CHING,VOC_TANYA_LAUGH};
- #else
- static VocType _tanya_response[] = {VOC_TANYA_CHEW,VOC_TANYA_CHING,VOC_TANYA_LAUGH,VOC_TANYA_ROCK};
- #endif
- static VocType _thief_response[] = {VOC_NONE};
- static VocType _default_response[] = {VOC_RIGHT_AWAY,VOC_AFFIRM,VOC_AFFIRM,VOC_UGOTIT,VOC_NO_PROB,VOC_YESSIR,VOC_YESSIR,VOC_YESSIR};
- static VocType _stavros[] = {VOC_STAVCRSE};
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- static VocType _mechanic[] = {VOC_MECHYEEHAW1,VOC_MECHHOTDIG1,VOC_MECHWRENCH1};
- static VocType _shock[] = {VOC_STLIGHT1,VOC_STBURN1,VOC_STCRISP1,VOC_STSHOCK1};
- #endif
- int size = 0;
- VocType * response = NULL;
- HousesType house = PlayerPtr->ActLike;
- switch (Class->Type) {
- case INFANTRY_GENERAL:
- if (house != HOUSE_USSR && house != HOUSE_BAD) {
- response = _stavros;
- size = ARRAY_SIZE(_stavros);
- } else {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- house = HOUSE_USSR;
- break;
- case INFANTRY_DOG:
- response = _dog_response;
- size = ARRAY_SIZE(_dog_response);
- break;
- case INFANTRY_SPY:
- response = _spy_response;
- size = ARRAY_SIZE(_spy_response);
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- if(house == HOUSE_USSR) {
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- }
- #endif
- break;
- case INFANTRY_EINSTEIN:
- response = _ein_response;
- size = ARRAY_SIZE(_ein_response);
- break;
- case INFANTRY_RENOVATOR:
- response = _eng_response;
- size = ARRAY_SIZE(_eng_response);
- break;
- case INFANTRY_MEDIC:
- response = _medic_response;
- size = ARRAY_SIZE(_medic_response);
- break;
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- case INFANTRY_MECHANIC:
- response = _mechanic;
- size = ARRAY_SIZE(_mechanic);
- break;
- case INFANTRY_SHOCK:
- response = _shock;
- size = ARRAY_SIZE(_shock);
- break;
- #endif
- case INFANTRY_TANYA:
- response = _tanya_response;
- size = ARRAY_SIZE(_tanya_response);
- break;
- case INFANTRY_THIEF:
- response = _thief_response;
- size = ARRAY_SIZE(_thief_response);
- break;
- default:
- response = _default_response;
- size = ARRAY_SIZE(_default_response);
- break;
- }
- if (response != NULL) {
- Sound_Effect(response[Sim_Random_Pick(0, size-1)], fixed(1), ID+1, 0, house);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::What_Action -- Infantry units might be able to capture -- check. *
- * *
- * This routine checks to see if the infantry unit can capture the specified object rather *
- * than merely attacking it. If this is the case, then ACTION_CAPTURE will be returned. *
- * *
- * INPUT: object -- The object that the mouse is currently over. *
- * *
- * OUTPUT: Returns the action that will be performed if the mouse were clicked over the *
- * object specified. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 03/01/1995 JLB : Created. *
- *=============================================================================================*/
- ActionType InfantryClass::What_Action(ObjectClass const * object) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- assert(object != NULL);
- ActionType action = FootClass::What_Action(object);
- /*
- ** If this is an engineer/renovator, we have to make some adjustments.
- ** If the cursor is over an enemy building, return action-none. If it's
- ** over a friendly building, we have to return action-capture so he can
- ** renovate it.
- ** However, abort the whole thing if the building is a barrel or mine.
- */
- if (*this == INFANTRY_RENOVATOR && object->What_Am_I() == RTTI_BUILDING && House->IsPlayerControl) {
- BuildingClass const * bldg = (BuildingClass *)object;
- if (bldg->Class->IsRepairable) {
- if (House->Is_Ally(bldg)) {
- if (bldg->Health_Ratio() == 1) {
- return(ACTION_NO_GREPAIR);
- }
- return(ACTION_GREPAIR);
- } else {
- if (bldg->Class->IsCaptureable) {
- #ifdef FIXIT_ENGINEER // checked - ajw 9/28/98
- if (bldg->Health_Ratio() <= EngineerCaptureLevel) {
- #else
- if (bldg->Health_Ratio() <= Rule.ConditionRed) {
- #endif
- return(ACTION_CAPTURE);
- }
- return(ACTION_DAMAGE);
- }
- // if (bldg->Health_Ratio() <= Rule.ConditionRed && bldg->Class->IsCaptureable) {
- }
- }
- }
- /*
- ** If this is a medic, and the cursor's over a friendly infantryman,
- ** execute an action-attack. In CSII, if this is a mechanic and the
- ** cursor's over a friendly vehicle, execute an action-attack.
- */
- if (Combat_Damage() < 0 && House->IsPlayerControl) {
- if (House->Is_Ally(object)) {
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- if( (object->What_Am_I() == RTTI_INFANTRY && object != this && *this == INFANTRY_MEDIC) ||
- (*this == INFANTRY_MECHANIC && (object->What_Am_I() == RTTI_UNIT || object->What_Am_I() == RTTI_AIRCRAFT) ) ) {
- if (object->Health_Ratio() < Rule.ConditionGreen) {
- // If it's a mechanic force-moving into an APC, don't try to heal it.
- if(*this == INFANTRY_MECHANIC && object->What_Am_I() == RTTI_UNIT && *(UnitClass *)object == UNIT_APC && (Keyboard->Down(Options.KeyForceMove1) || Keyboard->Down(Options.KeyForceMove2)) ) {
- } else {
- return(ACTION_HEAL);
- }
- }
- }
- #else
- if(object->What_Am_I() == RTTI_INFANTRY && object != this) {
- if (object->Health_Ratio() < Rule.ConditionGreen) {
- return(ACTION_HEAL);
- }
- }
- #endif
- if(!object->Is_Techno() || !((TechnoClass *)object)->Techno_Type_Class()->Max_Passengers()) {
- if (action == ACTION_GUARD_AREA || action == ACTION_MOVE) {
- return(action);
- }
- return(ACTION_SELECT);
- }
- } else {
- return(ACTION_NOMOVE);
- }
- }
- #ifdef OBSOLETE
- /*
- ** See if it's a thief attacking an enemy vehicle, let him CAPTURE it.
- */
- if (*this == INFANTRY_THIEF && object->What_Am_I() == RTTI_UNIT) {
- if (((UnitClass *)object)->House != House) {
- return(ACTION_CAPTURE);
- }
- }
- #endif
- /*
- ** Dogs can only attack infantrymen
- */
- if (Class->IsDog && action == ACTION_ATTACK && object->What_Am_I() != RTTI_INFANTRY) {
- action = ACTION_NONE;
- }
- /*
- ** See if it's a commando, and if he's attacking a building,
- ** have him return ACTION_SABOTAGE instead
- */
- if (Class->IsBomber && action == ACTION_ATTACK && object->What_Am_I() == RTTI_BUILDING) {
- BuildingClass const * obj = (BuildingClass *)object;
- /*
- ** Hack: Tanya should shoot barrels, bomb other structures.
- */
- if (obj->Class->IsRepairable) {
- // if (*obj != STRUCT_BARREL && *obj != STRUCT_BARREL3) {
- return(ACTION_SABOTAGE);
- } else {
- return(ACTION_ATTACK);
- }
- }
- /*
- ** See if this infantry is trying to move onto where a land mine is.
- */
- if (action == ACTION_NONE && object->What_Am_I() == RTTI_BUILDING && House->IsPlayerControl) {
- StructType blah = *((BuildingClass *)object);
- if (blah == STRUCT_AVMINE || blah == STRUCT_APMINE) return(ACTION_MOVE);
- }
- /*
- ** There is no self-select action available for infantry types.
- */
- if (action == ACTION_SELF) {
- action = ACTION_NONE;
- }
- /*
- ** Check to see if it can enter a transporter.
- */
- if (
- House->Is_Ally(object) &&
- House->IsPlayerControl && object->Is_Techno()) {
- #ifdef FIXIT_CARRIER // checked - ajw 9/28/98
- if (object->What_Am_I() != RTTI_VESSEL || *(VesselClass *)object != VESSEL_CARRIER) {
- #endif
- switch (((InfantryClass *)this)->Transmit_Message(RADIO_CAN_LOAD, (TechnoClass*)object)) {
- case RADIO_ROGER:
- action = ACTION_ENTER;
- break;
- case RADIO_NEGATIVE:
- action = ACTION_NO_ENTER;
- break;
- default:
- break;
- }
- #ifdef FIXIT_CARRIER // checked - ajw 9/28/98
- }
- #endif
- }
- if (Class->IsCapture && action == ACTION_ATTACK) {
- if (!House->Is_Ally(object) && (
- //Disable capturing of helicopters (object->What_Am_I() == RTTI_AIRCRAFT && ((AircraftClass *)object)->Pip_Count() == 0 && *((AircraftClass *)object) == AIRCRAFT_TRANSPORT) ||
- (object->What_Am_I() == RTTI_BUILDING && ((BuildingClass *)object)->Class->IsCaptureable) )
- ) {
- if (*this == INFANTRY_THIEF && (object->What_Am_I() == RTTI_BUILDING && ((BuildingClass *)object)->Class->Capacity == 0)) {
- action = ACTION_NONE;
- } else {
- /*
- ** If we're trying to capture a building, make sure we can get
- ** to it. Find an adjacent cell that's the same zone as us.
- ** The target circumstance is a naval yard that doesn't touch
- ** the shore - a total island. In that case, we can't capture
- ** it, so we shouldn't show the action-capture cursor.
- */
- action = ACTION_CAPTURE;
- if (object->What_Am_I() == RTTI_BUILDING) {
- CELL cell = ::As_Cell(object->As_Target());
- int targzone = Map[::As_Cell(As_Target())].Zones[Class->MZone];
- short const *list = ((BuildingClass *)object)->Class->Occupy_List(false);
- bool found = false;
- while (*list != REFRESH_EOL && !found) {
- CELL newcell = cell + *list++;
- for (FacingType i=FACING_N; i < FACING_COUNT; i++) {
- if (Map[Adjacent_Cell(newcell, i)].Zones[Class->MZone] == targzone) {
- found = true;
- break;
- }
- }
- }
- if (!found) {
- action = ACTION_NONE;
- }
- }
- }
- } else {
- if (!Is_Weapon_Equipped()) {
- action = ACTION_NONE;
- }
- }
- }
- /*
- ** If it doesn't know what to do with the object, then just
- ** say it can't move there.
- */
- if (action == ACTION_NONE) action = ACTION_NOMOVE;
- return(action);
- }
- /***********************************************************************************************
- * InfantryClass::Active_Click_With -- Handles action when clicking with infantry soldier. *
- * *
- * This routine is called when the player clicks over an object while this infantry soldier *
- * is selected. Capture attempts are prohibited if the infantry cannot capture. The *
- * command might respond if told to sabotage something. *
- * *
- * INPUT: action -- The action that is nominally to be performed. *
- * *
- * object -- The object over which the mouse was clicked. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/08/1995 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Active_Click_With(ActionType action, ObjectClass * object)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- action = What_Action(object);
- switch (action) {
- case ACTION_GREPAIR:
- case ACTION_DAMAGE:
- case ACTION_CAPTURE:
- action = ACTION_CAPTURE;
- break;
- case ACTION_HEAL:
- action = ACTION_ATTACK;
- break;
- // case ACTION_ENTER:
- // action = ACTION_MOVE;
- // break;
- case ACTION_SABOTAGE:
- case ACTION_ATTACK:
- case ACTION_GUARD_AREA:
- case ACTION_MOVE:
- action = action;
- break;
- default:
- // action = ACTION_NONE;
- break;
- }
- FootClass::Active_Click_With(action, object);
- }
- /***********************************************************************************************
- * InfantryClass::Set_Occupy_Bit -- Sets the occupy bit cell and bit pos *
- * *
- * INPUT: CELL - the cell we are setting the bit in *
- * *
- * int - the spot index we are setting the bit for *
- * *
- * OUTPUT: none *
- * *
- * HISTORY: *
- * 06/08/1995 PWG : Created. *
- *=============================================================================================*/
- void InfantryClass::Set_Occupy_Bit(CELL cell, int spot_index)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Set the occupy position for the spot that we passed in
- */
- Map[cell].Flag.Composite |= (1 << spot_index);
- /*
- ** Record the type of infantry that now owns the cell
- */
- Map[cell].InfType = Owner();
- }
- /***************************************************************************
- * InfantryClass::Clear_Occupy_Bit -- Clears occupy bit and given cell *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 06/08/1995 PWG : Created. *
- *=========================================================================*/
- void InfantryClass::Clear_Occupy_Bit(CELL cell, int spot_index)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- /*
- ** Clear the occupy bit for the infantry in that cell
- */
- Map[cell].Flag.Composite &= ~(1 << spot_index);
- /*
- ** If he was the last infantry recorded in the cell then
- ** remove the infantry ownership flag.
- */
- if (!(Map[cell].Flag.Composite & 0x1F)) {
- Map[cell].InfType = HOUSE_NONE;
- }
- }
- /***********************************************************************************************
- * InfantryClass::Full_Name -- Fetches the full name of the infantry unit. *
- * *
- * This routine will return with the full name (as a text number) for this infantry *
- * unit. Typically, this is the normal name, but in cases of civilian type survivors from *
- * a building explosion, it might be a technician instead. In such a case, the special *
- * technician name number is returned instead. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the full name to use for this infantry unit. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 06/30/1995 JLB : Created. *
- * 10/28/1996 JLB : Spy returns "enemy soldier" text name. *
- *=============================================================================================*/
- int InfantryClass::Full_Name(void) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (IsTechnician) {
- return(TXT_TECHNICIAN);
- }
- if (*this == INFANTRY_SPY && !House->IsPlayerControl) {
- return(TXT_E1);
- }
- return(Class->Full_Name());
- }
- /***********************************************************************************************
- * InfantryClass::Mission_Attack -- Intercept attack mission for special handling. *
- * *
- * This routine intercepts the normal attack mission and if an engineer is detected and the *
- * target is a building, then the engineer will be automatically assigned the capture *
- * mission. In other cases, the normal attack logic will proceed. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the number of game frames to delay before calling this routine again. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/07/1995 JLB : Created. *
- * 04/15/1996 BWG : Engineers can only attack their own house's buildings now. *
- * 05/29/1996 JLB : Engineers can now damage/capture enemy buildings. *
- *=============================================================================================*/
- int InfantryClass::Mission_Attack(void)
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- if (Class->IsBomber && As_Building(TarCom)) {
- Assign_Destination(TarCom);
- Assign_Mission(MISSION_SABOTAGE);
- return(1);
- }
- if (Class->IsCapture && As_Building(TarCom) != NULL) {
- Assign_Destination(TarCom);
- Assign_Mission(MISSION_CAPTURE);
- return(1);
- }
- return(FootClass::Mission_Attack());
- }
- /***********************************************************************************************
- * InfantryClass::What_Action -- Determines what action to perform for the cell specified. *
- * *
- * This routine will determine what action to perform if the mouse was clicked on the cell *
- * specified. This is just a courier function since the lower level classes actually *
- * perform the work. The need for this routine at this level is due to the existence of *
- * a similarly named function at this level as well. C++ namespace rules require this *
- * function courier to be in place or an error will result. *
- * *
- * INPUT: cell -- The cell that the mouse might be clicked upon. *
- * *
- * OUTPUT: Returns with the action that would be given to this infantry unit if the mouse *
- * were clicked at the cell specified. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/21/1995 JLB : Created. *
- *=============================================================================================*/
- ActionType InfantryClass::What_Action(CELL cell) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- ActionType action = FootClass::What_Action(cell);
- /*
- ** Dogs can only attack infantrymen
- */
- if (Class->IsDog && action == ACTION_ATTACK) {
- action = ACTION_NONE;
- }
- /*
- ** If this is a medic, and the cursor's over a friendly infantryman,
- ** execute an action-attack.
- */
- if (Combat_Damage() < 0 && House->IsPlayerControl) {
- if (action == ACTION_ATTACK) {
- action = ACTION_NOMOVE;
- }
- }
- /*
- ** Demolitioners may destroy a bridge
- */
- if (Class->IsBomber && action == ACTION_MOVE && !Special.IsCaptureTheFlag) {
- switch (Map[cell].TType) {
- case TEMPLATE_BRIDGE1:
- case TEMPLATE_BRIDGE2:
- case TEMPLATE_BRIDGE1H:
- case TEMPLATE_BRIDGE2H:
- case TEMPLATE_BRIDGE_1A:
- case TEMPLATE_BRIDGE_1B:
- case TEMPLATE_BRIDGE_2A:
- case TEMPLATE_BRIDGE_2B:
- // case TEMPLATE_BRIDGE_3A:
- // case TEMPLATE_BRIDGE_3B:
- return(ACTION_SABOTAGE);
- }
- }
- #ifdef OBSOLETE
- /*
- ** Engineers may repair a destroyed bridge.
- */
- if (*this == INFANTRY_RENOVATOR && action == ACTION_NOMOVE) {
- /*
- ** If they're pointing on the wrong side of the bridge, ignore it
- ** 'cause we can't get there.
- */
- TemplateType tt = Map[cell].TType;
- if (tt == TEMPLATE_BRIDGE1D || tt == TEMPLATE_BRIDGE2D ||
- tt == TEMPLATE_BRIDGE_1C || tt == TEMPLATE_BRIDGE_2C ||
- (tt >= TEMPLATE_BRIDGE_3C && tt <= TEMPLATE_BRIDGE_3E) ) {
- /*
- ** We know they're pointing at a destroyed bridge cell. If the cell
- ** they're pointing at is surrounded by impassables, return this
- ** cell as impassable. But, if any cell surrounding this cell is
- ** passable, return that this is a capturable cell.
- */
- if (Map[cell].Land_Type() == LAND_ROCK) {
- if (tt == TEMPLATE_BRIDGE_3C) return(ACTION_CAPTURE);
- if (tt == TEMPLATE_BRIDGE_3C) return(ACTION_CAPTURE);
- int y = Cell_Y(cell);
- if (y) {
- LandType above = Map[(CELL)(cell-(MAP_CELL_W-1))].Land_Type();
- if (above == LAND_CLEAR || above == LAND_ROAD) {
- if (Map[(CELL)(cell-(MAP_CELL_W-1))].Zone == Map[As_Cell(As_Target())].Zone) {
- return(ACTION_CAPTURE);
- }
- return(ACTION_NOMOVE);
- }
- }
- if (y < MAP_CELL_H) {
- LandType below = Map[(CELL)(cell + MAP_CELL_W-1)].Land_Type();
- if (below == LAND_CLEAR || below == LAND_ROAD) {
- if (Map[(CELL)(cell+MAP_CELL_W-1)].Zone == Map[As_Cell(As_Target())].Zone) {
- return(ACTION_CAPTURE);
- }
- return(ACTION_NOMOVE);
- }
- }
- }
- return(ACTION_NOMOVE);
- }
- }
- #endif
- return(action);
- }
- /***********************************************************************************************
- * InfantryClass::Class_Of -- Returns the class reference for this object. *
- * *
- * This routine will return a reference to the infantry type class object that describes *
- * this infantry's characteristics. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with a reference to the InfantryTypeClass object associated with this *
- * infantry object. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/21/1995 JLB : Created. *
- *=============================================================================================*/
- ObjectTypeClass const & InfantryClass::Class_Of(void) const
- {
- assert(Infantry.ID(this) == ID);
- assert(IsActive);
- return(*Class);
- }
- /***********************************************************************************************
- * InfantryClass::Read_INI -- Reads units from scenario INI file. *
- * *
- * This routine is used to read all the starting units from the *
- * scenario control INI file. The units are created and placed on the *
- * map by this routine. *
- * *
- * INI entry format: *
- * Housename, Typename, Strength, Cellnum, CellSublocation, Missionname, *
- * Facingnum, Triggername *
- * *
- * INPUT: buffer -- Pointer to the loaded scenario INI file. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/24/1994 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Read_INI(CCINIClass & ini)
- {
- InfantryClass * infantry; // Working infantry pointer.
- HousesType inhouse; // Infantry house.
- InfantryType classid; // Infantry class.
- char buf[128];
- char * validation;
- DirType dir;
- TriggerTypeClass * tp;
- int len = ini.Entry_Count(INI_Name());
- for (int index = 0; index < len; index++) {
- char const * entry = ini.Get_Entry(INI_Name(), index);
- /*
- ** Get an infantry entry
- */
- ini.Get_String(INI_Name(), entry, NULL, buf, sizeof(buf));
- /*
- ** 1st token: house name.
- */
- inhouse = HouseTypeClass::From_Name(strtok(buf, ",\n\r"));
- if (inhouse != HOUSE_NONE) {
- /*
- ** 2nd token: infantry type name.
- */
- classid = InfantryTypeClass::From_Name(strtok(NULL, ",\n\r"));
- if (classid != INFANTRY_NONE) {
- infantry = new InfantryClass(classid, inhouse);
- if (infantry != NULL) {
- /*
- ** 3rd token: strength.
- */
- int strength = atoi(strtok(NULL, ",\n\r"));
- /*
- ** 4th token: cell #.
- */
- CELL cell = atoi(strtok(NULL, ",\n\r"));
- COORDINATE coord = Cell_Coord(cell);
- /*
- ** 5th token: cell sub-location.
- */
- int sub = atoi(strtok(NULL, ","));
- coord = Coord_Add(Coord_Whole(coord), StoppingCoordAbs[ sub ]);
- /*
- ** Fetch the mission and facing.
- */
- MissionType mission = MissionClass::Mission_From_Name(strtok(NULL, ",\n\r"));
- validation = strtok(NULL, ",\n\r");
- if (validation) {
- dir = (DirType)atoi(validation);
- validation = strtok(NULL, ",\n\r");
- if (validation) {
- tp = TriggerTypeClass::From_Name(validation);
- } else {
- tp = NULL;
- }
- } else {
- dir = (DirType)0;
- tp = NULL;
- }
- infantry->Trigger = NULL;
- if (tp != NULL) {
- TriggerClass * tt = Find_Or_Make(tp);
- if (tt != NULL) {
- tt->AttachCount++;
- infantry->Trigger = tt;
- }
- }
- if (infantry->Unlimbo(coord, dir)) {
- infantry->Strength = infantry->Class_Of().MaxStrength * fixed(strength, 256);
- if (infantry->Strength > infantry->Class->MaxStrength-3) infantry->Strength = infantry->Class->MaxStrength;
- // infantry->Strength = Fixed_To_Cardinal(infantry->Class_Of().MaxStrength, strength);
- if (Session.Type == GAME_NORMAL || infantry->House->IsHuman) {
- infantry->Assign_Mission(mission);
- infantry->Commence();
- } else {
- infantry->Enter_Idle_Mode();
- }
- } else {
- /*
- ** If the infantry could not be unlimboed, then this is a big error.
- ** Delete the infantry.
- */
- delete infantry;
- }
- }
- }
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Write_INI -- Store the infantry to the INI database. *
- * *
- * This will store all the infantry objects to the INI database specified. *
- * *
- * INPUT: ini -- Reference to the INI database to store the infantry data to. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/03/1996 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Write_INI(CCINIClass & ini)
- {
- /*
- ** First, clear out all existing infantry data from the ini file.
- */
- ini.Clear(INI_Name());
- /*
- ** Write the infantry data out.
- */
- for (int index = 0; index < Infantry.Count(); index++) {
- InfantryClass * infantry = Infantry.Ptr(index);
- if (!infantry->IsInLimbo) {
- char uname[10];
- char buf[128];
- sprintf(uname, "%d", index);
- sprintf(buf, "%s,%s,%d,%u,%d,%s,%d,%s",
- infantry->House->Class->IniName,
- infantry->Class->IniName,
- infantry->Health_Ratio()*256,
- Coord_Cell(infantry->Coord),
- CellClass::Spot_Index(infantry->Coord),
- MissionClass::Mission_Name((infantry->Mission == MISSION_NONE) ?
- infantry->MissionQueue : infantry->Mission),
- infantry->PrimaryFacing.Current(),
- infantry->Trigger.Is_Valid() ? infantry->Trigger->Class->IniName : "None"
- );
- ini.Put_String(INI_Name(), uname, buf);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Fear_AI -- Process any fear related affects on this infantry. *
- * *
- * Use this routine to handle the fear logic for this infantry. It will slowly increase *
- * the bravery of the infantry as well as cause it to stand up or lie down as appropriate. *
- * It will even handle the special fraidy cat logic for civilian infantry. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: Only call this once per game logic loop per infantry unit. *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Fear_AI(void)
- {
- /*
- ** After a time, the infantry will gain courage.
- */
- if (Fear > 0) {
- Fear--;
- /*
- ** When an armed civilian becomes unafraid, he will then reload
- ** another clip into his pistol.
- */
- if (Fear == 0 && Ammo == 0 && Is_Weapon_Equipped()) {
- Ammo = Class->MaxAmmo;
- }
- /*
- ** Stand up if brave and lie down if afraid.
- */
- if (IsProne) {
- if (Fear < FEAR_ANXIOUS) {
- Do_Action(DO_GET_UP);
- }
- } else {
- /*
- ** Drop to the ground if anxious. Don't drop to the ground while moving
- ** and the special elite flag is active.
- */
- if (!Class->IsDog && Height == 0 && Fear >= FEAR_ANXIOUS && ((!Target_Legal(NavCom) && !IsDriving))) {
- Do_Action(DO_LIE_DOWN);
- }
- }
- }
- /*
- ** When in darkness or in doubt,
- ** run in circles, scream, and shout.
- */
- if (Class->IsFraidyCat && Fear > FEAR_ANXIOUS && !IsFalling && !IsDriving && !Target_Legal(NavCom)) {
- Scatter(0, true);
- }
- }
- /***********************************************************************************************
- * InfantryClass::Edge_Of_World_AI -- Detects when infantry has left the map. *
- * *
- * This routine will detect when the infantry has left the edge of the world and will *
- * delete it as necessary. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: bool; Was the infantry unit deleted by this routine? *
- * *
- * WARNINGS: Be sure the check the return value and if true, abort any further processing *
- * for this infantry unit. *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Edge_Of_World_AI(void)
- {
- /*
- ** Delete this unit if it finds itself off the edge of the map and it is in
- ** guard or other static mission mode.
- */
- if (Team.Is_Valid() && IsLocked) Team->IsLeaveMap = true;
- if (!Team.Is_Valid() && Mission == MISSION_GUARD && !Map.In_Radar(Coord_Cell(Coord))) {
- Stun();
- delete this;
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * InfantryClass::Firing_AI -- Handles firing and combat AI for the infantry. *
- * *
- * This will examine the infantry and determine what firing action is required. It will *
- * search for targets, starting firing animations, and launch bullets as necessary. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: Only call this routine once per infantry per game logic loop. *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Firing_AI(void)
- {
- if (Target_Legal(TarCom)) {
- int primary = What_Weapon_Should_I_Use(TarCom);
- if (!IsFiring) {
- switch (Can_Fire(TarCom, primary)) {
- case FIRE_ILLEGAL:
- if (Combat_Damage(primary) < 0) {
- ObjectClass * targ= As_Object(TarCom);
- #ifdef FIXIT_CSII // checked - ajw 9/28/98
- if (targ) {
- if( (targ->What_Am_I() == RTTI_INFANTRY && *this == INFANTRY_MEDIC) ||
- (*this == INFANTRY_MECHANIC && (targ->What_Am_I() == RTTI_AIRCRAFT || targ->What_Am_I() == RTTI_UNIT )) ) {
- if (targ->Health_Ratio() >= Rule.ConditionGreen) {
- Assign_Target(TARGET_NONE);
- }
- }
- } else {
- Assign_Target(TARGET_NONE);
- }
- #else
- if (targ && targ->What_Am_I() == RTTI_INFANTRY) {
- if (targ->Health_Ratio() >= Rule.ConditionGreen) {
- Assign_Target(TARGET_NONE);
- }
- } else {
- Assign_Target(TARGET_NONE);
- }
- #endif
- }
- break;
- case FIRE_CLOAKED:
- Do_Uncloak();
- break;
- case FIRE_OK:
- /*
- ** Start firing animation.
- */
- if (IsProne) {
- Do_Action(DO_FIRE_PRONE);
- } else {
- Do_Action(DO_FIRE_WEAPON);
- }
- Mark(MARK_OVERLAP_UP);
- IsFiring = true;
- Mark(MARK_OVERLAP_DOWN);
- PrimaryFacing.Set(Direction8(Center_Coord(), As_Coord(TarCom)));
- /*
- ** If the target is in range, and the NavCom is the same, then just
- ** stop and keep firing.
- */
- if (TarCom == NavCom) {
- NavCom = TARGET_NONE;
- Path[0] = FACING_NONE;
- }
- break;
- }
- }
- /*
- ** If in the middle of firing animation, then only
- ** process that. Infantry cannot fire and move simultaneously.
- ** At some point in the firing animation process, a projectile
- ** will be launched. When the required animation frames have
- ** been completed, the firing animation stops.
- */
- int firestage = Class->FireLaunch;
- if (IsProne) firestage = Class->ProneLaunch;
- if (IsFiring && Fetch_Stage() == firestage) {
- Fire_At(TarCom, primary);
- /*
- ** Run away from slowly approaching projectiles.
- */
- if (Class->PrimaryWeapon->MaxSpeed < Rule.Incoming) {
- Map[::As_Cell(TarCom)].Incoming(Coord, true);
- }
- /*
- ** If it's a dog, get rid of him (he'll be re-created when he hits)
- */
- if (Class->IsDog) {
- WasSelected = IsSelected;
- ScenarioInit++;
- Limbo();
- ScenarioInit--;
- }
- }
- } else {
- if (IsFiring) {
- Mark(MARK_OVERLAP_UP);
- IsFiring = false;
- Mark(MARK_OVERLAP_DOWN);
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Doing_AI -- Handles the animation AI processing. *
- * *
- * Infantry can be in one of many different animation sequences. At the conclusion of each *
- * sequence, the infantry will quite likely transition to a new animation state. This *
- * routine handles detecting when that trasition should occur and starting the infantry *
- * into its new state. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: Only call this routine once per infantry unit per game logic loop. *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Doing_AI(void)
- {
- if (Doing == DO_NOTHING || Fetch_Stage() >= Class->DoControls[Doing].Count) {
- switch (Doing) {
- default:
- if (IsDriving) {
- if (Class->IsDog) {
- /*
- ** Dog crawl animation is actually the run animation.
- */
- if (Target_Legal(TarCom)) {
- Do_Action(DO_CRAWL, true);
- } else {
- Do_Action(DO_WALK, true);
- }
- } else {
- if (IsProne) {
- Do_Action(DO_CRAWL, true);
- } else {
- Do_Action(DO_WALK, true);
- }
- }
- } else {
- if (Class->IsDog) {
- Do_Action(DO_STAND_READY, true);
- } else {
- if (IsProne) {
- Do_Action(DO_PRONE, true);
- } else {
- Do_Action(DO_STAND_READY, true);
- }
- }
- }
- break;
- case DO_DOG_MAUL:
- Do_Action(DO_STAND_READY, true);
- break;
- case DO_GUN_DEATH:
- case DO_EXPLOSION_DEATH:
- case DO_EXPLOSION2_DEATH:
- case DO_GRENADE_DEATH:
- case DO_FIRE_DEATH:
- if (Fetch_Stage() >= Class->DoControls[Doing].Count) {
- if (Doing == DO_GUN_DEATH && !Class->IsDog && Height==0) {
- new AnimClass(ANIM_CORPSE1, Coord_Add(Center_Coord(), XYP_Coord(-2, 4)));
- }
- if (Doing == DO_GRENADE_DEATH && !Class->IsDog && Height==0) {
- new AnimClass(ANIM_CORPSE1, Coord_Add(Center_Coord(), XYP_Coord(-10, 3)));
- }
- if (Doing == DO_EXPLOSION_DEATH && !Class->IsDog && Height==0) {
- new AnimClass(ANIM_CORPSE3, Coord_Add(Center_Coord(), XYP_Coord(-2, 4)));
- }
- if (Doing == DO_EXPLOSION2_DEATH && !Class->IsDog && Height==0) {
- new AnimClass(ANIM_CORPSE2, Center_Coord());
- }
- delete this;
- return;
- }
- }
- }
- }
- /***********************************************************************************************
- * InfantryClass::Movement_AI -- This routine handles all infantry movement logic. *
- * *
- * It examines the infantry state and determines what movement action should be initiated *
- * or processed. It handles the actual movement of the infantry as well as any path finding *
- * or infantry startup logic. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: Only call this routine once per infantry unit per game logic loop. *
- * *
- * HISTORY: *
- * 07/29/1996 JLB : Created. *
- *=============================================================================================*/
- void InfantryClass::Movement_AI(void)
- {
- /*
- ** Special hack check to ensure that infantry will never get stuck in a movement order if
- ** there is no place to go.
- */
- if (Mission == MISSION_MOVE && !Target_Legal(NavCom)) {
- Enter_Idle_Mode();
- }
- if (!IsFiring && !IsFalling && Doing != DO_DOG_MAUL) {
- if (!IsDriving) {
- /*
- ** When in guard mode, never allow a valid navcom.
- */
- if (Mission == MISSION_GUARD && MissionQueue == MISSION_NONE && Target_Legal(NavCom)) {
- Assign_Destination(TARGET_NONE);
- // if (IsTethered) Scatter(0, true);
- }
- /*
- ** Double check to make sure it doesn't have a movement destination into a zone
- ** that it can't travel to. In such a case, abort the movement process by clearing
- ** the navigation computer.
- */
- if ((!IsZoneCheat || Can_Enter_Cell(Coord_Cell(Coord)) != MOVE_NO) && !IsDriving && !IsTethered && Target_Legal(NavCom) && IsLocked && Map[Coord].Zones[Class->MZone] != Map[As_Cell(NavCom)].Zones[Class->MZone]) {
- // hack: if it's tanya, spy, or engineer, let 'em move there anyway.
- if (!Class->IsCapture && Mission != MISSION_ENTER) {
- // if (*this != INFANTRY_TANYA && *this != INFANTRY_SPY && *this != INFANTRY_RENOVATOR) {
- Assign_Destination(TARGET_NONE);
- }
- }
- /*
- ** A head to coordinate is needed. If there is no path
- ** available, then create one.
- */
- if (Target_Legal(NavCom) && Strength && Mission != MISSION_GUARD) {
- /*
- ** Determine if the next cell in the list is available
- ** to be entered. If not, then abort the path and try
- ** again.
- */
- if (Path[0] != FACING_NONE && Can_Enter_Cell(Adjacent_Cell(Coord_Cell(Center_Coord()), Path[0])) != MOVE_OK) {
- Path[0] = FACING_NONE;
- }
- /*
- ** Check to see if the target is closer than expected. This occurs
- ** when heading toward a moving object and that object is heading
- ** toward the unit. Shorten the precalculated path to be no longer
- ** than the distance to the target.
- */
- int d = Lepton_To_Cell(Distance(NavCom));
- if (d < CONQUER_PATH_MAX) {
- Path[d] = FACING_NONE;
- }
- /*
- ** Find a path to follow if one isn't already calculated.
- */
- if (Path[0] == FACING_NONE) {
- /*
- ** Calculate the path from the current location to the
- ** destination indicated by the navigation computer. If there
- ** was a fundamental error with finding a path, then this
- ** indicates that basic path & movement logic needs to be
- ** aborted.
- */
- if (PathDelay != 0) {
- return;
- }
- if (!Basic_Path()) {
- /*
- ** Check to ensure that if a computer controlled unit is in
- ** hunt mode, but cannot reach the target it would like to,
- ** abort the target tracking and let the normal hunt logic
- ** assign a new one.
- */
- if (!House->IsHuman && Mission == MISSION_HUNT) {
- Assign_Destination(TARGET_NONE);
- Assign_Target(TARGET_NONE);
- } else {
- /*
- ** If the infantry unit is close enough to the target, then
- ** tell it to stop.
- */
- if (Distance(NavCom) < Rule.CloseEnoughDistance && !IsTethered) {
- Assign_Destination(TARGET_NONE);
- } else {
- /*
- ** Update the try try again counter so that this
- ** infantry unit will try again at a later time.
- */
- if (TryTryAgain) {
- TryTryAgain--;
- } else {
- if (IsNewNavCom) Sound_Effect(VOC_SCOLD);
- IsNewNavCom = false;
- /*
- ** Abort the target and destination process since the path
- ** could not be found. In such a case, processing should stop
- ** or else the game will bog down with repeated path failures.
- ** Only perform the abort of the target is in a different zone.
- */
- if ((!IsZoneCheat || Can_Enter_Cell(Coord_Cell(Coord)) != MOVE_NO) && IsLocked && Target_Legal(NavCom) && Map[As_Cell(NavCom)].Zones[Class->MZone] != Map[Coord].Zones[Class->MZone]) {
- Assign_Destination(TARGET_NONE);
- }
- if (IsLocked && Target_Legal(TarCom) && Map[As_Cell(TarCom)].Zones[Class->MZone] != Map[Coord].Zones[Class->MZone]) {
- Assign_Target(TARGET_NONE);
- }
- }
- }
- }
- Stop_Driver();
- return;
- }
- TryTryAgain = PATH_RETRY;
- }
- /*
- ** Determine the coordinate to head to based on the infantry's
- ** current location and the next location in the path.
- */
- COORDINATE acoord = Adjacent_Cell(Coord, Path[0]);
- CELL acell = Coord_Cell(acoord);
- if (Can_Enter_Cell(acell) != MOVE_OK) {
- if ((Mission == MISSION_MOVE || Mission == MISSION_ENTER) && !IsTethered /*&& House->IsHuman*/ && Distance(NavCom) < Rule.CloseEnoughDistance) {
- Assign_Destination(TARGET_NONE);
- } else {
- /*
- ** If blocked by a moving block then just exit start of move and
- ** try again next tick.
- */
- if (Can_Enter_Cell(acell) == MOVE_DESTROYABLE) {
- if (Map[acell].Cell_Object()) {
- if (!House->Is_Ally(Map[acell].Cell_Object())) {
- Override_Mission(MISSION_ATTACK, Map[acell].Cell_Object()->As_Target(), TARGET_NONE);
- }
- } else {
- if (Map[acell].Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(Map[acell].Overlay).IsWall) {
- Override_Mission(MISSION_ATTACK, ::As_Target(acell), TARGET_NONE);
- }
- }
- }
- }
- Path[0] = FACING_NONE;
- Stop_Driver();
- if (IsNewNavCom) Sound_Effect(VOC_SCOLD);
- IsNewNavCom = false;
- } else {
- if (Start_Driver(acoord)) {
- if (!IsActive) return;
- PrimaryFacing.Set(Direction8(Center_Coord(), Head_To_Coord()));
- if (IsFormationMove) {
- Set_Speed(Ground[Map[Coord].Land_Type()].Cost[FormationSpeed] * 256);
- } else {
- Set_Speed(0xFF);
- }
- if (Class->IsDog) {
- /*
- ** Dog crawl animation is actually the run animation.
- */
- if (Target_Legal(TarCom)) {
- Do_Action(DO_CRAWL);
- } else {
- Do_Action(DO_WALK);
- }
- } else {
- if (IsProne) {
- Do_Action(DO_CRAWL);
- } else {
- Do_Action(DO_WALK);
- }
- }
- }
- }
- }
- } else {
- /*
- ** The infantry knows where it should be headed, so head there. Check
- ** to see if the infantry is "close enough" to the desired location that
- ** it should just consider itself to have arrived. In this case, force
- ** the infantry to the destination location and mark this path step
- ** as complete.
- */
- Mark(MARK_UP);
- if (Distance(Head_To_Coord()) < 0x0010) {
- memcpy(&Path[0], &Path[1], sizeof(Path)-sizeof(Path[0]));
- Path[(sizeof(Path)/sizeof(Path[0]))-1] = FACING_NONE;
- Coord = Head_To_Coord();
- Per_Cell_Process(PCP_END);
- if (!IsActive || IsInLimbo) return;
- Stop_Driver();
- if (!IsActive || IsInLimbo) return;
- if (Coord_Cell(Coord) == As_Cell(NavCom)) {
- NavCom = TARGET_NONE;
- if (Mission == MISSION_MOVE) {
- Enter_Idle_Mode();
- }
- //Stop_Driver();
- Path[0] = FACING_NONE;
- }
- } else {
- int movespeed = Speed;
- /*
- ** When prone, the infantry moves at half speed or double
- ** speed. This depends on whether the infantry actually has
- ** prone animation stages. Civilians don't, and so they
- ** run instead.
- */
- if (Class->IsDog && Target_Legal(TarCom)) {
- movespeed *= 2;
- }
- if (IsProne && !Class->IsDog) {
- if ((Class->IsFraidyCat && !Class->IsCrawling) ) {
- movespeed = Speed*2;
- } else {
- movespeed = Speed/2;
- }
- }
- if (IsTethered) {
- Transmit_Message(RADIO_REDRAW);
- }
- /*
- ** Advance the infantry as far as it should go.
- */
- MPHType maxspeed = MPHType(min(Class->MaxSpeed * SpeedBias * House->GroundspeedBias, MPH_LIGHT_SPEED));
- if (IsFormationMove) maxspeed = FormationMaxSpeed;
- Coord = Coord_Move(Coord, Direction(Head_To_Coord()), maxspeed * fixed(movespeed, 256));
- }
- Mark(MARK_DOWN);
- }
- IsNewNavCom = false;
- }
- }
- /***********************************************************************************************
- * InfantryClass::Get_Image_Data -- Fetches the image data for this infantry unit. *
- * *
- * The image data for the infantry differs from normal if this is a spy. A spy always *
- * appears like a minigunner to the non-owning players. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with a pointer to the image data to use for this infantry soldier. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/06/1996 JLB : Created. *
- *=============================================================================================*/
- void const * InfantryClass::Get_Image_Data(void) const
- {
- if (!IsOwnedByPlayer && *this == INFANTRY_SPY) {
- return(MFCD::Retrieve("E1.SHP"));
- }
- return(TechnoClass::Get_Image_Data());
- }
- /***********************************************************************************************
- * InfantryClass::Is_Ready_To_Random_Anima -- Checks to see if it is ready to perform an idle *
- * *
- * This routine will examine this infantry and determine if it is allowed and ready to *
- * perform an idle animation. The conditions under which idle animations can be performed *
- * are restrictive. Hence this routine. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: bool; Is this infantry ready to do an idle animation? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 10/01/1996 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Is_Ready_To_Random_Animate(void) const
- {
- /*
- ** See if the base classes (more rudimentary checking) determines that idle animations
- ** cannot occur. If they cannot, then return with the failure code.
- */
- if (!FootClass::Is_Ready_To_Random_Animate()) {
- return(false);
- }
- /*
- ** While the infantry is in the air (such as when paradropping), it won't be allowed
- ** to idle animate.
- */
- if (Height > 0) {
- return(false);
- }
- /*
- ** When the infantry is walking or otherwise engauged in travel, it won't idle animate.
- */
- if (IsDriving) {
- return(false);
- }
- /*
- ** When prone, idle animations cannot occur. This is primarily because there are no prone
- ** idle animations.
- */
- if (IsProne) {
- return(false);
- }
- /*
- ** When firing, the infantry should not perform any idle animations.
- */
- if (IsFiring) {
- return(false);
- }
- /*
- ** Only if the infantry is in guard or ready stance is idle animations allowed. This is
- ** because the idle animations start and end with these frames.
- */
- if (Doing != DO_STAND_GUARD && Doing != DO_STAND_READY) {
- return(false);
- }
- /*
- ** Since no reason was found to indicate it is not a good time to idle
- ** animate, then it must be a good time to do so.
- */
- return(true);
- }
- /***********************************************************************************************
- * InfantryClass::Paradrop -- Handles paradropping infantry. *
- * *
- * This routine will paradrop this soldier at the location specified. It will cause the *
- * soldier to hunt if controlled by the computer and to guard if controlledy by the *
- * human. *
- * *
- * INPUT: coord -- The coordinate to paradrop the soldier to. *
- * *
- * OUTPUT: bool; Was the paradrop successful? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 10/19/1996 JLB : Created. *
- *=============================================================================================*/
- bool InfantryClass::Paradrop(COORDINATE coord)
- {
- if (FootClass::Paradrop(coord)) {
- if (House->IsHuman) {
- Assign_Mission(MISSION_GUARD);
- } else {
- Assign_Mission(MISSION_HUNT);
- }
- return(true);
- }
- return(false);
- }
|