I want one-sided GetScenarioDiploModifier

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,773
Location
Calgary, Canada
The code below is working and returning the diplomatic modifier. However, when I play as a player without any of the cities in question, I seem to be getting the malus diplomacy with players who have the cities.

I want it so that the malus is strictly applied against any civilization with the listed cities...

But I can't figure out who is ePlayer1 is or ePlayer2... I have a feeling that one of the sections of code below needs to be deleted, but I am not certain which... or if that is the proper course.

Anyone know off-hand?

Code:
function VictoryCity (ePlayer1, ePlayer2)

-- check diplomacy for ePlayer1

	local pPlayer1 = Players[ePlayer1]
	if (pPlayer1:IsAlive ()) then

		local iCitiesOwned = 0;
		for pCity in pPlayer1:Cities() do				
				
			-- City exists and is a victory city
			if pCity ~= nil and (pCity:GetName() == "Winchester" or pCity:GetName() == "London" or pCity:GetName() == "Exeter" or pCity:GetName() == "York" or pCity:GetName() == "Leicester") then 
					
			iCitiesOwned = iCitiesOwned+1;	

			end							
    	end

		if (iCitiesOwned == 1) then
		print ("Kingdom of England diplomacy 1 city")
			return 20;		
		
		elseif (iCitiesOwned > 1) then
		print ("Kingdom of England diplomacy >1 city")
			return 70;

		else
			return 0;		
		end
	end

-- check diplomacy for ePlayer2

	local pPlayer2 = Players[ePlayer2]	
	if (pPlayer2:IsAlive ()) then

		local iCitiesOwned = 0;
		for pCity in pPlayer2:Cities() do				
				
			-- City exists and is a victory city
			if pCity ~= nil and (pCity:GetName() == "Winchester" or pCity:GetName() == "London" or pCity:GetName() == "Exeter" or pCity:GetName() == "York" or pCity:GetName() == "Leicester") then 
					
			iCitiesOwned = iCitiesOwned+1;	

			end							
    	end

		if (iCitiesOwned == 1) then
		print ("Kingdom of England diplomacy 1 city")
			return 20;		
		
		elseif (iCitiesOwned > 1) then
		print ("Kingdom of England diplomacy >1 city")
			return 70;

		else
			return 0;		
		end
	end
end

GameEvents.GetScenarioDiploModifier2.Add(VictoryCity)

Thank-you in advance.

PS I'll tinker with the cities and values once I figure out upon whom the malus is being applied :)

PPS I seem to recall reading that the event is run twice during each player's turn. Presumably once for ePlayer1 and and once for ePlayer2. Doesn't help me as to the order...
 
Back
Top Bottom