TEVENT.H 8.4 KB

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