HOUSE.H 29 KB

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