Skip to content

Modify Ammo on impact #1687

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

Open
wants to merge 14 commits 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 @@ -149,6 +149,7 @@ This page lists all the individual contributions to the project by their author.
- Warhead activation target health thresholds enhancements
- Event 606: AttachEffect is attaching to a Techno
- Linked superweapons
- Modify Ammo on impact
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 1 files
+3 −3 ScenarioClass.h
10 changes: 10 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,16 @@ LaunchSW.DisplayMoney.Offset=0,0 ; X,Y, pixels relative to default
Due to the nature of some superweapon types, not all superweapons are suitable for launch. **Please use with caution!**
```

### Modify Ammo on impact

- Warheads can now modify ammo of the affected objects.

In `rulesmd.ini`:
```ini
[SOMEWARHEAD] ; Warhead
Ammo=0 ; integer
```

### Parasite removal

- By default if unit takes negative damage from a Warhead (before `Verses` are calculated), any parasites infecting it are removed and deleted. This behaviour can now be customized to disable the removal for negative damage, or enable it for any arbitrary warhead.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ New:
- Draw visual effects for airburst weapons (by CrimRecya)
- Unit `Speed` setting now accepts floating point values (by Starkku)
- `Strafing` is now disabled by default when using `Trajectory` (by CrimRecya)
- Modify Ammo on impact (by FS-21)
- Skip target scanning function calling for unarmed technos (by TaranDahl & solar-III)

Vanilla fixes:
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
|| this->AttachEffects.RemoveGroups.size() > 0
|| this->BuildingSell
|| this->BuildingUndeploy
|| this->Ammo
);

char tempBuffer[32];
Expand Down Expand Up @@ -394,6 +395,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
else
this->SpawnsCrate_Weights.push_back(weight);
}

this->Ammo.Read(exINI, pSection, "Ammo");
}

template <typename T>
Expand Down Expand Up @@ -576,6 +579,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
.Process(this->DamageAreaTarget)

.Process(this->CanKill)

.Process(this->Ammo)
;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class WarheadTypeExt

Valueable<bool> CanKill;

Valueable<int> Ammo;

private:
Valueable<double> Shield_Respawn_Rate_InMinutes;
Valueable<double> Shield_SelfHealing_Rate_InMinutes;
Expand Down Expand Up @@ -396,6 +398,8 @@ class WarheadTypeExt
, KillWeapon_OnFirer_AffectsHouses { AffectedHouse::All }
, KillWeapon_Affects { AffectedTarget::All }
, KillWeapon_OnFirer_Affects { AffectedTarget::All }

, Ammo { 0 }
{ }

void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);
Expand Down Expand Up @@ -432,6 +436,7 @@ class WarheadTypeExt
void ApplyAttachEffects(TechnoClass* pTarget, HouseClass* pInvokerHouse, TechnoClass* pInvoker);
void ApplyBuildingUndeploy(TechnoClass* pTarget);
double GetCritChance(TechnoClass* pFirer) const;
void ApplyAmmoModifier(TechnoClass* pTarget);
};

class ExtContainer final : public Container<WarheadTypeExt>
Expand Down
12 changes: 12 additions & 0 deletions src/Ext/WarheadType/Detonate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ void WarheadTypeExt::ExtData::DetonateOnOneUnit(HouseClass* pHouse, TechnoClass*
if (this->Crit_CurrentChance > 0.0 && (!this->Crit_SuppressWhenIntercepted || !bulletWasIntercepted))
this->ApplyCrit(pHouse, pTarget, pOwner);

if (this->Ammo != 0)
this->ApplyAmmoModifier(pTarget);

if (this->Convert_Pairs.size() > 0)
this->ApplyConvert(pHouse, pTarget);

Expand Down Expand Up @@ -650,3 +653,12 @@ double WarheadTypeExt::ExtData::GetCritChance(TechnoClass* pFirer) const

return critChance + extraChance;
}

void WarheadTypeExt::ExtData::ApplyAmmoModifier(TechnoClass* pTarget)
{
int maxAmmo = pTarget->GetTechnoType()->Ammo;
int newCurrentAmmo = this->Ammo + pTarget->Ammo;

newCurrentAmmo = newCurrentAmmo < 0 ? 0 : newCurrentAmmo;
pTarget->Ammo = newCurrentAmmo > maxAmmo ? maxAmmo : newCurrentAmmo;
}
Loading