Bazaar developer reference

CvDiplomacyAI::ChangeOtherPlayerNumMajorsAttacked(PlayerTypes, int, TeamTypes)

Defined in
CvDiplomacyAI.cpp, line 10231
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked

Hooks

static bool BeforeCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked(CvDiplomacyAI* self, PlayerTypes ePlayer, int iChange, TeamTypes eAttackedTeam);static void AfterCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked(CvDiplomacyAI* self, PlayerTypes ePlayer, int iChange, TeamTypes eAttackedTeam);static void ReplaceCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked(void (*original)(CvDiplomacyAI*, PlayerTypes, int, TeamTypes), CvDiplomacyAI* self, PlayerTypes ePlayer, int iChange, TeamTypes eAttackedTeam);CivRegisterBefore<CivHooks::CvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked>(host, &BeforeCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked);CivRegisterAfter<CivHooks::CvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked>(host, &AfterCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked);CivRegisterReplace<CivHooks::CvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked>(host, &ReplaceCvDiplomacyAI_ChangeOtherPlayerNumMajorsAttacked);

Code

10230/// Changes how many Majors have we seen this Player attack10231void CvDiplomacyAI::ChangeOtherPlayerNumMajorsAttacked(PlayerTypes ePlayer, int iChange, TeamTypes eAttackedTeam)10232{10233	if(iChange > 0)10234	{10235		PlayerTypes eAttackedPlayer;10236		for(int iAttackedPlayerLoop = 0; iAttackedPlayerLoop < MAX_MAJOR_CIVS; iAttackedPlayerLoop++)10237		{10238			eAttackedPlayer = (PlayerTypes) iAttackedPlayerLoop;1023910240			// Player must be on this team10241			if(GET_PLAYER(eAttackedPlayer).getTeam() != eAttackedTeam)10242				continue;1024310244			// Don't ACTUALLY count this if we're at war with the guy also10245			if(IsAtWar(eAttackedPlayer))10246				return;10247		}10248	}1024910250#if defined(MOD_API_EXTENSIONS)10251	int iWarmongerModifier = 100;10252#endif1025310254	SetOtherPlayerNumMajorsAttacked(ePlayer, GetOtherPlayerNumMajorsAttacked(ePlayer) + iChange);10255#if defined(MOD_API_EXTENSIONS)10256		ChangeOtherPlayerWarmongerAmountTimes100(ePlayer, iChange * /*250 */ GC.getWARMONGER_THREAT_MAJOR_ATTACKED_WEIGHT() * iWarmongerModifier);10257#else10258		ChangeOtherPlayerWarmongerAmount(ePlayer, iChange * /*250 */ GC.getWARMONGER_THREAT_MAJOR_ATTACKED_WEIGHT());10259#endif10260}

Calls

Called by