Skip to content

Commit

Permalink
Add AmbientDamage.Warhead & IgnoreTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Jan 21, 2024
1 parent 4a74936 commit 6ebcfbb
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ This page lists all the individual contributions to the project by their author.
- Misc. singleplayer mission improvements
- Weapon effect obstacle interaction fix
- Fire particle rotation coordinate adjust toggle
- `AmbientDamage` warhead & main target ignore customization
- **Morton (MortonPL)**:
- `XDrawOffset` for animations
- Shield passthrough & absorption
Expand Down
11 changes: 11 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,17 @@ ShakeIsLocal=false ; boolean

## Weapons

### AmbientDamage customizations

- You can now specify separate Warhead used for `AmbientDamage` via `AmbientDamage.Warhead` or make it never apply to weapon's main target by setting `AmbientDamage.IgnoreTarget` to true.

In `rulesmd.ini`:
```ini
[SOMEWEAPON] ; WeaponType
AmbientDamage.Warhead= ; WarheadType
AmbientDamage.IgnoreTarget=false ; boolean
```

### Customizable disk laser radius

![image](_static/images/disklaser-radius-values-01.gif)
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 @@ -643,7 +643,7 @@ SW.Next.RandomWeightsN= ; List of integers.
In `rulesmd.ini`:
```ini
[SOMESW] ; Super Weapon
Detonate.Warhead= ; Warhead
Detonate.Warhead= ; WarheadType
Detonate.Weapon= ; WeaponType
Detonate.Damage= ; integer
Detonate.AtFirer=false ; boolean
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ New:
- Allow setting mission par times and related messages in `missionmd.ini` (by Starkku)
- Allow setting default singleplayer map loading screen and briefing offsets (by Starkku)
- Allow toggling whether or not fire particle systems adjust target coordinates when firer rotates (by Starkku)
- `AmbientDamage` warhead & main target ignore customization (by Starkku)
Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
37 changes: 37 additions & 0 deletions src/Ext/Techno/Hooks.WeaponEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,43 @@ DEFINE_HOOK(0x70CA64, TechnoClass_Railgun_Obstacles, 0x5)
return Continue;
}

DEFINE_HOOK(0x70C862, TechnoClass_Railgun_AmbientDamageIgnoreTarget1, 0x5)
{
enum { IgnoreTarget = 0x70CA59 };

GET_BASE(WeaponTypeClass*, pWeapon, 0x14);

if (WeaponTypeExt::ExtMap.Find(pWeapon)->AmbientDamage_IgnoreTarget)
return IgnoreTarget;

return 0;
}

DEFINE_HOOK(0x70CA8B, TechnoClass_Railgun_AmbientDamageIgnoreTarget2, 0x6)
{
enum { IgnoreTarget = 0x70CBB0 };

GET_BASE(WeaponTypeClass*, pWeapon, 0x14);
REF_STACK(DynamicVectorClass<ObjectClass*>, objects, STACK_OFFSET(0xC0, -0xAC));

if (WeaponTypeExt::ExtMap.Find(pWeapon)->AmbientDamage_IgnoreTarget)
{
R->EAX(objects.Count);
return IgnoreTarget;
}

return 0;
}

DEFINE_HOOK(0x70CBE0, TechnoClass_Railgun_AmbientDamageWarhead, 0x5)
{
GET(WeaponTypeClass*, pWeapon, EDI);

R->EDX(WeaponTypeExt::ExtMap.Find(pWeapon)->AmbientDamage_Warhead.Get(pWeapon->Warhead));

return 0;
}

// Do not adjust map coordinates for railgun or fire stream particles that are below cell coordinates.
DEFINE_HOOK(0x62B8BC, ParticleClass_CTOR_CoordAdjust, 0x6)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->OmniFire_TurnToTarget.Read(exINI, pSection, "OmniFire.TurnToTarget");
this->ExtraWarheads.Read(exINI, pSection, "ExtraWarheads");
this->ExtraWarheads_DamageOverrides.Read(exINI, pSection, "ExtraWarheads.DamageOverrides");
this->AmbientDamage_Warhead.Read(exINI, pSection, "AmbientDamage.Warhead");
this->AmbientDamage_IgnoreTarget.Read(exINI, pSection, "AmbientDamage.IgnoreTarget");
}

template <typename T>
Expand All @@ -84,6 +86,8 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->OmniFire_TurnToTarget)
.Process(this->ExtraWarheads)
.Process(this->ExtraWarheads_DamageOverrides)
.Process(this->AmbientDamage_Warhead)
.Process(this->AmbientDamage_IgnoreTarget)
;
};

Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class WeaponTypeExt
Valueable<bool> OmniFire_TurnToTarget;
ValueableVector<WarheadTypeClass*> ExtraWarheads;
ValueableVector<int> ExtraWarheads_DamageOverrides;
Nullable<WarheadTypeClass*> AmbientDamage_Warhead;
Valueable<bool> AmbientDamage_IgnoreTarget;

ExtData(WeaponTypeClass* OwnerObject) : Extension<WeaponTypeClass>(OwnerObject)
, DiskLaser_Radius { DiskLaserClass::Radius }
Expand All @@ -60,6 +62,8 @@ class WeaponTypeExt
, OmniFire_TurnToTarget { false }
, ExtraWarheads {}
, ExtraWarheads_DamageOverrides {}
, AmbientDamage_Warhead {}
, AmbientDamage_IgnoreTarget { false }
{ }

int GetBurstDelay(int burstIndex);
Expand Down

0 comments on commit 6ebcfbb

Please sign in to comment.