From a21baa68910d27988e7b2f98d7c77cbc26d9c006 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Mon, 20 Jul 2020 12:15:27 -0700 Subject: [PATCH] FireSale can be toggled via lua script, the AI in soviet 1 won't do a fire sale, and the allied radar dome is no longer a fake dome. --- SCU01EA.MAP | 4 ++-- code/redalert/house.cpp | 6 ++++++ code/redalert/house.h | 3 +++ code/redalert/mapscript.cpp | 20 ++++++++++++++++++++ scripts/SCU01EA.MAP.script | 2 ++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/SCU01EA.MAP b/SCU01EA.MAP index 103b163..5be6a2e 100644 --- a/SCU01EA.MAP +++ b/SCU01EA.MAP @@ -507,9 +507,9 @@ HomeCell=2742 30=Neutral,ABAN02,256,5172,0,None,1,0 31=Neutral,ABAN02,256,5175,0,None,1,0 32=Neutral,ABAN02,256,5178,0,None,1,0 -33=Greece,DOMF,256,6538,0,None,0,0 +33=Greece,DOME,256,6538,0,None,0,0 34=Greece,HOSP,256,6154,0,None,0,0 -35=Greece,FACT,256,6160,0,None,0,0 +35=Greece,APWR,256,6160,0,None,0,0 36=Greece,PROC,256,6800,0,None,0,0 37=Greece,APWR,256,6548,0,None,0,0 38=Greece,APWR,256,6036,0,None,0,0 diff --git a/code/redalert/house.cpp b/code/redalert/house.cpp index 9829ab9..fd1d136 100644 --- a/code/redalert/house.cpp +++ b/code/redalert/house.cpp @@ -525,6 +525,7 @@ HouseClass::HouseClass(HousesType house) : RepairDelay(0), BuildDelay(0), ActLike(Class->House), + fireSaleAvailable(false), IsHuman(false), WasHuman(false), IsPlayerControl(false), @@ -7513,6 +7514,11 @@ bool HouseClass::Is_Hack_Prevented(RTTIType rtti, int value) const *=============================================================================================*/ bool HouseClass::Fire_Sale(void) { + // Toggle the fire sale ability. + if(!fireSaleAvailable) { + return false; + } + if (CurBuildings > 0) { for (int index = 0; index < Buildings.Count(); index++) { BuildingClass * b = Buildings.Ptr(index); diff --git a/code/redalert/house.h b/code/redalert/house.h index d21a745..3f266e0 100644 --- a/code/redalert/house.h +++ b/code/redalert/house.h @@ -688,6 +688,7 @@ class HouseClass { // Added so the ally flags could be sent to client machines - 09 / 12 / 2019 JAS unsigned Get_Ally_Flags(); + void ToggleFireSaleAbility(bool fireSaleEnabled) { this->fireSaleAvailable = fireSaleEnabled; } bool Fire_Sale(void); bool Is_Hack_Prevented(RTTIType rtti, int value) const; bool Is_No_YakMig(void) const; @@ -851,6 +852,8 @@ class HouseClass { int AI_Infantry(void); int AI_Aircraft(void); + bool fireSaleAvailable; + /* ** This is a bit field record of all the other houses that are allies with ** this house. It is presumed that any house that isn't an ally, is therefore diff --git a/code/redalert/mapscript.cpp b/code/redalert/mapscript.cpp index 3a4e7f2..39dfa4e 100644 --- a/code/redalert/mapscript.cpp +++ b/code/redalert/mapscript.cpp @@ -5,6 +5,24 @@ * Red Alert Vanilla Actions * *=============================================================================================*/ +static int Script_ToggleFireSale(lua_State* L) { + + int houseType = lua_tointeger(L, 1); + int fireSaleEnabled = lua_tointeger(L, 2); + + if (houseType != HOUSE_NONE) { + + HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType); + + if (this_house != NULL) { + this_house->ToggleFireSaleAbility(fireSaleEnabled != 0); + } + } + + return 1; +} + + /*********************************************************************************************** * Script_Win - The specified player wins * * * @@ -7620,6 +7638,8 @@ bool MapScript::Init(const char* mapName) { * Script Globals * *=============================================================================================*/ + lua_register(L, "ToggleFireSale", Script_ToggleFireSale); + lua_pushnumber(L, PlayerPtr->ID); // Local player (house) index lua_setglobal(L, "_localPlayer"); diff --git a/scripts/SCU01EA.MAP.script b/scripts/SCU01EA.MAP.script index a216040..65d81da 100644 --- a/scripts/SCU01EA.MAP.script +++ b/scripts/SCU01EA.MAP.script @@ -7,6 +7,7 @@ end function map_start() GiveSpecialWeapon(SpecialWeapons.Paratroops, Houses.USSR, 1) + ToggleFireSale(Houses.GREECE, 0) -- Disable fire sale for the AI, otherwise it sells the radar dome we're trying to capture :) end function map_frame() @@ -19,6 +20,7 @@ function map_frame() end if numRadarDomes == 2 then + ToggleFireSale(Houses.GREECE, 1) -- Renable the fire sale for the AI Win(Houses.USSR) end