GameEvents.GetScenarioDiploModifier

Lord Yanaek

Emperor
Joined
Aug 15, 2003
Messages
1,664
Has anyone investigated what this method does? It seems like it's used only in scenarios.
Am i right thinking this is a way to add custom diplomatic relations modifiers?
Here is an example from the Smoky Skies scenario.
Code:
-- Medium negative modifier when other player has exactly 2 Titles
GameEvents.GetScenarioDiploModifier1.Add(function(ePlayer1, ePlayer2)
	if (GetNumTokensOwned(ePlayer2) == 2) then
		return 20;
	end
	return 0;
end)

-- Large negative modifier when other player has more than 2 Titles (about to win)
GameEvents.GetScenarioDiploModifier2.Add(function(ePlayer1, ePlayer2)
	if (GetNumTokensOwned(ePlayer2) > 2) then
		return 70;
	end
	return 0;
end)
Searching for a match in the C++ code, i found 3 "instances" of this code in CvDiplomacyAI.cpp :
Code:
int CvDiplomacyAI::GetScenarioModifier1(PlayerTypes ePlayer)
{
	ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
	if(pkScriptSystem)
	{
		CvLuaArgsHandle args;
		args->Push(m_pPlayer->GetID());
		args->Push(ePlayer);

		int iValue = 0;
		if (LuaSupport::CallAccumulator(pkScriptSystem, "GetScenarioDiploModifier1", args.get(), iValue))
		{
			return iValue;
		}
	}

	return 0;
}
If i understand and guess correctly, you can subscribe a Lua function to those 3 similar events, and the game will call them when checking diplomatic relations. Thus it is possible to actually modify diplomatic relations in Lua :)
Obviously, positive numbers give negative modifiers. Now, the question, does negative modifiers improve relations? I don't see anything that suggest negative numbers would be ignored in the C++ code, but i'm really bad at C++ and i guess more than i understand this code.
 
yep, it works, just use negative value to raise relation.
 
Back
Top Bottom