View Full Version : Unit Support Costs
krasny Jun 07, 2007, 07:10 AM i wish to create a simple mod to make more modern units more expensive to support
is it possible to do this simply by adjusting the value in:
<bMilitarySupport>1</bMilitarySupport>
to a higher number?
thanks :)
AlazkanAssassin Jun 07, 2007, 07:15 AM No.
The b in <bMilitarySupport> tells you that this must be a boolean value that is, either 1 or 0.
Gaius Octavius Jun 07, 2007, 07:51 AM I would like to be able to do this, too. Is there another way?
Dom Pedro II Jun 07, 2007, 09:06 AM Someone actually made a modcomp that would add an additional gold upkeep cost... but the modcomp doesn't work for a number of reasons, so I'd avoid that one, but yes, it can be done.
krasny Jun 07, 2007, 09:44 AM how, pray tell?
Zebra 9 Jun 07, 2007, 05:13 PM You could do it from python. At the beginning of a players turn you count all of the units that you want to charge extra for then multiply that by the amout extra you want to charge and subtract the result from the players gold.
The formula looks like: Players Gold - (Num Units * Extra Cost).
The code would be somthing like: numExtra = 0
for iUnit in range(pPlayer.getNumUnits()):
pUnit = pPlayer.getUnit(iUnit)
if punit.getUnitType == gc.getInfotypeForString("Units Type Tag"):
numExtra += 1
pPlayer.changeGold(-1 * (numExtra * the amount to charge for each unit))There is some code I left out so this is just a basic outline of what needs to be done.
Good Luck. :thumbsup:
Dom Pedro II Jun 07, 2007, 06:08 PM You can't solve all your problems with python, Zebra.. :nono:
;)
Zebra 9 Jun 07, 2007, 06:14 PM Well this might goof the AI up a little because they won't know when they are in finacial trouble (but they're always in trouble anyway:lol:). :D
Shqype Jun 07, 2007, 06:15 PM You could do it from python. At the beginning of a players turn you count all of the units that you want to charge extra for then multiply that by the amout extra you want to charge and subtract the result from the players gold.
The formula looks like: Players Gold - (Num Units * Extra Cost).
The code would be somthing like: numExtra = 0
for iUnit in range(pPlayer.getNumUnits()):
pUnit = pPlayer.getUnit(iUnit)
if punit.getUnitType == gc.getInfotypeForString("Units Type Tag"):
numExtra += 1
pPlayer.changeGold(-1 * (numExtra * the amount to charge for each unit))There is some code I left out so this is just a basic outline of what needs to be done.
Good Luck. :thumbsup:
That's a good way of doing it, but ideally it would be nice if this was defined in the CIV4UnitInfos.xml file and was automatically deducted as part of maintenance costs. If this won't be in BTS (which it most likely won't), I don't think it would be too difficult to do this with the SDK. There are enough tutorials (thanks, Kael) on adding new XML tags and getting them to function properly, so somebody motivated enough shouldn't have too much difficulty accomplishing this.
Dom Pedro II Jun 07, 2007, 06:21 PM No, the adding (or in this case replacing) of an XML tag is a fairly easy affair unless it references particular info types in which case it could be more complicated.
It's getting it to function that can be tricky... because getting the XML tag is like having a light switch without anything connected to it... just adding it or even getting the value to be read by the SDK doesn't mean it will work. In this particular case, I can't really speculate on how tough it would be since the unit maintenance cost handling in the SDK is something I've never really investigated.
Shqype Jun 07, 2007, 06:25 PM No, the adding (or in this case replacing) of an XML tag is a fairly easy affair unless it references particular info types in which case it could be more complicated.
It's getting it to function that can be tricky... because getting the XML tag is like having a light switch without anything connected to it... just adding it or even getting the value to be read by the SDK doesn't mean it will work. In this particular case, I can't really speculate on how tough it would be since the unit maintenance cost handling in the SDK is something I've never really investigated.
If you add an XML tag without connecting it to anything, then obviously it won't really do anything unless it is exposed to python and you access it that way; the maintenance cost handling would have to be examined in order for this to work in the way that I implied, you are correct. Perhaps my comment about difficulty was premature because I myself have not investigated that section of the C++ either, but I assume it wouldn't be that hard to factor individual unit maintenance costs into the equation provided one had some knowledge of C++ and knew where to look...
Dom Pedro II Jun 07, 2007, 06:39 PM If you add an XML tag without connecting it to anything, then obviously it won't really do anything unless it is exposed to python and you access it that way; the maintenance cost handling would have to be examined in order for this to work in the way that I implied, you are correct. Perhaps my comment about difficulty was premature because I myself have not investigated that section of the C++ either, but I assume it wouldn't be that hard to factor individual unit maintenance costs into the equation provided one had some knowledge of C++ and knew where to look...
Yeah, I wasn't really explaining that because I thought you didn't know but rather because there are many people who don't understand programming at all, and I wanted to make clear that, while Kael's tutorial threads are great and very helpful, the real bulk of the work comes after you get the XML tags to load correctly. I just didn't want the commonfolk getting too excited! :D
Anyway, I had a quick peek at the maintenance stuff... basically, if the <bMilitarySupport> tag is set to true, the game adds +1 to the number of military units a player has when the unit is initialized... then multiplies that number by the flat military unit upkeep cost (which is in turn affected by Civics). When the unit is killed, it reduces the player's total number of military units by one naturally.
The trick is to have to so that when a unit is initialized the game adds its upkeep cost directly to the calculated upkeep cost for the military and then deducts that much when the unit is killed... fairly straight forward, at least just eyeballing it like I am right now.
My advice to to change from the boolean <bMilitarySupport> to the integer <iMilitarySupport>... and a value of 0 assumes then that this is not a military unit and thus does not count it as part of the player's total military number. You'd then store the player's base military upkeep costs which would be added together with the added upkeep from civics times the total number of units:
Total Upkeep = Base Upkeep + (civics upkeep change * number of military units)
EDIT: AH! But what about Free Units from civics?? Should the more expensive units be included with the freebies? Should they be excluded so that anything above a value of 1 is exempt from being counted among the free units? Then it starts to get complicated with actually calculating that....
Shqype Jun 07, 2007, 07:23 PM Good assessment, Dom Pedro II. I really like the idea of <iMilitarySupport> instead; I wish the creators of CIV 4 originally created it this way.
Free units would definitely have to be handled differently. Perhaps instead of free units, there can be a deduction of the maintenance costs from unit upkeep?
Edgecrusher Jun 07, 2007, 07:48 PM What about the "<iExtraCost>0</iExtraCost>" Tag in the XML
For what its worth, every single unit in the game is set to zero?
....time to go expirement!
Just tested it out...
It shows up in the pedia as "+1 :gold: Cost"
Edgecrusher Jun 07, 2007, 07:56 PM I always wanted to mod the way units were done.
I wanted every unit to cost 1 :gold:
That would make the "Free Units" provided in the civics (and any subsequent wonders or improvements more important).
With that I would change the barracks to give +8 Free Units (Seeing as how Barracks were housing for troups. and create a new building called "Training Ground" which would replicate what a barracks currently does.
That way you create an economy for units.
1 :gold: Cost per unit - X Free Units from Buildings/Civics/Wonders = Total Military Cost.
Dom Pedro II Jun 07, 2007, 08:14 PM I always wanted to mod the way units were done.
I wanted every unit to cost 1 :gold:
That would make the "Free Units" provided in the civics (and any subsequent wonders or improvements more important).
With that I would change the barracks to give +8 Free Units (Seeing as how Barracks were housing for troups. and create a new building called "Training Ground" which would replicate what a barracks currently does.
That way you create an economy for units.
1 :gold: Cost per unit - X Free Units from Buildings/Civics/Wonders = Total Military Cost.
Well, with the exception of the free units from buildings, that's essentially what the system is now...
Edgecrusher Jun 07, 2007, 08:21 PM I guess I ment making the units "more" expensive.
Shqype Jun 07, 2007, 09:26 PM What about the "<iExtraCost>0</iExtraCost>" Tag in the XML
For what its worth, every single unit in the game is set to zero?
....time to go expirement!
Just tested it out...
It shows up in the pedia as "+1 :gold: Cost"
LOL, it seems that's pretty much the solution to the issue, isn't it?
Dom Pedro II Jun 07, 2007, 10:04 PM LOL, it seems that's pretty much the solution to the issue, isn't it?
That's for civics though, for adding extra cost to units.
Shqype Jun 07, 2007, 11:04 PM I don't follow ...
By changing that value to a positive number you are increasing the individual unit cost by x gold per turn. Wasn't that the objective?
There is still the problem of the civics granting free units (which units are granted free? Does the extra cost stay or not?)
Aside from that, what does the extra unit cost have to do with civics?
Dom Pedro II Jun 08, 2007, 07:39 AM I don't follow ...
By changing that value to a positive number you are increasing the individual unit cost by x gold per turn. Wasn't that the objective?
The tag though is in the civics file... it's used for Pacifism to give +1 gold cost to all units, it's not for the unit file to give that unit specifically +1 gold cost.
Shqype Jun 08, 2007, 08:15 AM Ohhhh; I thought it was in the units file...
But, if the framework for increasing unit maintenance cost is there in the civics file, wouldn't it be easier to just copy that SDK code, and then create a new XML tag in the units file?
Dom Pedro II Jun 08, 2007, 09:36 AM Ohhhh; I thought it was in the units file...
But, if the framework for increasing unit maintenance cost is there in the civics file, wouldn't it be easier to just copy that SDK code, and then create a new XML tag in the units file?
Well, it would work fine for loading it into the XML... however you're going to need to make some real mechanical changes in the SDK beyond just copying the civics code. The civics code takes the number of units you have and multiplies it by the extra cost... it's a blanket increase and doesn't take into account varying costs for units.
I've already proposed the way to have varying unit costs, but the problem of free units arises. The simplest solution, to me, is to simply have it that the free unit bonuses will just deduct the cost of the X cheapest units. Or... have it take the base gold cost for all the units and divide it by the number of units to get the average unit cost and then have it subtract that much from your military upkeep.
Shqype Jun 08, 2007, 11:10 AM That sounds like a good alternative as well.
Ambreville Jun 08, 2007, 03:48 PM i wish to create a simple mod to make more modern units more expensive to support
is it possible to do this simply by adjusting the value in:
<bMilitarySupport>1</bMilitarySupport>
to a higher number?
I guess a critical question to ask is -- why? Are you trying to somehow limit the number of troops as your end goal?
The reason why I'm asking is that I just posted a question that parallels this thread pretty closely (sorry, I just stumbled on your thread after the fact). What I was investigating there was a way to curb the total number of units a CIV can build (all types combined) based on the number of cities it controls, or based on its current population.
Changing the cost of maintenance of units is one way to accomplish this of course, but very often I see CIVs with insane mumbers of units gobbling up what limited RAM/virtual memory my computer can swing. The other issue has to do with both demographic and food limitations.
There are a finite number of people in a CIV's population capable of bearing arms. I don't care how much money a CIV has, it still should not be able to recruit all its 80 year old grannies and make them Templar Knights to smite the infidel!
Likewise, a CIV with one city filled with an insane number of troops, ought not to be able to build more in that city, regardless of how much money it has. This could happen after a CIV was repeatedly defeated and remnants of its once mighty army retreated into this last stronghold... Food will become a problem far more quickly than budget considerations (let alone recruiting even more troops in that city!)
So my question I think is critical here. Maybe my suggestion, although pretty radical, might be more effective than tweaking military maintenance cost.
Just a thought. Sorry for the double-posting. :)
---------------------------------------------
Edit -- Zebra 9 has come up with a solution for the above. Thread is here (http://forums.civfanatics.com/showthread.php?t=226352) .
Edgecrusher Jun 08, 2007, 04:43 PM The tag though is in the civics file... it's used for Pacifism to give +1 gold cost to all units, it's not for the unit file to give that unit specifically +1 gold cost.
The tag is in the UnitInfos File. Its toward the bottom.
<UnitInfo>
<Class>UNITCLASS_LION</Class>
<Type>UNIT_LION</Type>
<UniqueNames/>
<Special>NONE</Special>
<Capture>NONE</Capture>
<Combat>NONE</Combat>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ANIMAL</DefaultUnitAI>
<Invisible>NONE</Invisible>
<SeeInvisible>NONE</SeeInvisible>
<Description>TXT_KEY_UNIT_LION</Description>
<Civilopedia>TXT_KEY_CONCEPT_ANIMALS_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_ANIMAL_STRATEGY</Strategy>
<Advisor>NONE</Advisor>
<bAnimal>1</bAnimal>
<bFood>0</bFood>
<bNoBadGoodies>0</bNoBadGoodies>
<bOnlyDefensive>0</bOnlyDefensive>
<bNoCapture>0</bNoCapture>
<bRivalTerritory>0</bRivalTerritory>
<bMilitaryHappiness>0</bMilitaryHappiness>
<bMilitarySupport>0</bMilitarySupport>
<bMilitaryProduction>0</bMilitaryProduction>
<bPillage>0</bPillage>
<bSabotage>0</bSabotage>
<bDestroy>0</bDestroy>
<bStealPlans>0</bStealPlans>
<bInvestigate>0</bInvestigate>
<bCounterSpy>0</bCounterSpy>
<bFound>0</bFound>
<bGoldenAge>0</bGoldenAge>
<bInvisible>0</bInvisible>
<bFirstStrikeImmune>0</bFirstStrikeImmune>
<bNoDefensiveBonus>1</bNoDefensiveBonus>
<bIgnoreBuildingDefense>0</bIgnoreBuildingDefense>
<bCanMoveImpassable>0</bCanMoveImpassable>
<bFlatMovementCost>0</bFlatMovementCost>
<bIgnoreTerrainCost>0</bIgnoreTerrainCost>
<bNukeImmune>0</bNukeImmune>
<bPrereqBonuses>0</bPrereqBonuses>
<bPrereqReligion>0</bPrereqReligion>
<bMechanized>0</bMechanized>
<UnitClassUpgrades/>
<UnitClassTargets/>
<UnitCombatTargets/>
<UnitClassDefenders/>
<UnitCombatDefenders/>
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_ANIMAL</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
</UnitAIs>
<NotUnitAIs/>
<Builds/>
<ReligionSpreads/>
<GreatPeoples/>
<Buildings/>
<ForceBuildings/>
<HolyCity>NONE</HolyCity>
<ReligionType>NONE</ReligionType>
<StateReligion>NONE</StateReligion>
<PrereqReligion>NONE</PrereqReligion>
<PrereqBuilding>NONE</PrereqBuilding>
<PrereqTech>NONE</PrereqTech>
<TechTypes/>
<BonusType>NONE</BonusType>
<PrereqBonuses/>
<ProductionTraits/>
<Flavors/>
<iAIWeight>0</iAIWeight>
<iCost>-1</iCost>
<iHurryCostModifier>0</iHurryCostModifier>
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>1</iMoves>
<iAirRange>0</iAirRange>
<iNukeRange>-1</iNukeRange>
<iWorkRate>0</iWorkRate>
<iBaseDiscover>0</iBaseDiscover>
<iDiscoverMultiplier>0</iDiscoverMultiplier>
<iBaseHurry>0</iBaseHurry>
<iHurryMultiplier>0</iHurryMultiplier>
<iBaseTrade>0</iBaseTrade>
<iTradeMultiplier>0</iTradeMultiplier>
<iGreatWorkCulture>0</iGreatWorkCulture>
<TerrainImpassables/>
<FeatureImpassables/>
<iCombat>2</iCombat>
<iAirCombat>0</iAirCombat>
<iAirCombatLimit>0</iAirCombatLimit>
<iXPValueAttack>4</iXPValueAttack>
<iXPValueDefense>2</iXPValueDefense>
<iFirstStrikes>0</iFirstStrikes>
<iChanceFirstStrikes>0</iChanceFirstStrikes>
<iInterceptionProbability>0</iInterceptionProbability>
<iEvasionProbability>0</iEvasionProbability>
<iWithdrawalProb>0</iWithdrawalProb>
<iCollateralDamage>0</iCollateralDamage>
<iCollateralDamageLimit>0</iCollateralDamageLimit>
<iCollateralDamageMaxUnits>0</iCollateralDamageMaxUnits>
<iCityAttack>0</iCityAttack>
<iCityDefense>0</iCityDefense>
<iAnimalCombat>0</iAnimalCombat>
<iHillsAttack>0</iHillsAttack>
<iHillsDefense>0</iHillsDefense>
<TerrainNatives>
<TerrainNative>
<TerrainType>TERRAIN_GRASS</TerrainType>
<bTerrainNative>1</bTerrainNative>
</TerrainNative>
<TerrainNative>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<bTerrainNative>1</bTerrainNative>
</TerrainNative>
<TerrainNative>
<TerrainType>TERRAIN_DESERT</TerrainType>
<bTerrainNative>1</bTerrainNative>
</TerrainNative>
</TerrainNatives>
<FeatureNatives/>
<TerrainDefenses/>
<FeatureDefenses/>
<UnitClassAttackMods/>
<UnitClassDefenseMods/>
<UnitCombatMods/>
<UnitCombatCollateralImmunes/>
<DomainMods/>
<BonusProductionModifiers/>
<iBombRate>0</iBombRate>
<iBombardRate>0</iBombardRate>
<SpecialCargo>NONE</SpecialCargo>
<DomainCargo>NONE</DomainCargo>
<iCargo>0</iCargo>
<iConscription>0</iConscription>
<iCultureGarrison>0</iCultureGarrison>
<iExtraCost>0</iExtraCost>
<iAsset>0</iAsset>
<iPower>0</iPower>
<UnitMeshGroups>
<iGroupSize>3</iGroupSize>
<fMaxSpeed>1.75</fMaxSpeed>
<iMeleeWaveSize>3</iMeleeWaveSize>
<iRangedWaveSize>0</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>3</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_LION</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<Button>,Art/Interface/Buttons/Units/Lion.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,6,5</Button>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<FreePromotions/>
<LeaderPromotion>NONE</LeaderPromotion>
<iLeaderExperience>0</iLeaderExperience>
</UnitInfo>
Shqype Jun 08, 2007, 06:17 PM I thought it was in the UnitInfos.xml file. It would be interesting to figure out how the vanilla game handles the free units from civics if the units have higher costs.
Edgecrusher Jun 08, 2007, 06:55 PM I think all Vasselage does is subtract X from the Unit Maintenance Cost.
I did a quick test.
enabled Pacifism and Vasselage and build 8 units, 4 w/ the extra cost at 1 and 4 without.
The financial advisor in game gives a breakdown of where the costs come from:
X Unit Cost (12 Units Free)-->Changes to 17 when I enabled Vasselage.
X Military Unit Cost (2 Free)--> Pacifism made this number 6 (1 for each unit - the 2 free)
X Extra Cost (this number was 4)
X Handicap
Total Cost.
For what its worth I had 1 city.
krasny Jun 10, 2007, 05:21 AM Likewise, a CIV with one city filled with an insane number of troops, ought not to be able to build more in that city, regardless of how much money it has. This could happen after a CIV was repeatedly defeated and remnants of its once mighty army retreated into this last stronghold... Food will become a problem far more quickly than budget considerations (let alone recruiting even more troops in that city!)
brilliant contribution ambre :goodjob:
i had never thought of that
i do believe there is a XML boolean tag for making units consume food
i do still want to increase the support costs of units though, i am stuck as to how to go about it
Ambreville Jun 10, 2007, 09:55 AM brilliant contribution ambre :goodjob:
i had never thought of that
i do believe there is a XML boolean tag for making units consume food
i do still want to increase the support costs of units though, i am stuck as to how to go about it
Thanks.
You haven't actually answered my original question though. Were you trying to limit the number of troops or did you have another goal entirely? :)
krasny Jun 10, 2007, 10:19 AM limit troops
the endgame is IMHO a bit of a drag because of the vast numbers of units
Ambreville Jun 10, 2007, 04:05 PM limit troops
the endgame is IMHO a bit of a drag because of the vast numbers of units
Thought so. We're on the same track then. ;)
Gaius Octavius Jun 13, 2007, 06:27 AM I believe the XML tag which sets units to consume food only deals with building them, e.g. like a settler or worker. Food + Hammers = Production.
|
|