CnC_Remastered_Collection

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

TEVENT.H (8701B)


      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/TEVENT.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 : TEVENT.H                                                     *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 11/28/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : November 28, 1995 [JLB]                                      *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 
     36 #ifndef TEVENT_H
     37 #define TEVENT_H
     38 
     39 /*
     40 **	These are the trigger events that are checked for and if qualified, they will signal
     41 **	a successful trigger event. This might result in the trigger action being performed.
     42 */
     43 typedef enum TEventType : unsigned char {
     44 	TEVENT_NONE,
     45 	TEVENT_PLAYER_ENTERED,					// player enters this square
     46 	TEVENT_SPIED,								// Spied by.
     47 	TEVENT_THIEVED,							// Thieved by (raided or stolen vehicle).
     48 	TEVENT_DISCOVERED,						// player discovers this object
     49 	TEVENT_HOUSE_DISCOVERED,				// House has been discovered.
     50 	TEVENT_ATTACKED,							// player attacks this object
     51 	TEVENT_DESTROYED,							// player destroys this object
     52 	TEVENT_ANY,									// Any object event will cause the trigger.
     53 	TEVENT_UNITS_DESTROYED,					// all house's units destroyed
     54 	TEVENT_BUILDINGS_DESTROYED,			// all house's buildings destroyed
     55 	TEVENT_ALL_DESTROYED,					// all house's units & buildings destroyed
     56 	TEVENT_CREDITS,							// house reaches this many credits
     57 	TEVENT_TIME,								// Scenario elapsed time from start.
     58 	TEVENT_MISSION_TIMER_EXPIRED,			// Pre expired mission timer.
     59 	TEVENT_NBUILDINGS_DESTROYED,			// Number of buildings destroyed.
     60 	TEVENT_NUNITS_DESTROYED,				// Number of units destroyed.
     61 	TEVENT_NOFACTORIES,						// No factories left.
     62 	TEVENT_EVAC_CIVILIAN,					// Civilian has been evacuated.
     63 	TEVENT_BUILD,								// Specified building has been built.
     64 	TEVENT_BUILD_UNIT,						// Specified unit has been built.
     65 	TEVENT_BUILD_INFANTRY,					// Specified infantry has been built.
     66 	TEVENT_BUILD_AIRCRAFT,					// Specified aircraft has been built.
     67 	TEVENT_LEAVES_MAP,						// Specified team member leaves map.
     68 	TEVENT_ENTERS_ZONE,						// Enters same zone as waypoint 'x'.
     69 	TEVENT_CROSS_HORIZONTAL,				// Crosses horizontal trigger line.
     70 	TEVENT_CROSS_VERTICAL,					// Crosses vertical trigger line.
     71 	TEVENT_GLOBAL_SET,						// If specified global has been set.
     72 	TEVENT_GLOBAL_CLEAR,						// If specified global has been cleared.
     73 	TEVENT_FAKES_DESTROYED,					// If all fake structures are gone.
     74 	TEVENT_LOW_POWER,							// When power drops below 100%.
     75 	TEVENT_ALL_BRIDGES_DESTROYED,			// All bridges destroyed.
     76 	TEVENT_BUILDING_EXISTS,					// Check for building existing.
     77 
     78 	TEVENT_COUNT,
     79 	TEVENT_FIRST=0
     80 } TEventType;
     81 
     82 TEventType Event_From_Name(char const * name);
     83 NeedType Event_Needs(TEventType event);
     84 char const * Name_From_Event(TEventType event);
     85 
     86 /*
     87 **	This holds the changable data that is associated with an event as
     88 **	it relates to a trigger.
     89 */
     90 struct TDEventClass {
     91 	/*
     92 	**	If this event has been triggered by something that is temporal, then
     93 	**	this flag will be set to true so that subsequent trigger examination
     94 	**	will return a successful event trigger flag. Typical use of this is
     95 	**	for when objects of a specific type are built.
     96 	*/
     97 	unsigned IsTripped:1;
     98 
     99 	/*
    100 	**	Timer based events require a special timer control handler.
    101 	*/
    102 	CDTimerClass<FrameTimerClass> Timer;
    103 
    104 	TDEventClass(void) : IsTripped(false), Timer(0) {};
    105 	TDEventClass(NoInitClass const & x) : Timer(x) {};
    106 };
    107 
    108 
    109 /*
    110 **	This elaborates the information necessary to trigger
    111 **	an event.
    112 */
    113 class TeamTypeClass;
    114 struct TEventClass {
    115 
    116 	/*
    117 	**	This is the event that will controls how this event gets triggered.
    118 	*/
    119 	TEventType Event;
    120 
    121 	/*
    122 	**	If this event needs to reference a team type, then this is the pointer
    123 	**	to the team type object. This must be separated from the following
    124 	**	union because Watcom compiler won't allow a class that has a
    125 	**	constructor to be declared in a union.
    126 	*/
    127 	CCPtr<TeamTypeClass> Team;
    128 
    129 	union {
    130 		StructType				Structure;	// Used for structure type checking.
    131 		UnitType					Unit;			// Used for unit type checking.
    132 		InfantryType			Infantry;	//	Used for infantry type checking.
    133 		AircraftType			Aircraft;	// Used for aircraft type checking.
    134 		HousesType				House;		// Used for house specific events.
    135 		long	Value;							// Used for other events that need data.
    136 	} Data;
    137 
    138 	TEventClass(void) : Event(TEVENT_NONE) {Data.Value = 0;};
    139 	TEventClass(TEventType event) : Event(event) {Data.Value = 0;};
    140 	TEventClass(NoInitClass const & x) : Team(x) {};
    141 
    142 	void Code_Pointers(void);
    143 	void Decode_Pointers(void);
    144 	void Reset(TDEventClass & td) const;
    145 	bool operator () (TDEventClass & td, TEventType event, HousesType house, ObjectClass const * object, bool forced);
    146 	void Read_INI(void);
    147 	void Build_INI_Entry(char * buffer) const;
    148 };
    149 
    150 
    151 typedef enum AttachType : unsigned char {
    152 	ATTACH_NONE=0x00,				// Trigger doesn't attach to anything (orphan trigger types).
    153 	ATTACH_CELL=0x01,				// Trigger can only attach to a cell.
    154 	ATTACH_OBJECT=0x02,			// Trigger can attach only to object (usually building or vehicle).
    155 	ATTACH_MAP=0x04,				// Trigger applies to the general map (usually zone or parallel triggers).
    156 	ATTACH_HOUSE=0x08,			// Trigger applies only to a house.
    157 	ATTACH_GENERAL=0x10,			// General purpose trigger attached to game state.
    158 	ATTACH_TEAM=0x20				// Trigger applies to team object.
    159 } AttachType;
    160 
    161 AttachType Attaches_To(TEventType event);
    162 
    163 
    164 
    165 class EventChoiceClass {
    166 	public:
    167 		EventChoiceClass(TEventType event=TEVENT_NONE) : Event(event) {}
    168 
    169 		operator TEventType (void) const {return(Event);}
    170 		bool operator == (EventChoiceClass const & rvalue) const {return(Event == rvalue.Event);}
    171 		bool operator != (EventChoiceClass const & rvalue) const {return(Event != rvalue.Event);}
    172 		bool operator > (EventChoiceClass const & rvalue) const {return(stricmp(Description(), rvalue.Description()) > 0);}
    173 		bool operator < (EventChoiceClass const & rvalue) const {return(stricmp(Description(), rvalue.Description()) < 0);}
    174 		bool operator <= (EventChoiceClass const & rvalue) const {return(Event == rvalue.Event || stricmp(Description(), rvalue.Description()) < 0);}
    175 		bool operator >= (EventChoiceClass const & rvalue) const {return(Event == rvalue.Event || stricmp(Description(), rvalue.Description()) > 0);}
    176 		char const * Description(void) const {return(Name_From_Event(Event));}
    177 		void Draw_It(int index, int x, int y, int width, int height, bool selected, TextPrintType flags) const;
    178 
    179 		TEventType Event;
    180 };
    181 
    182 extern EventChoiceClass EventChoices[TEVENT_COUNT];
    183 
    184 
    185 #endif