From 5fbec59fb95db6df9f6f29c96848afd16c54799a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20K=C4=B1l=C4=B1=C3=A7o=C4=9Flu?= Date: Sun, 23 Nov 2025 03:08:53 +0300 Subject: [PATCH 1/2] Sound and item effects for failed spells have been added to the sphere.ini setting #1458 --- Changelog.txt | 10 ++++++++++ src/game/CServerConfig.cpp | 8 ++++++++ src/game/CServerConfig.h | 4 ++++ src/game/chars/CCharSpell.cpp | 21 +++++++++++++++------ src/sphere.ini | 6 ++++++ 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index eb6bead1f..fea0889c3 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4077,3 +4077,13 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Changed: Object timers are now saved in worldsave files as TIMERMS, to avoid ambiguity and reliance on git build number to determine if TIMER expressed a number in seconds or milliseconds. - Changed: Added 5 seconds timeout to DNS hostname resolution at startup (avoid getting stuck when connectivity is enabled but not working). - Changed: CANMASK formatted in worldsave files as hexadecimal number, instead of decimal. + +23-11-2025, canerksk +- Added: Sound and item effects for failed spells have been added to the sphere.ini setting. Additionally, the local.Sound (r/w) variable has been added, in addition to the previously existing localCreateObject1 (r/w) variable. + @SpellFail or @Fail + local.Sound=0 / 05C + [sphere.ini]: + - Added MagicFizzleSound = 05C // ID of the effect that occurs when the cast fails/aborts + - Added MagicFizzleEffect = 03735 // The sound made when cast fails/aborts + + \ No newline at end of file diff --git a/src/game/CServerConfig.cpp b/src/game/CServerConfig.cpp index f62fceb54..eb15e93fd 100644 --- a/src/game/CServerConfig.cpp +++ b/src/game/CServerConfig.cpp @@ -83,6 +83,7 @@ CServerConfig::CServerConfig() m_iWordsOfPowerTalkMode = TALKMODE_SPELL; m_fEquippedCast = true; m_iMagicUnlockDoor = 900; + m_iSpellTimeout = 0; m_iSpell_Teleport_Effect_Staff = ITEMID_FX_FLAMESTRIKE; // drama @@ -92,6 +93,9 @@ CServerConfig::CServerConfig() m_iSpell_Teleport_Effect_NPC = ITEMID_FX_HEAL_EFFECT; m_iSpell_Teleport_Sound_NPC = 0x01fe; + m_iSpell_Magic_Fizzle_Sound = SOUND_SPELL_FIZZLE; + m_iSpell_Magic_Fizzle_Effect = ITEMID_FX_SPELL_FAIL; + // Decay m_iDecay_Item = 30ll * 60 * MSECS_PER_SEC; m_iDecay_CorpsePlayer = 7ll * 60 * MSECS_PER_SEC; @@ -600,6 +604,8 @@ enum RC_TYPE RC_LOGMASK, // GetLogMask RC_LOOTINGISACRIME, // m_fLootingIsACrime RC_LOSTNPCTELEPORT, // m_fLostNPCTeleport + RC_MAGICFIZZLEEFFECT, // m_iSpell_Magic_Fizzle_Effect + RC_MAGICFIZZLESOUND, // m_iSpell_Magic_Fizzle_Sound RC_MAGICFLAGS, RC_MAGICUNLOCKDOOR, // m_iMagicUnlockDoor RC_MANALOSSABORT, // m_fManaLossAbort @@ -895,6 +901,8 @@ const CAssocReg CServerConfig::sm_szLoadKeys[RC_QTY + 1] { "LOGMASK", { ELEM_VOID, 0 }}, // GetLogMask { "LOOTINGISACRIME", { ELEM_BOOL, static_castOFFSETOF(CServerConfig,m_fLootingIsACrime) }}, { "LOSTNPCTELEPORT", { ELEM_INT, static_castOFFSETOF(CServerConfig,m_iLostNPCTeleport) }}, + { "MAGICFIZZLEEFFECT", { ELEM_INT, static_cast OFFSETOF(CServerConfig,m_iSpell_Magic_Fizzle_Effect) }}, + { "MAGICFIZZLESOUND", { ELEM_INT, static_cast OFFSETOF(CServerConfig,m_iSpell_Magic_Fizzle_Sound) }}, { "MAGICFLAGS", { ELEM_MASK_INT,static_castOFFSETOF(CServerConfig,m_iMagicFlags) }}, { "MAGICUNLOCKDOOR", { ELEM_INT, static_castOFFSETOF(CServerConfig,m_iMagicUnlockDoor) }}, { "MANALOSSABORT", { ELEM_BOOL, static_castOFFSETOF(CServerConfig,m_fManaLossAbort) }}, diff --git a/src/game/CServerConfig.h b/src/game/CServerConfig.h index 534b6b677..34fe47fd2 100644 --- a/src/game/CServerConfig.h +++ b/src/game/CServerConfig.h @@ -324,6 +324,10 @@ extern class CServerConfig : public CResourceHolder SOUND_TYPE m_iSpell_Teleport_Sound_Players; // Sound sent when a Player teleports. ITEMID_TYPE m_iSpell_Teleport_Effect_Staff; // ID of the item shown when a Staff member teleports. SOUND_TYPE m_iSpell_Teleport_Sound_Staff; // Sound sent when a Staff member teleports. + + ITEMID_TYPE m_iSpell_Magic_Fizzle_Effect; // + SOUND_TYPE m_iSpell_Magic_Fizzle_Sound; // Sound sent when a fizzle. + int64 m_iSpellTimeout; // Timeout for spell targeting in seconds. // In Game Effects diff --git a/src/game/chars/CCharSpell.cpp b/src/game/chars/CCharSpell.cpp index 7c063ea16..60f1922bf 100644 --- a/src/game/chars/CCharSpell.cpp +++ b/src/game/chars/CCharSpell.cpp @@ -3316,7 +3316,8 @@ bool CChar::Spell_CastDone() void CChar::Spell_CastFail(bool fAbort) { ADDTOCALLSTACK("CChar::Spell_CastFail"); - ITEMID_TYPE iT1 = ITEMID_FX_SPELL_FAIL; + ITEMID_TYPE iEffectId = g_Cfg.m_iSpell_Magic_Fizzle_Effect; + SOUND_TYPE iSound = g_Cfg.m_iSpell_Magic_Fizzle_Sound; ushort iManaLoss = 0, iTithingLoss = 0; CSpellDef *pSpell = g_Cfg.GetSpellDef(m_atMagery.m_iSpell); @@ -3342,8 +3343,9 @@ void CChar::Spell_CastFail(bool fAbort) CScriptTriggerArgsPtr pScriptArgs = CScriptParserBufs::GetCScriptTriggerArgsPtr(); pScriptArgs->Init(m_atMagery.m_iSpell, iManaLoss, 0, m_Act_Prv_UID.ObjFind()); - pScriptArgs->m_VarsLocal.SetNum("CreateObject1",iT1); + pScriptArgs->m_VarsLocal.SetNum("CreateObject1", iEffectId); pScriptArgs->m_VarsLocal.SetNum("TithingLoss", iTithingLoss); + pScriptArgs->m_VarsLocal.SetNum("Sound", iSound); if ( IsTrigUsed(TRIGGER_SPELLFAIL) ) { @@ -3363,11 +3365,18 @@ void CChar::Spell_CastFail(bool fAbort) HUE_TYPE iColor = (HUE_TYPE)(pScriptArgs->m_VarsLocal.GetKeyNum("EffectColor")); dword dwRender = (dword)pScriptArgs->m_VarsLocal.GetKeyNum("EffectRender"); - iT1 = (ITEMID_TYPE)(ResGetIndex((dword)pScriptArgs->m_VarsLocal.GetKeyNum("CreateObject1"))); - if (iT1) - Effect(EFFECT_OBJ, iT1, this, 1, 30, false, iColor, dwRender); - Sound( SOUND_SPELL_FIZZLE ); + iEffectId = (ITEMID_TYPE)(ResGetIndex((dword)pScriptArgs->m_VarsLocal.GetKeyNum("CreateObject1"))); + iSound = (SOUND_TYPE)(pScriptArgs->m_VarsLocal.GetKeyNum("Sound")); + if (iEffectId != ITEMID_NOTHING) + { + Effect(EFFECT_OBJ, iEffectId, this, 1, 30, false, iColor, dwRender); + } + if (iSound != SOUND_NONE) + { + Sound(iSound); + } + if ( IsClientActive() ) GetClientActive()->addObjMessage( g_Cfg.GetDefaultMsg( DEFMSG_SPELL_GEN_FIZZLES ), this ); diff --git a/src/sphere.ini b/src/sphere.ini index 6efee0d72..5823a603d 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -1068,6 +1068,12 @@ HitPointPercentOnRez=10 // Amount of skill of lock picking needed to unlock a magically locked door MagicUnlockDoor=900 +// ID of the effect that occurs when the cast fails/aborts +MagicFizzleSound=05C + +// The sound made when cast fails/aborts +MagicFizzleEffect=03735 + // Teleport effect for GMs and players. Setting 0 disables the effect TeleportEffectNPC=0376a TeleportEffectPlayers=03728 From 8a2cf3113c6bd932c813a8ebbc9873b381923889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20K=C4=B1l=C4=B1=C3=A7o=C4=9Flu?= Date: Mon, 24 Nov 2025 08:48:56 +0300 Subject: [PATCH 2/2] Update Changelog.txt --- Changelog.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index fea0889c3..0a2e03ee4 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4079,11 +4079,11 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Changed: CANMASK formatted in worldsave files as hexadecimal number, instead of decimal. 23-11-2025, canerksk -- Added: Sound and item effects for failed spells have been added to the sphere.ini setting. Additionally, the local.Sound (r/w) variable has been added, in addition to the previously existing localCreateObject1 (r/w) variable. +- Added: Sound and item effects for failed spells have been added to the sphere.ini setting. Additionally, the local.Sound (r/w) variable has been added, in addition to the previously existing local.CreateObject1 (r/w) variable. @SpellFail or @Fail local.Sound=0 / 05C [sphere.ini]: - - Added MagicFizzleSound = 05C // ID of the effect that occurs when the cast fails/aborts - - Added MagicFizzleEffect = 03735 // The sound made when cast fails/aborts + - Added MagicFizzleSound = 05C // The sound made when cast fails/aborts + - Added MagicFizzleEffect = 03735 // ID of the effect that occurs when the cast fails/aborts \ No newline at end of file