*Fix crash.

*Prevent applying cast time mod for spell twice.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-03-02 23:37:24 +01:00
parent 352df954f6
commit 1ebade03d5
6 changed files with 61 additions and 33 deletions
+1 -1
View File
@@ -2289,7 +2289,7 @@ void Spell::handle_immediate()
if (duration) if (duration)
{ {
//apply haste mods //apply haste mods
m_caster->ModSpellCastTime(m_spellInfo, duration); m_caster->ModSpellCastTime(m_spellInfo, duration, this);
// Apply duration mod // Apply duration mod
if(Player* modOwner = m_caster->GetSpellModOwner()) if(Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
+8 -8
View File
@@ -5698,14 +5698,14 @@ void Aura::PeriodicTick()
int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power); int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
//Viper sting and Drain Life take mana % amount from target, but not bigger than amount*2 of caster mana //Viper sting and Drain Life take mana % amount from target, but not bigger than amount*2 of caster mana
if ((m_spellProto->SpellFamilyName==SPELLFAMILY_WARLOCK && m_spellProto->SpellFamilyFlags[0]&0x10) if ((m_spellProto->SpellFamilyName==SPELLFAMILY_WARLOCK && m_spellProto->SpellFamilyFlags[0]&0x10)
|| (m_spellProto->SpellFamilyName==SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags[1]&0x80)) || (m_spellProto->SpellFamilyName==SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags[1]&0x80))
{ {
uint32 drain = m_target->GetMaxPower(power) * drain_amount /100; uint32 drain = m_target->GetMaxPower(power) * drain_amount /100;
if(drain > pCaster->GetMaxPower(power) * drain_amount / 50) if(drain > pCaster->GetMaxPower(power) * drain_amount / 50)
drain_amount = pCaster->GetMaxPower(power) * drain_amount / 50; drain_amount = pCaster->GetMaxPower(power) * drain_amount / 50;
else else
drain_amount = drain; drain_amount = drain;
} }
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
+8 -8
View File
@@ -2264,7 +2264,7 @@ void Spell::EffectApplyAura(uint32 i)
//mod duration of channeled aura by spell haste //mod duration of channeled aura by spell haste
if (IsChanneledSpell(m_spellInfo)) if (IsChanneledSpell(m_spellInfo))
caster->ModSpellCastTime(m_spellInfo, duration); caster->ModSpellCastTime(m_spellInfo, duration, this);
// if Aura removed and deleted, do not continue. // if Aura removed and deleted, do not continue.
if(duration== 0 && !(Aur->IsPermanent())) if(duration== 0 && !(Aur->IsPermanent()))
@@ -4766,13 +4766,13 @@ void Spell::EffectScriptEffect(uint32 effIndex)
unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE); unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE);
break; break;
} }
// Escape artist // Escape artist
case 20589: case 20589:
{ {
if(!unitTarget) if(!unitTarget)
return; return;
// It is said that removing effects by script should include dispel resist mods // It is said that removing effects by script should include dispel resist mods
unitTarget->RemoveSpellsCausingAuraWithDispel(SPELL_AURA_MOD_ROOT, this); unitTarget->RemoveSpellsCausingAuraWithDispel(SPELL_AURA_MOD_ROOT, this);
unitTarget->RemoveSpellsCausingAuraWithDispel(SPELL_AURA_MOD_DECREASE_SPEED, this); unitTarget->RemoveSpellsCausingAuraWithDispel(SPELL_AURA_MOD_DECREASE_SPEED, this);
} }
// Mirren's Drinking Hat // Mirren's Drinking Hat
+1 -1
View File
@@ -245,7 +245,7 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell)
int32 castTime = spellCastTimeEntry->CastTime; int32 castTime = spellCastTimeEntry->CastTime;
if (spell && spell->GetCaster()) if (spell && spell->GetCaster())
spell->GetCaster()->ModSpellCastTime(spellInfo, castTime); spell->GetCaster()->ModSpellCastTime(spellInfo, castTime, spell);
if (spellInfo->Attributes & SPELL_ATTR_RANGED && (!spell || !(spell->IsAutoRepeat()))) if (spellInfo->Attributes & SPELL_ATTR_RANGED && (!spell || !(spell->IsAutoRepeat())))
castTime += 500; castTime += 500;
+42 -14
View File
@@ -487,7 +487,7 @@ void Unit::RemoveSpellsCausingAuraWithDispel(AuraType auraType, Spell * spell)
if (*iter) if (*iter)
{ {
if (!(*iter)->GetDispelChance(spell)) if (!(*iter)->GetDispelChance( spell))
continue; continue;
RemoveAurasDueToSpell((*iter)->GetId()); RemoveAurasDueToSpell((*iter)->GetId());
if (!m_modAuras[auraType].empty()) if (!m_modAuras[auraType].empty())
@@ -4197,7 +4197,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
&& AurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]!= SPELL_AURA_DUMMY) && AurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]!= SPELL_AURA_DUMMY)
//don't stop channeling of scripted spells (this is actually a hack) //don't stop channeling of scripted spells (this is actually a hack)
{ {
caster->InterruptSpell(CURRENT_CHANNELED_SPELL); caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
} }
} }
} }
@@ -5485,14 +5485,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
triggered_spell_id = 56160; triggered_spell_id = 56160;
break; break;
} }
// Glyph of Dispel Magic // Glyph of Dispel Magic
case 55677: case 55677:
{ {
if(!target->IsFriendlyTo(this)) if(!target->IsFriendlyTo(this))
return false; return false;
basepoints0 = int32(target->GetMaxHealth() * triggerAmount / 100); basepoints0 = int32(target->GetMaxHealth() * triggerAmount / 100);
triggered_spell_id = 56131; triggered_spell_id = 56131;
break; break;
} }
// Oracle Healing Bonus ("Garments of the Oracle" set) // Oracle Healing Bonus ("Garments of the Oracle" set)
@@ -6330,6 +6330,35 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
} }
break; break;
} }
case SPELLFAMILY_POTION:
{
sLog.outError("It Procs!");
if (dummySpell->Id == 17619)
{
if (procSpell->Category==4) //potion category
{
for (uint8 i=0;i<3;i++)
{
if (procSpell->Effect[i]==SPELL_EFFECT_HEAL)
{
basepoints0 = damage * 0.4f;
triggered_spell_id = 21399;
}
else if (procSpell->Effect[i]==SPELL_EFFECT_ENERGIZE)
{
basepoints0 = CalculateSpellDamage(procSpell,i,procSpell->EffectBasePoints[i],this) * 0.4f;
triggered_spell_id = 21400;
}
else continue;
CastCustomSpell(this,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura);
}
if (triggered_spell_id)
return true;
return false;
}
}
}
default: default:
break; break;
} }
@@ -10272,13 +10301,13 @@ int32 Unit::ModSpellDuration(SpellEntry const* spellProto, uint8 effect_index, U
return duration>0 ? duration : 0; return duration>0 ? duration : 0;
} }
void Unit::ModSpellCastTime(SpellEntry const* spellProto, int32 & castTime) void Unit::ModSpellCastTime(SpellEntry const* spellProto, int32 & castTime, Spell const * spell)
{ {
if (!spellProto || castTime<0) if (!spellProto || castTime<0)
return; return;
//called from caster //called from caster
if(Player* modOwner = GetSpellModOwner()) if(Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CASTING_TIME, castTime); modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CASTING_TIME, castTime, spell);
if( !(spellProto->Attributes & (SPELL_ATTR_UNK4|SPELL_ATTR_UNK5)) ) if( !(spellProto->Attributes & (SPELL_ATTR_UNK4|SPELL_ATTR_UNK5)) )
castTime = int32( float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED)); castTime = int32( float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED));
@@ -11244,12 +11273,11 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
continue; continue;
procTriggered.push_back( ProcTriggeredData(spellProcEvent, itr->second) ); procTriggered.push_back( ProcTriggeredData(spellProcEvent, itr->second) );
} }
// Nothing found // Nothing found
if (procTriggered.empty()) if (procTriggered.empty())
return; return;
// Handle effects proceed this time // Handle effects proceed this time
for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i) for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i)
{ {
+1 -1
View File
@@ -1477,7 +1477,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target); int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target);
int32 CalcSpellDuration(SpellEntry const* spellProto); int32 CalcSpellDuration(SpellEntry const* spellProto);
int32 ModSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target, int32 duration); int32 ModSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target, int32 duration);
void ModSpellCastTime(SpellEntry const* spellProto, int32 & castTime); void ModSpellCastTime(SpellEntry const* spellProto, int32 & castTime, Spell const * spell=NULL);
float CalculateLevelPenalty(SpellEntry const* spellProto) const; float CalculateLevelPenalty(SpellEntry const* spellProto) const;
void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }