No building, only buying

One way which might work is to make unit's hammer cost very high (say, 100k), but change the hurry cost modifier. I did it to make units un-purchaseable, but it should work the other way around.

<Cost>100000</Cost>
<HurryCostModifier>1</HurryCostModifier>

so, gold cost for this unit should be like a cost for 100000 * 1% = 1000 hammers unit. I haven't tried it exactly this way though.
 
You can find the purchase cost formula here (it's an old thread and may have been changed with patches since then).
I don't think what you suggested will work as the HurryCostModifier is a percentage increase.
As I understand it setting cost to a negative number makes the unit unbuildable so doing that and setting HurryCostModifier as negative as well may make it purchaseable only. Of course setting cost to negative may prevent it from being acquired either way.
 
As I understand it setting cost to a negative number makes the unit unbuildable so doing that and setting HurryCostModifier as negative as well may make it purchaseable only.

It won't.
If Cost is negative, a unit isn't buildable.
If HurryCostModifier is negative, a unit isn't purchaseable.

So you can't set the cost really high and then use HurryCostModifier to make its purchase price reasonable. Now, if you wanted this to work for EVERY unit, you COULD set the cost really high, and either give the Palace a Wonder-like ability to greatly reduce hurry costs, or give each player a Policy that makes unit purchases much cheaper. But, this'd also have many other problems: disbanding a unit would give you a huge amount of money, for instance. So it's just a bad idea.

There are a few ways to do things like this through creative use of Lua, but not easily.
 
ok i thought it might only be achievable through lua but something not easy to do.. damn..

i like the idea of not being able to 'build' certain units and only be able to buy them as such.. hmm..
 
It won't.
If Cost is negative, a unit isn't buildable.
If HurryCostModifier is negative, a unit isn't purchaseable.

As I understand, setting Cost to negative would make unit not buildable, and not purchaseable either because it would mess up the gold cost formula? Otherwise that's what OP needs.

You can find the purchase cost formula here (it's an old thread and may have been changed with patches since then).

I have even posted in that thread a couple of days ago, but forgot about the formula already :blush:. I tested it and the formula still seems to work fyi.

A simplest way to do it in lua that I can think of is to check all city production on each player's turn start, and then when SerialEventUnitCreated triggers, disband the unit if it was previously registered as being built. This would probably have a dramatic effect on AI.

If you want it for human player only, you can manipulate the queue to remove all units once the city screen closes.
 
Back
Top Bottom