Skip to content
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

Warhead activation target health thresholds #1398

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This page lists all the individual contributions to the project by their author.
- Ability to disable shadow for debris & meteor animations
- Voxel light source position customization
- Voxel light source position and tilting fix
- Warhead activation target health thresholds
- **Uranusian (Thrifinesma)**:
- Mind Control enhancement
- Custom warhead splash list
Expand Down
14 changes: 14 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,20 @@ UseWeeds.ReadinessAnimationPercentage=0.9 ; double - when this many weeds

## Warheads

### Customizable Warhead trigger conditions

- It is now possible to make warheads only trigger when target's HP is above and/or below certain percentage.
- Both conditions need to evaluate to true in order for the warhead to trigger.
- 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`).

In `rulesmd.ini`:
```ini
[SOMEWARHEAD] ; WarheadType
AffectsAbovePercent=0.0 ; floating point value, percents or absolute
AffectsBelowPercent=1.0 ; floating point value, percents or absolute
EffectsRequireVerses=false ; boolean
```

### Customizable Warhead animation behaviour

- It is possible to make game play random animation from `AnimList` by setting `AnimList.PickRandom` to true. The result is similar to what `EMEffect=true` produces, however it comes with no side-effects (`EMEffect=true` prevents `Inviso=true` projectiles from snapping on targets, making them miss moving targets).
Expand Down
2 changes: 1 addition & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ DestroySound= ; Sound
All new Warhead effects
- Can be used with CellSpread and Ares' GenericWarhead superweapon where applicable.
- Cannot be used with `MindControl.Permanent=yes` of Ares.
- Respect `Verses` where applicable unless `EffectsRequireVerses` is set to false. If target has an active shield, its armor type is used instead unless warhead can penetrate the shield.
- Respect `Verses` where applicable unless `EffectsRequireVerses` is set to `false`. If target has an active shield, its armor type is used instead unless warhead can penetrate the shield.
```

### Break Mind Control on impact
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ New:
- `FireOnce` infantry sequence reset toggle (by Starkku)
- Assign Super Weapon cameo to any sidebar tab (by NetsuNegi)
- Customizing effect of level lighting on air units (by Starkku)
- Warhead activation target health thresholds (by Kerbiter)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
17 changes: 17 additions & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ bool WarheadTypeExt::ExtData::CanAffectTarget(TechnoClass* pTarget, TechnoExt::E
if (!pTarget)
return false;

auto hp = pTarget->GetHealthPercentage();

if (hp < this->AffectsAbovePercent)
return false;

if (this->AffectsBelowPercent < hp)
return false;

if (!this->EffectsRequireVerses)
return true;

Expand Down Expand Up @@ -266,6 +274,12 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->SuppressReflectDamage.Read(exINI, pSection, "SuppressReflectDamage");
this->SuppressReflectDamage_Types.Read(exINI, pSection, "SuppressReflectDamage.Types");

this->AffectsAbovePercent.Read(exINI, pSection, "AffectsAbovePercent");
this->AffectsBelowPercent.Read(exINI, pSection, "AffectsBelowPercent");

if (this->AffectsAbovePercent > this->AffectsBelowPercent)
Debug::Log("[Developer warning][%s] AffectsAbovePercent is bigger than AffectsBelowPercent, the warhead will never activate!\n", pSection);

// Convert.From & Convert.To
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);

Expand Down Expand Up @@ -480,6 +494,9 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
.Process(this->SuppressReflectDamage)
.Process(this->SuppressReflectDamage_Types)

.Process(this->AffectsAbovePercent)
.Process(this->AffectsBelowPercent)

.Process(this->InflictLocomotor)
.Process(this->RemoveInflictedLocomotor)

Expand Down
6 changes: 6 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ class WarheadTypeExt
Valueable<bool> SuppressReflectDamage;
ValueableVector<AttachEffectTypeClass*> SuppressReflectDamage_Types;

Valueable<double> AffectsAbovePercent;
Valueable<double> AffectsBelowPercent;

// Ares tags
// http://ares-developers.github.io/Ares-docs/new/warheads/general.html
Valueable<bool> AffectsEnemies;
Expand Down Expand Up @@ -300,6 +303,9 @@ class WarheadTypeExt
, SuppressReflectDamage { false }
, SuppressReflectDamage_Types {}

, AffectsAbovePercent { 0.0 }
, AffectsBelowPercent { 1.0 }

, AffectsEnemies { true }
, AffectsOwner {}
, EffectsRequireVerses { true }
Expand Down
Loading