bugfix: Detonated GLA Demo Battle Buses are no longer instantly deleted without firing their death weapons - #3264
Conversation
…ed without firing their death weapons
PR Summary by QodoEnsure Battle Bus detonations trigger all death behaviors
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent |
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp | Reorders lethal-damage handling to select an applicable second-life behavior before applying the second-life state, with real-death fallback. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp | Centralizes probability summation and filters slow-death behaviors according to whether damage is entering second life. |
| Core/GameEngine/Include/GameLogic/Damage.h | Adds the second-life routing flag, but its declaration violates the repository’s alignment convention. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SlowDeathBehavior.h | Extends the slow-death interface with real-death classification and shared probability calculation. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/BattleBusSlowDeathBehavior.h | Exposes the Battle Bus behavior’s current real-death state for applicability filtering. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/UndeadBody.h | Splits second-life selection from application and reports whether selection succeeded. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Lethal first-life damage] --> B[Mark request as entering second life]
B --> C[Find applicable second-life slow-death behaviors]
C -->|At least one| D[Apply capped damage]
D --> E[Install second-life health and armor]
E --> F[Begin selected slow-death behavior]
C -->|None| G[Clear second-life marker and force real death]
G --> H[Run ordinary death behaviors]
Prompt To Fix All With AI
### Issue 1
Core/GameEngine/Include/GameLogic/Damage.h:290
**Unaligned Member Declaration**
The new `m_enterSecondLife` member does not align with the surrounding type, name, and comment columns. This violates the repository directive to preserve column alignment within a modified data-oriented block, so the requirement must be satisfied before merging.
```suggestion
Bool m_enterSecondLife;
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (3): Last reviewed commit: "Improve battle bus second life impl (zer..." | Re-trigger Greptile
| if (sdu->isRealDeath()) | ||
| { | ||
| damageInfo->in.m_kill = true; | ||
| ActiveBody::attemptDamage(damageInfo); |
There was a problem hiding this comment.
I am confused by this implementation. The function says startSecondLife, so we now expect a second life with health restore, armor set change, ..., but here it will attempt the kill afterwards. Should this code perhaps be executed before this function is called? Aka shouldStartSecondLife is false when suicided?
The reason I am raising this is, the code reads confusing this way, regardless whether functionally it is working correctly in game.
There was a problem hiding this comment.
This implementation follows the existing setup where a death type handled by a different SlowDeathBehavior (not BattleBusSlowDeathBehavior) would immediately kill the unit. Instead of manually calling the SlowDeathBehavior modules' death logic, they are now intrinsically called through the damage → death path, and only if there's no SlowDeathBehavior to handle it.
Explicitly checking for SUICIDED or any such death types is not as clean or flexible because a mod might use a custom setup where the death types are handled differently. For example, someone might make a zombie unit that immediately dies without rising again if it dies via a HOLY death type.
Perhaps the naming is the source of the confusion. We already have attemptDamage - would attemptSecondLife be more suitable?
There was a problem hiding this comment.
It is not just the function name. Look at all the things that happen before the suicide:
m_isSecondLife = TRUE;
setMaxHealth(data->m_secondLifeMaxHealth, FULLY_HEAL);
setArmorSetFlag(ARMORSET_SECOND_LIFE);
So it fully prepares for a second life, but then it dies. How does that make sense?
There was a problem hiding this comment.
Perhaps it does not make sense, but this is how the retail logic already works. Whether the original logic makes sense is secondary to this fix, which I intended to involve minimal refactoring for safety and simplicity. Would you prefer I move all of those lines below the death logic?
There was a problem hiding this comment.
Yes I think the suicide kill should be before it decides to go to second life.
|
I would like to push a commit to this branch. |
|
I have applied additional edits to this change in order to try bring it into a state that makes more logical sense. I have done only limited testing with RETAIL_COMPATIBLE_CRC=0. I did not test VC6 and RETAIL_COMPATIBLE_CRC=1. Edits were made by hand without AI usage. |
I'm not a fan of adding data for a specific death implementation to the damage class, which should be generic / application-agnostic. We can already determine whether a second life will be entered from the modules themselves, so why do damage instances now need to pass this information? This new approach also effectively couples and enforces the |
|
The If we need Second Life to be death module independent, then it needs a different strategy. What would be the use case for that? Edit: Ok I see UndeadBody is supposed to drive Second Life, not the Slow Death module. Then it needs a different approach indeed. |
This change fixes an issue where the GLA Demo Battle Bus would not trigger any death behaviours besides
SlowDeathBehaviormodules when initially killed via an unhandled death type. This resolves the issue where aSUICIDEDdeath would instantly delete the Battle Bus without dealing any suicide damage if the Demolitions upgrade was researched.Before
The Battle Bus deals no damage to surrounding enemies when suicided
BEFORE.mp4
After
The Battle Bus now deals damage to surrounding enemies when suicided
AFTER.mp4