CnC_Remastered_Collection

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

TECHNO.H (16859B)


      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/TECHNO.H 1     3/03/97 10:25a 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 : TECHNO.H                                                     *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : April 14, 1994                                               *
     28  *                                                                                             *
     29  *                  Last Update : April 14, 1994   [JLB]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef TECHNO_H
     36 #define TECHNO_H
     37 
     38 #include	"radio.h"
     39 #include	"stage.h"
     40 #include	"cargo.h"
     41 #include	"flasher.h"
     42 #include	"house.h"
     43 #include	"target.h"
     44 #include	"bullet.h"
     45 #include	"door.h"
     46 #include	"crew.h"
     47 
     48 /****************************************************************************
     49 **	This is the common data between building and units.
     50 */
     51 class TechnoClass :	public RadioClass,
     52 							public FlasherClass,
     53 							public StageClass,
     54 							public CargoClass,
     55 							public DoorClass
     56 {
     57 	public:
     58 		CrewClass Crew;
     59 
     60 		/*
     61 		**	If this techno object has detected that it has outlived its
     62 		**	purpose, then this flag will be true. Such object will either
     63 		**	be sold or sacrificed at the first opportunity.
     64 		*/
     65 		unsigned IsUseless:1;
     66 
     67 		/*
     68 		**	This flag will be true if the object has been damaged with malice.
     69 		**	Damage received due to friendly fire or wear and tear does not count.
     70 		**	The computer is not allowed to sell a building unless it has been
     71 		**	damaged with malice.
     72 		*/
     73 		unsigned IsTickedOff:1;
     74 
     75 		/*
     76 		**	If this object has inherited the ability to cloak, then this bit will
     77 		**	be set to true.
     78 		*/
     79 		unsigned IsCloakable:1;
     80 
     81 		/*
     82 		**	If this object is designated as special then this flag will be true. For
     83 		**	buildings, this means that it is the primary factory. For units, it means
     84 		**	that the unit is the team leader.
     85 		*/
     86 		unsigned IsLeader:1;
     87 
     88 		/*
     89 		**	Certain units are flagged as "loaners".  These units are typically transports that
     90 		**	are created solely for the purpose of delivering reinforcements.  Such "loaner"
     91 		**	units are not owned by the player and thus cannot be directly controlled.  These
     92 		**	units will leave the game as soon as they have fulfilled their purpose.
     93 		*/
     94 		unsigned IsALoaner:1;
     95 
     96 		/*
     97 		**	Once a unit enters the map, then this flag is set. This flag is used to make
     98 		**	sure that a unit doesn't leave the map once it enters the map.
     99 		*/
    100 		unsigned IsLocked:1;
    101 
    102 		/*
    103 		**	Buildings and units with turrets usually have a recoil animation when they
    104 		**	fire. If this flag is true, then the next rendering of the object will be
    105 		**	in the "recoil state". The flag will then be cleared pending the next
    106 		**	firing event.
    107 		*/
    108 		unsigned IsInRecoilState:1;
    109 
    110 		/*
    111 		**	If this unit is "loosely attached" to another unit it is given special
    112 		**	processing. A unit is in such a condition when it is in the process of
    113 		**	unloading from a transport type object. During the unloading process
    114 		**	the transport object must stay still until the unit is free and clear.
    115 		**	At that time it radios the transport object and the "tether" is broken -
    116 		**	freeing both the unit and the transport object.
    117 		*/
    118 		unsigned IsTethered:1;
    119 
    120 		/*
    121 		**	Is this object owned by the player?  If not, then it is owned by the computer
    122 		**	or remote opponent. This flag facilitates the many logic differences when dealing
    123 		**	with player's or computer's units or buildings.
    124 		*/
    125 		unsigned IsOwnedByPlayer:1;
    126 
    127 		/*
    128 		**	The more sophisticated game objects must keep track of whether they are discovered
    129 		**	or not. This is because the state of discovery can often control how the object
    130 		**	behaves. In addition, this fact is used in radar and user I/O processing.
    131 		*/
    132 		unsigned IsDiscoveredByPlayer:1;
    133 
    134 		/*
    135 		**	This is used to control the computer recognizing this object.
    136 		*/
    137 		unsigned IsDiscoveredByComputer:1;
    138 
    139 		/*
    140 		**	Some game objects can be of the "lemon" variety. This means that they take damage
    141 		**	even when everything is ok. This adds a little variety to the game.
    142 		*/
    143 		unsigned IsALemon:1;
    144 
    145 		/*
    146 		**	This flag is used to control second shot processing for those units or buildings
    147 		**	that fire two shots in quick succession. When this flag is true, it indicates that
    148 		**	the second shot is ready to fire. After this shot is fired, regular rearm timing
    149 		**	is used rather than the short rearm time.
    150 		*/
    151 		unsigned IsSecondShot:1;
    152 
    153 		/*
    154 		**	This is the firepower and armor modifiers for this techno object. Normally,
    155 		**	these values are fixed at 0x0100, but they can be modified by certain
    156 		**	crate powerups.
    157 		*/
    158 		fixed ArmorBias;
    159 		fixed FirepowerBias;
    160 
    161 		/*
    162 		**	Idle animations (if any are supported by the object type) are regulated by
    163 		**	this timer. When the timer expires an idle animation occurs. Then the
    164 		**	timer is reinitialized to some random (bounded) setting.
    165 		*/
    166 		CDTimerClass<FrameTimerClass> IdleTimer;
    167 
    168 		/*
    169 		** This timer keeps track of how long the unit is under the influence
    170 		** of the iron curtain.
    171 		*/
    172 		CDTimerClass<FrameTimerClass> IronCurtainCountDown;
    173 
    174 
    175 		/*
    176 		** This is a list of bits of which houses are spying on this building,
    177 		** if in fact this is a building.
    178 		*/
    179 		unsigned SpiedBy;
    180 
    181 		/*
    182 		**	For units in area guard mode, this is the recorded home position. The guarding
    183 		**	unit will try to stay near this location in the course of it's maneuvers. This is
    184 		**	also used to record a pending transport for those passengers that are waiting for
    185 		**	the transport to become available. It is also used by harvesters so that they know
    186 		**	where to head back to after unloading.
    187 		*/
    188 		TARGET ArchiveTarget;
    189 
    190 		/*
    191 		**	This is the house that the unit belongs to.
    192 		*/
    193 		CCPtr<HouseClass> House;
    194 
    195 		/*
    196 		**	This records the current cloak state for this vehicle.
    197 		*/
    198 		CloakType Cloak;
    199 		StageClass CloakingDevice;
    200 		CDTimerClass<FrameTimerClass> CloakDelay;
    201 
    202 		/* (Targeting Computer)
    203 		**	This is the target value for the item that this vehicle should ATTACK. If this
    204 		**	is a vehicle with a turret, then it may differ from its movement destination.
    205 		*/
    206 		TARGET TarCom;
    207 		TARGET SuspendedTarCom;
    208 
    209 		/*
    210 		**	This is the visible facing for the unit or building.
    211 		*/
    212 		FacingClass PrimaryFacing;
    213 
    214 		/*
    215 		**	This is the arming countdown. It represents the time necessary
    216 		**	to reload the weapon.
    217 		*/
    218 		CDTimerClass<FrameTimerClass> Arm;
    219 
    220 		/*
    221 		**	The number of shot this object can fire before running out of ammo. If this
    222 		**	value is zero, then firing is not allowed. If -1, then there is no ammunition
    223 		**	limit.
    224 		*/
    225 		int Ammo;
    226 
    227 		/*
    228 		**	Used by the tesla to handle electric zap
    229 		*/
    230 		int ElectricZapDelay;
    231 		COORDINATE ElectricZapTarget;
    232 		int ElectricZapWhich;
    233 
    234 		/*
    235 		**	This is the amount of money spent to produce this object. This value really
    236 		**	only comes into play for the case of buildings that have special "free"
    237 		**	objects available when purchased at the more expensive rate.
    238 		*/
    239 		int PurchasePrice;
    240 
    241 		/*
    242 		**	Per-player view of whether a techno object is discovered. One bit for each house type. ST - 3/6/2019 11:15AM
    243 		*/
    244 		unsigned int IsDiscoveredByPlayerMask;
    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[16];
    250 
    251 
    252 		/*---------------------------------------------------------------------
    253 		**	Constructors, Destructors, and overloaded operators.
    254 		*/
    255 		TechnoClass(RTTIType rtti, int id, HousesType house=HOUSE_NONE);
    256 #ifdef FIXIT_MULTI_SAVE
    257 		TechnoClass(NoInitClass const & x) : RadioClass(x), FlasherClass(x), StageClass(x), CargoClass(x), DoorClass(x), IdleTimer(x), IronCurtainCountDown(x), House(x), Crew(x), CloakDelay(x), PrimaryFacing(x), Arm(x) {};
    258 #else
    259 		TechnoClass(NoInitClass const & x) : RadioClass(x), FlasherClass(x), StageClass(x), CargoClass(x), DoorClass(x), IronCurtainCountDown(x), House(x), Crew(x), CloakDelay(x), PrimaryFacing(x), Arm(x) {};
    260 #endif
    261 		virtual ~TechnoClass(void) {House=0;};
    262 
    263 		/*
    264 		**	Query functions.
    265 		*/
    266 		bool Is_Allowed_To_Retaliate(TechnoClass const * source) const;
    267 		bool Can_Teleport_Here(CELL cell) const;
    268 		bool Is_In_Same_Zone(CELL cell) const;
    269 		virtual bool Is_Players_Army(void) const;
    270 		int Combat_Damage(int which=-1) const;
    271 		bool Is_Ready_To_Cloak(void) const;
    272 		virtual int How_Many_Survivors(void) const;
    273 		virtual DirType Turret_Facing(void) const {return(PrimaryFacing.Current());}
    274 		CELL Nearby_Location(TechnoClass const * from=NULL, int locationmod=0) const;
    275 		TechnoTypeClass * Techno_Type_Class(void) const {return((TechnoTypeClass *)&Class_Of());};
    276 		bool Is_Visible_On_Radar(void) const;
    277 		int Anti_Air(void) const;
    278 		int Anti_Armor(void) const;
    279 		int Anti_Infantry(void) const;
    280 		int What_Weapon_Should_I_Use(TARGET target) const;
    281 		virtual ActionType What_Action(CELL cell) const;
    282 		virtual ActionType What_Action(ObjectClass const * target) const;
    283 		virtual BuildingClass * Find_Docking_Bay(StructType b, bool friendly) const;
    284 		virtual CELL Find_Exit_Cell(TechnoClass const * techno) const;
    285 		virtual FireDataType Fire_Data(int) const;
    286 		virtual COORDINATE Fire_Coord(int which) const;
    287 		virtual DirType Desired_Load_Dir(ObjectClass * , CELL & moveto) const;
    288 		virtual DirType Fire_Direction(void) const;
    289 		virtual HousesType Owner(void) const;
    290 		virtual InfantryType Crew_Type(void) const;
    291 		virtual bool Can_Player_Fire(void) const;
    292 		virtual bool Can_Player_Move(void) const;
    293 		virtual bool Is_Allowed_To_Recloak(void) const;
    294 		virtual bool Can_Repair(void) const;
    295 		virtual bool Is_Weapon_Equipped(void) const;
    296 		virtual fixed Tiberium_Load(void) const;
    297 		virtual int Pip_Count(void) const;
    298 		virtual int Rearm_Delay(bool second=true, int which=0) const;
    299 		virtual int Refund_Amount(void) const;
    300 		virtual int Risk(void) const;
    301 		virtual int Threat_Range(int control) const;
    302 		virtual int Value(void) const;
    303 		virtual int Get_Ownable(void) const;
    304 
    305 		/*
    306 		**	User I/O.
    307 		*/
    308 		virtual void Clicked_As_Target(HousesType house, int count = 7); // 2019/09/20 JAS - Added record of who clicked on the object
    309 		virtual bool Select(bool allow_mixed = false);
    310 		virtual void Response_Select(void);
    311 		virtual void Response_Move(void);
    312 		virtual void Response_Attack(void);
    313 		virtual void Player_Assign_Mission(MissionType order, TARGET target=TARGET_NONE, TARGET destination=TARGET_NONE);
    314 
    315 		/*
    316 		**	Combat related.
    317 		*/
    318 		fixed Area_Modify(CELL cell) const;
    319 		virtual int Made_A_Kill(void) {return(Crew.Made_A_Kill());}
    320 		void Base_Is_Attacked(TechnoClass const *enemy);
    321 		void Kill_Cargo(TechnoClass * source);
    322 		virtual void Record_The_Kill(TechnoClass * source);
    323 		virtual bool Target_Something_Nearby(ThreatType threat=THREAT_NORMAL);
    324 		virtual void Stun(void);
    325 		virtual bool In_Range(COORDINATE coord, int which=0) const;
    326 		virtual bool In_Range(TARGET target, int which=0, bool reciprocal_check = true) const;
    327 		virtual bool In_Range(ObjectClass const * target, int which=0, bool reciprocal_check = true) const;
    328 		virtual void Death_Announcement(TechnoClass const * source=0) const = 0;
    329 		virtual FireErrorType Can_Fire(TARGET target, int which=0) const;
    330 		virtual TARGET Greatest_Threat(ThreatType threat) const;
    331 		virtual void Assign_Target(TARGET target);
    332 		virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom);
    333 		virtual bool Restore_Mission(void);
    334 		virtual BulletClass * Fire_At(TARGET target, int which=0);
    335 		virtual int Weapon_Range(int which) const;
    336 		virtual bool Captured(HouseClass * newowner);
    337 		virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
    338 		bool Evaluate_Cell(ThreatType method, int mask, CELL cell, int range, TechnoClass const ** object, int & value, int zone=0) const;
    339 		bool Evaluate_Object(ThreatType method, int mask, int range, TechnoClass const * object, int & value, int zone=-1) const;
    340 		int Evaluate_Just_Cell(CELL cell) const;
    341 		virtual bool Electric_Zap (COORDINATE target_coord, int which, WindowNumberType window, COORDINATE source_coord=0L, unsigned char * remap=NULL) const;
    342 		bool Is_Cloaked(HousesType house, bool check_invisible=false) const;
    343 		bool Is_Cloaked(HouseClass const * house, bool check_invisible=false) const;
    344 		bool Is_Cloaked(ObjectClass const * object, bool check_invisible=false) const;
    345 
    346 		/*
    347 		**	AI.
    348 		*/
    349 		virtual void Renovate(void);
    350 		virtual void AI(void);
    351 		virtual bool Revealed(HouseClass * house);
    352 		virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
    353 		void Cloaking_AI(void);
    354 
    355 		/*
    356 		**	Scenario and debug support.
    357 		*/
    358 		#ifdef CHEAT_KEYS
    359 		virtual void Debug_Dump(MonoClass *mono) const;
    360 		#endif
    361 
    362 		/*
    363 		**	File I/O.
    364 		*/
    365 		virtual void Code_Pointers(void);
    366 		virtual void Decode_Pointers(void);
    367 
    368 		/*
    369 		**	Display and rendering support functionality. Supports imagery and how
    370 		**	object interacts with the map and thus indirectly controls rendering.
    371 		*/
    372 		virtual void const * Remap_Table(void) const;
    373 		VisualType Visual_Character(bool raw = false) const;
    374 		void Techno_Draw_Object(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100) const;
    375 
    376 		// Added. ST - 8/1/2019 5:37PM
    377 		void Techno_Draw_Object_Virtual(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100, const char *shape_name = NULL) const;
    378 
    379 		virtual void Draw_It(int x, int y, WindowNumberType window) const;
    380 		virtual void Draw_Pips(int x, int y, WindowNumberType window) const;
    381 		virtual void Hidden(void);
    382 		virtual bool Mark(MarkType mark=MARK_CHANGE);
    383 		virtual int Exit_Object(TechnoClass *);
    384 		virtual void Do_Uncloak(void);
    385 		virtual void Do_Cloak(void);
    386 		virtual void Do_Shimmer(void);
    387 
    388 		/*
    389 		**	Movement and animation.
    390 		*/
    391 		virtual bool Is_Ready_To_Random_Animate(void) const;
    392 		virtual bool Random_Animate(void) {return(false);}
    393 		virtual void Assign_Destination(TARGET target);
    394 		virtual void Per_Cell_Process(PCPType why);
    395 		virtual void Enter_Idle_Mode(bool initial=false);
    396 		virtual void Look(bool incremental=false);
    397 
    398 		/*
    399 		**	Map entry and exit logic.
    400 		*/
    401 		virtual bool Unlimbo(COORDINATE , DirType facing=DIR_N);
    402 		virtual void Detach(TARGET target, bool all);
    403 
    404 		/*
    405 		** New functions for per-player discovery for multiplayer. ST - 3/6/2019 11:17AM
    406 		*/
    407 		bool Is_Discovered_By_Player(HouseClass *player = NULL) const;
    408 		void Set_Discovered_By_Player(HouseClass *player = NULL);
    409 		void Clear_Discovered_By_Players();
    410 		bool Is_Owned_By_Player(HouseClass *player = NULL) const;
    411 
    412 		virtual unsigned Spied_By() const;
    413 
    414 		/*
    415 		**	Facing translation tables that fix the flaw with 3D studio when
    416 		**	it renders 45 degree angles.
    417 		*/
    418 		static int const BodyShape[32];
    419 };
    420 
    421 #endif