Bazaar developer reference

CvDllNetMessageHandler::ResponseBarbarianRansom(PlayerTypes, int, int)

Defined in
CvDllNetMessageHandler.cpp, line 71
Class
CvDllNetMessageHandler
Hook name
CivHooks::CvDllNetMessageHandler_ResponseBarbarianRansom

Hooks

static bool BeforeCvDllNetMessageHandler_ResponseBarbarianRansom(CvDllNetMessageHandler* self, PlayerTypes ePlayer, int iOptionChosen, int iUnitID);static void AfterCvDllNetMessageHandler_ResponseBarbarianRansom(CvDllNetMessageHandler* self, PlayerTypes ePlayer, int iOptionChosen, int iUnitID);static void ReplaceCvDllNetMessageHandler_ResponseBarbarianRansom(void (*original)(CvDllNetMessageHandler*, PlayerTypes, int, int), CvDllNetMessageHandler* self, PlayerTypes ePlayer, int iOptionChosen, int iUnitID);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseBarbarianRansom::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvDllNetMessageHandler_ResponseBarbarianRansom);host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseBarbarianRansom::ID, CIV_HOOK_AFTER, (void*)&AfterCvDllNetMessageHandler_ResponseBarbarianRansom);host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseBarbarianRansom::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvDllNetMessageHandler_ResponseBarbarianRansom);

Code

71void CvDllNetMessageHandler::ResponseBarbarianRansom(PlayerTypes ePlayer, int iOptionChosen, int iUnitID)72{73	CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);7475	// Pay ransom76	if(iOptionChosen == 0)77	{78		CvTreasury* pkTreasury = kPlayer.GetTreasury();79		int iNumGold = /*100*/ GC.getBARBARIAN_UNIT_GOLD_RANSOM_exp();80		const int iTreasuryGold = pkTreasury->GetGold();81		if(iNumGold > iTreasuryGold)82		{83			iNumGold = iTreasuryGold;84		}8586		pkTreasury->ChangeGold(-iNumGold);87	}88	// Abandon Unit89	else if(iOptionChosen == 1)90	{91		CvUnit* pkUnit = kPlayer.getUnit(iUnitID);92		if(pkUnit != NULL)93			pkUnit->kill(true, BARBARIAN_PLAYER);94	}95}

Calls