Skip to content

Commit

Permalink
Aloe vera bonus resource placing compatibility
Browse files Browse the repository at this point in the history
Edit of Communitu_79a.lua and AssignStartingPlots.lua to support my Aloe Vera resource modmod. Changes are similar to Even More Resource modmod.
I tested the changes beforehand and they work.
  • Loading branch information
jarcast authored and azum4roll committed Jul 12, 2024
1 parent ae34112 commit da50760
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 30 deletions.
94 changes: 64 additions & 30 deletions (2) Vox Populi/Core Files/Overrides/AssignStartingPlots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ function AssignStartingPlots.Create()
AdjustTiles = AssignStartingPlots.AdjustTiles,
PlaceBonusResources = AssignStartingPlots.PlaceBonusResources,
IsEvenMoreResourcesActive = AssignStartingPlots.IsEvenMoreResourcesActive,
IsAloeVeraResourceActive = AssignStartingPlots.IsAloeVeraResourceActive,
IsReducedSupplyActive = AssignStartingPlots.IsReducedSupplyActive,
Plot_GetPlotsInCircle = AssignStartingPlots.Plot_GetPlotsInCircle,
Plot_GetFertilityInRange = AssignStartingPlots.Plot_GetFertilityInRange,
Expand Down Expand Up @@ -464,36 +465,37 @@ function AssignStartingPlots:__Init()
self.coral_ID = resourceID;
elseif resourceType == "RESOURCE_LAPIS" then
self.lapis_ID = resourceID;
elseif self:IsEvenMoreResourcesActive() then
-- Even More Resources for Vox Populi (luxuries)
if resourceType == "RESOURCE_LAVENDER" then
self.lavender_ID = resourceID;
elseif resourceType == "RESOURCE_OBSIDIAN" then
self.obsidian_ID = resourceID;
elseif resourceType == "RESOURCE_PLATINUM" then
self.platinum_ID = resourceID;
elseif resourceType == "RESOURCE_POPPY" then
self.poppy_ID = resourceID;
elseif resourceType == "RESOURCE_TIN" then
self.tin_ID = resourceID;
-- Even More Resources for Vox Populi (bonus)
elseif resourceType == "RESOURCE_COCONUT" then
self.coconut_ID = resourceID;
elseif resourceType == "RESOURCE_HARDWOOD" then
self.hardwood_ID = resourceID;
elseif resourceType == "RESOURCE_LEAD" then
self.lead_ID = resourceID;
elseif resourceType == "RESOURCE_PINEAPPLE" then
self.pineapple_ID = resourceID;
elseif resourceType == "RESOURCE_POTATO" then
self.potato_ID = resourceID;
elseif resourceType == "RESOURCE_RUBBER" then
self.rubber_ID = resourceID;
elseif resourceType == "RESOURCE_SULFUR" then
self.sulfur_ID = resourceID;
elseif resourceType == "RESOURCE_TITANIUM" then
self.titanium_ID = resourceID;
end
elseif resourceType == "RESOURCE_LAVENDER" then
self.lavender_ID = resourceID;
elseif resourceType == "RESOURCE_OBSIDIAN" then
self.obsidian_ID = resourceID;
elseif resourceType == "RESOURCE_PLATINUM" then
self.platinum_ID = resourceID;
elseif resourceType == "RESOURCE_POPPY" then
self.poppy_ID = resourceID;
elseif resourceType == "RESOURCE_TIN" then
self.tin_ID = resourceID;
-- Even More Resources for Vox Populi (bonus)
elseif resourceType == "RESOURCE_COCONUT" then
self.coconut_ID = resourceID;
elseif resourceType == "RESOURCE_HARDWOOD" then
self.hardwood_ID = resourceID;
elseif resourceType == "RESOURCE_LEAD" then
self.lead_ID = resourceID;
elseif resourceType == "RESOURCE_PINEAPPLE" then
self.pineapple_ID = resourceID;
elseif resourceType == "RESOURCE_POTATO" then
self.potato_ID = resourceID;
elseif resourceType == "RESOURCE_RUBBER" then
self.rubber_ID = resourceID;
elseif resourceType == "RESOURCE_SULFUR" then
self.sulfur_ID = resourceID;
elseif resourceType == "RESOURCE_TITANIUM" then
self.titanium_ID = resourceID;
-- Aloe Vera for Vox Populi
elseif resourceType == "RESOURCE_JAR_ALOE_VERA" then
self.aloevera_ID = resourceID;
end
end

