[SDKMOD] Scriptable Leader Traits

Only those of us that traveled through the wormhole remember what happen in the alternate timeline. ;)
 
TheLopez said:
:confused: Kael, did I miss something? :confused:

Nope nope, everythings perfect. I added all of this to FfH today and released it in the latest patch. It works beautifully.

I certainly didn't come here and blame your wonderful code for issues only to find out that my problem was my own inability to follow simple instructions. Nope, that never happened. :mischief:
 
Ok good... I was starting to worry there for a sec when I saw your first message...
 
There is a bug in that yield modifiers aren't updated when traits are swapped. It can be fixed with the following:

Code:
void CvPlayer::addTrait(TraitTypes eTrait)
{
	CvTraitInfo objTraitInfo;
	int iJ;

	FAssertMsg((eTrait >= 0), "eTrait is less than zero");

	if(m_pbTraits[(int)eTrait])
	{
		return;
	}

	m_pbTraits[(int)eTrait] = true;

	changeExtraHealth(GC.getTraitInfo(eTrait).getHealth());
	changeUpkeepModifier(GC.getTraitInfo(eTrait).getUpkeepModifier());
	changeGreatPeopleRateModifier(GC.getTraitInfo(eTrait).getGreatPeopleRateModifier());
	changeMaxGlobalBuildingProductionModifier(GC.getTraitInfo(eTrait).getMaxGlobalBuildingProductionModifier());
	changeMaxTeamBuildingProductionModifier(GC.getTraitInfo(eTrait).getMaxTeamBuildingProductionModifier());
	changeMaxPlayerBuildingProductionModifier(GC.getTraitInfo(eTrait).getMaxPlayerBuildingProductionModifier());


	for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
	{
		changeTradeYieldModifier(((YieldTypes)iJ), GC.getTraitInfo(eTrait).getTradeYieldModifier(iJ));
	}

	for (iJ = 0; iJ < NUM_COMMERCE_TYPES; iJ++)
	{
		changeFreeCityCommerce(((CommerceTypes)iJ), GC.getTraitInfo(eTrait).getCommerceChange(iJ));
		changeCommerceRateModifier(((CommerceTypes)iJ), GC.getTraitInfo(eTrait).getCommerceModifier(iJ));
	}

	for (iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
	{
		if (GC.getCivicOptionInfo((CivicOptionTypes) iJ).getTraitNoUpkeep((int)eTrait))
		{
			setNoCivicUpkeepCount(((CivicOptionTypes)iJ), 1);
		}
	}

[b]	for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
	{
		updateExtraYieldThreshold((YieldTypes)iJ);
	}[/b]

	updateMaxAnarchyTurns();

}

void CvPlayer::removeTrait(TraitTypes eTrait)
{
	CvTraitInfo objTraitInfo;
	int iJ;

	FAssertMsg((eTrait >= 0), "eTrait is less than zero");

	if(!m_pbTraits[(int)eTrait])
	{
		return;
	}

	m_pbTraits[(int)eTrait] = false;

	changeExtraHealth(-GC.getTraitInfo(eTrait).getHealth());
	changeUpkeepModifier(-GC.getTraitInfo(eTrait).getUpkeepModifier());
	changeGreatPeopleRateModifier(-GC.getTraitInfo(eTrait).getGreatPeopleRateModifier());
	changeMaxGlobalBuildingProductionModifier(-GC.getTraitInfo(eTrait).getMaxGlobalBuildingProductionModifier());
	changeMaxTeamBuildingProductionModifier(-GC.getTraitInfo(eTrait).getMaxTeamBuildingProductionModifier());
	changeMaxPlayerBuildingProductionModifier(-GC.getTraitInfo(eTrait).getMaxPlayerBuildingProductionModifier());


	for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
	{
		changeTradeYieldModifier(((YieldTypes)iJ), -GC.getTraitInfo(eTrait).getTradeYieldModifier(iJ));
	}

	for (iJ = 0; iJ < NUM_COMMERCE_TYPES; iJ++)
	{
		changeFreeCityCommerce(((CommerceTypes)iJ), -GC.getTraitInfo(eTrait).getCommerceChange(iJ));
		changeCommerceRateModifier(((CommerceTypes)iJ), -GC.getTraitInfo(eTrait).getCommerceModifier(iJ));
	}

	for (iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
	{
		if (GC.getCivicOptionInfo((CivicOptionTypes) iJ).getTraitNoUpkeep((int)eTrait))
		{
			setNoCivicUpkeepCount(((CivicOptionTypes)iJ), 0);
		}
	}

[b]	for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
	{
		updateExtraYieldThreshold((YieldTypes)iJ);
	}[/b]

	updateMaxAnarchyTurns();
}

Additions are in bold.
 
Thanks Kael, I'll add these fixes in and post an update.
 
Ok, the new files have been posted!!
 
Civic No Upkeeps are kept after the traits are swapped. It can be fixed with the following change:

Code:
void CvPlayer::setNoCivicUpkeepCount(CivicOptionTypes eIndex, int iNewValue)
{
	FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
	FAssertMsg(eIndex < GC.getNumCivicOptionInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");

//	if (iNewValue != 0)
//	{
		m_paiNoCivicUpkeepCount[eIndex] = iNewValue;
		FAssert(getNoCivicUpkeepCount(eIndex) >= 0);

		if (getID() == GC.getGameINLINE().getActivePlayer())
		{
			gDLL->getInterfaceIFace()->setDirty(GameData_DIRTY_BIT, true);
		}
//	}
}

I just commented out the block on 0 (which you use later to try to reset the counters).
 
Kael, is this fix for the Warlords version or Vanilla?
 
TheLopez said:
Kael, is this fix for the Warlords version or Vanilla?

Vanilla, I dont know if the same issue exists in the warlods version or not.
 
I've incorporated this into my own Code base but changed it to ProcessTrait( eTrait, int iChange) so it more closly matches the style of the other functions like ProcessBuilding and ProcessCivics. The Python calls are unchanged and just call the single universal function with a 1 or -1.
 
Yes I'm going to put my new Trait tags in their as well and any tags I add in the future as well.

I simplified the code still further, now the Player Initialization is routed to ProcessTrait so ALL trait code can be in one place, also I was able to drop the setNoCivicUpkeep function and use the original changeNoCivicUpkeep function that Firaxis was using. This code could now form the core of a Leader changing function, I belive jdog5000 has made such a function, I'll be looking to merge these together now.
 
Impaler[WrG] said:
Yes I'm going to put my new Trait tags in their as well and any tags I add in the future as well.

I simplified the code still further, now the Player Initialization is routed to ProcessTrait so ALL trait code can be in one place, also I was able to drop the setNoCivicUpkeep function and use the original changeNoCivicUpkeep function that Firaxis was using. This code could now form the core of a Leader changing function, I belive jdog5000 has made such a function, I'll be looking to merge these together now.

Thats great to hear. I think this functionality has a huge amount of potential for all modders.
 
Updated Warlords version to be compatible with the v2.0.8.0 patch.
 
CCCP DLL includes this mod
 
reviving this thread -- I am starting to get into modding myself a little, and am wondering if this is compatible with BtS without too much of a headache?
 
reviving this thread -- I am starting to get into modding myself a little, and am wondering if this is compatible with BtS without too much of a headache?

9 Months later and still no answer. Thats just, epic......


BTW thanks Lopez for helping out the FFH mod, we love you.
 
Back
Top Bottom