Vanilla (no trait) option & UUs

P&nny

Warlord
Joined
Sep 1, 2007
Messages
195
Hello,

I'm trying to create an option that renders all traits useless/equal (effectively called the "VANILLA" option, usefule in MP). The difficult part is to have it done by an option, otherwise it's pretty easy to do in XML. I'm very familiar with option in the SDK, understanding the SDK averagely.

I've tried multiple things, helping me render the traits wortheless in much cases, i.e. the Spiritual trait doesn't allow revolution anymore, the Phi trait doesn't grant 100% GP anymore, etc.
Here is an example :

Code:
bool CvPlayer::hasTrait(TraitTypes eTrait) const
{
	FAssertMsg((getLeaderType() >= 0), "getLeaderType() is less than zero");
	FAssertMsg((eTrait >= 0), "eTrait is less than zero");
	//µGMM Start
	if (GC.getGameINLINE().isOption(GAMEOPTION_VANILLA_MOD))
	{
		return false;
	}
	else
	{
		return GC.getLeaderHeadInfo(getLeaderType()).hasTrait(eTrait);
	}
	//GMM End
}

But there are a few things I can't make work :

The building still gets the bonus applied, I can't get my around that, I've tried several things, including the following one, but to my surprise, it doesn't work.

Code:
int CvPlayer::getProductionModifier(BuildingTypes eBuilding) const
{
	int iMultiplier = 0;
	for (int iI = 0; iI < GC.getNumTraitInfos(); iI++)
	{
		if (hasTrait((TraitTypes)iI))
		{
			if (!(GC.getGameINLINE().isOption(GAMEOPTION_VANILLA_MOD)))
			{	
				iMultiplier += GC.getBuildingInfo(eBuilding).getProductionTraits(iI);
				
				if (GC.getBuildingInfo(eBuilding).getSpecialBuildingType() != NO_SPECIALBUILDING)
				{
					iMultiplier += GC.getSpecialBuildingInfo((SpecialBuildingTypes) GC.getBuildingInfo(eBuilding).getSpecialBuildingType()).getProductionTraits(iI);
				}
			}
		}
	}....

Also, while the starting units do not, the units that get created still receive the free promotion, i.e. a warrior with aggressive. I dunno where to implement that.
I do not get where this code is.



Finally, I'd like to have the possibility to impeach the civ to create it's own UU (so no UU either, full vanilla) and I can't find the code for that either.
I'm especially interested to know this, because I'd like to make another option to be able to produce ALL the UUs with all Civs, upon having extra bonus (define in xml by UUBonus in UnitInfos.xml). So i.e if UUBonusType for Immortal is Pig, then if the UUOption is checked, all civ can build immortal with Horse & pig.

Focusing on the Vanilla (= no UU) feature, here is what I though would work but didn't (tried other unseccful things) :

Code:
bool CvCity::canTrain(UnitTypes eUnit, bool bContinue, bool bTestVisible, bool bIgnoreCost, bool bIgnoreUpgrades) const
{
	if (eUnit == NO_UNIT)
	{
		return false;
	}


	
//Primax GMM Start - Vanilla Unique Unit Check - Doesnt work -
	if (GC.getGameINLINE().isOption(GAMEOPTION_VANILLA_MOD))
	{
		if (GC.getUnitInfo(eUnit).isUniqueUnit())
		{
			return false;
		}
	}
//Primax GMM Start - Vanilla Unique Unit Check


And Defining a "IsuniqueUnit" boolean in XML
And (other try) :
Code:
bool CvCity::canTrain(UnitCombatTypes eUnitCombat) const
{
	for (int i = 0; i < GC.getNumUnitClassInfos(); i++)
	{
		UnitTypes eUnit = (UnitTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(i);

		if (NO_UNIT != eUnit)
		{
			if (GC.getUnitInfo(eUnit).getUnitCombatType() == eUnitCombat)
			{
				if (canTrain(eUnit))
				{
					//if (GC.getGameINLINE().isOption(GAMEOPTION_VANILLA_MOD))
					//{
					//	return false;
					//}
					//else
					//{
						return true;
					//}
				}	
			}
		}
	}

	return false;
}
Unsuccesful too. I would have believed this was the UU code part though.



Thx for the help !

P&nny
 
Your first code snippet looks fine; I don't know why it's not working. I would only recommend moving the game option check outside the trait loop since there's no point looping over traits if you're going to ignore them:

Code:
int CvPlayer::getProductionModifier(BuildingTypes eBuilding) const
{
	int iMultiplier = 0;
	[B]if (!(GC.getGameINLINE().isOption(GAMEOPTION_VANILLA_MOD)))[/B]
	{	
		for (int iI = 0; iI < GC.getNumTraitInfos(); iI++)
		{
			if (hasTrait((TraitTypes)iI))
			{
				iMultiplier += GC.getBuildingInfo(eBuilding).getProductionTraits(iI);
				
				if (GC.getBuildingInfo(eBuilding).getSpecialBuildingType() != NO_SPECIALBUILDING)
				{
					iMultiplier += GC.getSpecialBuildingInfo((SpecialBuildingTypes) GC.getBuildingInfo(eBuilding).getSpecialBuildingType()).getProductionTraits(iI);
				}
			}
		}
	}....

This wouldn't change the problem, so perhaps you're editing the wrong file (different SDK folder by accident?) or you're not compiling all the right files. Try doing a clean build by deleting all .obj files in the Final_Release/Debug folder first.

If you still can't get it to work, try doing something that should obviously have an effect to make sure you're using the right files.

Code:
int iMultiplier = [B]500;  // boost every building[/B]

If that has no effect, you know something is really off.

As for affecting UUs, you need to attack the problem sooner: at CvCivilizationInfo.getCivilizationUnits(), and you won't be able to do exactly what you're hoping for. Otherwise you need to work on CvMainInterface.py to make it try all units and not just those belonging to the civilization. Here's how it works in CvMainInterface:

Code:
civInfo = gc.getCivilizationInfo(player.getCivilizationType())
for each unit class:
    eUnit = civInfo.getCivilizationUnits(i)
    if city.canTrain(eUnit, ...):
        add icon to panel

As you can see, if a unit class (e.g. Maceman) has multiple UUs (Samurai and Berserker), it can only check one. There must also be something similar in the AI code that chooses which units to produce.

You would need to change this to loop over all units to call canTrain(). It would result in more Python -> C++ calls (but it's in the UI so no big deal), and you would have to add a check for normal mode to allow only normal and UU of the player's civ to be built. Doable, just more code than you have above.

Now, as I said you could attack part of this problem at getCivilizationUnits()--the part that blocks all UUs. You would need to have that function check the game option and if enabled instead look up the default unit type for the unit class passed in. That would effectively erase all UUs.
 
Thanks for the fastanswer EF,

I only had time today to check the first idea (moving the Option code up and recompiling from the start) it didn't work, I wasn't surprise. I'll keep on investigating :crazyeye:
 
Top Bottom