Skip to content

Support arbitrary damage type as the "death type" #3287

Description

@efrec

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions