As of the 21 August 2018 release of OXCE+, new code has been introduced that allows for the spawning of new units during the battlescape using items. The ruleset for this feature consists of two new parameters on items:
items:
- type: STR_SOME_UNIT_SPAWNING_ITEM
spawnUnit: STR_SOME_UNIT # Default empty meaning don't spawn a unit, when a valid unit (defined in the units: ruleset) is defined here it will be spawned by this item.
spawnUnitFaction: -1 # Default -1 meaning the spawned unit will be the same faction as the unit using/firing the item, this defines which faction gets the new unit:
# -1: Same faction as item user
# 0: Player faction
# 1: Enemy faction
# 2: Civilian faction
When this item is fired/used and hits something and either causes a hit animation or an explosion, the chosen unit will be spawned after the hit/explosion. This means that the new unit cannot be damaged by this item except during an autoshot or if terrain explosions occur after the hit. If the tile at the center of the hit/explosion is occupied by a unit or an object, the surrounding tiles will be checked in the 3x3 'circle' around the hit/explosion, starting with the tile closest to the unit firing. The new unit's facing will be in the same direction of the original user. If there is no unit firing or using the item, then the search for a vaild spawn position will start on the north center tile of the surrounding 'circle' and the chosen facing for the new unit will be random.
Items that may be used to enable this behavior are:
- Firearms that use themselves as ammo - lasers, single-shot launchers, etc.
- Any ammunition for a firearm.
- Melee weapons or melee attacks on any item.
- Grenades and proximity mines.
- Psi-amps.
Player units spawned by this code will not count for the purposes of determining whether the player has any soldiers left, so you will automatically lose a mission if you lose all other units but the ones spawned this way. Spawned player units will be automatically removed before item/unit recovery. Enemy units spawned by this code will count for the total number of aliens left, and must be killed in order to end a mission by eliminating all hostiles.
This unit spawning also has a special interaction with items placed as part of map blocks: any items placed on a map block as a primed grenade with a timer of 0 will spawn their unit before the battle begins but without an explosion. The ruleset for this would look like:
items:
- type: STR_SOME_UNIT_SPAWNING_ITEM
spawnUnit: STR_SOME_UNIT
spawnUnitFaction: 0
battleType: 4 # Must be a grenade in order to spawn correctly before battle
terrains:
- name: STR_TERRAIN_WITH_BLOCK_THAT_SPAWNS_UNITS
mapBlocks:
- name: MAPTOSPAWNUNITS
items:
STR_SOME_UNIT_SPAWNING_ITEM:
- [0, 0, 0] # Position of the item in the map block
fuseTimers:
STR_SOME_UNIT_SPAWNING_ITEM: [0, 0] # Set all fuses on these items to 0
Since there is no "user" for this grenade item, the default spawnUnitFaction: -1 will cause the spawned unit to be an enemy - it is best to explicitly define this value for pre-battle unit spawning items.