-
Notifications
You must be signed in to change notification settings - Fork 117
bugfix(module): GLA Battle Bus can no longer be subdued indefinitely #1604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix(module): GLA Battle Bus can no longer be subdued indefinitely #1604
Conversation
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp
Outdated
Show resolved
Hide resolved
| if (isSubdued()) | ||
| { | ||
| const UndeadBodyModuleData* data = getUndeadBodyModuleData(); | ||
| internalAddSubdualDamage(data->m_secondLifeMaxHealth - getCurrentSubdualDamageAmount()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a Battle Bus gains 250 health when entering bunkered mode (400 health → 650 health), the subdual damage threshold can be shifted above the current subdual damage and thus cause the Battle Bus to remain subdued forever. To rectify this, the subdual damage is set to the threshold (max health) on transitioning to the bunkered state to ensure the subdued state is removed when healed.
This observation makes me wonder if it is desireable that a unit can get stuck in subdual to begin with. Where does this happen and is there maybe another way to fix this universally, so that even in these scenarios the sub dual damage can recover on its own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, and would explain why I've seen it happen to disabled tanks when the Composite Armour upgrade was likely timed with the disable. I'll look at updating the subdue status in the setMaxHealth method instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why the subdue gets stuck when the health is wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially because wasSubdued and isSubdued can both return false after a max health increase and so onSubdualChange is never triggered.
If we inline the logic, it looks like this:
bool wasSubdued = m_maxHealth <= m_currentSubdualDamage;
internalAddSubdualDamage(amount);
bool nowSubdued = m_maxHealth <= m_currentSubdualDamage;
if (wasSubdued != nowSubdued)
onSubdualChange(nowSubdued);
But now looking at it, I think there is a cleaner solution:
bool wasSubdued = getObject()->isDisabledByType(DISABLED_SUBDUED);
internalAddSubdualDamage(amount);
bool nowSubdued = m_maxHealth <= m_currentSubdualDamage;
if (wasSubdued != nowSubdued)
onSubdualChange(nowSubdued);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes a lot of sense. Fixing the root of the issue.
This change prevents bunkered Battle Buses from being subdued indefinitely (demonstrated below).
SAD_BUS.mp4
As a Battle Bus gains 250 health when entering bunkered mode (400 health → 650 health), the subdual damage threshold can be shifted above the current subdual damage and thus cause the Battle Bus to remain subdued forever. To rectify this, the subdual damage is set to the threshold (max health) on transitioning to the bunkered state to ensure the subdued state is removed when healed.