CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

INFANTRY.H (9149B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/INFANTRY.H 1     3/03/97 10:24a Joe_bostic $ */
     17 /***********************************************************************************************
     18  ***              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               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : INFANTRY.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : August 15, 1994                                              *
     28  *                                                                                             *
     29  *                  Last Update : August 15, 1994   [JLB]                                      *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef INFANTRY_H
     36 #define INFANTRY_H
     37 
     38 
     39 class InfantryClass : public FootClass
     40 {
     41 	public:
     42 		CCPtr<InfantryTypeClass> Class;
     43 
     44 		/*
     45 		**	If the infantry is undergoing some choreographed animation sequence, then
     46 		**	this holds the particular sequence number. The frame of animation is kept
     47 		**	track of by the regular frame tracking system. When performing an animation
     48 		**	sequence, the infantry cannot perform anything else (even move).
     49 		*/
     50 		DoType Doing;
     51 
     52 		/*
     53 		**	Certain infantry will either perform some comment or say something after an
     54 		**	amount of time has expired subsequent to an significant event. This is the
     55 		**	timer the counts down.
     56 		*/
     57 		CDTimerClass<FrameTimerClass> Comment;
     58 
     59 		/*
     60 		**	If this civilian is actually a technician, then this flag will be true.
     61 		**	It should only be set for the civilian type infantry. Typically, the
     62 		**	technician appears after a building is destroyed.
     63 		*/
     64 		unsigned IsTechnician:1;
     65 
     66 		/*
     67 		**	If the infantry just performed some feat, then it may respond with an action.
     68 		**	This flag will be true if an action is to be performed when the Comment timer
     69 		**	has expired.
     70 		*/
     71 		unsigned IsStoked:1;
     72 
     73 		/*
     74 		**	This flag indicates if the infantry unit is prone. Prone infantry become that way
     75 		**	when they are fired upon. Infantry in the prone position are less vulnerable to
     76 		**	combat.
     77 		*/
     78 		unsigned IsProne:1;
     79 
     80 		/*
     81 		**	If the infantry is allowed to move one cell from one zone to another, then this
     82 		**	flag will be true. It exists only so that when a bridge is destroyed, the bomb
     83 		**	placer is allowed to run from the destroyed bridge cell back onto a real cell.
     84 		*/
     85 		unsigned IsZoneCheat:1;
     86 
     87 		/*
     88 		** This flag is set for the dogs, when they launch into bullet mode.
     89 		** it's to remember if the unit was selected, and if it was, then
     90 		** when the dog is re-enabled, he'll reselect himself.
     91 		*/
     92 		unsigned WasSelected:1;
     93 
     94 		/*
     95 		**	The fear rating of this infantry unit. The more afraid the infantry, the more
     96 		**	likely it is to panic and seek cover.
     97 		*/
     98 		FearType Fear;
     99 
    100 		/*
    101 		** Track when movement last stopped.
    102 		*/
    103 		long StopDriverFrame;
    104 
    105 		/*
    106 		** Track the last cell we looked from.
    107 		*/
    108 		CELL LookCell;
    109 
    110 		/*---------------------------------------------------------------------
    111 		**	Constructors, Destructors, and overloaded operators.
    112 		*/
    113 		static void * operator new(size_t size);
    114 		static void * operator new(size_t , void * ptr) {return(ptr);};
    115 		static void operator delete(void *ptr);
    116 		InfantryClass(InfantryType classid, HousesType house);
    117 		InfantryClass(NoInitClass const & x) : FootClass(x), Class(x), Comment(x) {};
    118 		virtual ~InfantryClass(void);
    119 		operator InfantryType(void) const {return Class->Type;};
    120 
    121 		/*---------------------------------------------------------------------
    122 		**	Member function prototypes.
    123 		*/
    124 		static void Init(void);
    125 
    126 		virtual void Assign_Destination(TARGET);
    127 
    128 		/*
    129 		**	Query functions.
    130 		*/
    131 		virtual bool Is_Ready_To_Random_Animate(void) const;
    132 		void const * Get_Image_Data(void) const;
    133 		int Shape_Number(WindowNumberType window = WINDOW_MAIN) const;
    134 		virtual ObjectTypeClass const & Class_Of(void) const;
    135 		virtual int Full_Name(void) const;
    136 
    137 		/*
    138 		**	Object entry and exit from the game system.
    139 		*/
    140 		virtual bool Unlimbo(COORDINATE coord, DirType facing);
    141 		virtual bool Paradrop(COORDINATE coord);
    142 		virtual bool Limbo(void);
    143 		virtual void Detach(TARGET target, bool all);
    144 
    145 		/*
    146 		**	Display and rendering support functionality. Supports imagery and how
    147 		**	object interacts with the map and thus indirectly controls rendering.
    148 		*/
    149 		virtual short const * Overlap_List(bool redraw = false) const;
    150 		virtual void Draw_It(int x, int y, WindowNumberType window) const;
    151 
    152 		/*
    153 		**	User I/O.
    154 		*/
    155 		virtual void Response_Select(void);
    156 		virtual void Response_Move(void);
    157 		virtual void Response_Attack(void);
    158 		virtual void Active_Click_With(ActionType action, ObjectClass * object);
    159 		virtual void Active_Click_With(ActionType action, CELL cell) {FootClass::Active_Click_With(action, cell);}
    160 
    161 		/*
    162 		**	Combat related.
    163 		*/
    164 		virtual ActionType What_Action(ObjectClass const * object) const;
    165 		virtual ActionType What_Action(CELL cell) const;
    166 		virtual BulletClass * Fire_At(TARGET target, int which);
    167 		virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
    168 		virtual FireErrorType Can_Fire(TARGET target, int which) const;
    169 		virtual COORDINATE Fire_Coord(int which) const;
    170 		virtual void Assign_Target(TARGET);
    171 		void Set_Occupy_Bit(COORDINATE coord) {Set_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
    172 		void Set_Occupy_Bit(CELL cell, int spot_index);
    173 		void Clear_Occupy_Bit(COORDINATE coord) {Clear_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
    174 		void Clear_Occupy_Bit(CELL cell, int spot_index);
    175 
    176 		/*
    177 		**	Driver control support functions. These are used to control cell
    178 		**	occupation flags and driver instructions.
    179 		*/
    180 		virtual bool Stop_Driver(void);
    181 		virtual bool Start_Driver(COORDINATE & coord);
    182 
    183 		/*
    184 		**	AI.
    185 		*/
    186 		virtual void AI(void);
    187 		void Fear_AI(void);
    188 		virtual TARGET Greatest_Threat(ThreatType threat) const;
    189 		virtual int Mission_Attack(void);
    190 		bool Edge_Of_World_AI(void);
    191 		void Firing_AI(void);
    192 		void Doing_AI(void);
    193 		void Movement_AI(void);
    194 
    195 		/*
    196 		**	Scenario and debug support.
    197 		*/
    198 		#ifdef CHEAT_KEYS
    199 		virtual void Debug_Dump(MonoClass *mono) const;
    200 		#endif
    201 
    202 		/*
    203 		**	File I/O.
    204 		*/
    205 		static void Read_INI(CCINIClass & ini);
    206 		static void Write_INI(CCINIClass & ini);
    207 		static char *INI_Name(void) {return "INFANTRY";};
    208 		bool Load(Straw & file);
    209 		bool Save(Pipe & file) const;
    210 
    211 		/*
    212 		**	Movement and animation.
    213 		*/
    214 		virtual bool Do_Action(DoType todo, bool force=false);
    215 		virtual bool Random_Animate(void);
    216 		virtual MoveType Can_Enter_Cell(CELL , FacingType =FACING_NONE) const;
    217 		virtual void Per_Cell_Process(PCPType why);
    218 		virtual void Enter_Idle_Mode(bool initial=false);
    219 		virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false);
    220 		virtual void Look(bool incremental=false);
    221 
    222 		/*
    223 		**	Translation table to convert facing into infantry shape number. This special
    224 		**	table is needed since several facing stages are reused and flipped about the Y
    225 		**	axis.
    226 		*/
    227 		static int const HumanShape[32];
    228 
    229 	private:
    230 
    231 		static DoStruct const MasterDoControls[DO_COUNT];
    232 
    233 		/*
    234 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    235 		*/
    236 		unsigned char SaveLoadPadding[32];
    237 };
    238 
    239 #endif