Bazaar developer reference

CvMinorCivAI::DoGoldGiftFromMajor(PlayerTypes, int)

Defined in
CvMinorCivAI.cpp, line 9966
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoGoldGiftFromMajor
Lua events
GameEvents.PlayerGifted

Hooks

static bool BeforeCvMinorCivAI_DoGoldGiftFromMajor(CvMinorCivAI* self, PlayerTypes ePlayer, int iGold);static void AfterCvMinorCivAI_DoGoldGiftFromMajor(CvMinorCivAI* self, PlayerTypes ePlayer, int iGold);static void ReplaceCvMinorCivAI_DoGoldGiftFromMajor(void (*original)(CvMinorCivAI*, PlayerTypes, int), CvMinorCivAI* self, PlayerTypes ePlayer, int iGold);CivRegisterBefore<CivHooks::CvMinorCivAI_DoGoldGiftFromMajor>(host, &BeforeCvMinorCivAI_DoGoldGiftFromMajor);CivRegisterAfter<CivHooks::CvMinorCivAI_DoGoldGiftFromMajor>(host, &AfterCvMinorCivAI_DoGoldGiftFromMajor);CivRegisterReplace<CivHooks::CvMinorCivAI_DoGoldGiftFromMajor>(host, &ReplaceCvMinorCivAI_DoGoldGiftFromMajor);

Code

9965/// Major Civ gifted some Gold to this Minor9966void CvMinorCivAI::DoGoldGiftFromMajor(PlayerTypes ePlayer, int iGold)9967{9968	if(GET_PLAYER(ePlayer).GetTreasury()->GetGold() >= iGold)9969	{9970		int iFriendshipChange = GetFriendshipFromGoldGift(ePlayer, iGold);9971		if(iFriendshipChange > 0)9972			GET_PLAYER(ePlayer).GetTreasury()->LogExpenditure(GetPlayer()->GetMinorCivAI()->GetNamesListAsString(0), iGold,4);99739974		GET_PLAYER(ePlayer).GetTreasury()->ChangeGold(-iGold);9975		9976		ChangeNumGoldGifted(ePlayer, iGold);9977		9978		ChangeFriendshipWithMajor(ePlayer, iFriendshipChange);99799980		// In case we had a Gold Gift quest active, complete it now9981		DoTestActiveQuestsForPlayer(ePlayer, /*bTestComplete*/ true, /*bTestObsolete*/ false, MINOR_CIV_QUEST_GIVE_GOLD);9982		9983#if defined(MOD_EVENTS_MINORS_INTERACTION)9984		if (MOD_EVENTS_MINORS_INTERACTION) {9985			GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerGifted, ePlayer, GetPlayer()->GetID(), iGold, -1, -1, -1);9986		}9987#endif9988	}99899990	GC.GetEngineUserInterface()->setDirty(GameData_DIRTY_BIT, true);9991}

Calls

Called by