World Unit Help

Underdog Ally

Chieftain
Joined
Feb 22, 2019
Messages
63
I need some thoughtful input on creating a world unit please. My intention is to make a unit that is globally limited to 1, to be specific a powerful submarine variant the Red October. I thought of making the unit free to the first person who researches fission. But from what I understand free units spawn in the capital and what if the capital isn’t coastal? Would it spawn in a landlocked city? Can I change the spawn location? Any help or tips are greatly appreciated c:
 
I don't really know, but assuming there is no xml only way to do this. A work around might be to have it be a normal unit, but limited to 1 like the missionaries are limited to 3.
 
I need some thoughtful input on creating a world unit please. My intention is to make a unit that is globally limited to 1, to be specific a powerful submarine variant the Red October. I thought of making the unit free to the first person who researches fission. But from what I understand free units spawn in the capital and what if the capital isn’t coastal? Would it spawn in a landlocked city? Can I change the spawn location? Any help or tips are greatly appreciated c:
Yes it can spawn in a landlocked city. Been there done that :lol:
I don't really know, but assuming there is no xml only way to do this. A work around might be to have it be a normal unit, but limited to 1 like the missionaries are limited to 3.
You would probably have to use the canTrain callback and use python. Something similar to what Platyping does in his World Tech mod but for units.
 
Thanks for the input ! To make things easy what I might do is instead of making it a “free” unit when reaching the tech first, I will just make it very cheap production cost so that whoever gets the tech first can just build it quickly in a desired city.
 
You could also include it in the upgrade path for submarines. Then you could instantly upgrade a normal submarine and have it instantly.

But, if another civ researches fission and kills your super submarine they could then upgrade one of theirs before you could replace it. Unless each civ is allowed one each.
 
I had not considered that once it dies someone else can produce it again, I forget that the 1 allowed limit really means 1 at a time. But that could actually be cool because once it dies someone else can have it and so fourth. That would play into the “defection” tendency that the Red October is known for. Thus it would be a never ending hunt for an elusive, side switching super sub.
 
By setting the unitclass's global limit to 1, it will prevent the unit from being rebuilt if it is destroyed. Setting it to 1 per player or team would allow it to be rebuilt, but also let everyone have their own Red October at the same time.

I think Python trickery can allow you to limit the amount of Red Octobers to 1 on Earth while allowing a new one afterword.

<UnitClassInfo>
<Type>UNITCLASS_LION</Type>
<Description>TXT_KEY_UNIT_LION</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>-1</iMaxPlayerInstances>
<iInstanceCostModifier>0</iInstanceCostModifier>
<DefaultUnit>UNIT_LION</DefaultUnit>
</UnitClassInfo>
 
You can try this:

<UnitClassInfo>
<Type>UNITCLASS_LION</Type>
<Description>TXT_KEY_UNIT_LION</Description>
<iMaxGlobalInstances>1</iMaxGlobalInstances>

and

<UnitInfo>
<Class>UNITCLASS_LION</Class>
<Type>UNIT_LION</Type>
<UniqueNames/>
<Special>NONE</Special>
<Capture>UNITCLASS_LION</Capture>

So there will always be 1 unit. If it is defeated it "changes owner". Well, it will loose all promotions but you can consider it as having a new crew. You can add starting promotions so it won't feel so empty when captured.
 
Back
Top Bottom