OpenXcom Forum

Modding => OpenXcom Extended => Topic started by: Alex_D on September 16, 2021, 05:23:01 pm

Title: [request] specify the quantity of spawned units
Post by: Alex_D on September 16, 2021, 05:23:01 pm
Currently the game spawns other units from dead units, or from items using the "spawnUnit" and "spawnUnitFaction" commands. Examples:
Code: [Select]
  - type: STR_ZOMBIE

    spawnUnit: STR_ZERG_ZERGLING
    spawnUnitFaction: 1
But it's currently limited to only one unit at the time.

I'd like to see if it's possible to implement the following feature: Specify the quantity of spawned units. Example:
Code: [Select]
  - type: STR_MEGAWORM #2x2 unit
    spawnUnit: STR_MICROWORM
    spawnUnitQty: 4

    spawnUnit: STR_ZERG_ZERGLING
    spawnUnitFaction: 1
    spawnUnitQty: 2

I know there are current workarounds such as activated spawner grenades in backpacks and such, but this may be a more direct and "clean" way to implement this feature.
I don't know if it's even possible due to code limitations. But if it is, can you implement it? If not both, at least the case of a 2x2 unit to "die" leaving behind more than one.
Title: Re: [request] specify the quantity of spawned units
Post by: Yankes on September 17, 2021, 12:14:23 pm
This would require lot of refactoring to make possible as current spawn code effective replace old unit with new one.
This mean you can have multiple spawned units because second spawned unit can't replace old unit as it do not exists any more.
Title: Re: [request] specify the quantity of spawned units
Post by: Buscher on September 18, 2021, 01:10:15 am
You can do all that with clever use of spawner grenades.
I had a similar proof of concept sitting around to play around with. Back then it was a recursive spawning of units. When they die, they drop spawner grenades, which spawn units, which then die again to drop more spawner grenades.
Now I have refactored and cleaned it up a bit. This also works fine with 1x1 creating 2x2 units.

The number of new units is limited per corpse as the game needs to find a nearby spot to spawn the new units.
You can see an example here (