How to restrict an improvement to 1 *ever* ?

Hi all,

I've got a few faction specific unique buildings in my mod that create bonus resources etc nearby when built.  They are unique... only one per faction...  However they can be misused by razing the improvement and building it multiple times to create multiple bonus resources.  Doh.

Ideally these improvements would be "you can only be one of these, ever".

I tried making a unique resource, giving the faction 1 of them and then adding a ProductionRequirement (of 1 of the unique resource) to the Improvement.  It didn't work.... it caused problems with the Improvement... i'm guessing that ProdutionRequirement doesn't work properly on improvements.

Any ideas on how make an improvement "build 1 ever", or other ideas on how I could prevent misuse of these improvements?

Thanks.

6,642 views 14 replies
Reply #1 Top

There was a thread about summoning a stamp for the Darkling City, and another thread about summoning stamps for Burning Land tiles.

 

Maybe you can create a stamp which already contains your unique resource and summon it? To have it only done once, you could set cooldown to something like 800. (or whatever max game turns is these days).

 

As a wild guess, I would make a 2-stage improvement that gives the bonus on the "second" stage, the upgrade. Most people won't raze a second-level city.

 

I have some buildings on the Nexus which give bonus resources you can look at and use as a design template if you want.

 

You can set <RequiresCityImprovement>1</RequiresCityImprovement> and make a second building which either upgrades to, or depends on the one you want to give the ability to. You can try giving Prereq of a unique improvement.

 

My final option is to find the spot where the Capital City is hardcoded, and use that to make it Capital Only.

Reply #2 Top

Change the cost to demolish in ElementalDefs to something ridiculous like 1000000000000000000000000000000000000000000000000.

Reply #3 Top

Maybe make a fake resource that the player cannot see and give each player a certain amount of this resource that is required to build the building in question. If there is no way of generating this resource (for example give it to the player when he builds his first city), then he can only build your building exactly once. Unless he removes his entire empire (or knows of the exploit to get a lot of the I can build it resource).

Or think of another way of giving someone this resource that they can exploit, I'm sure there are other ways about it.

Reply #4 Top

how do you give an ability when the first city is settled? that might help me with some of my problems.

Reply #5 Top

Giving a building a unique resource cost shouldn't be a problem, I've done that before.

Reply #6 Top

Do you know if you have an example in Stormworld currently?

Reply #7 Top

Do you know if you have an example in Stormworld currently?

Nevermind, I found one (magma forge).

 

And, this works a treat!  I was using the wrong type of tag... I had been using a <ProductionRequirement> as used by UnitTypes (which doesn't work properly).  To get it working you can instead use this on an ImprovementType:

<GameModifier>
   <ModType>ConstructionResourceCost</ModType>
   <Attribute>MySpecialResource</Attribute>
   <Value>-1</Value>
</GameModifier>

For my purpose I then just have a faction trait that grants +1 of MySpecialResource.  You can then construct the unique building.  If you raze it you can't build another one.  Huzzah!

Thanks (again) HF.     :grin:

 

Thanks to everyone else for the quick responses too.  I also tried using a Spell (as suggested by thadianaphena) to create the bonus resource and also got that to work   :thumbsup:

So now i've actually got a couple of options at least, yay.

 

 

 

Reply #8 Top

how do you give an ability when the first city is settled?

Not sure if that's what he was suggesting as the solution.  But either way I'm pretty sure that's not possible.  Would be happy to be proven otherwise though.

Reply #9 Top

I think the key is to remove your unique resource as a building effect, not as a CostResourceEffect, because when you demolish a building you get back the resources marked as construction costs.

The CoreImprovements.xml has the GuildLendingHouse improvement, that gives 2000 gold just once. Perhaps looking at it could help you. Use that code and replace Gold by your resource and 2000 by -1

Code: xml
  1. &lt;GameModifier&gt;
  2.     &lt;ModType&gt;Resource&lt;/ModType&gt;
  3.    &lt;Attribute&gt;UniqueResource&lt;/Attribute&gt;
  4.    &lt;Value&gt;-1&lt;/Value&gt;
  5.    &lt;Provides&gt;You can only build one of those. Ever&lt;/Provides&gt;
  6. &lt;/GameModifier&gt;

Reply #10 Top

BUT it is possible to get many lendinghouses, just one per city, in some of my games I have had over 10 lending houses in various cities of mine.

harpo

 

Reply #11 Top


Yes, but the important thing about the lending house in this case is that it provides a one time lasting effect. I was just using it as an example of this behaviour. With that code I believe that the unique building will substract one unit of the unique resorce, and this substraction won't be "fixed" after demolishing the building / losing the city. I have not tested it because I am not at home but I am fully convinced it works.

Reply #12 Top

...because when you demolish a building you get back the resources marked as construction costs.


It works fine, if you used the tag I mentioned above, i.e. <ModType>ConstructionResourceCost</ModType>... then when you raze the building you definitely don't get the resource back.  So all good.

Thanks.



Reply #13 Top

Great! Now I am curious to learn about those faction buildings ;-)

 

Reply #14 Top

Another thing you might try is placing the Unique Building by a City Enchantment spell. The player will be able to raze the city, and re-build it, however that might fix the problem of exploiting it with rebuild, because they will lose the benefit of the building and have to re-cast.

 

I am working with an attempt to give a resource per turn for a City Enchantment however I am copying Tireless March as the base because something in it makes it "one only", just need to switch the tags from unit to friendly city.

 

I might have to play with ConstructionResourceCost.

 

 

Here are some posts I found helpful regarding unique buildings.

 

https://forums.elementalgame.com/420176

 

https://forums.elementalgame.com/419061