Unit cap for certain units - any ideas how?

Hi all,

I'm trying to figure out different ways to limit the number of certain units that a faction can have in play at any one time.  There's a number of possible applications to this, for example capping the number of henchmen, capping the number of Juggs.  For my mod I am trying to introduce some free/cheap "special" units to factions... but I would like to be able to limit the number.  The idea being that the faction can then be given some unique powerful units for a cheap cost (as part of their special faction trait)... and it shouldn't get too overpowered because they will only be allowed 3 of them.... or maybe one per city or whatever.

I have tried using the limited unit cap thing that the Order of Asok, Ogre Camps etc have... it's interesting but it only really works for units that can not be designed.  I'd like to have a limited number of a designable unit like Henchmen.

What i'm looking at currently is using custom resource types... I thought of have a "special" resource set to 3 or whatever, then each "special" unit would have a maintenance cost of 1 special resource.  But I can't figure out how to have a unit have a maintenance cost of anything (other than teh default 5% initial value gold or whatever it is)?

Any suggestions very welcome.   :S

Thanks.

 

 

  

28,533 views 15 replies
Reply #1 Top

First you need a special trait for the unit design, make one up but they all need it. Then add this

              <ProductionRequirement>
        <Type>Resource</Type>
        <Attribute>TestRes</Attribute>
        <Value>1</Value>
        <Provides>This unit costs 1 Testres per member</Provides>
    </ProductionRequirement>

The above makes it require 1 Testres per member when you train, and it will continuously drain that resource as long as the unit lives (if damaged it still drains the max amount, ie 2/3 members alive = drain 3).

Then set up a new resource like below

   <ResourceType InternalName="TestRes">
        <DisplayName>Fire Shard</DisplayName>
        <Type>TestRes</Type>
        <Description>Increases the power of your Fire spells.</Description>
        <IconColor>0,0,0</IconColor>
        <Icon>Gfx//Icons//Icon_Fire.png</Icon>
        <HideInHiergamenon>1</HideInHiergamenon>
        <ShownInGlobalDisplay>1</ShownInGlobalDisplay>
        <Global>1</Global>
        <Stored>0</Stored>
        <Shared>0</Shared>
        <TradedByCaravans>0</TradedByCaravans>
        <RummagedPerTurn>0.01</RummagedPerTurn>
        <!-- AI Info -->
        <AIData AIPersonality="AI_General">
            <AITag>Shard</AITag>
        </AIData>
</ResourceType>

Then all you need is to add the production of the resource to somewhere. Here I added 3 production to each tower of dominion a player controls:

   <ImprovementType InternalName="TowerOfDominion">
       <GameModifier>
            <ModType>Resource</ModType>
            <Attribute>TestRes</Attribute>
            <Value>3</Value>
            <PerTurn>1</PerTurn>
            <Provides>+1 TestRes</Provides>
    </GameModifier>
    </ImprovementType>
 

This would allow you to build 1 unit with 3 members (per tower of dominion), but nothing else. As long as the unit is alive, you can't build another one.

Reply #2 Top

First let me say, I was hoping you might answer ;-)

Second I think that's what I already have and it doesn't seem do quite what i'm after, I don't think it was "continuously drain that resource as long as the unit lives" .. lemme do another test and check...

Reply #3 Top

Well, looks like you nailed it.  Just did some testing and it certainly appears to do exactly what I want.

I thought I had already tried that same setup... possibly the only thing I might have done differently before, is that I think I previously had the ProductionRequirement against the unit directly rather than the ability, can't quite remember.  I'm wondering what difference that makes.... actually thinking about it, the bound widow has a production requirement of like 20 mana so why doesn't that contionually train 20 mana?  Is it because the cost is against the unit directly rather than the ability?

Reply #4 Top

On a side note, I was also hoping to add a maintenance cost to henchmen, maybe 1 influence per turn (as suggested by someone over in another thread - good idea I thought).

This would be possible using the above method, but would use up one of the 4 (3 minus the blood trait) ability slots for henchmen right?

Reply #5 Top

