How to add a resource?

I am adding a resource "UnitStat_EmmagineXPGiver"

This is given to a city when a governor is in it.

The step I can't seem to figure out on my own:   Where do I define the resource (do I need to?) and How would I go about making the city give that bonus to the champions?

 

Basically, I've added the code for the ability on the hero, but I'm lost when it comes to where to start on basic city functions, and resources.

Thanks for any help,

 

Emmagine 

6,943 views 18 replies
Reply #1 Top

What are you trying to do? Because that's a unitstat, not a resource.

Reply #2 Top

Sorry I explained that horribly.  I added the stat UnitStat_EmmagineXPGiver

Now I want to have a city give xp to the units in it based on the total of that stat of the units in the city.

Reply #3 Top

I don't know how to do that.

Reply #4 Top

how would I add it if it were a resource from a tile?

My thought was that I could add a recourse to the city, and have the unit give a bonus to that resource.  Then have the city give a bonus to xp of units stationed in it.  I know it sounds overly complicated, but I can't find another way. 

 

Reply #5 Top

I haven't tried anything with those functions so I don't know. There's a few buildings that give bonuses that scale with essence - I'd start there and see if you can modify the modifiers that give experience like that building.

Reply #6 Top

That's a really good idea.   Is there a place to put code if I want it to always be present in every city?  Like The default stats for a cities production before constructed buildings?

Reply #7 Top

In CoreImprovements.xml put them in cityhub1 and the forced choices for level 2 cities - fortress, conclave and town.

Reply #8 Top

Ok.  Does the change need to go into each one? and for each level of the city? or as a city upgrades does it retain it's lower level options?

Reply #9 Top

Just those I mentioned, since every city has one of those 4. No, they don't stay if the improvement gets replaced.

Reply #10 Top

My next question relates more to testing than modding.  If I load a saved game after having changed my data files, will it use the old or the new data files?

Reply #11 Top

The old ones, you have to restart the client and start a new game.

Reply #12 Top

I really appreciate all your help heavenfall.

Okay, so this works:

<GameModifier>
<ModType>StationedUnitStatBonus</ModType>
<StrVal>UnitStat_Experience</StrVal>
<PerTurn>1</PerTurn>
<Provides>Stationed units gain 1 xp per season.</Provides>
<Value>1</Value>
</GameModifier>

 

This doesnt

<GameModifier>
<ModType>StationedUnitStatBonus</ModType>
<StrVal>UnitStat_Experience</StrVal>
<PerTurn>1</PerTurn>
<Provides>Stationed units gain 1 xp / essence / season.</Provides>
<Calculate InternalName="Value" ValueOwner="OwnerCity">
<Expression><![CDATA[[TileYieldEssence]]]></Expression>
</Calculate>
</GameModifier>

Shouldn't the 2nd one grant 1 xp per essence in the city? 

Reply #13 Top

It looks right.

Reply #14 Top

That's what I thought.  There is something wrong here with my thinking.


<GameModifier>
<ModType>StationedUnitStatBonus</ModType>
<StrVal>UnitStat_Experience</StrVal>
<PerTurn>1</PerTurn>
<Provides>+10 experience to stationed units / turn</Provides>
<Calculate InternalName="Value" ValueOwner="OwnerCity">
<Expression>10</Expression>
</Calculate>
</GameModifier>

Doesn't work.


<GameModifier>
<ModType>StationedUnitStatBonus</ModType>
<StrVal>UnitStat_Experience</StrVal>
<PerTurn>1</PerTurn>
<Provides>+10 experience to stationed units / turn</Provides>
<Value>10</Value>
</GameModifier>

 Does Work.

 

Any other attempt to calculate a number to place in the value doesn't work either.  Any ideas?

Reply #15 Top

Is there a possibility the issue is with OwnerValue?   

Reply #16 Top

The modifier probably just doesn't support those types of calculations.

Reply #17 Top

I would have thought they would use the same subroutine to acquire values from xml, for all functions & loading them into an object, but everyone programs their own way.

I wonder if we can unlock a building with leveling up somehow..... 

 

 

Never mind, that wouldn't work either.   Ah well, perhaps this trait was not meant to be.

Reply #18 Top

You should have no problems making a trait unlock a building.