Need help with special unit

jkp1187

Unindicted Co-Conspirator
Joined
Aug 29, 2004
Messages
2,496
Location
Pittsburgh, Pennsylvania
Okay, I posted this question in the general forum, but am posting here, too, because I think the answer is going to require an SDK or Python solution. (Though I'm not sure how, exactly.)

I want to create a special unit (part of, say, UNITCLASS_INFANTRY) that can never be actually constructed by any Civ. Instead, it can only be received via the Civ triggering a special random event that 'awards' this special unit. I don't think this will be an XML solution (though I'll be ecstatic if it is). Can someone point me in the right direction on this?

Thanks.
 
GIR's partisan mod uses a unit, which cannot be built by anyone, but which appears when a city is conquered for the defending side. It's a python mod, and the unit is xml'ed as all other units. You can find it in the modcomp forum. :)
 
Set the iCost (and AdvancedStartCost) to -1 and the unit can't be built or purchased during advanced starts. The unit can still be given out in a variety of ways such as the first free unit for a tech, as an event, etc.

However, it needs to be its own unitclass, the only way to use multiple versions of the same unitclass is with the unique units. If you want to have what are essentially unique units (variants of an existing unitclass) that can only be awarded you will have some serious work to do.

Alternatively, you can create the stock unit and modify it as needed to make it unique :)
 
Thanks. I'll give this a try.

Why does it need to be its own UNITCLASS, though? CIV4UnitClassInfos.xml doesn't really contain much information at all.... and there doesn't seem to be any restriction on awarding one civ's unique unit to another civ via an Event.
 
Because you don't build units, you build uniclasses :)

The terminology may not make perfect sense but essentially a unitclass is a 'unit' and a unit (in the xml) is a particular template for a unitclass. Or, all Praets are Swordsmen but not all Swordsmen are Praets. In cases where no unique units exist (settler for example) you'll see there is exactly one unit in the unitclass. When a unit is created in the game it is choosen by unitclass using the default unit unless a replacment is specified by the civilization that the unit is being created for. For general classification of unit types you have unitcombats, not unitclasses. So in your case of 'infantry' what you want is a new unit in the UNICOMBAT_GUN classification, not a new unit in UNITCLASS_INFANTRY.

Of course if you can creat unique units via an event than simply create a new unit under unitclass_infantry (or wherever) and don't assign it to anybody as a unique unit. Should have the same net effect assuming you're correct about being able to spawn unique units via event. In the SDK all unit creation is essentially limited to builds which are handled by unitclass not specific units.
 
Back
Top Bottom