TEVENT.H 8.5 KB

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