Unit upgrade problem

Warl0rd

Chieftain
Joined
Aug 7, 2007
Messages
47
say I have unit A which can be upgraded to unit B1 and unit B2.
Unit B2 can be upgraded to unit C.

Now I'm able to upgrade unit A to unit B1 and unit C.

But I wanna have my unit A to be upgradeable to unit B1 and unit B2.

Can someone please give me a hint or code to solve this dilemma?:cry:
 
well in the unitclassupgrades tag of the units, you will want to put what unit it upgrades to there.

so for example, in the unit A unitclassupgrades tag, it will include unit BI and B2.
the unit B2 unitclassupgrades tag should include unit C.

the tag looks like this if its used;

Code:
			<UnitClassUpgrades>
				<UnitClassUpgrade>
					<UnitClassUpgradeType>UNITCLASS_EXPLORER</UnitClassUpgradeType>
					<bUnitClassUpgrade>1</bUnitClassUpgrade>
				</UnitClassUpgrade>
			</UnitClassUpgrades>

if you include more then two there (which you will need to), then you put two seperate entries within the unitClassUpgrades tag.... so you'll have two unitClassupgrade

notice the lack of s on the second one.

so basically

unitclassupgrades
unitclassupgrade
the stuff here
/unitclassupgrade
unitclassupgrade
more stuff here
/unitclassupgrade
/unitclassupgrades

whew 1,000 post!!!! :band: :dance: :hammer2:
 
ok ,maby my explanation was not clear enough:

I have an Archer which can be upgraded to Crossbowman and Longbowman.
The Longbowman can be upgraded to Rifleman.

I have all the technologies and resources to produce all four units.
But I can upgrade my Archer only to Crossbowman and Rifleman, NOT Longbowman.

The game seems to make upgrades only available to the latest, highest tech in the specific line. Archer->Crossbowman // Archer->Longbowman->Rifleman

But I wann be able to upgrade my Archer to Crossbowman and Longbowman. Only one techjump per upgrade.

thx anyway
 
I wanna have the time delay that is produced this way and i need the unit in between. Speaking within the example above i need the Longbowman to be produceable all the time because it's a keyunit.

I've only taken this as example. My moddesign is different from CIV4 and it's units.
 
your really confusing what you want with what it already does.

I have an Archer which can be upgraded to Crossbowman and Longbowman.
The Longbowman can be upgraded to Rifleman.

the game already works like that

I have all the technologies and resources to produce all four units.
But I can upgrade my Archer only to Crossbowman and Rifleman, NOT Longbowman.

And of course it already works like this as well

The game seems to make upgrades only available to the latest, highest tech in the specific line. Archer->Crossbowman // Archer->Longbowman->Rifleman

yes that would be the whole point of new technologies

But I wann be able to upgrade my Archer to Crossbowman and Longbowman. Only one techjump per upgrade.

thx anyway

I see where your going here... to me seems like way to much work for really hardly any difference in gameplay.
 
I was really confused too, by what you were trying to accomplish.

To me it sounded like you want to be able to upgrade the Archer to Longbowmen (not Rifleman). Then have the Longbowman upgrade to the Rifleman

At the moment, the game lets you do that, during the stretch between Feudalism, untill you develop Rifling, which is quite a lengthy gap.

Anyway, sorry, but I am really confused
 
Sorry for confusing you guys :(

what i want to is as simple as that:
i have all technologies for the units Longbowman/Crossbowman/Rifleman/Grenadier to upgrade/build;

-> i want to be able to upgrade my Archer to Longbowman;
-> i want to be able to upgrade my Archer to Crossbowman;

these two things are not possible, because as i said before i have Rifling and Military Science - so the Archer could only be upgraded to Rifleman and Grenadier

-> i want to be able to upgrade my Longbowman/Crossbowman to Rifleman or Crossbowman to Grenadier;(possible)

-> i do NOT want to be able to upgrade my Archer directly to Rifleman
(not possible - the Archer would always upgrade to Rilfeman)


i hope this clarifies what i need :cool:

and never mind if it makes no sense for you to upgrade to older units - it makes sense in my concept and would impact the gameplay massively
 
Is clarified. -> Can't be done :(.
There's no way with .xml, and i see no way with python.

That's what I've expected. Can't be done with .xml and maby python too.

So it can be done with hardcoding. Does someone know in which method the game decides to upgrade the unit to the newest upgrade and not the next in the row?

CvUnit::upgradeAvailable
CvUnit::getUpgradeCity

or whichever
 
When it comes to C++ your best bet is to experiment or pull some suspect code and write up what you have in the Python/SDK forums and ask for help on what you have going, and any leads that failed/kinda worked.
 
ok, finally it seems to work now :D

just for the record - i removed

CvCity.cpp
Code:
bool CvCity::canTrain(UnitTypes eUnit, bool bContinue, bool bTestVisible, bool bIgnoreCost, bool bIgnoreUpgrades) const
{
	...

	/* unit upgrade
	if (!bIgnoreUpgrades)
	{
		if (allUpgradesAvailable(eUnit) != NO_UNIT)
		{
			return false;
		}
	}*/
	
	...

	return true;
}

and

CvUnit.cpp
Code:
bool CvUnit::upgradeAvailable(UnitTypes eFromUnit, UnitClassTypes eToUnitClass, int iCount) const
{
	...

	/* unit upgrade
	for (iI = 0; iI < numUnitClassInfos; iI++)
	{
		if (fromUnitInfo.getUpgradeUnitClass(iI))
		{
			eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iI)));

			if (eLoopUnit != NO_UNIT)
			{
				if (upgradeAvailable(eLoopUnit, eToUnitClass, (iCount + 1)))
				{
					return true;
				}
			}
		}
	}*/

	return false;
}
 
:blush: after using the end round button the production always changed to the best upgrade - to fix this i had to remove that stuff down there

actually i don't need this, that's the reason i haven't checked it, sry

don't know about a database:dunno:

CvCity.cpp
Code:
bool CvCity::doCheckProduction()
{
	...

	/* unit upgrade
	for (iI = 0; iI < GC.getNumUnitInfos(); iI++)
	{
		if (getFirstUnitOrder((UnitTypes)iI) != -1)
		{
			eUpgradeUnit = allUpgradesAvailable((UnitTypes)iI);

			...
			}
		}
	}*/

	for (iI = (getOrderQueueLength() - 1); iI >= 0; iI--)
	{
		...
	}

	return bOK;
}
 
I meant, you should compile that, also add your changed files, .zip them and add them to the database.
Make sure you comment the changes you make, otherwise merging in the source so that others can use your modcomp is pretty much impossible.
 
Top Bottom