Bazaar developer reference

CvBarbarians::DoCampActivationNotice(CvPlot *)

Defined in
CvBarbarians.cpp, line 111
Class
CvBarbarians
Hook name
CivHooks::CvBarbarians_DoCampActivationNotice

Hooks

static bool BeforeCvBarbarians_DoCampActivationNotice(CvPlot* pPlot);static void AfterCvBarbarians_DoCampActivationNotice(CvPlot* pPlot);static void ReplaceCvBarbarians_DoCampActivationNotice(void (*original)(CvPlot*), CvPlot* pPlot);CivRegisterBefore<CivHooks::CvBarbarians_DoCampActivationNotice>(host, &BeforeCvBarbarians_DoCampActivationNotice);CivRegisterAfter<CivHooks::CvBarbarians_DoCampActivationNotice>(host, &AfterCvBarbarians_DoCampActivationNotice);CivRegisterReplace<CivHooks::CvBarbarians_DoCampActivationNotice>(host, &ReplaceCvBarbarians_DoCampActivationNotice);

Code

110/// Gameplay informing us when a Camp has either been created or spawned a Unit so we can reseed the spawn counter111void CvBarbarians::DoCampActivationNotice(CvPlot* pPlot)112{113	CvGame& kGame = GC.getGame();114	// Default to between 8 and 12 turns per spawn115	int iNumTurnsToSpawn = 8 + kGame.getJonRandNum(5, "Barb Spawn Rand call");116117	// Raging118	if (kGame.isOption(GAMEOPTION_RAGING_BARBARIANS))119		iNumTurnsToSpawn /= 2;120121#if defined(MOD_BUGFIX_BARB_CAMP_SPAWNING)122	if (m_aiPlotBarbCampNumUnitsSpawned == NULL) {123		// Probably means we are being called as CvWorldBuilderMapLoaded is adding camps, MapInit() will follow soon and set everything up correctly124		return;125	}126#endif127		128	// Num Units Spawned129	int iNumUnitsSpawned = m_aiPlotBarbCampNumUnitsSpawned[pPlot->GetPlotIndex()];130131	// Reduce turns between spawn if we've pumped out more guys (meaning we're further into the game)132	iNumTurnsToSpawn -= min(3, iNumUnitsSpawned);	// -1 turns if we've spawned one Unit, -3 turns if we've spawned three133134	// Increment # of barbs spawned from this camp135	m_aiPlotBarbCampNumUnitsSpawned[pPlot->GetPlotIndex()]++;	// This starts at -1 so when a camp is first created it will bump up to 0, which is correct136137	//// If it's too early to spawn then add in a small amount to delay things a bit - between 3 and 6 extra turns138	//if (CanBarbariansSpawn())139	//{140	//	iNumTurnsToSpawn += 3;141	//	iNumTurnsToSpawn += auto_ptr<ICvGame1> pGame = GameCore::GetGame();\n.getJonRandNum(4, "Early game Barb Spawn Rand call");142	//}143144	// Difficulty level can add time between spawns (e.g. Settler is +8 turns)145	CvHandicapInfo* pHandicapInfo = GC.getHandicapInfo(kGame.getHandicapType());146	if (pHandicapInfo)147		iNumTurnsToSpawn += pHandicapInfo->getBarbSpawnMod();148149	// Game Speed can increase or decrease amount of time between spawns (ranges from 67 on Quick to 400 on Marathon)150	CvGameSpeedInfo* pGameSpeedInfo = GC.getGameSpeedInfo(kGame.getGameSpeedType());151	if (pGameSpeedInfo)152	{153		iNumTurnsToSpawn *= pGameSpeedInfo->getBarbPercent();154		iNumTurnsToSpawn /= 100;155	}156157	m_aiPlotBarbCampSpawnCounter[pPlot->GetPlotIndex()] = iNumTurnsToSpawn;158}

Calls

Called by