Open Borders Among Humans in Multiplayer Games

bob_sanders

Chieftain
Joined
Oct 17, 2018
Messages
1
Goal: Write a mod to give all human players open borders with each other (obviously in Multiplayer games).

Why: My buddies and I got sick of getting kicked out of eachothers cities once an Open Borders deal expired (especially in the middle of a war with a nearby enemy civ, city state, or barbarians).

What we've done so far: We've been playing with the code used in Tiramisu's mod City States Open Borders. We've tried a few different variations of code but can't seem to get it to work. Can anyone give any input? Like Tiramisu's mod, we've been editing the TutorialGoals.lua file and replaced his code with the code below. Any help would be appreciated.

What works: The mod is showing as loaded for all of us and is listed in the mod list when creating and in a multiplayer game.

What doesn't work: The mod isn't behaving properly at all. Once any or all of us have the ability to enforce open borders, it is not granting open borders automatically.

Code:
function GrantOpenBorderInHumans()
    for iPlayerID = 0, GameDefines.MAXPLAYERS-1, 1 do
        local pPlayer = Players[iPlayerID]; 
        if (pPlayer:IsAlive() and pPlayer:IsMajor() and pPlayer:IsHuman()) then
            for _, iHumanPlayerID in ipairs(GameConfiguration.GetHumanPlayerIDs()) do
                  DiplomacyManager.SendAction(iPlayerID, iHumanPlayerID, DiplomacyActionTypes.SET_OPEN_BORDERS);                 
            end
        end
    end
end

Events.TurnBegin.Add( GrantOpenBorderInHumans )

I suck with lua code but I don't understand why this code isn't working. Anyone able to help?
 
Have you figured this out? I suspect the value is being overwritten when player researches Early Empire.

Try setting the code to activate when researching that civic.
 
Back
Top Bottom