CnC_Remastered_Collection

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

INFANTRY.H (9395B)


      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:   F:\projects\c&c\vcs\code\infantry.h_v   2.18   16 Oct 1995 16:48:08   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 **	Infantry can be afraid. These defines are for the various infantry
     40 **	fear levels. When infantry be come scared enough they take cover and
     41 **	even run away in panic.
     42 */
     43 #define	FEAR_ANXIOUS	10			// Something makes them scared.
     44 #define	FEAR_SCARED		100		// Scared enough to take cover.
     45 #define	FEAR_PANIC		200		// Run away! Run away!
     46 #define	FEAR_MAXIMUM	255		// Scared to death.
     47 
     48 
     49 class InfantryClass : public FootClass
     50 {
     51 	public:
     52 		InfantryTypeClass const * const Class;
     53 		operator InfantryType(void) const {return Class->Type;};
     54 
     55 		/*
     56 		**	If the infantry is undergoing some choreographed animation sequence, then
     57 		**	this holds the particular sequence number. The frame of animation is kept
     58 		**	track of by the regular frame tracking system. When performing an animation
     59 		**	sequence, the infantry cannot perform anything else (even move).
     60 		*/
     61 		DoType Doing;
     62 
     63 		/*
     64 		**	Certain infantry will either perform some comment or say something after an
     65 		**	amount of time has expired subsiquent to an significant event. This is the
     66 		**	timer the counts down.
     67 		*/
     68 		TCountDownTimerClass Comment;
     69 
     70 		/*
     71 		**	If this civilian is actually a technician, then this flag will be true.
     72 		**	It should only be set for the civilian type infantry. Typically, the
     73 		**	technician appears after a building is destroyed.
     74 		*/
     75 		unsigned IsTechnician:1;
     76 
     77 		/*
     78 		**	If the infantry just performed some feat, then it may respond with an action.
     79 		**	This flag will be true if an action is to be performed when the Comment timer
     80 		**	has expired.
     81 		*/
     82 		unsigned IsStoked:1;
     83 
     84 		/*
     85 		**	This flag indicates if the infantry unit is prone. Prone infantry become that way
     86 		**	when they are fired upon. Infantry in the prone position are less vulnerable to
     87 		**	combat.
     88 		*/
     89 		unsigned IsProne:1;
     90 
     91 		/*
     92 		** This flag is set when the infantryman is engaged in hand-to-hand
     93 		** combat.  By setting this flag, it'll play the put-down-the-gun
     94 		** sequence only once, and it'll know to pick up the gun when the
     95 		** fight is over.
     96 		*/
     97 		unsigned	IsBoxing:1;
     98 
     99 		/*
    100 		** Track when movement last stopped.
    101 		*/
    102 		long StopDriverFrame;
    103 
    104 		/*
    105 		**	The fear rating of this infantry unit. The more afraid the infantry, the more
    106 		**	likely it is to panic and seek cover.
    107 		*/
    108 		unsigned char Fear;
    109 
    110 		/*---------------------------------------------------------------------
    111 		**	Constructors, Destructors, and overloaded operators.
    112 		*/
    113 		static void * operator new(size_t size);
    114 		static void operator delete(void *ptr);
    115 		InfantryClass(void);
    116 		InfantryClass(InfantryType classid, HousesType house);
    117 		virtual ~InfantryClass(void);
    118 		virtual RTTIType What_Am_I(void) const;
    119 
    120 		/*---------------------------------------------------------------------
    121 		**	Member function prototypes.
    122 		*/
    123 		static void Init(void);
    124 
    125 		virtual void Assign_Destination(TARGET);
    126 
    127 		/*
    128 		**	Query functions.
    129 		*/
    130 		virtual bool Is_Infantry(void) const;
    131 		virtual ObjectTypeClass const & Class_Of(void) const;
    132 		virtual int Full_Name(void) const;
    133 
    134 		/*
    135 		**	Coordinate inquiry functions. These are used for both display and
    136 		**	combat purposes.
    137 		*/
    138 		virtual COORDINATE Fire_Coord(int which) const;
    139 
    140 		/*
    141 		**	Object entry and exit from the game system.
    142 		*/
    143 		virtual bool Unlimbo(COORDINATE coord, DirType facing);
    144 		virtual bool Limbo(void);
    145 		virtual void Detach(TARGET target, bool all);
    146 
    147 		/*
    148 		**	Display and rendering support functionality. Supports imagery and how
    149 		**	object interacts with the map and thus indirectly controls rendering.
    150 		*/
    151 		virtual short const * Overlap_List(void) const;
    152 		virtual void Draw_It(int x, int y, WindowNumberType window);
    153 		virtual void Look(bool incremental=false);
    154 
    155 		/*
    156 		**	User I/O.
    157 		*/
    158 		virtual void Response_Select(void);
    159 		virtual void Response_Move(void);
    160 		virtual void Response_Attack(void);
    161 		virtual void Active_Click_With(ActionType action, ObjectClass * object);
    162 
    163 		/*
    164 		**	Combat related.
    165 		*/
    166 		virtual int Made_A_Kill(void);
    167 		virtual ActionType What_Action(ObjectClass * object) const;
    168 		virtual ActionType What_Action(CELL cell) const;
    169 		virtual void Assign_Mission(MissionType order);
    170 		virtual BulletClass * Fire_At(TARGET target, int which);
    171 		virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0);
    172 		virtual TARGET As_Target(void) const;
    173 		virtual FireErrorType Can_Fire(TARGET target, int which) const;
    174 		virtual void Assign_Target(TARGET);
    175 		virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
    176 		virtual int Rearm_Delay(bool second) const;
    177 		void  Set_Occupy_Bit(COORDINATE coord) {Set_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
    178 		void  Set_Occupy_Bit(CELL cell, int spot_index);
    179 		void  Clear_Occupy_Bit(COORDINATE coord) {Clear_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
    180 		void  Clear_Occupy_Bit(CELL cell, int spot_index);
    181 
    182 		/*
    183 		**	Driver control support functions. These are used to control cell
    184 		**	occupation flags and driver instructions.
    185 		*/
    186 		virtual bool Stop_Driver(void);
    187 		virtual bool Start_Driver(COORDINATE & coord);
    188 
    189 		/*
    190 		**	AI.
    191 		*/
    192 		virtual void AI(void);
    193 		virtual TARGET Greatest_Threat(ThreatType threat) const;
    194 		virtual int Mission_Attack(void);
    195 
    196 		/*
    197 		**	Scenario and debug support.
    198 		*/
    199 		#ifdef CHEAT_KEYS
    200 		virtual void Debug_Dump(MonoClass *mono) const;
    201 		#endif
    202 
    203 		/*
    204 		**	File I/O.
    205 		*/
    206 		static void  Read_INI(char *buffer);
    207 		static void  Write_INI(char *buffer);
    208 		static char *INI_Name(void) {return "INFANTRY";};
    209 		bool  Load(FileClass & file);
    210 		bool  Save(FileClass & file);
    211 		virtual void Code_Pointers(void);
    212 		virtual void Decode_Pointers(void);
    213 
    214 		/*
    215 		**	Movement and animation.
    216 		*/
    217 		virtual bool Do_Action(DoType todo, bool force=false);
    218 		virtual void Random_Animate(void);
    219 		virtual MoveType Can_Enter_Cell(CELL , FacingType =FACING_NONE) const;
    220 		virtual void Per_Cell_Process(bool center);
    221 		virtual void Enter_Idle_Mode(bool initial=false);
    222 		virtual void Scatter(COORDINATE threat, bool forced =false, bool nokidding =false);
    223 
    224 		/*
    225 		**	Dee-buggin' support.
    226 		*/
    227 		int Validate(void) const;
    228 
    229 		/*
    230 		**	Translation table to convert facing into infantry shape number. This special
    231 		**	table is needed since several facing stages are reused and flipped about the Y
    232 		**	axis.
    233 		*/
    234 		static int const HumanShape[32];
    235 
    236 	private:
    237 
    238 		static DoStruct const MasterDoControls[DO_COUNT];
    239 
    240 		/*
    241 		** This contains the value of the Virtual Function Table Pointer
    242 		*/
    243 		static void * VTable;
    244 
    245 		/*
    246 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    247 		*/
    248 		unsigned char SaveLoadPadding[32];
    249 };
    250 
    251 #endif