Declaration of Friendship check failing for the AI

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
I have some code that checks for what other players my civilisation is friends with. This works perfectly fine for the human/active player, but fails to pass with the AI.

Code:
for otherPlayerID, otherPlayer in pairs(Players) do
     if otherPlayer:IsAlive() and otherPlayer ~= player and not otherPlayer:IsMinorCiv() then
    if otherPlayer:IsDoF(player) then
	print("friend: " .. otherPlayer:GetName())
	table.insert(friends, otherPlayerID)
    end
    end
end

Is there any inherent reason why this check might work for the active player, but fail for the AI?
 
IsDoF() wants a player ID not a player object.

At a guess otherPlayer:IsDoF(player) is treating the player object "player" as 0, ie the human

It should be

otherPlayer:IsDoF(player:GetID())
 
Back
Top Bottom