From 49217b6f5d818dfaf9a5a5984ef7c851406f9734 Mon Sep 17 00:00:00 2001 From: lvjia Date: Sat, 31 May 2025 12:28:00 +0800 Subject: [PATCH] Add LaunchTheme option for superweapons --- docs/New-or-Enhanced-Logics.md | 11 +++++++++++ src/Ext/SWType/Body.cpp | 12 +++++++----- src/Ext/SWType/Body.h | 13 ++++++++----- src/Ext/SWType/FireSuperWeapon.cpp | 6 +++++- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 7d3f228f5f..f769165d6b 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1032,6 +1032,17 @@ In `rulesmd.ini`: TabIndex=1 ; integer ``` +### Play theme on superweapon launch + +- Superweapons can now trigger a soundtrack theme when fired using `LaunchTheme`. + - Provide a soundtrack theme ID to play immediately upon activation. + +In `rulesmd.ini`: +```ini +[SOMESW] ; SuperWeaponType +LaunchTheme= ; 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/src/Ext/SWType/Body.cpp b/src/Ext/SWType/Body.cpp index c009999ab2..367fe9113b 100644 --- a/src/Ext/SWType/Body.cpp +++ b/src/Ext/SWType/Body.cpp @@ -47,10 +47,11 @@ 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->SW_Next_RandomWeightsData) + .Process(this->SW_Next_RollChances) + .Process(this->ShowTimer_Priority) + .Process(this->LaunchTheme) + .Process(this->Convert_Pairs) .Process(this->ShowDesignatorRange) .Process(this->TabIndex) .Process(this->UseWeeds) @@ -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->LaunchTheme = pINI->ReadTheme(pSection, "LaunchTheme", this->LaunchTheme); 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..9147811e7e 100644 --- a/src/Ext/SWType/Body.h +++ b/src/Ext/SWType/Body.h @@ -56,7 +56,9 @@ class SWTypeExt Valueable SW_Next_IgnoreDesignators; ValueableVector SW_Next_RollChances; - Valueable ShowTimer_Priority; + Valueable ShowTimer_Priority; + + Valueable LaunchTheme; Valueable Detonate_Warhead; Valueable Detonate_Weapon; @@ -118,10 +120,11 @@ class SWTypeExt , SW_Next_IgnoreInhibitors { false } , SW_Next_IgnoreDesignators { true } , SW_Next_RollChances {} - , SW_Next_RandomWeightsData {} - , ShowTimer_Priority { 0 } - , Convert_Pairs {} - , ShowDesignatorRange { true } + , SW_Next_RandomWeightsData {} + , ShowTimer_Priority { 0 } + , LaunchTheme { -1 } + , Convert_Pairs {} + , ShowDesignatorRange { true } , TabIndex { 1 } , UseWeeds { false } , UseWeeds_Amount { RulesClass::Instance->WeedCapacity } diff --git a/src/Ext/SWType/FireSuperWeapon.cpp b/src/Ext/SWType/FireSuperWeapon.cpp index f467873c64..52d77bc4e4 100644 --- a/src/Ext/SWType/FireSuperWeapon.cpp +++ b/src/Ext/SWType/FireSuperWeapon.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -17,7 +18,10 @@ void SWTypeExt::FireSuperWeaponExt(SuperClass* pSW, const CellStruct& cell) { - auto const pTypeExt = SWTypeExt::ExtMap.Find(pSW->Type); + auto const pTypeExt = SWTypeExt::ExtMap.Find(pSW->Type); + + if(pTypeExt->LaunchTheme >= 0) + ThemeClass::Instance.Play(pTypeExt->LaunchTheme); if (pTypeExt->LimboDelivery_Types.size() > 0) pTypeExt->ApplyLimboDelivery(pSW->Owner);