Bazaar developer reference

CvMinorCivAI::DoUnitGiftFromMajor(PlayerTypes, CvUnit *, bool)

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

Hooks

static bool BeforeCvMinorCivAI_DoUnitGiftFromMajor(CvMinorCivAI* self, PlayerTypes eFromPlayer, CvUnit* pGiftUnit, bool bDistanceGift);static void AfterCvMinorCivAI_DoUnitGiftFromMajor(CvMinorCivAI* self, PlayerTypes eFromPlayer, CvUnit* pGiftUnit, bool bDistanceGift);static void ReplaceCvMinorCivAI_DoUnitGiftFromMajor(void (*original)(CvMinorCivAI*, PlayerTypes, CvUnit*, bool), CvMinorCivAI* self, PlayerTypes eFromPlayer, CvUnit* pGiftUnit, bool bDistanceGift);CivRegisterBefore<CivHooks::CvMinorCivAI_DoUnitGiftFromMajor>(host, &BeforeCvMinorCivAI_DoUnitGiftFromMajor);CivRegisterAfter<CivHooks::CvMinorCivAI_DoUnitGiftFromMajor>(host, &AfterCvMinorCivAI_DoUnitGiftFromMajor);CivRegisterReplace<CivHooks::CvMinorCivAI_DoUnitGiftFromMajor>(host, &ReplaceCvMinorCivAI_DoUnitGiftFromMajor);

Code

9872void CvMinorCivAI::DoUnitGiftFromMajor(PlayerTypes eFromPlayer, CvUnit* pGiftUnit, bool bDistanceGift)9873{9874	CvAssertMsg(eFromPlayer >= 0, "eFromPlayer is expected to be non-negative (invalid Index)");9875	CvAssertMsg(eFromPlayer < MAX_MAJOR_CIVS, "eFromPlayer is expected to be within maximum bounds (invalid Index)");9876	if (eFromPlayer < 0 || eFromPlayer >= MAX_MAJOR_CIVS) return;98779878	CvAssertMsg(pGiftUnit != NULL, "pGiftUnit is NULL");9879	if (pGiftUnit == NULL) return;98809881	ChangeNumUnitsGifted(eFromPlayer, 1);98829883	// Influence9884	int iInfluence = GetFriendshipFromUnitGift(eFromPlayer, pGiftUnit->IsGreatPerson(), bDistanceGift);9885	ChangeFriendshipWithMajor(eFromPlayer, iInfluence);98869887	// We can't keep Great Person units9888	if(pGiftUnit->IsGreatPerson())9889	{9890		pGiftUnit->kill(false);9891	}9892	9893#if defined(MOD_EVENTS_MINORS_INTERACTION)9894	if (MOD_EVENTS_MINORS_INTERACTION) {9895		GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerGifted, eFromPlayer, GetPlayer()->GetID(), -1, pGiftUnit->getUnitType(), -1, -1);9896	}9897#endif9898}

Calls

Called by