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

[Highly Customized] Burst without delay #1467

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
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ This page lists all the individual contributions to the project by their author.
- Allow to change the speed of gas particles
- **CrimRecya**
- Fix `LimboKill` not working reliably
- Burst without delay
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand All @@ -380,6 +381,7 @@ This page lists all the individual contributions to the project by their author.
- Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode
- Skirmish AI "gather when MCV deploy" behavior dehardcode
- Global value of `RepairBaseNodes`
- Burst without delay
- **tyuah8** - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- **Aephiex** - initial fix for Ares academy not working on the initial payloads of vehicles built from a war factory
- **Ares developers**
Expand Down
10 changes: 10 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,16 @@ Burst.Delays=-1 ; integer - burst delays (comma-separated) for s
Burst.FireWithinSequence=false ; boolean
```

### Burst without delay

- In vanilla, vehicles and infantries will only fire once in one frame, even if their `ROF` or `BurstDelay` is set to 0. Now you can force units to fire all bursts in one frame by setting the `Burst.NoDelay` to true (useless for buildings yet).

In `rulesmd.ini`:
```ini
[SOMEWEAPON] ; WeaponType
Burst.NoDelay=false ; boolean
```

### Extra warhead detonations

- It is now possible to have same weapon detonate multiple Warheads on impact by listing `ExtraWarheads`. The warheads are detonated at same location as the main one, after it in listed order. This only works in cases where a projectile has been fired by a weapon and still remembers it when it is detonated (due to currently existing technical limitations, this excludes `AirburstWeapon`).
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ New:
- Allow infantry to use land sequences in water (by Starkku)
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku)
- Allow customizing charge turret delays per burst on a weapon (by Starkku)
- Burst without delay (by CrimRecya & TaranDahl)
- Unit `Speed` setting now accepts floating point values (by Starkku)

Vanilla fixes:
Expand Down
82 changes: 82 additions & 0 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,88 @@ DEFINE_HOOK(0x6F3C88, TechnoClass_GetFLH_BurstFLH_2, 0x6)
}
#pragma endregion

#pragma region NoBurstDelay

DEFINE_HOOK(0x5209EE, InfantryClass_UpdateFiring_BurstNoDelay, 0x5)
{
enum { SkipVanillaFire = 0x520A57 };

GET(InfantryClass* const, pThis, EBP);
GET(const int, wpIdx, ESI);
GET(AbstractClass* const, pTarget, EAX);

if (const auto pWeapon = pThis->GetWeapon(wpIdx)->WeaponType)
{
if (pWeapon->Burst > 1)
{
if (WeaponTypeExt::ExtMap.Find(pWeapon)->Burst_NoDelay)
{
if (pThis->Fire(pTarget, wpIdx))
{
if (!pThis->CurrentBurstIndex)
return SkipVanillaFire;

auto rof = pThis->RearmTimer.TimeLeft;
pThis->RearmTimer.Start(0);

for (auto i = pThis->CurrentBurstIndex; i != pWeapon->Burst && pThis->GetFireError(pTarget, wpIdx, true) == FireError::OK && pThis->Fire(pTarget, wpIdx); ++i)
{
rof = pThis->RearmTimer.TimeLeft;
pThis->RearmTimer.Start(0);
}

pThis->RearmTimer.Start(rof);
}

return SkipVanillaFire;
}
}
}

return 0;
}

DEFINE_HOOK(0x736F67, UnitClass_UpdateFiring_BurstNoDelay, 0x6)
{
enum { SkipVanillaFire = 0x737063 };

GET(UnitClass* const, pThis, ESI);
GET(const int, wpIdx, EDI);
GET(AbstractClass* const, pTarget, EAX);

if (const auto pWeapon = pThis->GetWeapon(wpIdx)->WeaponType)
{
if (pWeapon->Burst > 1)
{
if (WeaponTypeExt::ExtMap.Find(pWeapon)->Burst_NoDelay)
{
if (pThis->Fire(pTarget, wpIdx))
{
if (!pThis->CurrentBurstIndex)
return SkipVanillaFire;

auto rof = pThis->RearmTimer.TimeLeft;
pThis->RearmTimer.Start(0);

for (auto i = pThis->CurrentBurstIndex; i != pWeapon->Burst && pThis->GetFireError(pTarget, wpIdx, true) == FireError::OK && pThis->Fire(pTarget, wpIdx); ++i)
{
rof = pThis->RearmTimer.TimeLeft;
pThis->RearmTimer.Start(0);
}

pThis->RearmTimer.Start(rof);
}

return SkipVanillaFire;
}
}
}

return 0;
}

#pragma endregion

// Basically a hack to make game and Ares pick laser properties from non-Primary weapons.
DEFINE_HOOK(0x70E1A0, TechnoClass_GetTurretWeapon_LaserWeapon, 0x5)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->AttachEffect_CheckOnFirer.Read(exINI, pSection, "AttachEffect.CheckOnFirer");
this->AttachEffect_IgnoreFromSameSource.Read(exINI, pSection, "AttachEffect.IgnoreFromSameSource");
this->KickOutPassengers.Read(exINI, pSection, "KickOutPassengers");
this->Burst_NoDelay.Read(exINI, pSection, "Burst.NoDelay");
}

template <typename T>
Expand Down Expand Up @@ -160,6 +161,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->AttachEffect_CheckOnFirer)
.Process(this->AttachEffect_IgnoreFromSameSource)
.Process(this->KickOutPassengers)
.Process(this->Burst_NoDelay)
;
};

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class WeaponTypeExt
Valueable<bool> AttachEffect_CheckOnFirer;
Valueable<bool> AttachEffect_IgnoreFromSameSource;
Valueable<bool> KickOutPassengers;
Valueable<bool> Burst_NoDelay;

ExtData(WeaponTypeClass* OwnerObject) : Extension<WeaponTypeClass>(OwnerObject)
, DiskLaser_Radius { DiskLaserClass::Radius }
Expand Down Expand Up @@ -101,6 +102,7 @@ class WeaponTypeExt
, AttachEffect_CheckOnFirer { false }
, AttachEffect_IgnoreFromSameSource { false }
, KickOutPassengers { true }
, Burst_NoDelay { false }
{ }

int GetBurstDelay(int burstIndex) const;
Expand Down
Loading