Since #1638, we have envDamageTypes for games to define their own damage types as custom weaponDefIDs. This has a lot of crossover with defining death types, which game code can interpret already via weaponDefID.
Currently, though a game can add CullingStrike:
envTypes.CullingStrike = envTypes.KilledByLua - 1
And knows how to listen to one, it's unclear how to cause one.
There are a couple of ways we might try, both with issues:
-
Spring.DestroyUnit hardcodes a single damage type.
|
unit->ForcedKillUnit(attacker, selfDestr, reclaimed, -CSolidObject::DAMAGE_KILLED_LUA); |
-
Spring.AddUnitDamage takes any negative weaponDefID but passes reclaimed = false, so can't be used for a reclaimed/atomized death type.
|
KillUnit(attacker, false, false, weaponDefID); |
We also have to be careful that the damage event goes through and the amount is lethal.
So the ask is to add a params table to Spring.DestroyUnit like so:
Spring.DestroyUnit(unitID, {
reclaimed = true,
weaponDefID = Game.envDamageTypes.Reclaimed,
})
And possibly allow more clear keys like noDeathExplosion and noWreck etc for the keys.
Maybe related to #2772, killing factories with ForcedKillUnit skips CFactory::KillUnit, for some discussion on whether the engine or the game holds these behaviors consistent (or some mix).
Since #1638, we have
envDamageTypesfor games to define their own damage types as custom weaponDefIDs. This has a lot of crossover with defining death types, which game code can interpret already via weaponDefID.Currently, though a game can add
CullingStrike:And knows how to listen to one, it's unclear how to cause one.
There are a couple of ways we might try, both with issues:
Spring.DestroyUnithardcodes a single damage type.RecoilEngine/rts/Lua/LuaSyncedCtrl.cpp
Line 1986 in 9b4be36
Spring.AddUnitDamagetakes any negative weaponDefID but passesreclaimed = false, so can't be used for a reclaimed/atomized death type.RecoilEngine/rts/Sim/Units/Unit.cpp
Line 1373 in 9b4be36
We also have to be careful that the damage event goes through and the amount is lethal.
So the ask is to add a params table to
Spring.DestroyUnitlike so:And possibly allow more clear keys like
noDeathExplosionandnoWrecketc for the keys.Maybe related to #2772, killing factories with
ForcedKillUnitskipsCFactory::KillUnit, for some discussion on whether the engine or the game holds these behaviors consistent (or some mix).