sman1975
Emperor
Hello,
Am working on a mod that needs to know if two civs have an Open Borders agreement in place.
After establishing an embassy, and then bribing the other civ with free IGE Gold, they agreed to a 'Mutual OB Agreement.' I know there is an agreement in place - can see it in the Diplomacy UI.
Have seen a few examples of how to test for OBs in other mods, and have recycled code that looks like the fragment below. The variable iPlayer is the player ID of the Active Player, having a value of 0. iOwner has a value of 1, for the Civ that owns the plot in question:
The code looks good, nice, and compact. The problem? It doesn't work.
Using print statements, I know the first IF statement (with the 2 conditionals) works, leading to the 2nd IF.
The second IF statement (with the IsPlayerHasOpenBorders) never returns TRUE even though I know the condition is true.
I've reversed the player ID's in the second IF, but the results were the same.
Is there anything peculiar about the IsPlayerHasOpenBorders method that might cause it to fail? Or (as is usually more likely) is there something bone-headed I've missed?
Thanks!
Am working on a mod that needs to know if two civs have an Open Borders agreement in place.
After establishing an embassy, and then bribing the other civ with free IGE Gold, they agreed to a 'Mutual OB Agreement.' I know there is an agreement in place - can see it in the Diplomacy UI.
Have seen a few examples of how to test for OBs in other mods, and have recycled code that looks like the fragment below. The variable iPlayer is the player ID of the Active Player, having a value of 0. iOwner has a value of 1, for the Civ that owns the plot in question:
Code:
...
local iOwner = pPlot:GetOwner() -- Check ownership of the tile
if (iPlayer ~= iOwner) and (iOwner >= 0) then -- If plot owner is not active player AND plot is owned by anyone, then...
if Players[iPlayer]:IsPlayerHasOpenBorders(iOwner) then -- If Active Player has open borders with plot owner, then...
return true -- Return TRUE early
end
end
...
The code looks good, nice, and compact. The problem? It doesn't work.
Using print statements, I know the first IF statement (with the 2 conditionals) works, leading to the 2nd IF.
The second IF statement (with the IsPlayerHasOpenBorders) never returns TRUE even though I know the condition is true.
I've reversed the player ID's in the second IF, but the results were the same.
Is there anything peculiar about the IsPlayerHasOpenBorders method that might cause it to fail? Or (as is usually more likely) is there something bone-headed I've missed?
Thanks!
Last edited: