Please HELP an Old Newbie

JA_Lamb

Warlord
Joined
Aug 19, 2009
Messages
253
Location
The changing Dark Continent
8th July 21
Hi everyone. After a long hiatus from gaming and modding, I was last here in 2012/3, I began to play Civ again due to lock downs. To my dismay I find that almost all my old skills (Civ4) have sort of disappeared except some Algorithmic thinking capability.
I'll sound like a total newbie here, but please bear with me. I find Civ6 good for the young, (and I'm old) and Civ5 dumped down in order to play quick and win awards which make everyone happy.
The developers who make money, the players who can boast they play at perceived high difficulty because the AI is given disproportionate game advantages etc. etc. you all have read, heard and moaned about ir.
I would like to mod Civ5 into what i would like it to be for myself, as I perceive it to be more in the trajectory of Civ1 to Civ4.
So... I have a number of questions, anyone with answers I'll be thankful.
Q1: In the Units Schema, there is a line in the main Schema that reads
<Column name="Requirements" type="text"/> [What does this mean specifically? Can it be used? How can it be used? and will it actuakky work?]
Q2: Staying with the Units Schema,
<Column name="PrereqResources" type="boolean" default="false"/> [ I suspect that if 'true', then one has to supply one or more of 'RUSH' Resources in the appropriate table below =>
<Table name="Unit_ResourceQuantityRequirements"> etc.] Is that correct and will it work correctly?
Q2a: Could one instead of requiring a 'RUSH' resource ask for a 'LUXURY' or 'BONUS' Resource to be present next to the City or within the Empire itself for the Unit to be built? eg Copper for Spearmen as the game itself is set up at present? Or does one have to dive in the unholy mess that Bob Thomas bequeathed us, innocently named 'AssignStartingPlots', and mod Copper into a 'RUSH' Resource? (A vaunting task indeed).
I find myself being semi-literate in Lua, i.e. I can more or less read it and see the point the code is making, but at present I'm unable to write anything with it that would make any sense to a programmer or the machine!
Since I have traveled and lived between 0 Longitude and about 30/35 Longitude from Inverness jn the North to Cape Town in the South, I found that 'There are plenty of Fish in all the Seas!' so Mr. Thomas's Fish restrictions seem to be a 'Sieg Heil' overcompensating impulse to control.
Thus, I would like to fill a big number of coves with Crustaceans and Fish along the Coasts of the Continents. Ok, not so many, but with a consistency that makes a kind of sense, not like at present every 12 Plots which would take a ship 6 turns to traverse or more than 5 generations!
Thus Q3: What would the Lua code be to effect the following:

-- "FishCode"
1 - Check - if a plot <is not>= Coast, then end
2 - elseif plot == Coast but not a Lake (FresjWater) then
3 - check if it has 5 adjacent plots of Land
4 - if yes, then roll [6]
5 - if roll == 3 (1/6 =+- 15%chance)
4 - place 'crustacean' [Mod to give FOOD as well as GOLD in XML? bears thinking ]
5 - elseif plot has 4 adjacent plots of land
6 - AND no other adjacent WaterResource then
7 - roll [5]
8 - if roll ==3 (1/5 = 20% chance)
9 - place 'fish'
10 - else end.

Point A: By having the two 'rolls' one can adjust the amount of 'sea resources' and not let them get out of hand or do let them get out of hand as one wishes.
Point B: This piece of code would be placed at the end of 'AssignStartingPlots' as follows:

'Map.RecalculateAreas();' -- as is at present

'FishCode -- Insert - (Thumping a nose here ;D)

'Map.RecalculateAreas();' -- as it will be

' -- Activate for debug only -- as is at present
self:printFinalResourceTotalsToLog() ' -- as is at present
--
end

---
Putting this at the end, one does not disrupt the previous balances, it is a gift of Poseidon, the God of the Seas!! ;D
Thanks JA_Lamb
 
