HOUSE.H 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  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/HOUSE.H 1 3/03/97 10:24a 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 : HOUSE.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : May 21, 1994 *
  26. * *
  27. * Last Update : May 21, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef HOUSE_H
  33. #define HOUSE_H
  34. #include "type.h"
  35. #include "region.h"
  36. #include "vector.h"
  37. #include "Credits.h"
  38. class TriggerClass;
  39. class FootClass;
  40. class FactoryClass;
  41. #define HOUSE_NAME_MAX 12
  42. /****************************************************************************
  43. ** Certain aspects of the house "country" are initially set by the scenario
  44. ** control file. This information is static for the duration of the current
  45. ** scenario, but is dynamic between scenarios. As such, it can't be placed in
  46. ** the static HouseTypeClass structure, but is embedded into the house
  47. ** class instead.
  48. */
  49. class HouseStaticClass {
  50. public:
  51. HouseStaticClass(void);
  52. HouseStaticClass(NoInitClass const & ) {};
  53. /*
  54. ** This value indicates the degree of smartness to assign to this house.
  55. ** A value is zero is presumed for human controlled houses.
  56. */
  57. int IQ;
  58. /*
  59. ** This is the buildable tech level for this house. This value is used
  60. ** for when the computer is deciding what objects to build.
  61. */
  62. int TechLevel;
  63. /*
  64. ** This is the original ally specification to use at scenario
  65. ** start. Various forces during play may adjust the ally state
  66. ** of this house.
  67. */
  68. int Allies;
  69. /*
  70. ** This is the maximum number allowed to be built by this house. The
  71. ** value depends on the scenario being played.
  72. */
  73. unsigned MaxUnit;
  74. unsigned MaxBuilding;
  75. unsigned MaxInfantry;
  76. unsigned MaxVessel;
  77. unsigned MaxAircraft;
  78. /*
  79. ** This records the initial credits assigned to this house when the scenario
  80. ** was loaded.
  81. */
  82. long InitialCredits;
  83. /*
  84. ** For generic (unspecified) reinforcements, they arrive by a common method. This
  85. ** specifies which method is to be used.
  86. */
  87. SourceType Edge;
  88. };
  89. /****************************************************************************
  90. ** Player control structure. Each player (computer or human) has one of
  91. ** these structures associated. These are located in a global array.
  92. */
  93. class HouseClass {
  94. public:
  95. RTTIType RTTI;
  96. int ID;
  97. /*
  98. ** Pointer to the HouseTypeClass that this house is "owned" by.
  99. ** All constant data for a house type is stored in that class.
  100. */
  101. CCPtr<HouseTypeClass> Class;
  102. /*
  103. ** This is the handicap (difficulty level) assigned to this house.
  104. */
  105. DiffType Difficulty;
  106. /*
  107. ** Override handicap control values.
  108. */
  109. fixed FirepowerBias;
  110. fixed GroundspeedBias;
  111. fixed AirspeedBias;
  112. fixed ArmorBias;
  113. fixed ROFBias;
  114. fixed CostBias;
  115. fixed BuildSpeedBias;
  116. fixed RepairDelay;
  117. fixed BuildDelay;
  118. /*
  119. ** The initial house data as loaded from the scenario control file is
  120. ** stored here. Although this data changes for each scenario, it remains
  121. ** static for the duration of the current scenario.
  122. */
  123. HouseStaticClass Control;
  124. /*
  125. ** This is the house type that this house object should act like. This
  126. ** value controls production choices and radar cover plate imagery.
  127. */
  128. HousesType ActLike;
  129. /*
  130. ** Is this player active? Usually that answer is true, but for civilians, it
  131. ** might possibly be false.
  132. */
  133. unsigned IsActive:1;
  134. /*
  135. ** If this house is controlled by the player, then this flag will be true. The
  136. ** computer controls all other active houses.
  137. */
  138. unsigned IsHuman:1;
  139. unsigned WasHuman:1;
  140. /*
  141. ** If the player can control units of this house even if the player doesn't
  142. ** own units of this house, then this flag will be true.
  143. */
  144. unsigned IsPlayerControl:1;
  145. /*
  146. ** This flag enables production. If the flag is false, production is disabled.
  147. ** By timing when this flag gets set, the player can be given some breathing room.
  148. */
  149. unsigned IsStarted:1;
  150. /*
  151. ** When alerted, the house will create teams of the special "auto" type and
  152. ** will generate appropriate units to fill those team types.
  153. */
  154. unsigned IsAlerted:1;
  155. /*
  156. ** If automatic base building is on, then this flag will be set to true.
  157. */
  158. unsigned IsBaseBuilding:1;
  159. /*
  160. ** If the house has been discovered, then this flag will be set
  161. ** to true. However, the trigger even associated with discovery
  162. ** will only be executed during the next house AI process.
  163. */
  164. unsigned IsDiscovered:1;
  165. /*
  166. ** If Tiberium storage is maxed out, then this flag will be set. At some point
  167. ** the player is told of this fact and then this flag is cleared. This allows the
  168. ** player to be told, but only occasionally rather than continuously.
  169. */
  170. unsigned IsMaxedOut:1;
  171. /*
  172. ** If this house is played by a human in a multiplayer game, this flag
  173. ** keeps track of whether this house has been defeated or not.
  174. */
  175. unsigned IsDefeated:1;
  176. /*
  177. ** These flags are used in conjunction with the BorrowedTime timer. When
  178. ** that timer expires and one of these flags are set, then that event is
  179. ** applied to the house. This allows a dramatic pause between the event
  180. ** trigger and the result.
  181. */
  182. unsigned IsToDie:1;
  183. unsigned IsToWin:1;
  184. unsigned IsToLose:1;
  185. /*
  186. ** This flag is set when a transport carrying a civilian has been
  187. ** successfully evacuated. It is presumed that a possible trigger
  188. ** event will be sprung by this event.
  189. */
  190. unsigned IsCivEvacuated:1;
  191. /*
  192. ** If potentially something changed that might affect the sidebar list of
  193. ** buildable objects, then this flag indicates that at the first LEGAL opportunity,
  194. ** the sidebar will be recalculated.
  195. */
  196. unsigned IsRecalcNeeded:1;
  197. /*
  198. ** If the map has been completely revealed to the player, then this flag
  199. ** will be set to true. By examining this flag, a second "reveal all map"
  200. ** crate won't be given to the player.
  201. */
  202. unsigned IsVisionary:1;
  203. /*
  204. ** This flag is set to true when the house has determined that
  205. ** there is insufficient Tiberium to keep the harvesters busy.
  206. ** In such a case, the further refinery/harvester production
  207. ** should cease. This is one of the first signs that the endgame
  208. ** has begun.
  209. */
  210. unsigned IsTiberiumShort:1;
  211. /*
  212. ** These flags are used for the general house trigger events of being
  213. ** spied and thieved. The appropriate flag will be set when the event
  214. ** occurs.
  215. */
  216. unsigned IsSpied:1;
  217. unsigned IsThieved:1;
  218. /*
  219. ** This flag is used to control non-human repairing of buildings. Each
  220. ** house gets to repair one building per loop, and this flag controls
  221. ** whether this house has 'spent' its repair option this time through.
  222. */
  223. unsigned DidRepair:1;
  224. /*
  225. ** This flag is used to control whether or not this house has the GPS
  226. ** satellite in orbit. If the satellite's there, they have unlimited
  227. ** radar and the map is fully revealed.
  228. */
  229. unsigned IsGPSActive:1;
  230. /*
  231. ** If the JustBuilt??? variable has changed, then this flag will
  232. ** be set to true.
  233. */
  234. unsigned IsBuiltSomething:1;
  235. /*
  236. ** Did this house lose via resignation?
  237. */
  238. unsigned IsResigner:1;
  239. /*
  240. ** Did this house lose because the player quit?
  241. */
  242. unsigned IsGiverUpper:1;
  243. /*
  244. ** If this computer controlled house has reason to be mad at humans,
  245. ** then this flag will be true. Such a condition prevents alliances with
  246. ** a human and encourages the computers players to ally amongst themselves.
  247. */
  248. unsigned IsParanoid:1;
  249. /*
  250. ** A gap generator shrouded cells and all units of this house must perform
  251. ** a look just in case their look radius intersects the shroud area.
  252. */
  253. unsigned IsToLook:1;
  254. /*
  255. ** MBL 03.23.2020 - Support for queued movement mode (informed from the client)
  256. */
  257. unsigned IsQueuedMovementToggle:1;
  258. /*
  259. ** This value indicates the degree of smartness to assign to this house.
  260. ** A value of zero indicates that the player controls everything.
  261. */
  262. int IQ;
  263. /*
  264. ** This records the current state of the base. This state is used to control
  265. ** what action the base will perform and directly affects production and
  266. ** unit disposition. The state will change according to time and combat
  267. ** events.
  268. */
  269. StateType State;
  270. /*
  271. ** These super weapon control objects are used to control the recharge
  272. ** and availability of these special weapons to this house.
  273. */
  274. SuperClass SuperWeapon[SPC_COUNT];
  275. /*
  276. ** This is a record of the last building that was built. For buildings that
  277. ** were built as a part of scenario creation, it will be the last one
  278. ** discovered.
  279. */
  280. StructType JustBuiltStructure;
  281. InfantryType JustBuiltInfantry;
  282. UnitType JustBuiltUnit;
  283. AircraftType JustBuiltAircraft;
  284. VesselType JustBuiltVessel;
  285. /*
  286. ** This records the number of triggers associated with this house that are
  287. ** blocking a win condition. A win will only occur if all the blocking
  288. ** triggers have been deleted.
  289. */
  290. int Blockage;
  291. /*
  292. ** For computer controlled houses, there is an artificial delay between
  293. ** performing repair actions. This timer regulates that delay. If the
  294. ** timer has not expired, then no repair initiation is allowed.
  295. */
  296. CDTimerClass<FrameTimerClass> RepairTimer;
  297. /*
  298. ** This timer controls the computer auto-attack logic. When this timer expires
  299. ** and the house has been alerted, then it will create a set of attack
  300. ** teams.
  301. */
  302. CDTimerClass<FrameTimerClass> AlertTime;
  303. /*
  304. ** This timer is used to handle the delay between some catastrophic
  305. ** event trigger and when it is actually carried out.
  306. */
  307. CDTimerClass<FrameTimerClass> BorrowedTime;
  308. /*
  309. ** This is the last working scan bits for buildings. If a building is
  310. ** active and owned by this house, it will have a bit set in this element
  311. ** that corresponds to the building type number. Since this value is
  312. ** accumulated over time, the "New" element contains the under-construction
  313. ** version.
  314. */
  315. unsigned long BScan;
  316. unsigned long ActiveBScan;
  317. unsigned long OldBScan;
  318. /*
  319. ** This is the last working scan bits for units. For every existing unit
  320. ** type owned by this house, a corresponding bit is set in this element. As
  321. ** the scan bits are being constructed, they are built into the "New" element
  322. ** and then duplicated into the regular element at the end of every logic cycle.
  323. */
  324. unsigned long UScan;
  325. unsigned long ActiveUScan;
  326. unsigned long OldUScan;
  327. /*
  328. ** Infantry type existence bits. Similar to unit and building bits.
  329. */
  330. unsigned long IScan;
  331. unsigned long ActiveIScan;
  332. unsigned long OldIScan;
  333. /*
  334. ** Aircraft type existence bits. Similar to unit and building bits.
  335. */
  336. unsigned long AScan;
  337. unsigned long ActiveAScan;
  338. unsigned long OldAScan;
  339. /*
  340. ** Vessel type existence bits. Similar to unit and building bits.
  341. */
  342. unsigned long VScan;
  343. unsigned long ActiveVScan;
  344. unsigned long OldVScan;
  345. /*
  346. ** Record of gains and losses for this house during the course of the
  347. ** scenario.
  348. */
  349. unsigned CreditsSpent;
  350. unsigned HarvestedCredits;
  351. int StolenBuildingsCredits;
  352. /*
  353. ** This is the running count of the number of units owned by this house. This
  354. ** value is used to keep track of ownership limits.
  355. */
  356. unsigned CurUnits;
  357. unsigned CurBuildings;
  358. unsigned CurInfantry;
  359. unsigned CurVessels;
  360. unsigned CurAircraft;
  361. /*
  362. ** This is the running total of the number of credits this house has accumulated.
  363. */
  364. long Tiberium;
  365. long Credits;
  366. long Capacity;
  367. /*
  368. ** Stuff to keep track of the total number of units built by this house.
  369. */
  370. UnitTrackerClass * AircraftTotals;
  371. UnitTrackerClass * InfantryTotals;
  372. UnitTrackerClass * UnitTotals;
  373. UnitTrackerClass * BuildingTotals;
  374. UnitTrackerClass * VesselTotals;
  375. /*
  376. ** Total number of units destroyed by this house
  377. */
  378. UnitTrackerClass * DestroyedAircraft;
  379. UnitTrackerClass * DestroyedInfantry;
  380. UnitTrackerClass * DestroyedUnits;
  381. UnitTrackerClass * DestroyedBuildings;
  382. UnitTrackerClass * DestroyedVessels;
  383. /*
  384. ** Total number of enemy buildings captured by this house
  385. */
  386. UnitTrackerClass * CapturedBuildings;
  387. /*
  388. ** Total number of crates found by this house
  389. */
  390. UnitTrackerClass * TotalCrates;
  391. /*
  392. ** Records the number of infantry and vehicle factories active. This value is
  393. ** used to regulate the speed of production.
  394. */
  395. int AircraftFactories;
  396. int InfantryFactories;
  397. int UnitFactories;
  398. int VesselFactories;
  399. int BuildingFactories;
  400. /*
  401. ** This is the accumulation of the total power and drain factors. From these
  402. ** values a ratio can be derived. This ratio is used to control the rate
  403. ** of building decay.
  404. */
  405. int Power; // Current power output.
  406. int Drain; // Power consumption.
  407. /*
  408. ** For human controlled houses, only one type of unit can be produced
  409. ** at any one instant. These factory objects control this production.
  410. */
  411. int AircraftFactory;
  412. int InfantryFactory;
  413. int UnitFactory;
  414. int VesselFactory;
  415. int BuildingFactory;
  416. /*
  417. ** For human controlled houses, the current state of the radar map
  418. */
  419. RadarEnum Radar;
  420. /*
  421. ** This target value specifies where the flag is located. It might be a cell
  422. ** or it might be an object.
  423. */
  424. TARGET FlagLocation;
  425. /*
  426. ** This is the flag-home-cell for this house. This is where we must bring
  427. ** another house's flag back to, to defeat that house.
  428. */
  429. CELL FlagHome;
  430. /*
  431. ** For multiplayer games, each house needs to keep track of how many
  432. ** objects of each other house they've killed.
  433. */
  434. unsigned UnitsKilled[HOUSE_COUNT];
  435. unsigned UnitsLost;
  436. unsigned BuildingsKilled[HOUSE_COUNT];
  437. unsigned BuildingsLost;
  438. /*
  439. ** This keeps track of the last house to destroy one of my units.
  440. ** It's used for scoring multiplayer games.
  441. */
  442. HousesType WhoLastHurtMe;
  443. /*
  444. ** Start location (waypoint index) passed in from GlyphX
  445. */
  446. int StartLocationOverride;
  447. /*
  448. ** This records information about the location and size of
  449. ** the base.
  450. */
  451. COORDINATE Center; // Center of the base.
  452. int Radius; // Average building distance from center (leptons).
  453. struct {
  454. int AirDefense;
  455. int ArmorDefense;
  456. int InfantryDefense;
  457. } ZoneInfo[ZONE_COUNT];
  458. /*
  459. ** This records information about the last time a building of this
  460. ** side was attacked. This information is used to determine proper
  461. ** response.
  462. */
  463. int LATime; // Time of attack.
  464. RTTIType LAType; // Type of attacker.
  465. ZoneType LAZone; // Last zone that was attacked.
  466. HousesType LAEnemy; // Owner of attacker.
  467. /*
  468. ** This target value is the building that must be captured as soon as possible.
  469. ** Typically, this will be one of the buildings of this house that has been
  470. ** captured and needs to be recaptured.
  471. */
  472. TARGET ToCapture;
  473. /*
  474. ** This value shows who is spying on this house's radar facilities.
  475. ** This is used for the other side to be able to update their radar
  476. ** map based on the cells that this house's units reveal.
  477. */
  478. int RadarSpied;
  479. /*
  480. ** Running score, based on units destroyed and units lost.
  481. */
  482. int PointTotal;
  483. /*
  484. ** This is the targeting directions for when this house gets a
  485. ** special weapon.
  486. */
  487. QuarryType PreferredTarget;
  488. /*
  489. ** Screen shake timer.
  490. */
  491. CDTimerClass<FrameTimerClass> ScreenShakeTime;
  492. private:
  493. /*
  494. ** Tracks number of each building type owned by this house. Even if the
  495. ** building is in construction, it will be reflected in this total.
  496. */
  497. #ifdef FIXIT_ANTS
  498. int BQuantity[STRUCT_COUNT-3];
  499. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  500. int UQuantity[UNIT_RA_COUNT-3];
  501. #else
  502. int UQuantity[UNIT_COUNT-3];
  503. #endif
  504. #else
  505. int BQuantity[STRUCT_COUNT];
  506. int UQuantity[UNIT_COUNT];
  507. #endif
  508. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  509. int IQuantity[INFANTRY_RA_COUNT];
  510. #else
  511. int IQuantity[INFANTRY_COUNT];
  512. #endif
  513. int AQuantity[AIRCRAFT_COUNT];
  514. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  515. int VQuantity[VESSEL_RA_COUNT];
  516. #else
  517. int VQuantity[VESSEL_COUNT];
  518. #endif
  519. /*
  520. ** This timer keeps track of when an all out attack should be performed.
  521. ** When this timer expires, send most of this house's units in an
  522. ** attack.
  523. */
  524. CDTimerClass<FrameTimerClass> Attack;
  525. public:
  526. /*
  527. ** This records the overriding enemy that the computer will try to
  528. ** destroy. Typically, this is the last house to attack, but can be
  529. ** influenced by nearness.
  530. */
  531. HousesType Enemy;
  532. /*
  533. ** The house expert system is regulated by this timer. Each computer controlled
  534. ** house will process the Expert System AI at intermittent intervals. Not only will
  535. ** this distribute the overhead more evenly, but will add variety to play.
  536. */
  537. CDTimerClass<FrameTimerClass> AITimer;
  538. /*
  539. ** For the moebius effect, this is a pointer to the unit that we
  540. ** selected to teleport. Only one teleporter should be active per house.
  541. */
  542. TARGET UnitToTeleport;
  543. /*
  544. ** This elaborates the suggested objects to construct. When the specified object
  545. ** is constructed, then this corresponding value will be reset to nill state. The
  546. ** expert system decides what should be produced, and then records the
  547. ** recommendation in these variables.
  548. */
  549. StructType BuildStructure;
  550. UnitType BuildUnit;
  551. InfantryType BuildInfantry;
  552. AircraftType BuildAircraft;
  553. VesselType BuildVessel;
  554. /*---------------------------------------------------------------------
  555. ** Constructors, Destructors, and overloaded operators.
  556. */
  557. static void * operator new(size_t size);
  558. static void * operator new(size_t , void * ptr) {return(ptr);};
  559. static void operator delete(void *ptr);
  560. HouseClass(HousesType house);
  561. HouseClass(NoInitClass const & x) : Class(x), Control(x), AlertTime(x), BorrowedTime(x), Attack(x), AITimer(x), DamageTime(x), TeamTime(x), TriggerTime(x), SpeakAttackDelay(x), SpeakPowerDelay(x), SpeakMoneyDelay(x), SpeakMaxedDelay(x) {};
  562. ~HouseClass(void);
  563. operator HousesType(void) const;
  564. /*---------------------------------------------------------------------
  565. ** Member function prototypes.
  566. */
  567. CELL Random_Cell_In_Zone(ZoneType zone) const;
  568. static void Computer_Paranoid(void);
  569. bool Is_Allowed_To_Ally(HousesType house) const;
  570. void Do_All_To_Hunt(void) const;
  571. void Super_Weapon_Handler(void);
  572. int * Factory_Counter(RTTIType rtti);
  573. int Factory_Count(RTTIType rtti) const;
  574. DiffType Assign_Handicap(DiffType handicap);
  575. TARGET Find_Juicy_Target(COORDINATE coord) const;
  576. void Print_Zone_Stats(int x, int y, ZoneType zone, MonoClass * mono) const;
  577. CELL Where_To_Go(FootClass const * object) const;
  578. CELL Zone_Cell(ZoneType zone) const;
  579. ZoneType Which_Zone(COORDINATE coord) const;
  580. ZoneType Which_Zone(ObjectClass const * object) const;
  581. ZoneType Which_Zone(CELL cell) const;
  582. CELL Find_Cell_In_Zone(TechnoClass const * techno, ZoneType zone) const;
  583. ProdFailType Begin_Production(RTTIType type, int id);
  584. ProdFailType Suspend_Production(RTTIType type);
  585. ProdFailType Abandon_Production(RTTIType type);
  586. bool Place_Object(RTTIType type, CELL cell);
  587. bool Manual_Place(BuildingClass * builder, BuildingClass * object);
  588. void Special_Weapon_AI(SpecialWeaponType id);
  589. bool Place_Special_Blast(SpecialWeaponType id, CELL cell);
  590. bool Flag_Attach(CELL cell, bool set_home = false);
  591. bool Flag_Attach(UnitClass * object, bool set_home = false);
  592. bool Flag_Remove(TARGET target, bool set_home = false);
  593. void Init_Data(PlayerColorType color, HousesType house, int credits);
  594. COORDINATE Find_Build_Location(BuildingClass * building) const;
  595. BuildingClass * Find_Building(StructType type, ZoneType zone=ZONE_NONE) const;
  596. char const * Name(void) const {return(Class->Name());}
  597. // Added so the ally flags could be sent to client machines - 09 / 12 / 2019 JAS
  598. unsigned Get_Ally_Flags();
  599. bool Fire_Sale(void);
  600. bool Is_Hack_Prevented(RTTIType rtti, int value) const;
  601. bool Is_No_YakMig(void) const;
  602. int Expert_AI(void);
  603. void Production_Begun(TechnoClass const * rtti);
  604. void Sell_Wall(CELL cell);
  605. bool Flag_To_Die(void);
  606. bool Flag_To_Win(void);
  607. bool Flag_To_Lose(void);
  608. void Make_Ally(HousesType house);
  609. void Make_Ally(ObjectClass * object) {if (object) Make_Ally(object->Owner());};
  610. void Make_Enemy(HousesType house);
  611. void Make_Enemy(ObjectClass * object) {if (object) Make_Enemy(object->Owner());};
  612. bool Is_Ally(HousesType house) const;
  613. bool Is_Ally(HouseClass const * house) const;
  614. bool Is_Ally(ObjectClass const * object) const;
  615. unsigned int Get_Allies(void) const {return Allies;}
  616. #ifdef CHEAT_KEYS
  617. void Debug_Dump(MonoClass *mono) const;
  618. #endif
  619. void AI(void);
  620. bool Can_Build(RTTIType rtti, int type, HousesType house) const;
  621. // Factory controls.
  622. FactoryClass * Fetch_Factory(RTTIType rtti) const;
  623. void Set_Factory(RTTIType rtti, FactoryClass * factory);
  624. bool Can_Build(ObjectTypeClass const * type, HousesType house) const;
  625. int Get_Quantity(AircraftType aircraft);
  626. int Get_Quantity(StructType building);
  627. unsigned char const * Remap_Table(bool blushing=false, RemapType remap=REMAP_NORMAL) const;
  628. TechnoTypeClass const * Suggest_New_Object(RTTIType objectype, bool kennel=false) const;
  629. BuildingTypeClass const * Suggest_New_Building(void) const;
  630. void Recalc_Center(void);
  631. bool Does_Enemy_Building_Exist(StructType) const;
  632. void Harvested(unsigned tiberium);
  633. void Stole(unsigned worth);
  634. long Available_Money(void) const;
  635. void Spend_Money(unsigned money);
  636. void Refund_Money(unsigned money);
  637. void Attacked(BuildingClass* source);
  638. void Adjust_Power(int adjust);
  639. void Adjust_Drain(int adjust);
  640. void Update_Spied_Power_Plants(void);
  641. int Adjust_Capacity(int adjust, bool inanger=false);
  642. fixed Power_Fraction(void) const;
  643. fixed Tiberium_Fraction(void) const;
  644. void Begin_Production(void) {IsStarted = true;};
  645. TeamTypeClass const * Suggested_New_Team(bool alertcheck = false);
  646. void Adjust_Threat(int region, int threat);
  647. void Tracking_Remove(TechnoClass const * techno);
  648. void Tracking_Add(TechnoClass const * techno);
  649. void Active_Remove(TechnoClass const * techno);
  650. void Active_Add(TechnoClass const * techno);
  651. UrgencyType Check_Attack(void) const;
  652. UrgencyType Check_Build_Power(void) const;
  653. UrgencyType Check_Build_Defense(void) const;
  654. UrgencyType Check_Build_Offense(void) const;
  655. UrgencyType Check_Build_Income(void) const;
  656. UrgencyType Check_Fire_Sale(void) const;
  657. UrgencyType Check_Build_Engineer(void) const;
  658. UrgencyType Check_Raise_Money(void) const;
  659. UrgencyType Check_Raise_Power(void) const;
  660. UrgencyType Check_Lower_Power(void) const;
  661. bool AI_Attack(UrgencyType urgency);
  662. bool AI_Build_Power(UrgencyType urgency) const;
  663. bool AI_Build_Defense(UrgencyType urgency) const;
  664. bool AI_Build_Offense(UrgencyType urgency) const;
  665. bool AI_Build_Income(UrgencyType urgency) const;
  666. bool AI_Fire_Sale(UrgencyType urgency);
  667. bool AI_Build_Engineer(UrgencyType urgency) const;
  668. bool AI_Raise_Money(UrgencyType urgency) const;
  669. bool AI_Raise_Power(UrgencyType urgency) const;
  670. bool AI_Lower_Power(UrgencyType urgency) const;
  671. bool Can_Make_Money(void) const {
  672. return(Available_Money() > 300 || (BScan & STRUCTF_REFINERY));
  673. };
  674. static void Init(void);
  675. static void One_Time(void);
  676. static HouseClass * As_Pointer(HousesType house);
  677. static void Recalc_Attributes(void);
  678. /*
  679. ** New default win mode to avoid griefing. ST - 1/31/2020 3:33PM
  680. */
  681. void Check_Pertinent_Structures(void);
  682. void Init_Unit_Trackers(void);
  683. void Free_Unit_Trackers(void);
  684. // MBL 09.08.2020 Mod support stub
  685. void Handle_Mod_Game_Command(CELL cell, int mod_command_index); // mod_command_index = 0-3
  686. /*
  687. ** File I/O.
  688. */
  689. static void Read_INI(CCINIClass & ini);
  690. static void Write_INI(CCINIClass & ini);
  691. static void Read_Flag_INI(char *buffer);
  692. static void Write_Flag_INI(char *buffer);
  693. bool Load(Straw & file);
  694. bool Save(Pipe & file) const;
  695. void Code_Pointers(void);
  696. void Decode_Pointers(void);
  697. /*
  698. ** Special house actions.
  699. */
  700. void Detach(TARGET target, bool all);
  701. /*
  702. ** This vector holds the recorded status of the map regions. It is through
  703. ** this region information that team paths are calculated.
  704. */
  705. RegionClass Regions[MAP_TOTAL_REGIONS];
  706. /*
  707. ** This count down timer class decrements and then changes
  708. ** the Atomic Bomb state.
  709. */
  710. CELL NukeDest;
  711. /*
  712. ** Per-house credits class to track the visible credits state for each house. Redundant in the original game, but needed
  713. ** to preserve the exact credits count behavior in the GlyphX client. ST - 10/16/2019 2:31PM
  714. */
  715. CreditClass VisibleCredits;
  716. bool DebugUnlockBuildables;
  717. /*
  718. ** This routine completely removes this house & all its objects from the game.
  719. */
  720. void Clobber_All(void);
  721. /*
  722. ** This routine blows up everything in this house. Fun!
  723. */
  724. void Blowup_All(void);
  725. /*
  726. ** This routine gets called in multiplayer games when every unit, building,
  727. ** and infantry for a house is destroyed.
  728. */
  729. void MPlayer_Defeated(void);
  730. /*
  731. ** When the game's over, this routine assigns everyone their score.
  732. */
  733. void Tally_Score(void);
  734. friend class MapEditClass;
  735. private:
  736. void Silo_Redraw_Check(long oldtib, long oldcap);
  737. int AI_Building(void);
  738. int AI_Unit(void);
  739. int AI_Vessel(void);
  740. int AI_Infantry(void);
  741. int AI_Aircraft(void);
  742. /*
  743. ** This is a bit field record of all the other houses that are allies with
  744. ** this house. It is presumed that any house that isn't an ally, is therefore
  745. ** an enemy. A house is always considered allied with itself.
  746. */
  747. unsigned Allies;
  748. /*
  749. ** General low-power related damaged is doled out whenever this timer
  750. ** expires.
  751. */
  752. CDTimerClass<FrameTimerClass> DamageTime;
  753. /*
  754. ** Team creation is done whenever this timer expires.
  755. */
  756. CDTimerClass<FrameTimerClass> TeamTime;
  757. /*
  758. ** This controls the rate that the trigger time logic is processed.
  759. */
  760. CDTimerClass<FrameTimerClass> TriggerTime;
  761. /*
  762. ** At various times, the computer may announce the player's condition. The following
  763. ** variables are used as countdown timers so that these announcements are paced
  764. ** far enough apart to reduce annoyance.
  765. */
  766. CDTimerClass<FrameTimerClass> SpeakAttackDelay;
  767. CDTimerClass<FrameTimerClass> SpeakPowerDelay;
  768. CDTimerClass<FrameTimerClass> SpeakMoneyDelay;
  769. CDTimerClass<FrameTimerClass> SpeakMaxedDelay;
  770. /*
  771. ** This structure is used to record a build request as determined by
  772. ** the house AI processing. Higher priority build requests take precidence.
  773. */
  774. struct BuildChoiceClass {
  775. static void * operator new(size_t, void * ptr) {return(ptr);};
  776. UrgencyType Urgency; // The urgency of the build request.
  777. StructType Structure; // The type of building to produce.
  778. BuildChoiceClass(UrgencyType u, StructType s) : Urgency(u), Structure(s) {};
  779. BuildChoiceClass(NoInitClass const & ) {};
  780. int Save(Pipe &) const {return(true);};
  781. int Load(Straw &) {return(true);};
  782. void Code_Pointers(void) {};
  783. void Decode_Pointers(void) {};
  784. };
  785. static TFixedIHeapClass<BuildChoiceClass> BuildChoice;
  786. /*
  787. ** These values are for multiplay only.
  788. */
  789. public:
  790. /*
  791. ** For multiplayer games, each house instance has a remap table; the table
  792. ** in the HousesTypeClass isn't used. This variable is set to the remap
  793. ** table for the color the player wants to play.
  794. */
  795. PlayerColorType RemapColor;
  796. /*
  797. ** This is the name ("handle") the player has chosen for himself.
  798. */
  799. char IniName[HOUSE_NAME_MAX];
  800. #ifdef WOLAPI_INTEGRATION
  801. // For Internet games only, unchanging name of player when game began.
  802. // This name does not get changed to "Computer" if computer takes over for player.
  803. char InitialName[HOUSE_NAME_MAX];
  804. #endif
  805. int QuantityB(int index) {return(BQuantity[index]);}
  806. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  807. int QuantityU(int index) {
  808. if(index >= UNIT_RA_COUNT) index -= UNIT_RA_COUNT;
  809. return(UQuantity[index]);
  810. }
  811. int QuantityI(int index) {
  812. if(index >= INFANTRY_RA_COUNT) index -= INFANTRY_RA_COUNT;
  813. return(IQuantity[index]);
  814. }
  815. int QuantityA(int index) {return(AQuantity[index]);}
  816. int QuantityV(int index) {
  817. if(index >= VESSEL_RA_COUNT) index -= VESSEL_RA_COUNT;
  818. return(VQuantity[index]);
  819. }
  820. #else
  821. int QuantityU(int index) {return(UQuantity[index]);}
  822. int QuantityI(int index) {return(IQuantity[index]);}
  823. int QuantityA(int index) {return(AQuantity[index]);}
  824. int QuantityV(int index) {return(VQuantity[index]);}
  825. #endif
  826. /*
  827. ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
  828. */
  829. unsigned char SaveLoadPadding[256];
  830. };
  831. #endif