diff --git a/CREDITS.md b/CREDITS.md index 7ec395a368..30ebfeb4b1 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -533,6 +533,7 @@ This page lists all the individual contributions to the project by their author. - **Joshy** - Original FlyingStrings implementation - **CnCVK** - Original custom locomotors experiment - **ZΞPHYɌUS** - win/lose themes code +- **Codex** - SuperWeapon theme playback feature - **Neargye (Daniil Goncharov)** - [nameof library](https://github.com/Neargye/nameof) (MIT) - **ayylmao** - help with docs, extensive and thorough testing - **SMxReaver** - help with docs, extensive and thorough testing diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 7d3f228f5f..be9a426a84 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1032,6 +1032,16 @@ In `rulesmd.ini`: TabIndex=1 ; integer ``` +### SuperWeapon theme playback + +- `PlayTheme` can be used to specify a soundtrack theme that will start playing when the Super Weapon is fired. + +In `rulesmd.ini`: +```ini +[SOMESW] ; SuperWeaponType +PlayTheme= ; Soundtrack theme ID +``` + ### EMPulse settings - It is possible to customize which weapon a building with `EMPulseCannon=true` fires when an associated `Type=EMPulse` superweapon (**only** if `EMPulse.TargetSelf=false` or omitted) is fired by setting `EMPulse.WeaponIndex`. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 9ec4651894..272c946106 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -429,6 +429,7 @@ New: - Custom `SlavesFreeSound` (by TwinkleStar) - Allows jumpjet to crash without rotation (by TwinkleStar) - Customizable priority of superweapons timer sorting(by ststl) +- SuperWeapon theme playback on firing (by Codex) - Customizable aircraft spawner spawn delay (by Starkku) - Customizable `Cluster` scatter distance (by Starkku) - Customizable `FlakScatter` distance (by Starkku) diff --git a/src/Ext/SWType/Body.cpp b/src/Ext/SWType/Body.cpp index c009999ab2..ead5cf148f 100644 --- a/src/Ext/SWType/Body.cpp +++ b/src/Ext/SWType/Body.cpp @@ -47,12 +47,13 @@ void SWTypeExt::ExtData::Serialize(T& Stm) .Process(this->SW_Next_RealLaunch) .Process(this->SW_Next_IgnoreInhibitors) .Process(this->SW_Next_IgnoreDesignators) - .Process(this->SW_Next_RandomWeightsData) - .Process(this->SW_Next_RollChances) - .Process(this->ShowTimer_Priority) - .Process(this->Convert_Pairs) - .Process(this->ShowDesignatorRange) - .Process(this->TabIndex) + .Process(this->SW_Next_RandomWeightsData) + .Process(this->SW_Next_RollChances) + .Process(this->ShowTimer_Priority) + .Process(this->PlayTheme) + .Process(this->Convert_Pairs) + .Process(this->ShowDesignatorRange) + .Process(this->TabIndex) .Process(this->UseWeeds) .Process(this->UseWeeds_Amount) .Process(this->UseWeeds_StorageTimer) @@ -108,7 +109,8 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->SW_Next_IgnoreDesignators.Read(exINI, pSection, "SW.Next.IgnoreDesignators"); this->SW_Next_RollChances.Read(exINI, pSection, "SW.Next.RollChances"); - this->ShowTimer_Priority.Read(exINI, pSection, "ShowTimer.Priority"); + this->ShowTimer_Priority.Read(exINI, pSection, "ShowTimer.Priority"); + this->PlayTheme = pINI->ReadTheme(pSection, "PlayTheme", this->PlayTheme); this->EMPulse_WeaponIndex.Read(exINI, pSection, "EMPulse.WeaponIndex"); this->EMPulse_SuspendOthers.Read(exINI, pSection, "EMPulse.SuspendOthers"); diff --git a/src/Ext/SWType/Body.h b/src/Ext/SWType/Body.h index aae1713b62..64d1b371b3 100644 --- a/src/Ext/SWType/Body.h +++ b/src/Ext/SWType/Body.h @@ -56,7 +56,8 @@ class SWTypeExt Valueable SW_Next_IgnoreDesignators; ValueableVector SW_Next_RollChances; - Valueable ShowTimer_Priority; + Valueable ShowTimer_Priority; + Valueable PlayTheme; Valueable Detonate_Warhead; Valueable Detonate_Weapon; @@ -119,7 +120,8 @@ class SWTypeExt , SW_Next_IgnoreDesignators { true } , SW_Next_RollChances {} , SW_Next_RandomWeightsData {} - , ShowTimer_Priority { 0 } + , ShowTimer_Priority { 0 } + , PlayTheme { -1 } , Convert_Pairs {} , ShowDesignatorRange { true } , TabIndex { 1 } diff --git a/src/Ext/SWType/FireSuperWeapon.cpp b/src/Ext/SWType/FireSuperWeapon.cpp index f467873c64..849530ce41 100644 --- a/src/Ext/SWType/FireSuperWeapon.cpp +++ b/src/Ext/SWType/FireSuperWeapon.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -34,8 +35,11 @@ void SWTypeExt::FireSuperWeaponExt(SuperClass* pSW, const CellStruct& cell) if (pTypeExt->Convert_Pairs.size() > 0) pTypeExt->ApplyTypeConversion(pSW); - if (static_cast(pSW->Type->Type) == 28 && !pTypeExt->EMPulse_TargetSelf) // Ares' Type=EMPulse SW - pTypeExt->HandleEMPulseLaunch(pSW, cell); + if (static_cast(pSW->Type->Type) == 28 && !pTypeExt->EMPulse_TargetSelf) // Ares' Type=EMPulse SW + pTypeExt->HandleEMPulseLaunch(pSW, cell); + + if (pTypeExt->PlayTheme >= 0) + ThemeClass::Instance.Play(pTypeExt->PlayTheme); auto& sw_ext = HouseExt::ExtMap.Find(pSW->Owner)->SuperExts[pSW->Type->ArrayIndex]; sw_ext.ShotCount++;