-
-
Notifications
You must be signed in to change notification settings - Fork 110
[Minor] Fix number of issues with health threshold checks #1745
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
base: develop
Are you sure you want to change the base?
[Minor] Fix number of issues with health threshold checks #1745
Conversation
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
7b630d6
to
dd1f9bb
Compare
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.
The main part looks fine. But personally, I have some small questions.
Would it be better to place WeaponTypeExt::ExtData::IsHealthInThreshold
‘s sanity check outside like others? (Then we can use abstract_cast<ObjectClass*, true>(pTarget)
inside)
And regarding IncludeZero
, I think negative numbers should be allowed? Then only need to provide a prompt in the document, without adding a new key.
b429215
to
280b1c8
Compare
Not sure on this, why? |
When it comes to weapon targeting / selection stuff, the target is pretty much always Negative values already work. The main issue is that introduction of the health checks changes the default behaviour of.. well everything because zero health-objects were previously not excluded by default from warhead detonations etc. and now they are. Warranting modder config migration here is not feasible. There are different ways to solve this issue including making the lower bound check inclusive so zero health is included if the minimum threshold is 0. I would not be against it (it would effectively be possible to make the check exclusive by using a very small value instead) and it would make certain degree of sense given that the upper bound check is but this didn't seem to be a viable option for Kerbiter when we discussed this matter. |
dd1f9bb
to
b2a8c0a
Compare
I agree that 0 health is a rare edgy case that shouldn't even be considered in actual modding, so |
if (!pTarget) | ||
if (auto const pObject = abstract_cast<ObjectClass*>(pTarget)) | ||
return GeneralUtils::IsHealthInThreshold(pObject, this->CanTarget_MinHealth, this->CanTarget_MaxHealth, this->CanTarget_MinHealth_IncludeZero); | ||
else | ||
return true; |
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.
I have reviewed the discussion on DC, so in fact, IncludeZero
is designed to handle the situation after the death of the target object. In this case, I think there are some issues.
For example, in ExtraWarheads
, the target is reacquired every time it detonates. When the target dies, AnnounceInvalidPointer
is called, resulting in an empty Target
. In this case, the target obtained afterwards is empty and can no longer participate in subsequent checks. Therefore, some special handling like "return true;" -> "return this->CanTarget_MinHealth_IncludeZero;"
is needed in this situation. (The external of the function may also require some processing, but I haven't looked closely yet)
I mean, objects can have zero HP when dying, and we don't really know if there's any potential situation where that state should have different behavior, so it's best to leave it that way. Besides, it's a special case, so a special tag for special case makes sense. |
@fagonghaiwo can you elaborate what is being shown on the screenshot? |
• Warhead
AffectsBelow/AbovePercent
check is no longer bypassed inBulletClass::Logics()
if bullet target and firer are same object.• Removed incorrect
CanTarget.Max/MinHealth
check on firing techno itself in force weapon selection code.• Warhead
AffectsAbovePercent
will now by default bypass the check if target has 0 health left. Can be overridden by settingAffectsAbovePercent.IncludeZero
to false.• Weapon
CanTarget.MinHealth
is no longer inclusive to be in line with WarheadAffectsAbovePercent
.• Weapon
CanTarget.MinHealth
will now by default bypass the check if target has 0 health left. Can be overridden by settingCanTarget.MinHealth.IncludeZero
to false.• None of the health threshold checks are now restricted to TechnoTypes only where appropriate (may be subject to further changes depending on if issues crop up with checking projectile/tree healths).
• Added missing
Crit.AffectsAbovePercent
to be in line with other checks.• Unified the health threshold checking code.
Some considerations.
• Unsure if
CanTarget.MinHealth.IncludeZero
is necessary, it is my understanding that the fire error checks do not hard disallow targeting objects with zero health but is covering this edge case necessary?Crit
is by design not able to occur on technos with zero health so that is why equivalent was not added for it.• Uncertain if problems could occur with the health thresholds being applied on trees and projectiles in case of InterceptorWeapon and if reverting that part or adding more toggles would be necessary.
Fixes #1743