Q1: The Requirements column is only used for the Settler, where it points to a TXT_KEY titled TXT_KEY_NO_ACTION_SETTLER_SIZE_LIMIT_HARDCODED. Offhand, I would guess that this tag links to a description of the limitation that Settlers can only be built in cities with 2 or more citizens, and so— in turn— the column would just store textual descriptions of any unique limitations that may prevent you from building certain units. (The column doesn't seem to have any functional purpose, but simply acts as a repository for this text.)

Q2: As for PrereqResources, I can't say I really know what it does; the only vanilla unit that sets the column to "true" is the Work Boat.

Q2a: Although I don't know offhand what would happen if you tried to make a unit require luxury or bonus resources, it would be a fairly easy change to turn Copper (or any other resource) into a Strategic Resource. You don't need to touch AssignStartingPlots at all for this one, you could just do it in SQL:
Code:
UPDATE Resources
SET ResourceClassType = 'RESOURCECLASS_RUSH'
WHERE Type = 'RESOURCE_COPPER';

INSERT INTO Unit_ResourceQuantityRequirements
(UnitType, ResourceType)
VALUES ('UNIT_SPEARMAN', 'RESOURCE_COPPER');
You may also want to change other columns, such as AIObjective and PlacementOrder, to get the resource to behave fully like a Strategic Resource— but just changing the ResourceClassType will most likely get the basics taken care of. What would make things more complicated, though, would be if you wanted Copper to not just act like a Strategic Resource but also to still give Happiness like a luxury; that would probably require making a dummy resource, and just being kind of a convoluted pain in general, so I won't get into it for now.

Q3: See under the spoiler for the full code. Note that I would recommend not placing this into AssignStartingPlots.lua, but instead making it into a wholly separate Lua file that will be set to InGameUIAddin in Modbuddy.
Spoiler :

Code:
function JFD_GetRandom(lower, upper)
    return Game.Rand((upper + 1) - lower, "") + lower
end

local iNumDirections = DirectionTypes.NUM_DIRECTION_TYPES - 1

local iCoast = GameInfoTypes["TERRAIN_COAST"]
local iCrab = GameInfoTypes["RESOURCE_CRAB"]
local iFish = GameInfoTypes["RESOURCE_FISH"]

function UpdateSeaResources()
    if Game.GetGameTurn() > 0 then return end
    for i = 0, Map.GetNumPlots() - 1, 1 do
        local pPlot = Map.GetPlotByIndex(i)
        if (pPlot:GetTerrainType() == iCoast) and (not pPlot:IsLake()) then
            local iNumAdjLandPlots = 0
            local bHasAdjacentSeaResource = false
            for iDir = 0, iNumDirections, 1 do
                local pAdjPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), iDir)
                if pAdjPlot then
                    if pAdjPlot:IsWater() then
                        if pAdjPlot:GetResourceType() > -1 then
                            bHasAdjacentSeaResource = true
                        end
                    else
                        iNumAdjLandPlots = iNumAdjLandPlots + 1
                    end
                end
            end
           
            if iNumAdjLandPlots == 5 then
                if JFD_GetRandom(1, 6) == 3 then
                    pPlot:SetResourceType(iCrab, 1)
                end
            elseif iNumAdjLandPlots == 4 and not bHasAdjacentSeaResource then
                if JFD_GetRandom(1, 5) == 3 then
                    pPlot:SetResourceType(iFish, 1)
                end
            end
        end
    end
end

Events.LoadScreenClose.Add(UpdateSeaResources)
 
Thank you very much for the quick turn around reply. No, Copper does not need to have happiness. As for the other settings to make Copper a RUSH resource, I think... I can handle that. Thank you for the Fish Code and I will seriously rethink it's placement.
 
Have you checked out the Community Patch section? It might give you somethings you want.
Thank you for the reply. TopHatPaladin replied to all my questions very adequately for now. Anyway thanksfor the heads up, I'll check them out.:thumbsup:
 
Top Bottom