beyond-all-reason / beyond-all-reason/RecoilEngine

Support arbitrary damage type as the "death type"

Open
#3,287 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

Since https://github.com/beyond-all-reason/RecoilEngine/issues/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.

https://github.com/beyond-all-reason/RecoilEngine/blob/9b4be369822c92553a87dbe436a55d38c193ceb9/rts/Lua/LuaSyncedCtrl.cpp#L1986

- `Spring.AddUnitDamage` takes any negative weaponDefID but passes `reclaimed = false`, so can't be used for a reclaimed/atomized death type.

https://github.com/beyond-all-reason/RecoilEngine/blob/9b4be369822c92553a87dbe436a55d38c193ceb9/rts/Sim/Units/Unit.cpp#L1373

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

Contributor guide

Open the contributing guide

Research direction

Start with the Spring.DestroyUnit implementation in rts/Lua/LuaSyncedCtrl.cpp around line 1986, then inspect damage handling in rts/Sim/Units/Unit.cpp around line 1373. Compare the existing DestroyUnit and AddUnitDamage behavior, including reclaimed damage and lethal damage events. Done means Lua can cause an arbitrary weaponDefID death type through the proposed parameters without breaking existing death, wreck, or explosion behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
backend-api-design, game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.