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