CnC_Remastered_Collection

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

AIRCRAFT.H (10071B)


      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/AIRCRAFT.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 : AIRCRAFT.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : July 22, 1994                                                *
     28  *                                                                                             *
     29  *                  Last Update : November 28, 1994 [JLB]                                      *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef AIRCRAFT_H
     36 #define AIRCRAFT_H
     37 
     38 #include	"radio.h"
     39 #include	"fly.h"
     40 #include	"target.h"
     41 
     42 
     43 /*
     44 **	This aircraft class is used for all flying sentient objects. This includes fixed wing
     45 **	aircraft as well as helicopters. It excludes bullets even though some bullets might
     46 **	be considered to be "flying" in a loose interpretatin of the word.
     47 */
     48 class AircraftClass : public FootClass, public FlyClass
     49 {
     50 	public:
     51 		/*
     52 		**	This is a pointer to the class control structure for the aircraft.
     53 		*/
     54 		CCPtr<AircraftTypeClass> Class;
     55 
     56 		//-----------------------------------------------------------------------------
     57 		static void * operator new(size_t);
     58 		static void * operator new(size_t, void * ptr) {return(ptr);};
     59 		static void operator delete(void *);
     60 		operator AircraftType(void) const {return Class->Type;};
     61 		AircraftClass(AircraftType classid, HousesType house);
     62 		AircraftClass(NoInitClass const & x) : FootClass(x), FlyClass(x), Class(x), SecondaryFacing(x), SightTimer(x) {};
     63 		virtual ~AircraftClass(void);
     64 
     65 		static void Init(void);
     66 
     67 		virtual int Mission_Attack(void);
     68 		virtual int Mission_Unload(void);
     69 		virtual int Mission_Hunt(void);
     70 		virtual int Mission_Retreat(void);
     71 		virtual int Mission_Move(void);
     72 		virtual int Mission_Enter(void);
     73 		virtual int Mission_Guard(void);
     74 		virtual int Mission_Guard_Area(void);
     75 
     76 		virtual void Assign_Destination(TARGET target);
     77 		/*
     78 		**	State machine support routines.
     79 		*/
     80 		bool Process_Take_Off(void);
     81 		bool Process_Landing(void);
     82 		int Process_Fly_To(bool slowdown, TARGET dest);
     83 
     84 		/*
     85 		**	Query functions.
     86 		*/
     87 		virtual LayerType In_Which_Layer(void) const;
     88 		virtual DirType Turret_Facing(void) const {return(SecondaryFacing.Current());}
     89 		int Shape_Number(void) const;
     90 		virtual MoveType Can_Enter_Cell(CELL cell, FacingType facing=FACING_NONE) const;
     91 		virtual ObjectTypeClass const & Class_Of(void) const {return *Class;};
     92 		virtual ActionType What_Action(ObjectClass const * target) const;
     93 		virtual ActionType What_Action(CELL cell) const;
     94 		virtual DirType Desired_Load_Dir(ObjectClass * passenger, CELL & moveto) const;
     95 		virtual int Pip_Count(void) const;
     96 		TARGET Good_Fire_Location(TARGET target) const;
     97 		bool Cell_Seems_Ok(CELL cell, bool landing=false) const;
     98 		DirType Pose_Dir(void) const;
     99 		TARGET Good_LZ(void) const;
    100 		virtual DirType Fire_Direction(void) const;
    101 		virtual FireErrorType Can_Fire(TARGET target, int which) const;
    102 
    103 		/*
    104 		**	Landing zone support functionality.
    105 		*/
    106 		virtual void Per_Cell_Process(PCPType why);
    107 		bool Is_LZ_Clear(TARGET target) const;
    108 		TARGET New_LZ(TARGET oldlz) const;
    109 
    110 		/*
    111 		**	Coordinate inquiry functions. These are used for both display and
    112 		**	combat purposes.
    113 		*/
    114 		virtual COORDINATE Sort_Y(void) const;
    115 
    116 		/*
    117 		**	Object entry and exit from the game system.
    118 		*/
    119 		virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
    120 
    121 		/*
    122 		**	Display and rendering support functionality. Supports imagery and how
    123 		**	object interacts with the map and thus indirectly controls rendering.
    124 		*/
    125 		virtual void Look(bool incremental=false);
    126 		void Draw_Rotors(int x, int y, WindowNumberType window) const;
    127 		virtual int Exit_Object(TechnoClass *);
    128 		virtual short const * Overlap_List(bool redraw=false) const;
    129 		virtual void Draw_It(int x, int y, WindowNumberType window) const;
    130 		virtual void Set_Speed(int speed);
    131 
    132 		/*
    133 		**	User I/O.
    134 		*/
    135 		virtual void Active_Click_With(ActionType action, ObjectClass * object);
    136 		virtual void Active_Click_With(ActionType action, CELL cell);
    137 		virtual void Player_Assign_Mission(MissionType mission, TARGET target=TARGET_NONE, TARGET destination=TARGET_NONE);
    138 		virtual void Response_Select(void);
    139 		virtual void Response_Move(void);
    140 		virtual void Response_Attack(void);
    141 
    142 		/*
    143 		**	Combat related.
    144 		*/
    145 		virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source, bool forced=false);
    146 		virtual BulletClass * Fire_At(TARGET target, int which);
    147 
    148 		/*
    149 		**	AI.
    150 		*/
    151 		bool Landing_Takeoff_AI(void);
    152 		bool Edge_Of_World_AI(void);
    153 		void Movement_AI(void);
    154 		void Rotation_AI(void);
    155 		int Paradrop_Cargo(void);
    156 		virtual void AI(void);
    157 		virtual void Enter_Idle_Mode(bool initial = false);
    158 		virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
    159 		virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false);
    160 
    161 		/*
    162 		**	Scenario and debug support.
    163 		*/
    164 		#ifdef CHEAT_KEYS
    165 		virtual void Debug_Dump(MonoClass *mono) const;
    166 		#endif
    167 
    168 		/*
    169 		**	File I/O.
    170 		*/
    171 		static void Read_INI(CCINIClass & ini);
    172 		static char * INI_Name(void) {return "AIRCRAFT";};
    173 		bool Load(Straw & file);
    174 		bool Save(Pipe & file) const;
    175 
    176 		virtual unsigned Spied_By() const;
    177 
    178 	public:
    179 
    180 		/*
    181 		**	This is the facing used for the body of the aircraft. Typically, this is the same
    182 		**	as the PrimaryFacing, but in the case of helicopters, it can be different.
    183 		*/
    184 		FacingClass SecondaryFacing;
    185 
    186 		/*
    187 		**	If this is a passenger carrying aircraft then this flag will be set. This is
    188 		**	necessary because once the passengers are unloaded, the fact that it was a
    189 		**	passenger carrier must still be known.
    190 		*/
    191 		bool Passenger;
    192 
    193 	private:
    194 
    195 		/*
    196 		**	Aircraft can be in either state of landing, taking off, or in steady altitude.
    197 		**	These flags are used to control transition between flying and landing. It is
    198 		**	necessary to handle the transition in this manner so that it occurs smoothly
    199 		**	during the graphic processing section.
    200 		*/
    201 		unsigned IsLanding:1;
    202 		unsigned IsTakingOff:1;
    203 
    204 		/*
    205 		**	It is very common for aircraft to be homing in on a target. When this flag is
    206 		**	true, the aircraft will constantly adjust its facing toward the TarCom. When the
    207 		**	target is very close (one cell away or less), then this flag is automatically cleared.
    208 		**	This is because the homing algorithm is designed to get the aircraft to the destination
    209 		**	but no more. Checking when this flag is cleared is a way of flagging transition into
    210 		**	a new mode. Example: Transport helicopters go into a hovering into correct position
    211 		**	mode when the target is reached.
    212 		*/
    213 		unsigned IsHoming:1;
    214 
    215 		/*
    216 		**	Helicopters that are about to land must hover into a position exactly above the landing
    217 		**	zone. When this flag is true, the aircraft will be adjusted so that it is exactly over
    218 		**	the TarCom. The facing of the aircraft is not altered by this movement. The affect
    219 		**	like the helicopter is hovering and shifting sideways to position over the landing
    220 		**	zone. When the position is over the landing zone, then this flag is set to false.
    221 		*/
    222 		unsigned IsHovering:1;
    223 
    224 		/*
    225 		**	This is the jitter tracker to be used when the aircraft is a helicopter and
    226 		**	is flying. It is most noticeable when the helicopter is hovering.
    227 		*/
    228 		unsigned char Jitter;
    229 
    230 	private:
    231 
    232 		/*
    233 		**	This timer controls when the aircraft will reveal the terrain around itself.
    234 		**	When this timer expires and this aircraft has a sight range, then the
    235 		**	look around process will occur.
    236 		*/
    237 		CDTimerClass<FrameTimerClass> SightTimer;
    238 
    239 		/*
    240 		**	Most attack aircraft can make several attack runs. This value contains the
    241 		**	number of attack runs the aircraft has left. When this value reaches
    242 		**	zero then the aircraft is technically out of ammo.
    243 		*/
    244 		char AttacksRemaining;
    245 
    246 		/*
    247 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    248 		*/
    249 		unsigned char SaveLoadPadding[32];
    250 };
    251 
    252 #endif