Since henchmen are always just 1 member, you can instead just simply remove 1 influence per turn, like the opposite of merchant trait.

The "trick" to making the sort of resource-upkeep we did above actually lies in the resourcetype, in particular this <Stored>0</Stored> which makes the game treat the resource as continuous (like shards) instead of stockpiling (like metal). There was some code used in E:wom for food for that type of resource that allowed us to create the unit scenario we did above here.

 

Reply #6 Top

Yeah I just figured out the henchmen thing just been testing it, seems to work ok using this directly against the unit:

<GameModifier>

   <ModType>Unit</ModType>
   <Attribute>ProduceResource</Attribute>
   <StrVal>DiplomaticCapital</StrVal>
   <Value>-1</Value>
   <Provides>-1 Influence per Season</Provides>
</GameModifier>

So that's cool, looks like all is well!

 

In fact, FWIW i've been trawling through the Stormworld resource stuff looking in particular at the Shadows and Death Legion because the thing I am mucking around with is adding "cultist" units to stuff like the Cult 1000 eyes.  One of the ideas I had was to base the availability of "TestRes" on the population.... theory being that the more population you have the more suckers you can get to join the cult (and thus more cultist units).

It looks like a combination of your solution above, combined with the way you have the shadow/souls setup based on population in Shadowworld would probably work... do you see any reason why not?

(Thanks for the help and quick response btw)

 

 

Reply #7 Top

OMG it works a treat, this is awesome.  I'm trying to upload a pic but this forum software is so rubbish...

Reply #8 Top

Buggered if I can get an image to embed here  >:(

https://www.dropbox.com/s/zqbg5za9etnc2nb/serpent_cult_influence.png

 

So cool.  All I need now is another 8 hours in the day..

Reply #9 Top

Quoting abob101, reply 7
Yeah I just figured out the henchmen thing just been testing it, seems to work ok using this directly against the unit:

<GameModifier>

   <ModType>Unit</ModType>
   <Attribute>ProduceResource</Attribute>
   <StrVal>DiplomaticCapital</StrVal>
   <Value>-1</Value>
   <Provides>-1 Influence per Season</Provides>
</GameModifier>

So that's cool, looks like all is well!

 

In fact, FWIW i've been trawling through the Stormworld resource stuff looking in particular at the Shadows and Death Legion because the thing I am mucking around with is adding "cultist" units to stuff like the Cult 1000 eyes.  One of the ideas I had was to base the availability of "TestRes" on the population.... theory being that the more population you have the more suckers you can get to join the cult (and thus more cultist units).

It looks like a combination of your solution above, combined with the way you have the shadow/souls setup based on population in Shadowworld would probably work... do you see any reason why not?

(Thanks for the help and quick response btw)

 

 

The only danger I see is it possibly going negative, which would limit further production but not cause anything else to happen (players may expect them to disband?).

Reply #10 Top

btw to insert an image upload the image to an online image sharing program like imgur or photobucket.  Once you've done that copy the direct link to the image (url.)

Then when making a post click the little tree symbol where you want to put the picture then paste the url into the popup, and voila.

Reply #11 Top

Hmm lemme try.....

 

 

Ok cool, got it after a bit of mucking about.  I was trying to use the https dropbox url before silly me.

Thanks!

 

 

Reply #12 Top

Further to this, any ideas why I get this "String not found"?  Can't figure how to get a description in there... I have tried setting a <Description> for the resourcetype but that doesn't seem to be it.

 

Reply #13 Top

I bet that string is the formatted description 

Reply #14 Top

It's a hardcoded value for each vanilla resource type gathered from elemental.str. Afaik you can't add more.

 

Reply #15 Top

Ah, good work HF!  Just tested, well you *can* actually get it to work if you add an entry to elemental.str, eg in my case this:

[JB_CultSerpent_Influence_Description] Foobar.

And you get this:

 

 

However doing that would break my rule of editing anything in the install folder.  And I presume it would be a bit of a no no it terms of support, and probably get overwritten every patch so a bit crap all round really :-(

Thanks for pointing me to it though.

+1 Loading…