Expand Down Expand Up @@ -10843,6 +10845,10 @@ function AssignStartingPlots:PrintFinalResourceTotalsToLog()
print(self.titanium_ID, "Titanium: ", self.amounts_of_resources_placed[self.titanium_ID + 1]);
end
-- MOD.HungryForFood: End
if self:IsAloeVeraResourceActive() then
print("- Aloe Vera for Vox Populi (Bonus) -");
print(self.aloevera_ID, "AloeVera: ", self.amounts_of_resources_placed[self.aloevera_ID + 1]);
end
print("-----------------------------------------------------");
end
------------------------------------------------------------------------------
Expand Down Expand Up @@ -11057,6 +11063,13 @@ function AssignStartingPlots:PlaceBonusResources()

local resources_to_place = {};

if self:IsAloeVeraResourceActive() then
resources_to_place = {
{self.aloevera_ID, 1, 100, 1, 2}
};
self:ProcessResourceList(10 * resMultiplier, ImpactLayers.LAYER_BONUS, tPlotList[PlotListTypes.FLAT_DESERT_NO_FEATURE], resources_to_place);
end

if self:IsEvenMoreResourcesActive() then
resources_to_place = {
{self.deer_ID, 1, 100, 0, 2}
Expand Down Expand Up @@ -11201,14 +11214,14 @@ function AssignStartingPlots:PlaceBonusResources()
};
self:ProcessResourceList(35 * resMultiplier, ImpactLayers.LAYER_BONUS, tPlotList[PlotListTypes.HILLS_NO_FEATURE], resources_to_place);
-- Even More Resources for VP end

-- Placed last, since this blocks a large area
resources_to_place = {
{self.deer_ID, 1, 100, 3, 4}
};
self:ProcessResourceList(50 * resMultiplier, ImpactLayers.LAYER_BONUS, tPlotList[PlotListTypes.FLAT_PLAINS_GRASS_FOREST], resources_to_place);
self:ProcessResourceList(50 * resMultiplier, ImpactLayers.LAYER_BONUS, tPlotList[PlotListTypes.HILLS_FOREST], resources_to_place);
else

resources_to_place = {
{self.deer_ID, 1, 100, 0, 2}
};
Expand Down Expand Up @@ -11355,6 +11368,27 @@ function AssignStartingPlots:IsEvenMoreResourcesActive()
return false;
end
--------------------------------------------------------------------------------
function AssignStartingPlots:IsAloeVeraResourceActive()
local communityPatchModID = "d1b6328c-ff44-4b0d-aad7-c657f83610cd";
local aloeVeraModID = "c2c3797b-2728-417c-94c8-f30410528bf2";
local isUsingCommunityPatch = false;

for _, mod in pairs(Modding.GetActivatedMods()) do
if mod.ID == communityPatchModID then -- if Community Patch is not activated, then we are running in modpack mode
isUsingCommunityPatch = true;
elseif mod.ID == aloeVeraModID then
return true;
end
end

if not isUsingCommunityPatch then -- fallback method for modpack mode
for _ in DB.Query("SELECT * FROM Resources WHERE Type = 'RESOURCE_JAR_ALOE_VERA'") do
return true;
end
end
return false;
end
--------------------------------------------------------------------------------
-- Check if Reduced Supply for Vox Populi is activated
function AssignStartingPlots:IsReducedSupplyActive()
local communityPatchModID = "d1b6328c-ff44-4b0d-aad7-c657f83610cd";
Expand Down
7 changes: 7 additions & 0 deletions (2) Vox Populi/Mapscripts/Communitu_79a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,13 @@ function MapGlobals:New()

local resources_to_place = {};

if ASP:IsAloeVeraResourceActive() then
resources_to_place = {
{ASP.aloevera_ID, 1, 100, 1, 2}
};
ASP:ProcessResourceList(10 * resMultiplier, ImpactLayers.LAYER_BONUS, tPlotList[PlotListTypes.FLAT_DESERT_NO_FEATURE], resources_to_place);
end

if ASP:IsEvenMoreResourcesActive() then
resources_to_place = {
{ASP.deer_ID, 1, 100, 0, 2}
Expand Down

0 comments on commit da50760

Please sign in to comment.