From bb2208f70346dda54328bbbed74e6e8ede82ae4b Mon Sep 17 00:00:00 2001 From: DavideRei <118212274+DavideRei@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:51:00 +0200 Subject: [PATCH] Blocked spelleffect on ridden chars if the spell has field or area flags. Fixed duration of hallucination spell. Fixed wrong layer for potion delay. Fixed wrong sound id for changing monster sounds schema. Fixed Attacker_GetHighestThreat: return -1 would make the NPC threat lesser than the ATTACKER_THREAT_TOLDBYMASTER and make CChar::NPC_GetAttackMotivation not work correctly for attacking pets. Fixed NPC_Act_Follow use combat target even if the npc is not in combat. --- Changelog.txt | 6 ++++++ src/game/chars/CCharAct.cpp | 2 +- src/game/chars/CCharAttacker.cpp | 2 +- src/game/chars/CCharNPCAct.cpp | 4 +++- src/game/chars/CCharSpell.cpp | 6 ++++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 13bf32317..7650ca5e8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3452,3 +3452,9 @@ Additionally, the problem of zig-zag issue following in the South direction has 13-03-2024, Jhobean - Added: Item properties functionnality:HITAREAPHYSICAL,HITAREAFIRE,HITAREACOLD,HITAREAPOISON,HITAREAENERGY,HITFIREBALL,HITHARM,HITLIGHTNING,HITMAGICARROW,REFLECTPHYSICALDAM +18-04-2024, DavideRei +- Fixed: hallucination spell duration (before it was fixed at 1000 seconds) +- Fixed: wrong layer checked for potion delay to set the memory name +- Modified: blocked spelleffect on ridden chars for spells with flag SPELLFLAG_FIELD or SPELLFLAG_AREA +- Fixed: NPC_Act_Follow use combat target even if the npc is not in combat +- Fixed: wrong highest threat when there are no attackers diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index 4a90c9469..1c2c21e8c 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -1591,7 +1591,7 @@ void CChar::SoundChar( CRESND_TYPE type ) default: if (id < 0x4D6) // before the crane sound the sound IDs are ordered in a way... id += (SOUND_TYPE)type; - else if (id < 0x5D5) // starting with the crane and ending before absymal infernal there's another scheme + else if (id < 0x5D4) // starting with the crane and ending before absymal infernal there's another scheme { switch (type) { diff --git a/src/game/chars/CCharAttacker.cpp b/src/game/chars/CCharAttacker.cpp index d582548d5..c43e8ecbd 100644 --- a/src/game/chars/CCharAttacker.cpp +++ b/src/game/chars/CCharAttacker.cpp @@ -116,7 +116,7 @@ int CChar::Attacker_GetHighestThreat() const { ADDTOCALLSTACK("CChar::Attacker_GetHighestThreat"); if (m_lastAttackers.empty()) - return -1; + return 0; int highThreat = 0; for (const LastAttackers & refAttacker : m_lastAttackers) diff --git a/src/game/chars/CCharNPCAct.cpp b/src/game/chars/CCharNPCAct.cpp index 7a5fb8c91..4b0dd754a 100644 --- a/src/game/chars/CCharNPCAct.cpp +++ b/src/game/chars/CCharNPCAct.cpp @@ -1278,8 +1278,10 @@ bool CChar::NPC_Act_Follow(bool fFlee, int maxDistance, bool fMoveAway) //If the NPC action is following somebody, directly assign the character from the m_Act_UID value. if (Skill_GetActive() == NPCACT_FOLLOW_TARG) pChar = m_Act_UID.CharFind(); - else + else if (Fight_IsActive()) pChar = m_Fight_Targ_UID.IsValidUID() ? m_Fight_Targ_UID.CharFind() : m_Act_UID.CharFind(); + else + pChar = m_Act_UID.CharFind(); if (pChar == nullptr) { // free to do as i wish ! diff --git a/src/game/chars/CCharSpell.cpp b/src/game/chars/CCharSpell.cpp index 239fd4481..7610d4f85 100644 --- a/src/game/chars/CCharSpell.cpp +++ b/src/game/chars/CCharSpell.cpp @@ -2039,7 +2039,7 @@ CItem * CChar::Spell_Effect_Create( SPELL_TYPE spell, LAYER_TYPE layer, int iEff switch ( layer ) { case LAYER_FLAG_Criminal: pSpell->SetName("Criminal Timer"); break; - case LAYER_FLAG_Potion: pSpell->SetName("Potion Cooldown"); break; + case LAYER_FLAG_PotionUsed: pSpell->SetName("Potion Cooldown"); break; case LAYER_FLAG_Drunk: pSpell->SetName("Drunk Effect"); break; case LAYER_FLAG_Hallucination: pSpell->SetName("Hallucination Effect"); break; case LAYER_FLAG_Murders: pSpell->SetName("Murder Decay"); break; @@ -3527,6 +3527,8 @@ bool CChar::OnSpellEffect( SPELL_TYPE spell, CChar * pCharSrc, int iSkillLevel, return false; if ( spell == SPELL_Poison_Field && IsStatFlag(STATF_POISONED) ) return false; + if (IsStatFlag(STATF_RIDDEN) && (pSpellDef->IsSpellType(SPELLFLAG_FIELD) || pSpellDef->IsSpellType(SPELLFLAG_AREA))) + return false; iSkillLevel = (iSkillLevel / 2) + Calc_GetRandVal(iSkillLevel / 2); // randomize the potency int iEffect = g_Cfg.GetSpellEffect(spell, iSkillLevel); @@ -3913,7 +3915,7 @@ bool CChar::OnSpellEffect( SPELL_TYPE spell, CChar * pCharSrc, int iSkillLevel, case SPELL_Hallucination: { - CItem * pItem = Spell_Effect_Create( spell, LAYER_FLAG_Hallucination, iEffect, 100*MSECS_PER_TENTH, pCharSrc ); + CItem * pItem = Spell_Effect_Create( spell, LAYER_FLAG_Hallucination, iEffect, iDuration, pCharSrc ); ASSERT(pItem); pItem->m_itSpell.m_spellcharges = Calc_GetRandVal(30); }