Skip to content

Commit

Permalink
Blocked spelleffect on ridden chars if the spell has field or area fl…
Browse files Browse the repository at this point in the history
…ags. (#1237)

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.
  • Loading branch information
DavideRei authored Jul 20, 2024
1 parent 32c3a0e commit c9665c2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3792,3 +3792,10 @@ Added: 'H' shortcut for variables to get the value as hexadecimal.

26-06-2024, Jhobean
- Changed: @NPCRESTOCK References modification. Now SRC:Server I:NPC (Before it was always server)

30-06-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
2 changes: 1 addition & 1 deletion src/game/chars/CCharAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/chars/CCharAttacker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/game/chars/CCharNPCAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,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 !
Expand Down
6 changes: 4 additions & 2 deletions src/game/chars/CCharSpell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,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;
Expand Down Expand Up @@ -3536,6 +3536,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) + g_Rand.GetVal(iSkillLevel / 2); // randomize the potency
int iEffect = g_Cfg.GetSpellEffect(spell, iSkillLevel);
Expand Down Expand Up @@ -3922,7 +3924,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 = g_Rand.GetVal(30);
}
Expand Down

0 comments on commit c9665c2

Please sign in to comment.