Bazaar developer reference

CvUnit::found()

Defined in
CvUnit.cpp, line 8005
Class
CvUnit
Hook name
CivHooks::CvUnit_found
Lua events
GameEvents.UnitCityFounded

Hooks

static bool BeforeCvUnit_found(CvUnit* self, bool& result);static void AfterCvUnit_found(CvUnit* self, bool& result);static bool ReplaceCvUnit_found(bool (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_found>(host, &BeforeCvUnit_found);CivRegisterAfter<CivHooks::CvUnit_found>(host, &AfterCvUnit_found);CivRegisterReplace<CivHooks::CvUnit_found>(host, &ReplaceCvUnit_found);

Code

8005bool CvUnit::found()8006{8007	VALIDATE_OBJECT80088009	CvPlot* pPlot = plot();8010	8011#if defined(MOD_AI_SECONDARY_SETTLERS)8012	if (IsCombatUnit()) {8013		// CUSTOMLOG("Trying to found a city with combat unit %s at (%i, %i)", getName().c_str(), getX(), getY());8014	}8015#endif	80168017	if(!canFound(pPlot))8018	{8019		return false;8020	}80218022	PlayerTypes eActivePlayer = GC.getGame().getActivePlayer();80238024	if(eActivePlayer == getOwner())8025	{8026		auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);8027		DLLUI->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);8028	}80298030	CvPlayerAI& kPlayer = GET_PLAYER(getOwner());8031#if !defined(NO_ACHIEVEMENTS)8032	CvPlayerAI& kActivePlayer = GET_PLAYER(eActivePlayer);8033#endif80348035#if defined(MOD_GLOBAL_RELIGIOUS_SETTLERS)8036	if (MOD_GLOBAL_RELIGIOUS_SETTLERS && GetReligionData()->GetReligion() > RELIGION_PANTHEON)8037	{8038		kPlayer.found(getX(), getY(), GetReligionData()->GetReligion());8039	} else {8040#endif8041		kPlayer.found(getX(), getY());8042#if defined(MOD_GLOBAL_RELIGIOUS_SETTLERS)8043	}8044#endif80458046#if defined(MOD_AI_SECONDARY_SETTLERS)8047	if (IsCombatUnit()) {8048		// CUSTOMLOG("  ... success!  They founded %s", plot()->getPlotCity()->getName().c_str());8049	}8050#endif	80518052	if(pPlot->isActiveVisible(false))8053	{8054		auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));8055		gDLL->GameplayUnitActivate(pDllUnit.get());80568057#if !defined(NO_ACHIEVEMENTS)8058		//Achievement8059		if(eActivePlayer == getOwner() && kActivePlayer.getNumCities() >= 2 && kActivePlayer.isHuman() && !GC.getGame().isGameMultiPlayer())8060		{8061			gDLL->UnlockAchievement(ACHIEVEMENT_SECOND_CITY);8062		}8063#endif8064	}80658066#if defined(MOD_EVENTS_UNIT_FOUNDED)8067	if (MOD_EVENTS_UNIT_FOUNDED) {8068		GAMEEVENTINVOKE_HOOK(GAMEEVENT_UnitCityFounded, getOwner(), GetID(), getUnitType(), getX(), getY());8069	}8070#endif8071	auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));8072	gDLL->GameplayUnitVisibility(pDllUnit.get(), false);8073	kill(true);80748075	return true;8076}

Calls

Called by