From 93da107e6093cc12bf2af82b5a7da705cc5696a2 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 17 May 2020 20:50:47 +0000 Subject: [PATCH] New feature: factories allows facilities to create items For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=360075&#msg_360075 git-svn-id: https://ja2svn.mooo.com/source/ja2_v1.13_data@2534 4f8fa57e-7814-0410-bad4-adc449f26b7c --- gamedir/Data-1.13/Ja2_Options.INI | 8 + gamedir/Data-1.13/Scripts/strategicmap.lua | 170 +++++++++- .../Data-1.13/TableData/Map/Facilities.xml | 17 + .../Data-1.13/TableData/Map/FacilityTypes.xml | 316 +++++++++++++++++- gamedir/Data/Interface/OPTIONSCHECKBOXES.STI | Bin 0 -> 2527 bytes gamedir/Data/Ja2_Options.INI | 8 + gamedir/Data/Scripts/strategicmap.lua | 51 ++- 7 files changed, 565 insertions(+), 5 deletions(-) create mode 100644 gamedir/Data/Interface/OPTIONSCHECKBOXES.STI diff --git a/gamedir/Data-1.13/Ja2_Options.INI b/gamedir/Data-1.13/Ja2_Options.INI index 2b223c28e..843d212ba 100644 --- a/gamedir/Data-1.13/Ja2_Options.INI +++ b/gamedir/Data-1.13/Ja2_Options.INI @@ -3352,6 +3352,14 @@ FACILITY_EVENT_RARITY = 1000 ; noticeable. Increase this for the opposite. Default = 50. FACILITY_DANGER_RATE = 50 +;------------------------------------------------------------------------------------------------------------------------------ +; Facilities can produce items. +; This requires defining production lines for each item in FacilityTypes.xml and some set up in SetFactoryLeftoverProgress(...) +; and GetFactoryLeftoverProgress(...) in scripts/strategicmap.lua. +;------------------------------------------------------------------------------------------------------------------------------ + +FACTORIES = FALSE + ;****************************************************************************************************************************** ; Activates the new additional repair mode. ; While the old JA 1.13 repair system goes from soldier to soldier, this algorithm goes through item types, priorizing diff --git a/gamedir/Data-1.13/Scripts/strategicmap.lua b/gamedir/Data-1.13/Scripts/strategicmap.lua index 22274a0fa..1b534755d 100644 --- a/gamedir/Data-1.13/Scripts/strategicmap.lua +++ b/gamedir/Data-1.13/Scripts/strategicmap.lua @@ -78,6 +78,7 @@ Facts = { FACT_MARIA_ESCORTED = 116, FACT_ANGEL_LEFT_DEED = 120, FACT_CHALICE_STOLEN = 184, + FACT_CONVO_ERNEST = 215, FACT_MUSEUM_ALARM_WENT_OFF = 278, FACT_KINGPIN_KNOWS_MONEY_GONE = 103, FACT_KINGPIN_DEAD = 308, @@ -194,6 +195,19 @@ Profil = ELDIN = 127, ELLIOT = 135, MADLAB = 146, + DARYL = 150, +} + +Flags1 = +{ + PROFILE_MISC_FLAG_RECRUITED = 1, + PROFILE_MISC_FLAG_HAVESEENCREATURE = 2, + PROFILE_MISC_FLAG_FORCENPCQUOTE = 4, + PROFILE_MISC_FLAG_WOUNDEDBYPLAYER = 8, + PROFILE_MISC_FLAG_TEMP_NPC_QUOTE_DATA_EXISTS = 16, + PROFILE_MISC_FLAG_SAID_HOSTILE_QUOTE = 32, + PROFILE_MISC_FLAG_EPCACTIVE = 64, + PROFILE_MISC_FLAG_ALREADY_USED_ITEMS = 128, } SoldierClass = @@ -378,8 +392,156 @@ ModSpecificFacts = TIXA_PRISON_VOLUNTEERSGAINED = 123, TIXA_PRISON_SUBLEVEL_VOLUNTEERSGAINED = 124, ALMA_PRISON_VOLUNTEERSGAINED = 125, + + -- |||||||||||||||||||||||||||||||||| factories ||||||||||||||||||||||||||||||||||||| + FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_1 = 159, -- 9 products + FACTORY_PROGRESS_CAMBRIA_HICKSFARM_1 = 168, -- 4 products + FACTORY_PROGRESS_GRUMM_MUNITIONSFACTORY_1 = 172, -- 6 products + FACTORY_PROGRESS_GRUMM_BOMBWORKSHOP_1 = 178, -- 5 products + FACTORY_PROGRESS_GRUMM_ORTAFACTORY = 183, -- 6 products + -- |||||||||||||||||||||||||||||||||| factories ||||||||||||||||||||||||||||||||||||| } +FactorySpecialValues = +{ + FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_UPGRADE = 6, +} + +-- sSectorX, sSectorY and bSectorZ indicate the sector coordinates +-- usFacilityType is facility number from FacilitTypes.xml +-- usProductionNumber denotes which FACTORY of the facility this is for +-- sProgressLeft is the progress to be saved. +-- +-- As factories can be added or removed in the xml at will, we can't hardcode their progress in the savegame. +-- Therefore we let the modder store their progress in here via LUAFacts into the modder-administered part of the savefile. +-- We also want factories to be deactivated initially (so the player doesn't suddenly lose money if he takes their sector). Initially all values are 0. +-- In the code, values < 0 indicate a factory is offline, >= 0 online. +-- We thus add '1' to every value, so we store the progress as 1 + sProgressLeft, this means a luafact value of <= 0 is offline, > 0 is online +-- +-- We also use the Getter to check for other conditions, like quest progress. For example, even if we control Drassen, we can only use the T-Shirt factory once Doreen is gone. +-- We achieve that by returning a value < -10 if these extra conditions are not satisfied. +-- The code checks that too and won't allow us to even turn a factory on in this case, so the player knows he has something else to do first. +function SetFactoryLeftoverProgress(sSectorX, sSectorY, bSectorZ, usFacilityType, usProductionNumber, sProgressLeft) + + if ( bSectorZ == 0 ) then + + if ( sSectorX == 13 and sSectorY == SectorY.MAP_ROW_C and usFacilityType == 23 ) then + + SetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_1 + usProductionNumber, 1 + sProgressLeft) + + -- if we 'finished' the upgrade (see comment in GetFactoryLeftoverProgress(...), notify us of that fact + if ( usProductionNumber == FactorySpecialValues.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_UPGRADE and sProgressLeft > 170 ) then + + SetScreenMsg(FontColour.FONT_MCOLOR_LTGREEN, "Upgrade in T-Shirt Factory is finished.") + + end + + elseif ( sSectorX == 10 and sSectorY == SectorY.MAP_ROW_F and usFacilityType == 24 ) then + + SetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_CAMBRIA_HICKSFARM_1 + usProductionNumber, 1 + sProgressLeft) + + elseif ( sSectorX == 2 and sSectorY == SectorY.MAP_ROW_H and usFacilityType == 5 ) then + + SetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_MUNITIONSFACTORY_1 + usProductionNumber, 1 + sProgressLeft) + + elseif ( sSectorX == 2 and sSectorY == SectorY.MAP_ROW_G and usFacilityType == 25 ) then + + SetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_BOMBWORKSHOP_1 + usProductionNumber, 1 + sProgressLeft) + + elseif ( sSectorX == 4 and sSectorY == SectorY.MAP_ROW_K and usFacilityType == 15 ) then + + SetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_ORTAFACTORY + usProductionNumber, 1 + sProgressLeft) + + end + + end + +end + +function GetFactoryLeftoverProgress(sSectorX, sSectorY, bSectorZ, usFacilityType, usProductionNumber, sProgressLeft) + + CANT_ACTIVATE_FACTORY = -20 + + val = -1 + + if ( bSectorZ == 0 ) then + + if ( sSectorX == 13 and sSectorY == SectorY.MAP_ROW_C and usFacilityType == 23 ) then + + -- The T-Shirt factory can only be used once Doreen is gone, one way or the other + if ( gubQuest( Quests.QUEST_FREE_CHILDREN ) == qStatus.QUESTDONE ) then + + val = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_1 + usProductionNumber) - 1 + + -- The T-Shirt factory can be 'upgraded' to also produce uniforms + -- The upgrade is not an item, it exists purely in the lua values + -- We've set the upgrade time to be 03:01. As we set the progress on each full hour, there will be a point in time where the value is 180 + -- We use that value as 'upgrade has been done'. The upgrade cannot be built anymore -> val = CANT_ACTIVATE_FACTORY. + -- The uniform production lines always return CANT_ACTIVATE_FACTORY if the upgrade is not there yet. + if ( usProductionNumber == FactorySpecialValues.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_UPGRADE and val > 170 ) then + + val = CANT_ACTIVATE_FACTORY + + elseif ( usProductionNumber > FactorySpecialValues.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_UPGRADE ) then + + tmp = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_1 + FactorySpecialValues.FACTORY_PROGRESS_DRASSEN_TSHIRTFACTORY_UPGRADE) - 1 + + if ( tmp < 170 ) then + + val = CANT_ACTIVATE_FACTORY + + end + + end + + else + + val = CANT_ACTIVATE_FACTORY + + end + + elseif ( sSectorX == 10 and sSectorY == SectorY.MAP_ROW_F and usFacilityType == 24 ) then + + -- the Hicks farm can only be used if the quest was solved by killing the Hicks family + if ( MercIsDead(Profil.DARREL) and MercIsDead(Profil.DARYL) ) then + + val = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_CAMBRIA_HICKSFARM_1 + usProductionNumber) - 1 + + else + + val = CANT_ACTIVATE_FACTORY + + end + + elseif ( sSectorX == 2 and sSectorY == SectorY.MAP_ROW_H and usFacilityType == 5 ) then + + val = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_MUNITIONSFACTORY_1 + usProductionNumber) - 1 + + elseif ( sSectorX == 2 and sSectorY == SectorY.MAP_ROW_G and usFacilityType == 25 ) then + + val = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_BOMBWORKSHOP_1 + usProductionNumber) - 1 + + elseif ( sSectorX == 4 and sSectorY == SectorY.MAP_ROW_K and usFacilityType == 15 ) then + + -- the Orta factory can only be used once Ernest gave us the rifles (and presumably control over the assembly lines) + if ( (CheckFact( Facts.FACT_CONVO_ERNEST, 0 ) == true) ) then + + val = GetModderLUAFact(ModSpecificFacts.FACTORY_PROGRESS_GRUMM_ORTAFACTORY + usProductionNumber) - 1 + + else + + val = CANT_ACTIVATE_FACTORY + + end + + end + + end + + return val + +end + -- this function is called whenever we liberate a sector. If fFirstTime is true, this is the first time we liberate this sector function HandleSectorLiberation( sNewSectorX, sNewSectorY, bNewSectorZ, fFirstTime ) @@ -853,12 +1015,16 @@ MapSymbols = { FLAG = 10, QUESTIONMARK_BLUE = 11, -- sector might be relevant for a quest EXCLAMATIONMARK_BLUE = 12, -- sector is definetely relevant for a quest - QUESTIONMARK_GREEN = 13, -- alternate colours for other uses? + QUESTIONMARK_GREEN = 13, -- alternate colours for other uses EXCLAMATIONMARK_GREEN = 14, QUESTIONMARK_RED = 15, EXCLAMATIONMARK_RED = 16, QUESTIONMARK_YELLOW = 17, - EXCLAMATIONMARK_YELLOW = 18, + EXCLAMATIONMARK_YELLOW = 18, + FACTORY_YELLOW = 19, + FACTORY_GREEN = 20, + FACTORY_RED = 21, + FACTORY_NOCONTROL = 22, } -- this function allows us to data for the intel/quest map diff --git a/gamedir/Data-1.13/TableData/Map/Facilities.xml b/gamedir/Data-1.13/TableData/Map/Facilities.xml index ce612e1da..acaf038a7 100644 --- a/gamedir/Data-1.13/TableData/Map/Facilities.xml +++ b/gamedir/Data-1.13/TableData/Map/Facilities.xml @@ -40,6 +40,11 @@ 19 1 + + C13 + 23 + 1 + D13 18 @@ -238,6 +243,13 @@ 10 1 + + + + F10 + 24 + 1 + @@ -257,6 +269,11 @@ 18 2 + + G2 + 25 + 1 + H1 18 diff --git a/gamedir/Data-1.13/TableData/Map/FacilityTypes.xml b/gamedir/Data-1.13/TableData/Map/FacilityTypes.xml index 060f90ffe..c054ef5e6 100644 --- a/gamedir/Data-1.13/TableData/Map/FacilityTypes.xml +++ b/gamedir/Data-1.13/TableData/Map/FacilityTypes.xml @@ -126,6 +126,55 @@ 70 + + + 1446 + 180 + 9972 + 70 + 35 + + + + 1447 + 180 + 9973 + 50 + 35 + + + + 1448 + 180 + 9974 + 100 + 35 + + + + 1449 + 180 + 9975 + 150 + 35 + + + + 1451 + 180 + 9976 + 80 + 35 + + + + 7.62x39 Box HP C + 1452 + 180 + 9977 + 60 + 35 + @@ -169,7 +218,7 @@ STRATEGIC_MILITIA_MOVEMENT - This military installation has a war room that allows you to move your militia in the strategic screen. You can order them to move via the 'W', 'A', 'S' or 'D' keys. + This military installation has a war room that allows you to move your militia in the strategic screen. 2 70 @@ -301,6 +350,49 @@ Laboratory Lab 0 + + + - Requires storage access + 55 + 600 + 17023 + 700 + + + + 65 + 720 + 17023 + 700 + + + + 111 + 120 + 17026 + 350 + + + + 112 + 120 + 17027 + 350 + + + + 113 + 120 + 17028 + 350 + + + + 1738 + 120 + 17029 + 1000 + @@ -453,4 +545,226 @@ + + 23 + T-Shirt Factory + Factory + 4 + + + - Requires: Doreen quest + 311 + 10 + 11306 + 0 + 2 + 15 + + + + 1022 + 25 + 11307 + 6 + 15 + 311 + + + + 1710 + 35 + 11309 + 4 + 15 + 311 + 1022 + + + + 194 + 120 + 12758 + 7 + 15 + 311 + 1022 + 1022 + + + + 195 + 120 + 12759 + 7 + 15 + 311 + 1022 + 1022 + + + + 1609 + 120 + 12917 + 7 + 15 + 311 + 1022 + 1022 + + + + Upgrade + 181 + 100 + 15 + + + + - Uniform requires upgrade + 284 + 300 + 11316 + 25 + 30 + 311 + 311 + 311 + 1022 + 1022 + 1022 + + + + 284 + 180 + 11316 + 37 + 30 + 311 + 311 + 1022 + 1609 + + + + + 24 + Hicks Farm + Farm + 4 + + + - Requires: Hicks dead + 1565 + 300 + 15432 + 2 + + + + 1567 + 100 + 15592 + 2 + + + + 1568 + 90 + 15272 + 3 + + + + 1572 + 60 + 15112 + 2 + + + + + 25 + Bomb Workshop + Workshop + 2 + + PRACTICE_EXPLOSIVES + This well-equipped workshop has the tools you need to create some makeshift bombs. Very dangerous, but it just might be worth it. + 2 + 150 + + 70 + 50 + + + 50 + -5 + 4 + + + + + 140 + 60 + 19101 + 1 + 137 + 137 + + + + 140 + 60 + 18941 + 1 + 135 + 135 + 135 + 135 + 135 + 135 + + + + 940 + 60 + 18781 + 1 + 146 + 146 + 146 + 146 + 146 + 146 + + + + 941 + 60 + 18461 + 1 + 151 + 151 + 151 + 151 + 151 + 151 + + + + 951 + 60 + 18141 + 1 + 133 + 133 + 133 + 133 + 133 + 133 + + + \ No newline at end of file diff --git a/gamedir/Data/Interface/OPTIONSCHECKBOXES.STI b/gamedir/Data/Interface/OPTIONSCHECKBOXES.STI new file mode 100644 index 0000000000000000000000000000000000000000..8c38641fa2a3282094ceaa1621c73e360eabe40a GIT binary patch literal 2527 zcmeH{y>7xV5XYTXAd0%AkvdfB-o61lQ>99kXs3#ek&%%VRUH_44=+3bYagZ}X^8`l zUG;p99UC(sgj6B*;`rmI^Tqk+a?dZ_hxaBSPjD-{gZr915)u*8AgxvlsqWml!M9h! zO!pcWi^Y6C@AvziPG_$T|4yf)z|ZL%H9ToMX*Zh}yTXApx<-H6{QF zmqZ0W6zzz0Y*hM3RpEJvq=zKDc3!yZ2+l~HrP=B$M`J8sWf|F9!o)Q#p-U1i;UNh1 z@;4qEm0@@uBI%*yOXz)}Dhql2jZ7Ak>F9GQ_iBY2oT?aSm>44XuaNS zHt^JyMrD+;0&Tti)`&-GZ5sVW7CI7|EOaC^$ciIHfCNvpgo*VkivaN*h=pExjjV(k zl@Q)as1Z+U1yhX<%|cqI4bCXk3F_5CinWkBX-KOqtQj@=6&VJjEsvV1-XiovUS**Q wPpjPyGVvS~dZ{>mEL= 0 online. +-- We thus add '1' to every value, so we store the progress as 1 + sProgressLeft, this means a luafact value of <= 0 is offline, > 0 is online +-- +-- We also use the Getter to check for other conditions, like quest progress. For example, even if we control Drassen, we can only use the T-Shirt factory once Doreen is gone. +-- We achieve that by returning a value < -10 if these extra conditions are not satisfied. +-- The code checks that too and won't allow us to even turn a factory on in this case, so the player knows he has something else to do first. +function SetFactoryLeftoverProgress(sSectorX, sSectorY, bSectorZ, usFacilityType, usProductionNumber, sProgressLeft) + + + +end + +function GetFactoryLeftoverProgress(sSectorX, sSectorY, bSectorZ, usFacilityType, usProductionNumber, sProgressLeft) + + val = -1 + + return val + +end + -- this function is called whenever we liberate a sector. If fFirstTime is true, this is the first time we liberate this sector function HandleSectorLiberation( sNewSectorX, sNewSectorY, bNewSectorZ, fFirstTime ) @@ -450,12 +493,16 @@ MapSymbols = { FLAG = 10, QUESTIONMARK_BLUE = 11, -- sector might be relevant for a quest EXCLAMATIONMARK_BLUE = 12, -- sector is definetely relevant for a quest - QUESTIONMARK_GREEN = 13, -- alternate colours for other uses? + QUESTIONMARK_GREEN = 13, -- alternate colours for other uses EXCLAMATIONMARK_GREEN = 14, QUESTIONMARK_RED = 15, EXCLAMATIONMARK_RED = 16, QUESTIONMARK_YELLOW = 17, - EXCLAMATIONMARK_YELLOW = 18, + EXCLAMATIONMARK_YELLOW = 18, + FACTORY_YELLOW = 19, + FACTORY_GREEN = 20, + FACTORY_RED = 21, + FACTORY_NOCONTROL = 22, } -- this function allows us to data for the intel/quest map