beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
209 stars 98 forks source link

Add reclaimer to UnitDestroyed #1611

Open sprunk opened 2 months ago

sprunk commented 2 months ago

Bill of materials to be done before starting this ticket:


Reclaim can kill a unit: https://github.com/beyond-all-reason/spring/blob/19d1a003ed2b327ec0f96767bfd8cc26c5766419/rts/Sim/Units/Unit.cpp#L2054-L2058

But it's very hard to detect that this happened (when using the "drain health" method of reclaim) because the unit suddently just dies with no attacker in UnitDestroyed.

Pass the builder as the killer to CUnit::KillUnit. This needs to be done after the weaponDefID ticket (#1639) says this was via reclaim, since otherwise you can't distinguish it from the builder just murdering the unit (e.g. via collision damage).

Do this also for other death events that have a culprit (e.g. pass transport for the "died with my transport", pass factory for the "i got cancelled" etc).

Caveats:

keelefi commented 1 month ago

I propose this ticket be split in two. The first ticket adding weapondDefID as an argument in UnitDestroyed(). After that ticket has been completed, this ticket can be implemented.

sprunk commented 1 month ago

Sure. Added a bunch of tickets for each step (#1638, #1639) and added a bill of materials here in #1611.