ChangeMinorCivFriendshipWithMajor works (maybe) but not showing up in game

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,773
Location
Calgary, Canada
I am trying to mod in changing CS influence. My testing of the following code shows that it is working (printing GetMinorCivFriendshipWithMajor before and after the function shows the change), but the altered influence is not showing up when hovering over the city state.

The log... showing my print results. Notice the change from 0 to 100.

Spoiler :

[8614.234] DiplomacyCS: Wiht
[8614.250] DiplomacyCS: Alfred
[8614.250] DiplomacyCS: 0
[8614.250] DiplomacyCS: 100


Ideally, I eventually want to set this so that every turn +1 is added to influence over the CS. This would essentially set up almost permanent alliances.

I'll work on that coding next.

Anyhow, I'm not certain what I am missing... maybe the change from 0 to 100 is just adding a number and not in influence, because something basic is wrong with the code.

Code:
-- Lua Script2
-- Author: Craig and Nancy
-- DateCreated: 8/11/2012 9:40:39 PM
--------------------------------------------------------------

function SetCsFriendships()

if Game.GetGameTurn() == 0 then

print(">>>> Friendship");

local pWiht
local pWessex
local Wessex

for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

local pWessex = Players[iPlayer]
	
  if (pWessex:IsAlive()) then
		if (GameInfo.Civilizations.CIVILIZATION_ENGLAND.ID == pWessex:GetCivilizationType()) then
     
	    Wessex = pWessex:GetCivilizationType()

for iWiht = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-2, 1 do

local pWiht = Players[iWiht]

   if (pWiht:IsAlive()) then
		if (GameInfo.MinorCivilizations.MINOR_CIV_WIHT.ID == pWiht:GetMinorCivType()) then

		print(pWiht:GetName()); 
		print(pWessex:GetName());
		print(pWiht:GetMinorCivFriendshipWithMajor(Wessex))
						
      pWiht:ChangeMinorCivFriendshipWithMajor(Wessex, 100 + pWiht:GetMinorCivFriendshipWithMajor(Wessex))

		print(pWiht:GetMinorCivFriendshipWithMajor(Wessex))

	  end
    end
  end
end
end
end
end
end

Events.ActivePlayerTurnEnd.Add(SetCsFriendships)
 
I tried a couple of things...

First, I adjusted the scenario map to give 180 influence for Wessex over Wiht.

As well, I switched and played another civilization.

The lau log remained unchanged...
Spoiler :

DiplomacyCS: >>>> Friendship
DiplomacyCS: Wiht
DiplomacyCS: Alfred
DiplomacyCS: 0
DiplomacyCS: 100


So, the right civilizations are coming up; however, I am somehow picking up 0 rather than 180 when I GetMinorCivFriendshipWithMajor(Wessex). I can only presume that ChangeMinorCivFriendshipWithMajor is also being misapplied... the same way.

So the 0 value is coming from somewhere, and the 100 is being added from somewhere, but apparently, that somewhere is not Wessex/Wiht but something else... despite the fact the print commands are giving me Wiht and Alfred(Wessex).

I'm puzzled.
 
This will add .67 influence every turn to a civilizations influence over a CS. Essentially, this will mean it is a puppet once you get it allied. In scenarios, I preset the influence in Worldbuilder, and this can maintain that influence over time. You can change the major civ and minor civ and variables to conform to your own ideas.

Code:
function SetCsFriendships()

if Game.GetGameTurn() >= 0 then

print(">>>> Friendship");

local pWiht
local pWessex
local Wessex

for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

local pWessex = Players[iPlayer]
	
  if (pWessex:IsAlive()) then
		if (GameInfo.Civilizations.CIVILIZATION_ENGLAND.ID == pWessex:GetCivilizationType()) then
     
	   	Wessex = iPlayer
		

for iWiht = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-2, 1 do

local pWiht = Players[iWiht]

   if (pWiht:IsAlive()) then
		if (GameInfo.MinorCivilizations.MINOR_CIV_WIHT.ID == pWiht:GetMinorCivType()) then
										
      pWiht:ChangeMinorCivFriendshipWithMajor(Wessex, .67)

		end
    end
  end
end
end
end
end
end

Events.ActivePlayerTurnEnd.Add(SetCsFriendships)
 
Back
Top Bottom