From 8646791d1d7e248806710d3bf2719dbe31007788 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 29 May 2015 03:26:35 -0400 Subject: [PATCH] Proc buffs like the shissar rogue poisons have a level override This corrects the level in those cases. Probably should propagate the level overrides a bit more, but this fixes the main issues right now. --- zone/attack.cpp | 2 +- zone/client_packet.cpp | 2 +- zone/common.h | 1 + zone/mob.cpp | 24 ++++++++++++++---------- zone/mob.h | 10 +++++----- zone/spell_effects.cpp | 35 ++++++++++++++++++----------------- zone/spells.cpp | 18 +++++++++++------- 7 files changed, 51 insertions(+), 41 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index c5dfcc6d7..666cb19f8 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -4143,7 +4143,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, outapp->priority = 3; entity_list.QueueCloseClients(this, outapp, false, 200, 0, true); safe_delete(outapp); - ExecWeaponProc(nullptr, SpellProcs[i].spellID, on); + ExecWeaponProc(nullptr, SpellProcs[i].spellID, on, SpellProcs[i].level_override); CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, SpellProcs[i].base_spellID); } else { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 01046d7fb..ccb27a188 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -704,7 +704,7 @@ void Client::CompleteConnect() case SE_AddMeleeProc: case SE_WeaponProc: { - AddProcToWeapon(GetProcID(buffs[j1].spellid, x1), false, 100 + spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid); + AddProcToWeapon(GetProcID(buffs[j1].spellid, x1), false, 100 + spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid, buffs[j1].casterlevel); break; } case SE_DefensiveProc: diff --git a/zone/common.h b/zone/common.h index b2e4d5ed5..13a65f7c5 100644 --- a/zone/common.h +++ b/zone/common.h @@ -468,6 +468,7 @@ typedef struct uint16 spellID; uint16 chance; uint16 base_spellID; + int level_override; } tProc; struct Shielders_Struct { diff --git a/zone/mob.cpp b/zone/mob.cpp index f7348a869..7f6cb9fbf 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -263,15 +263,19 @@ Mob::Mob(const char* in_name, PermaProcs[j].spellID = SPELL_UNKNOWN; PermaProcs[j].chance = 0; PermaProcs[j].base_spellID = SPELL_UNKNOWN; + PermaProcs[j].level_override = -1; SpellProcs[j].spellID = SPELL_UNKNOWN; SpellProcs[j].chance = 0; SpellProcs[j].base_spellID = SPELL_UNKNOWN; + SpellProcs[j].level_override = -1; DefensiveProcs[j].spellID = SPELL_UNKNOWN; DefensiveProcs[j].chance = 0; DefensiveProcs[j].base_spellID = SPELL_UNKNOWN; + DefensiveProcs[j].level_override = -1; RangedProcs[j].spellID = SPELL_UNKNOWN; RangedProcs[j].chance = 0; RangedProcs[j].base_spellID = SPELL_UNKNOWN; + RangedProcs[j].level_override = -1; } for (i = 0; i < _MaterialCount; i++) @@ -3160,7 +3164,7 @@ int32 Mob::GetActSpellCasttime(uint16 spell_id, int32 casttime) { return casttime; } -void Mob::ExecWeaponProc(const ItemInst *inst, uint16 spell_id, Mob *on) { +void Mob::ExecWeaponProc(const ItemInst *inst, uint16 spell_id, Mob *on, int level_override) { // Changed proc targets to look up based on the spells goodEffect flag. // This should work for the majority of weapons. if(spell_id == SPELL_UNKNOWN || on->GetSpecialAbility(NO_HARM_FROM_CLIENT)) { @@ -3199,14 +3203,14 @@ void Mob::ExecWeaponProc(const ItemInst *inst, uint16 spell_id, Mob *on) { twinproc = true; if (IsBeneficialSpell(spell_id)) { - SpellFinished(spell_id, this, 10, 0, -1, spells[spell_id].ResistDiff, true); + SpellFinished(spell_id, this, 10, 0, -1, spells[spell_id].ResistDiff, true, level_override); if(twinproc) - SpellOnTarget(spell_id, this, false, false, 0, true); + SpellOnTarget(spell_id, this, false, false, 0, true, level_override); } else if(!(on->IsClient() && on->CastToClient()->dead)) { //dont proc on dead clients - SpellFinished(spell_id, on, 10, 0, -1, spells[spell_id].ResistDiff, true); + SpellFinished(spell_id, on, 10, 0, -1, spells[spell_id].ResistDiff, true, level_override); if(twinproc) - SpellOnTarget(spell_id, on, false, false, 0, true); + SpellOnTarget(spell_id, on, false, false, 0, true, level_override); } return; } @@ -5605,15 +5609,15 @@ void Mob::SendRemovePlayerState(PlayerState old_state) safe_delete(app); } -void Mob::SetCurrentSpeed(int in){ +void Mob::SetCurrentSpeed(int in){ if (current_speed != in) - { - current_speed = in; + { + current_speed = in; tar_ndx = 20; if (in == 0) { SetRunAnimSpeed(0); SetMoving(false); SendPosition(); } - } -} \ No newline at end of file + } +} diff --git a/zone/mob.h b/zone/mob.h index 896b9c71b..944b80d97 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -227,10 +227,10 @@ public: void CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot, uint16 mana_used, uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0); bool SpellFinished(uint16 spell_id, Mob *target, uint16 slot = 10, uint16 mana_used = 0, - uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0, bool isproc = false); + uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0, bool isproc = false, int level_override = -1); virtual bool SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect = false, - bool use_resist_adjust = false, int16 resist_adjust = 0, bool isproc = false); - virtual bool SpellEffect(Mob* caster, uint16 spell_id, float partial = 100); + bool use_resist_adjust = false, int16 resist_adjust = 0, bool isproc = false, int level_override = -1); + virtual bool SpellEffect(Mob* caster, uint16 spell_id, float partial = 100, int level_override = -1); virtual bool DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_center, CastAction_type &CastAction); virtual bool CheckFizzle(uint16 spell_id); @@ -536,7 +536,7 @@ public: bool HasDefensiveProcs() const; bool HasSkillProcs() const; bool HasSkillProcSuccess() const; - bool AddProcToWeapon(uint16 spell_id, bool bPerma = false, uint16 iChance = 3, uint16 base_spell_id = SPELL_UNKNOWN); + bool AddProcToWeapon(uint16 spell_id, bool bPerma = false, uint16 iChance = 3, uint16 base_spell_id = SPELL_UNKNOWN, int level_override = -1); bool RemoveProcFromWeapon(uint16 spell_id, bool bAll = false); bool HasProcs() const; bool IsCombatProc(uint16 spell_id); @@ -1077,7 +1077,7 @@ protected: void TryWeaponProc(const ItemInst* inst, const Item_Struct* weapon, Mob *on, uint16 hand = MainPrimary); void TrySpellProc(const ItemInst* inst, const Item_Struct* weapon, Mob *on, uint16 hand = MainPrimary); void TryWeaponProc(const ItemInst* weapon, Mob *on, uint16 hand = MainPrimary); - void ExecWeaponProc(const ItemInst* weapon, uint16 spell_id, Mob *on); + void ExecWeaponProc(const ItemInst* weapon, uint16 spell_id, Mob *on, int level_override = -1); virtual float GetProcChances(float ProcBonus, uint16 hand = MainPrimary); virtual float GetDefensiveProcChances(float &ProcBonus, float &ProcChance, uint16 hand = MainPrimary, Mob *on = nullptr); virtual float GetSpecialProcChances(uint16 hand); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index ce1d444fb..28f5518fa 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -44,7 +44,7 @@ extern WorldServer worldserver; // the spell can still fail here, if the buff can't stack // in this case false will be returned, true otherwise -bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) +bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_override) { int caster_level, buffslot, effect, effect_value, i; ItemInst *SummonedItem=nullptr; @@ -59,26 +59,27 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) const SPDat_Spell_Struct &spell = spells[spell_id]; bool c_override = false; - if(caster && caster->IsClient() && GetCastedSpellInvSlot() > 0) - { - const ItemInst* inst = caster->CastToClient()->GetInv().GetItem(GetCastedSpellInvSlot()); - if(inst) - { - if(inst->GetItem()->Click.Level > 0) - { + if (caster && caster->IsClient() && GetCastedSpellInvSlot() > 0) { + const ItemInst *inst = caster->CastToClient()->GetInv().GetItem(GetCastedSpellInvSlot()); + if (inst) { + if (inst->GetItem()->Click.Level > 0) { caster_level = inst->GetItem()->Click.Level; c_override = true; - } - else - { + } else { caster_level = caster ? caster->GetCasterLevel(spell_id) : GetCasterLevel(spell_id); } - } - else + } else if (level_override > 0) { + caster_level = level_override; + c_override = true; + } else { caster_level = caster ? caster->GetCasterLevel(spell_id) : GetCasterLevel(spell_id); - } - else + } + } else if (level_override > 0) { + caster_level = level_override; + c_override = true; + } else { caster_level = caster ? caster->GetCasterLevel(spell_id) : GetCasterLevel(spell_id); + } if(c_override) { @@ -1786,9 +1787,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) #endif if(spells[spell_id].base2[i] == 0) - AddProcToWeapon(procid, false, 100, spell_id); + AddProcToWeapon(procid, false, 100, spell_id, level_override); else - AddProcToWeapon(procid, false, spells[spell_id].base2[i]+100, spell_id); + AddProcToWeapon(procid, false, spells[spell_id].base2[i]+100, spell_id, level_override); break; } diff --git a/zone/spells.cpp b/zone/spells.cpp index f90335e31..7286ba0aa 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1897,7 +1897,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce // we can't interrupt in this, or anything called from this! // if you need to abort the casting, return false bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 mana_used, - uint32 inventory_slot, int16 resist_adjust, bool isproc) + uint32 inventory_slot, int16 resist_adjust, bool isproc, int level_override) { //EQApplicationPacket *outapp = nullptr; Mob *ae_center = nullptr; @@ -2060,14 +2060,14 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 return(false); } if (isproc) { - SpellOnTarget(spell_id, spell_target, false, true, resist_adjust, true); + SpellOnTarget(spell_id, spell_target, false, true, resist_adjust, true, level_override); } else { if (spells[spell_id].targettype == ST_TargetOptional){ if (!TrySpellProjectile(spell_target, spell_id)) return false; } - else if(!SpellOnTarget(spell_id, spell_target, false, true, resist_adjust, false)) { + else if(!SpellOnTarget(spell_id, spell_target, false, true, resist_adjust, false, level_override)) { if(IsBuffSpell(spell_id) && IsBeneficialSpell(spell_id)) { // Prevent mana usage/timers being set for beneficial buffs if(casting_spell_type == 1) @@ -3292,7 +3292,8 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) // and if you don't want effects just return false. interrupting here will // break stuff // -bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_resist_adjust, int16 resist_adjust, bool isproc) +bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_resist_adjust, int16 resist_adjust, + bool isproc, int level_override) { // well we can't cast a spell on target without a target @@ -3324,7 +3325,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r if(!IsValidSpell(spell_id)) return false; - uint16 caster_level = GetCasterLevel(spell_id); + uint16 caster_level = level_override > 0 ? level_override : GetCasterLevel(spell_id); Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s with effective caster level %d", spell_id, spelltar->GetName(), caster_level); @@ -3739,7 +3740,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r } // cause the effects to the target - if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness)) + if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness, level_override)) { // if SpellEffect returned false there's a problem applying the // spell. It's most likely a buff that can't stack. @@ -5098,7 +5099,7 @@ bool Mob::IsCombatProc(uint16 spell_id) { return false; } -bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 base_spell_id) { +bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 base_spell_id, int level_override) { if(spell_id == SPELL_UNKNOWN) return(false); @@ -5109,6 +5110,7 @@ bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 b PermaProcs[i].spellID = spell_id; PermaProcs[i].chance = iChance; PermaProcs[i].base_spellID = base_spell_id; + PermaProcs[i].level_override = level_override; Log.Out(Logs::Detail, Logs::Spells, "Added permanent proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; @@ -5121,6 +5123,7 @@ bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 b SpellProcs[i].spellID = spell_id; SpellProcs[i].chance = iChance; SpellProcs[i].base_spellID = base_spell_id;; + SpellProcs[i].level_override = level_override; Log.Out(Logs::Detail, Logs::Spells, "Added spell-granted proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; } @@ -5136,6 +5139,7 @@ bool Mob::RemoveProcFromWeapon(uint16 spell_id, bool bAll) { SpellProcs[i].spellID = SPELL_UNKNOWN; SpellProcs[i].chance = 0; SpellProcs[i].base_spellID = SPELL_UNKNOWN; + SpellProcs[i].level_override = -1; Log.Out(Logs::Detail, Logs::Spells, "Removed proc %d from slot %d", spell_id, i); } }