Skip to content

Commit 693924e

Browse files
authored
Further adjustments to health threshold checks (#1841)
@Metadorius - Makes lower bound check of health threshold checks (weapon, warhead, crit) exclusive e.g equal to it does not satisfy the condition. This allows for creating distinct ranges for weapon/warhead eligibility e.g no overlapping. - Ignore health threshold checks for objects with zero health. They are not relevant consideration for current health checks (other checks filter out unalive objects), if need to consider them in future appears, conditions can be added then and there. Migration notice is currently absent due to uncertainty about where to place it.
1 parent 625ef31 commit 693924e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ Conventional.IgnoreUnits=false ; boolean
21092109

21102110
### Customizable Warhead trigger conditions
21112111

2112-
- It is now possible to make warheads only trigger when target's (TechnoTypes only) HP is above/below or equal to certain percentage. Both conditions need to evaluate to true in order for the warhead to trigger.
2112+
- `AffectsBelowPercent` and `AffectsAbovePercent` can be used to set the health percentage thresholds that target needs to be below/equal and/or above of for the Warhead to detonate. If target has zero health left this check is bypassed.
21132113
- If set to `false`, `AffectsNeutral` makes the warhead can't damage or affect target that belongs to neutral house.
21142114
- If set to `false`, `EffectsRequireVerses` makes the Phobos-introduced warhead effects trigger even if it can't damage the target because of it's current ArmorType (e.g. 0% in `Verses`).
21152115

docs/New-or-Enhanced-Logics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ RemoveMindControl=false ; boolean
21472147
- `Crit.Warhead.FullDetonation` controls whether or not the Warhead is detonated fully on the targets (as part of a dummy weapon) or simply deals area damage and applies Phobos' Warhead effects.
21482148
- `Crit.Affects` can be used to customize types of targets that this Warhead can deal critical hits against. Critical hits cannot affect empty cells or cells containing only TerrainTypes, overlays etc.
21492149
- `Crit.AffectsHouses` can be used to customize houses that this Warhead can deal critical hits against.
2150-
- `Crit.AffectBelowPercent` and `Crit.AffectsAbovePercent` can be used to set the health percentage that targets must be below or above respectively to be affected by critical hits.
2150+
- `Crit.AffectBelowPercent` and `Crit.AffectsAbovePercent` can be used to set the health percentage that targets must be above and/or below/equal to respectively to be affected by critical hits. If target has zero health left this check is bypassed.
21512151
- `Crit.AnimList` can be used to set a list of animations used instead of Warhead's `AnimList` if Warhead deals a critical hit to even one target. If `Crit.AnimList.PickRandom` is set (defaults to `AnimList.PickRandom`) then the animation is chosen randomly from the list. If `Crit.AnimList.CreateAll` is set (defaults to `AnimList.CreateAll`), all animations from the list are created.
21522152
- `Crit.AnimOnAffectedTargets`, if set, makes the animation(s) from `Crit.AnimList` play on each affected target *in addition* to animation from Warhead's `AnimList` playing as normal instead of replacing `AnimList` animation. Note that because these animations are independent from `AnimList`, `Crit.AnimList.PickRandom` and `Crit.AnimList.CreateAll` will not default to their `AnimList` counterparts here and need to be explicitly set if needed.
21532153
- `Crit.ActiveChanceAnims` can be used to set animation to be always displayed at the Warhead's detonation coordinates if the current Warhead has a chance to critically hit. If more than one animation is listed, a random one is selected.
@@ -2685,7 +2685,7 @@ This function is only used as an additional scattering visual display, which is
26852685
*`Weapon target filter - different weapon used against enemies & allies as well as units & buildings in [Project Phantom](https://www.moddb.com/mods/project-phantom)*
26862686

26872687
- You can now specify which targets or houses a weapon can fire at. This also affects weapon selection, other than certain special cases where the selection is fixed.
2688-
- `CanTarget.MaxHealth` and `CanTarget.MinHealth` set health percentage thresholds for allowed targets (TechnoTypes only), maximum/minimum respectively.
2688+
- `CanTarget.MaxHealth` and `CanTarget.MinHealth` set health percentage thresholds for allowed targets (TechnoTypes only) that the target's health must be above and/or below/equal to, respectively. If target has zero health left this check is bypassed.
26892689

26902690
In `rulesmd.ini`:
26912691
```ini

src/Ext/Techno/Body.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,11 @@ bool TechnoExt::HandleDelayedFireWithPauseSequence(TechnoClass* pThis, int weapo
728728

729729
bool TechnoExt::IsHealthInThreshold(TechnoClass* pObject, double min, double max)
730730
{
731+
if (!pObject->Health && !pObject->GetType()->Strength)
732+
return true;
733+
731734
const double hp = pObject->GetHealthPercentage();
732-
return hp <= max && hp >= min;
735+
return (hp > 0 ? hp > min : hp >= min) && hp <= max;
733736
}
734737

735738
bool TechnoExt::CannotMove(UnitClass* pThis)

0 commit comments

Comments
 (0)