diff --git a/changelog.txt b/changelog.txt index fdc882932..156244941 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,11 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) Uleat: Re-ordered server opcodes and handlers to give them some predictability of location (I need this for the inventory re-enumeration.) demonstar55: Added helper function bool EQEmu::IsTradeskill(uint32 skill) +== 09/23/2014 == +Kayen: Spell recourse effects will now be applied AFTER the base spells effects have been applied (consistent with live). +Kayen: SE_ApplySpell and SE_TriggerSpell will now be applied based on which effect slot they are used in (instead of always before all spell effects are checked). +Note: If a spell has multiple SE_TriggerSpell effects within it. Only one will be able to trigger. (If you want multiple spells use SE_ApplySpell) + == 09/22/2014 == Akkadius: #resetaa now covers the function of #resetaa and #refundaa - #resetaa will wipe all AA data, refund the spent points into the available points and send character to character select properly diff --git a/zone/attack.cpp b/zone/attack.cpp index a515a08c4..d52d2a6ba 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3331,10 +3331,13 @@ int32 Mob::ReduceAllDamage(int32 damage) if(damage <= 0) return damage; - if(spellbonuses.ManaAbsorbPercentDamage[0] && (GetMana() > damage * spellbonuses.ManaAbsorbPercentDamage[0] / 100)) { - damage -= (damage * spellbonuses.ManaAbsorbPercentDamage[0] / 100); - SetMana(GetMana() - damage); - TryTriggerOnValueAmount(false, true); + if(spellbonuses.ManaAbsorbPercentDamage[0]) { + int32 mana_reduced = damage * spellbonuses.ManaAbsorbPercentDamage[0] / 100; + if (GetMana() >= mana_reduced){ + damage -= mana_reduced; + SetMana(GetMana() - mana_reduced); + TryTriggerOnValueAmount(false, true); + } } CheckNumHitsRemaining(NUMHIT_IncomingDamage); diff --git a/zone/mob.cpp b/zone/mob.cpp index 77ff4938a..06e125aab 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3031,12 +3031,11 @@ void Mob::TriggerOnCast(uint32 focus_spell, uint32 spell_id, bool aa_trigger) } } -void Mob::TrySpellTrigger(Mob *target, uint32 spell_id) +bool Mob::TrySpellTrigger(Mob *target, uint32 spell_id, int effect) { - if(target == nullptr || !IsValidSpell(spell_id)) - { - return; - } + if(!target || !IsValidSpell(spell_id)) + return false; + int spell_trig = 0; // Count all the percentage chances to trigger for all effects for(int i = 0; i < EFFECT_COUNT; i++) @@ -3055,8 +3054,10 @@ void Mob::TrySpellTrigger(Mob *target, uint32 spell_id) if(MakeRandomInt(0, trig_chance) <= spells[spell_id].base[i]) { // If we trigger an effect then its over. - SpellFinished(spells[spell_id].base2[i], target, 10, 0, -1, spells[spell_id].ResistDiff); - break; + if (IsValidSpell(spells[spell_id].base2[i])){ + SpellFinished(spells[spell_id].base2[i], target, 10, 0, -1, spells[spell_id].ResistDiff); + return true; + } } else { @@ -3070,37 +3071,15 @@ void Mob::TrySpellTrigger(Mob *target, uint32 spell_id) // if the chances don't add to 100, then each effect gets a chance to fire, chance for no trigger as well. else { - for(int i = 0; i < EFFECT_COUNT; i++) + if(MakeRandomInt(0, 100) <= spells[spell_id].base[effect]) { - if (spells[spell_id].effectid[i] == SE_SpellTrigger) - { - if(MakeRandomInt(0, 100) <= spells[spell_id].base[i]) - { - SpellFinished(spells[spell_id].base2[i], target, 10, 0, -1, spells[spell_id].ResistDiff); - } - } - } - } -} - -void Mob::TryApplyEffect(Mob *target, uint32 spell_id) -{ - if(target == nullptr || !IsValidSpell(spell_id)) - { - return; - } - - for(int i = 0; i < EFFECT_COUNT; i++) - { - if (spells[spell_id].effectid[i] == SE_ApplyEffect) - { - if(MakeRandomInt(0, 100) <= spells[spell_id].base[i]) - { - if(target) - SpellFinished(spells[spell_id].base2[i], target, 10, 0, -1, spells[spell_id].ResistDiff); + if (IsValidSpell(spells[spell_id].base2[effect])){ + SpellFinished(spells[spell_id].base2[effect], target, 10, 0, -1, spells[spell_id].ResistDiff); + return true; //Only trigger once of these per spell effect. } } } + return false; } void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsPet) diff --git a/zone/mob.h b/zone/mob.h index 93682962c..cf6a032e5 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -579,8 +579,7 @@ public: void DoBuffWearOffEffect(uint32 index); void TryTriggerOnCast(uint32 spell_id, bool aa_trigger); void TriggerOnCast(uint32 focus_spell, uint32 spell_id, bool aa_trigger); - void TrySpellTrigger(Mob *target, uint32 spell_id); - void TryApplyEffect(Mob *target, uint32 spell_id); + bool TrySpellTrigger(Mob *target, uint32 spell_id, int effect); void TryTriggerOnValueAmount(bool IsHP = false, bool IsMana = false, bool IsEndur = false, bool IsPet = false); void TryTwincast(Mob *caster, Mob *target, uint32 spell_id); void TrySympatheticProc(Mob *target, uint32 spell_id); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index a81377f5d..9d7a93a7b 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -188,6 +188,8 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) if (!IsPowerDistModSpell(spell_id)) SetSpellPowerDistanceMod(0); + + bool SE_SpellTrigger_HasCast = false; // iterate through the effects in the spell for (i = 0; i < EFFECT_COUNT; i++) @@ -2729,6 +2731,25 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) Message(10, "The power of your next illusion spell will flow to your grouped target in your place."); break; } + + case SE_ApplyEffect: { + + if (caster && IsValidSpell(spells[spell_id].base2[i])){ + + if(MakeRandomInt(0, 100) <= spells[spell_id].base[i]) + caster->SpellFinished(spells[spell_id].base2[i], this, 10, 0, -1, spells[spell_id].ResistDiff); + } + break; + } + + case SE_SpellTrigger: { + + if (!SE_SpellTrigger_HasCast) { + if (caster && caster->TrySpellTrigger(this, spell_id, i)) + SE_SpellTrigger_HasCast = true; + } + break; + } // Handled Elsewhere case SE_ImmuneFleeing: @@ -2839,8 +2860,6 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) case SE_HealRate: case SE_SkillDamageTaken: case SE_FcSpellVulnerability: - case SE_SpellTrigger: - case SE_ApplyEffect: case SE_FcTwincast: case SE_DelayDeath: case SE_CastOnFadeEffect: @@ -6454,8 +6473,12 @@ void Mob::ResourceTap(int32 damage, uint16 spellid){ if (spells[spellid].max[i] && (damage > spells[spellid].max[i])) damage = spells[spellid].max[i]; - if (spells[spellid].base2[i] == 0) //HP Tap - SetHP((GetHP()+ damage)); + if (spells[spellid].base2[i] == 0){ //HP Tap + if (damage > 0) + HealDamage(damage); + else + Damage(this, -damage,0, SkillEvocation,false); + } if (spells[spellid].base2[i] == 1) //Mana Tap SetMana(GetMana() + damage); diff --git a/zone/spells.cpp b/zone/spells.cpp index b007cd311..a18eabe20 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -3606,108 +3606,9 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r spell_effectiveness = 100; } - // Recourse means there is a spell linked to that spell in that the recourse spell will - // be automatically casted on the casters group or the caster only depending on Targettype - // this is for things like dark empathy, shadow vortex - int recourse_spell=0; - recourse_spell = spells[spell_id].RecourseLink; - if(recourse_spell) - { - if(spells[recourse_spell].targettype == ST_Group || spells[recourse_spell].targettype == ST_GroupTeleport) - { - if(IsGrouped()) - { - Group *g = entity_list.GetGroupByMob(this); - if(g) - g->CastGroupSpell(this, recourse_spell); - else{ - SpellOnTarget(recourse_spell, this); -#ifdef GROUP_BUFF_PETS - if (GetPet()) - SpellOnTarget(recourse_spell, GetPet()); -#endif - } - } - else if(IsRaidGrouped() && IsClient()) - { - Raid *r = entity_list.GetRaidByClient(CastToClient()); - uint32 gid = 0xFFFFFFFF; - if(r) - gid = r->GetGroup(GetName()); - else - gid = 13; // Forces ungrouped spell casting - - if(gid < 12) - { - r->CastGroupSpell(this, recourse_spell, gid); - } - else{ - SpellOnTarget(recourse_spell, this); -#ifdef GROUP_BUFF_PETS - if (GetPet()) - SpellOnTarget(recourse_spell, GetPet()); -#endif - } - } - else if(HasOwner()) - { - if(GetOwner()->IsGrouped()) - { - Group *g = entity_list.GetGroupByMob(GetOwner()); - if(g) - g->CastGroupSpell(this, recourse_spell); - else{ - SpellOnTarget(recourse_spell, GetOwner()); - SpellOnTarget(recourse_spell, this); - } - } - else if(GetOwner()->IsRaidGrouped() && GetOwner()->IsClient()) - { - Raid *r = entity_list.GetRaidByClient(GetOwner()->CastToClient()); - uint32 gid = 0xFFFFFFFF; - if(r) - gid = r->GetGroup(GetOwner()->GetName()); - else - gid = 13; // Forces ungrouped spell casting - - if(gid < 12) - { - r->CastGroupSpell(this, recourse_spell, gid); - } - else - { - SpellOnTarget(recourse_spell, GetOwner()); - SpellOnTarget(recourse_spell, this); - } - } - else - { - SpellOnTarget(recourse_spell, GetOwner()); - SpellOnTarget(recourse_spell, this); - } - } - else - { - SpellOnTarget(recourse_spell, this); -#ifdef GROUP_BUFF_PETS - if (GetPet()) - SpellOnTarget(recourse_spell, GetPet()); -#endif - } - - } - else - { - SpellOnTarget(recourse_spell, this); - } - } - if(spelltar->spellbonuses.SpellDamageShield && IsDetrimentalSpell(spell_id)) spelltar->DamageShield(this, true); - TrySpellTrigger(spelltar, spell_id); - TryApplyEffect(spelltar, spell_id); - if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) { int32 aggro_amount = CheckAggroAmount(spell_id, isproc); mlog(SPELLS__CASTING, "Spell %d cast on %s generated %d hate", spell_id, spelltar->GetName(), aggro_amount); @@ -3746,7 +3647,9 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r return false; } - + if (IsValidSpell(spells[spell_id].RecourseLink)) + SpellFinished(spells[spell_id].RecourseLink, this, 10, 0, -1, spells[spells[spell_id].RecourseLink].ResistDiff); + if (IsDetrimentalSpell(spell_id)) { CheckNumHitsRemaining(NUMHIT_OutgoingSpells);