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