Bazaar developer reference

CvUnit::blastTourism()

Defined in
CvUnit.cpp, line 10185
Class
CvUnit
Hook name
CivHooks::CvUnit_blastTourism

Hooks

static bool BeforeCvUnit_blastTourism(CvUnit* self, bool& result);static void AfterCvUnit_blastTourism(CvUnit* self, bool& result);static bool ReplaceCvUnit_blastTourism(bool (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_blastTourism>(host, &BeforeCvUnit_blastTourism);CivRegisterAfter<CivHooks::CvUnit_blastTourism>(host, &AfterCvUnit_blastTourism);CivRegisterReplace<CivHooks::CvUnit_blastTourism>(host, &ReplaceCvUnit_blastTourism);

Code

10185bool CvUnit::blastTourism()10186{10187	VALIDATE_OBJECT1018810189	CvPlot* pPlot = plot();1019010191	if(!canBlastTourism(pPlot))10192	{10193		return false;10194	}1019510196	int iTourismBlast = getBlastTourism();1019710198	int iTourismBlastPercentOthers = m_pUnitInfo->GetOneShotTourismPercentOthers();10199	PlayerTypes eOwner = pPlot->getOwner();10200	CvPlayer &kUnitOwner = GET_PLAYER(getOwner());1020110202	// Apply to target10203	kUnitOwner.GetCulture()->ChangeInfluenceOn(eOwner, iTourismBlast);1020410205	// Apply lesser amount to other civs10206	int iTourismBlastOthers = iTourismBlast * iTourismBlastPercentOthers / 100;10207	PlayerTypes eLoopPlayer;10208	for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)10209	{10210		eLoopPlayer = (PlayerTypes) iPlayerLoop;1021110212		if (eLoopPlayer != eOwner && eLoopPlayer != getOwner() && kUnitOwner.GetDiplomacyAI()->IsPlayerValid(eLoopPlayer))10213		{10214			kUnitOwner.GetCulture()->ChangeInfluenceOn(eLoopPlayer, iTourismBlastOthers);10215		}10216	}1021710218	if(pPlot->isActiveVisible(false))10219	{10220		auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));10221		gDLL->GameplayUnitActivate(pDllUnit.get());10222	}1022310224	if(IsGreatPerson())10225	{10226#if defined(MOD_EVENTS_GREAT_PEOPLE)10227		kUnitOwner.DoGreatPersonExpended(getUnitType(), this);10228#else10229		kUnitOwner.DoGreatPersonExpended(getUnitType());10230#endif10231	}1023210233	kill(true);10234 10235 	// Show tourism spread10236 	if (pPlot->GetActiveFogOfWarMode() == FOGOFWARMODE_OFF)10237 	{10238		CvString strInfluenceText;10239		InfluenceLevelTypes eLevel = kUnitOwner.GetCulture()->GetInfluenceLevel(eOwner);1024010241		if (eLevel == INFLUENCE_LEVEL_UNKNOWN)10242			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_UNKNOWN" );10243		else if (eLevel == INFLUENCE_LEVEL_EXOTIC)10244			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_EXOTIC");10245		else if (eLevel == INFLUENCE_LEVEL_FAMILIAR)10246			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_FAMILIAR");10247		else if (eLevel == INFLUENCE_LEVEL_POPULAR)10248			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_POPULAR");10249		else if (eLevel == INFLUENCE_LEVEL_INFLUENTIAL)10250			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_INFLUENTIAL");10251		else if (eLevel == INFLUENCE_LEVEL_DOMINANT)10252			strInfluenceText = GetLocalizedText( "TXT_KEY_CO_DOMINANT");1025310254 		char text[256] = {0};10255		sprintf_s(text, "[COLOR_WHITE]+%d [ICON_TOURISM][ENDCOLOR]   %s", iTourismBlast, strInfluenceText.c_str());10256#if defined(SHOW_PLOT_POPUP)10257		SHOW_PLOT_POPUP(pPlot, getOwner(), text, 0.0f);10258#else10259 		float fDelay = 0.0f;10260 		DLLUI->AddPopupText(pPlot->getX(), pPlot->getY(), text, fDelay);10261#endif10262 	}1026310264#if !defined(NO_ACHIEVEMENTS)10265	// Achievements10266#if defined(MOD_BUGFIX_USE_GETTERS)10267	if (GET_MY_PLAYER().isHuman() && !GC.getGame().isGameMultiPlayer())10268#else10269	if (GET_PLAYER(m_eOwner).isHuman() && !GC.getGame().isGameMultiPlayer())10270#endif10271	{10272		if (strcmp(GET_PLAYER(eOwner).getCivilizationTypeKey(),   "CIVILIZATION_AMERICA") == 0 &&10273#if defined(MOD_BUGFIX_USE_GETTERS)10274			strcmp(GET_MY_PLAYER().getCivilizationTypeKey(), "CIVILIZATION_ENGLAND") == 0)10275#else10276			strcmp(GET_PLAYER(m_eOwner).getCivilizationTypeKey(), "CIVILIZATION_ENGLAND") == 0)10277#endif10278		{10279			gDLL->UnlockAchievement(ACHIEVEMENT_XP2_36);10280		}1028110282		ImprovementTypes eTempImprovement = pPlot->getImprovementType();10283		if (eTempImprovement != NO_IMPROVEMENT)10284		{10285			CvImprovementEntry* pkImprovement = GC.getImprovementInfo(eTempImprovement);10286			if (strcmp(pkImprovement->GetType(), "IMPROVEMENT_KASBAH") == 0)10287			{10288				gDLL->UnlockAchievement(ACHIEVEMENT_XP2_37);10289			}10290		}10291	}10292#endif1029310294	return true;10295}

Calls

Called by