bugfix: Occupants killed by their containers now kill their occupants#2239
bugfix: Occupants killed by their containers now kill their occupants#2239Stubbjax wants to merge 2 commits intoTheSuperHackers:mainfrom
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp | Refactored to use percentDamage parameter and added recursive killing logic for nested containers |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp | Added recursive killing logic for nested containers matching Generals implementation |
Sequence Diagram
sequenceDiagram
participant Chinook as Chinook Container
participant TC as Troop Crawler (contained)
participant RG as Red Guards (nested contained)
Note over Chinook: Chinook dies
Chinook->>Chinook: onDie()
Chinook->>Chinook: processDamageToContained(1.0)
Note over Chinook,TC: Iterate through contained units
Chinook->>TC: Check if killContained (percentDamage == 1.0)
alt killContained is true
Chinook->>TC: getContain()->processDamageToContained(1.0)
Note over TC: Recursive call before killing TC
TC->>RG: Iterate through TC's occupants
TC->>RG: attemptDamage()
TC->>RG: kill() if not dead
Note over RG: Red Guards die
end
Chinook->>TC: attemptDamage()
Chinook->>TC: kill() if not dead
Note over TC: Troop Crawler dies
Note over Chinook,RG: All nested occupants killed recursively
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Line: 1307:1307
Comment:
Should use `percentDamage` parameter instead of `data->m_damagePercentageToUnits` to match the GeneralsMD implementation and ensure nested containers receive the correct damage value.
```suggestion
Real damage = object->getBodyModule()->getMaxHealth() * percentDamage;
```
How can I resolve this? If you propose a fix, please make it concise. |
61f80fa to
b1aaa96
Compare
b1aaa96 to
05dc39e
Compare
|
Does this also happen with Troopcrawler in helix? |
A Troop Crawler takes up eight slots and thus cannot fit inside a Helix. But we can demonstrate the same behaviour with a Helix by loading an Ambulance or Technical. AMBO_LIX.mp4 |
Closes #184
This change fixes an issue where occupants killed via the destruction of their container do not kill their occupants, and so on. For example, if a Chinook containing a Troop Crawler dies, the Red Guards inside the Troop Crawler survive and fall to the ground, which looks silly and can leave them floating in the air.
Before
A Troop Crawler dies inside a Chinook, but its occupants survive and fall to the ground or float in the air
YES_SURVIVORS.mp4
After
A Troop Crawler dies inside a Chinook, and kills its own occupants as a result
NO_SURVIVORS.mp4