CTP2 Bureau
The Modding
Knowledgebase
Apolyton CTP2 section
Apolyton CTP2 files
Apolyton CTP2 forums
Source Code Project SVN

Actions

Pages

Recent Changes Search

Create a new page:

AE Modding Wiki : Database : TechCostKnownDeduction

Revision 1016 - 2009-07-29: Added: New database flags for modders:

diffDB.txt

TechCostKnownDeduction 0.0 - 1.0

Description: Deducts a percentage of an advance's cost based on % of total civs in the game that you know that already have the advance.

=========================

Example:

TechCostKnownDeduction 0.3

Out of the 8 civs alive (including you), you've met 2 that have the archery advance:

(0.3 * 2) / 8 = 7.5% deduction of archery cost.

In the same example if all civs had archery AND you had met them all, the deduction would be:

(0.3 * 7) / 8 = 26.25% deduction of archery cost.

The deduction can never be the full 30% because you yourself cannot simultaneously have the advance and be researching it. =========================

Code:

//////////////////////////////////////////
// Calculate tech dissemination deduction

double techCostKnownMod = 0.0;

if (g_theDifficultyDB->Get(g_theGameSettings->GetDifficulty())->
	GetTechCostKnownDeduction(techCostKnownMod))
{
	double knownToCivs = 0.0;
	double allAliveCivs = 0.0;

	// Barbs not included since you can't
	// guarantee meeting them.
	for(sint32 i = 1; i < k_MAX_PLAYERS; ++i)
	{
		if(g_player[i] && !g_player[i]->IsDead())
		{
			if(g_player[m_owner]->HasContactWith(i))
			{
				if(g_player[i]->HasAdvance(adv))
				{
					knownToCivs++;
				}
			}

			allAliveCivs++;

		}
	}

	if (allAliveCivs > 0)
	{
		double baseMod = (techCostKnownMod * knownToCivs) / allAliveCivs;

		if(baseMod > 0.0)
		{
			cost -= 
				static_cast<sint32>(ceil(static_cast<double>(g_theAdvanceDB->Get(adv)->GetCost())
				* baseMod));
		}

		if (cost < 1) cost = 1;
	}
}
// End Calculate tech dissemination deduction
///////////////////////////////////////////////
Page last modified on July 30, 2009, at 01:43 AM
  Administration
AE Modding Wiki built with PmWiki Design: BureauBert
Share this page:  VK Facebook Twitter LiveJournal OK MR Google+ LinkedIn tumblr Pinterest Blogger Digg Evernote