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)
This commit is contained in:
KayenEQ 2014-09-23 09:15:02 -04:00
parent ec01e6c69b
commit c03a70651c
5 changed files with 29 additions and 18 deletions

View File

@ -1,6 +1,9 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 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
@ -8,7 +11,6 @@ Akkadius: #resetaa now covers the function of #resetaa and #refundaa
Akkadius: Removed #refundaa
Akkadius: Removed a lot of debug code for blob conversion
Akkadius: Changed status logging for loads/saves to Debug category
Kayen: Spell recourse effects / triggerable spell effects will now be applied AFTER the base spells effects have been applied (consistent with live)
== 09/21/2014 ==
Akkadius: Player Profile Blob to Database Conversion

View File

@ -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,17 +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);
}
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)

View File

@ -579,7 +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);
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);

View File

@ -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++)
@ -2739,6 +2741,15 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
}
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:

View File

@ -3647,7 +3647,6 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r
return false;
}
TrySpellTrigger(spelltar, spell_id);
if (IsValidSpell(spells[spell_id].RecourseLink))
SpellFinished(spells[spell_id].RecourseLink, this, 10, 0, -1, spells[spells[spell_id].RecourseLink].ResistDiff);