Bazaar developer reference

CvPlayer::doBarbarianRansom(int, int)

Defined in
CvPlayer.cpp, line 4340
Class
CvPlayer
Hook name
CivHooks::CvPlayer_doBarbarianRansom

Hooks

static bool BeforeCvPlayer_doBarbarianRansom(CvPlayer* self, int iOption, int iUnitID);static void AfterCvPlayer_doBarbarianRansom(CvPlayer* self, int iOption, int iUnitID);static void ReplaceCvPlayer_doBarbarianRansom(void (*original)(CvPlayer*, int, int), CvPlayer* self, int iOption, int iUnitID);CivRegisterBefore<CivHooks::CvPlayer_doBarbarianRansom>(host, &BeforeCvPlayer_doBarbarianRansom);CivRegisterAfter<CivHooks::CvPlayer_doBarbarianRansom>(host, &AfterCvPlayer_doBarbarianRansom);CivRegisterReplace<CivHooks::CvPlayer_doBarbarianRansom>(host, &ReplaceCvPlayer_doBarbarianRansom);

Code

4340void CvPlayer::doBarbarianRansom(int iOption, int iUnitID)4341{4342	UnitHandle pUnit = getUnit(iUnitID);43434344	// Pay the Price4345	if(iOption == 0)4346	{4347		int iNumGoldStolen = GC.getBARBARIAN_UNIT_GOLD_RANSOM();	// 10043484349		if(iNumGoldStolen > GetTreasury()->GetGold())4350		{4351			iNumGoldStolen = GetTreasury()->GetGold();4352		}43534354		// Unit is ransomed for Gold4355		GetTreasury()->ChangeGold(-iNumGoldStolen);4356	}4357	// Leave them to the Barbs4358	else if(iOption == 1)4359	{4360		if(GetID() == GC.getGame().getActivePlayer())4361		{4362			GC.GetEngineUserInterface()->AddUnitMessage(0, pUnit->GetIDInfo(), GetID(), true, GC.getEVENT_MESSAGE_TIME(), GetLocalizedText("TXT_KEY_MISC_YOU_UNIT_RANSOM_KILL_BY_BARBARIANS", pUnit->getNameKey()));//,GC.getEraInfo(GC.getGame().getCurrentEra())->getAudioUnitDefeatScript(), MESSAGE_TYPE_INFO, pUnit->getUnitInfo().GetButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pUnit->getX(), pUnit->getY(), true, true);4363		}43644365		pUnit->kill(true, BARBARIAN_PLAYER);4366	}4367}

Calls