diff options
| -rw-r--r-- | sql/world_script_waypoints.sql | 88 | ||||
| -rw-r--r-- | src/game/SpellAuras.cpp | 15 | ||||
| -rw-r--r-- | src/game/SpellAuras.h | 2 | ||||
| -rw-r--r-- | src/game/SpellEffects.cpp | 69 | ||||
| -rw-r--r-- | src/game/SpellMgr.cpp | 15 | ||||
| -rw-r--r-- | src/game/SpellMgr.h | 16 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 38 | 
7 files changed, 120 insertions, 123 deletions
diff --git a/sql/world_script_waypoints.sql b/sql/world_script_waypoints.sql index 076a27b1e15..701de8ee4b0 100644 --- a/sql/world_script_waypoints.sql +++ b/sql/world_script_waypoints.sql @@ -1,44 +1,44 @@ --- This file contains all waypoints used by escortAI scripts
 -
 -/* GHOSTLANDS */
 -
 -DELETE FROM script_waypoint WHERE entry=16295;
 -INSERT INTO script_waypoint VALUES
 -(16295, 0, 7545.070000, -7359.870000, 162.354000, 4000, 'SAY_START'),
 -(16295, 1, 7550.048340, -7362.237793, 162.235657, 0, ''),
 -(16295, 2, 7566.976074, -7364.315430, 161.738770, 0, ''),
 -(16295, 3, 7578.830566, -7361.677734, 161.738770, 0, ''),
 -(16295, 4, 7590.969238, -7359.053711, 162.257660, 0, ''),
 -(16295, 5, 7598.354004, -7362.815430, 162.256683, 4000, 'SAY_PROGRESS_1'),
 -(16295, 6, 7605.861328, -7380.424316, 161.937073, 0, ''),
 -(16295, 7, 7605.295410, -7387.382813, 157.253998, 0, ''),
 -(16295, 8, 7606.131836, -7393.893555, 156.941925, 0, ''),
 -(16295, 9, 7615.207520, -7400.187012, 157.142639, 0, ''),
 -(16295, 10, 7618.956543, -7402.652832, 158.202042, 0, ''),
 -(16295, 11, 7636.850586, -7401.756836, 162.144791, 0, 'SAY_PROGRESS_2'),
 -(16295, 12, 7637.058105, -7404.944824, 162.206970, 4000, ''),
 -(16295, 13, 7636.910645, -7412.585449, 162.366425, 0, ''),
 -(16295, 14, 7637.607910, -7425.591797, 162.630661, 0, ''),
 -(16295, 15, 7637.816895, -7459.057129, 163.302704, 0, ''),
 -(16295, 16, 7638.859863, -7470.902344, 162.517059, 0, ''),
 -(16295, 17, 7641.395996, -7488.217285, 157.381287, 0, ''),
 -(16295, 18, 7634.455566, -7505.451660, 154.682159, 0, 'SAY_PROGRESS_3'),
 -(16295, 19, 7631.906738, -7516.948730, 153.597382, 0, ''),
 -(16295, 20, 7622.231445, -7537.037598, 151.587112, 0, ''),
 -(16295, 21, 7610.921875, -7550.670410, 149.639374, 0, ''),
 -(16295, 22, 7598.229004, -7562.551758, 145.953888, 0, ''),
 -(16295, 23, 7588.509277, -7577.755371, 148.294479, 0, ''),
 -(16295, 24, 7567.339355, -7608.456055, 146.006485, 0, ''),
 -(16295, 25, 7562.547852, -7617.417969, 148.097504, 0, ''),
 -(16295, 26, 7561.508789, -7645.064453, 151.245163, 0, ''),
 -(16295, 27, 7563.337402, -7654.652344, 151.227158, 0, ''),
 -(16295, 28, 7565.533691, -7658.296387, 151.248886, 0, ''),
 -(16295, 39, 7571.155762, -7659.118652, 151.244568, 0, ''),
 -(16295, 30, 7579.119629, -7662.213867, 151.651505, 0, 'quest complete'),
 -(16295, 31, 7603.768066, -7667.000488, 153.997726, 0, ''),
 -(16295, 32, 7603.768066, -7667.000488, 153.997726, 4000, 'SAY_END_1'),
 -(16295, 33, 7603.768066, -7667.000488, 153.997726, 8000, 'SAY_END_2'),
 -(16295, 34, 7603.768066, -7667.000488, 153.997726, 0, '');
 -
 -/* EOF */
 -
 +-- This file contains all waypoints used by escortAI scripts + +/* GHOSTLANDS */ + +DELETE FROM script_waypoint WHERE entry=16295; +INSERT INTO script_waypoint VALUES +(16295, 0, 7545.070000, -7359.870000, 162.354000, 4000, 'SAY_START'), +(16295, 1, 7550.048340, -7362.237793, 162.235657, 0, ''), +(16295, 2, 7566.976074, -7364.315430, 161.738770, 0, ''), +(16295, 3, 7578.830566, -7361.677734, 161.738770, 0, ''), +(16295, 4, 7590.969238, -7359.053711, 162.257660, 0, ''), +(16295, 5, 7598.354004, -7362.815430, 162.256683, 4000, 'SAY_PROGRESS_1'), +(16295, 6, 7605.861328, -7380.424316, 161.937073, 0, ''), +(16295, 7, 7605.295410, -7387.382813, 157.253998, 0, ''), +(16295, 8, 7606.131836, -7393.893555, 156.941925, 0, ''), +(16295, 9, 7615.207520, -7400.187012, 157.142639, 0, ''), +(16295, 10, 7618.956543, -7402.652832, 158.202042, 0, ''), +(16295, 11, 7636.850586, -7401.756836, 162.144791, 0, 'SAY_PROGRESS_2'), +(16295, 12, 7637.058105, -7404.944824, 162.206970, 4000, ''), +(16295, 13, 7636.910645, -7412.585449, 162.366425, 0, ''), +(16295, 14, 7637.607910, -7425.591797, 162.630661, 0, ''), +(16295, 15, 7637.816895, -7459.057129, 163.302704, 0, ''), +(16295, 16, 7638.859863, -7470.902344, 162.517059, 0, ''), +(16295, 17, 7641.395996, -7488.217285, 157.381287, 0, ''), +(16295, 18, 7634.455566, -7505.451660, 154.682159, 0, 'SAY_PROGRESS_3'), +(16295, 19, 7631.906738, -7516.948730, 153.597382, 0, ''), +(16295, 20, 7622.231445, -7537.037598, 151.587112, 0, ''), +(16295, 21, 7610.921875, -7550.670410, 149.639374, 0, ''), +(16295, 22, 7598.229004, -7562.551758, 145.953888, 0, ''), +(16295, 23, 7588.509277, -7577.755371, 148.294479, 0, ''), +(16295, 24, 7567.339355, -7608.456055, 146.006485, 0, ''), +(16295, 25, 7562.547852, -7617.417969, 148.097504, 0, ''), +(16295, 26, 7561.508789, -7645.064453, 151.245163, 0, ''), +(16295, 27, 7563.337402, -7654.652344, 151.227158, 0, ''), +(16295, 28, 7565.533691, -7658.296387, 151.248886, 0, ''), +(16295, 39, 7571.155762, -7659.118652, 151.244568, 0, ''), +(16295, 30, 7579.119629, -7662.213867, 151.651505, 0, 'quest complete'), +(16295, 31, 7603.768066, -7667.000488, 153.997726, 0, ''), +(16295, 32, 7603.768066, -7667.000488, 153.997726, 4000, 'SAY_END_1'), +(16295, 33, 7603.768066, -7667.000488, 153.997726, 8000, 'SAY_END_2'), +(16295, 34, 7603.768066, -7667.000488, 153.997726, 0, ''); + +/* EOF */ + diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 9313b7e6fd4..4f7ba18beb4 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -5245,21 +5245,6 @@ void Aura::HandleShapeshiftBoosts(bool apply)      m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/  } -bool Aura::GetDispelChance(Spell* spell) -{ -    // we assume that aura dispel chance is 100% on start -    // need formula for level difference based chance -    int32 miss_chance = 100; -    // Apply dispel mod from aura caster -    if (Unit *caster = GetCaster()) -    { -        if ( Player* modOwner = caster->GetSpellModOwner() ) -            modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, miss_chance, spell); -    } -    // Try dispel -    return roll_chance_i(miss_chance); -} -  void Aura::HandleAuraEmpathy(bool apply, bool Real)  {      if(m_target->GetTypeId() != TYPEID_UNIT) diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 7266f30f713..48611018f94 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -318,8 +318,6 @@ class TRINITY_DLL_SPEC Aura          void HandleAuraAllowOnlyAbility(bool apply, bool Real);          void HandleShapeshiftBoosts(bool apply); -        bool GetDispelChance(Spell* spell); -          // Allow Apply Aura Handler to modify and access m_AuraDRGroup          void setDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; }          DiminishingGroup getDiminishGroup() const { return m_AuraDRGroup; } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 66cc9f56d3e..9c1e6c36daf 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3464,8 +3464,9 @@ void Spell::EffectDispel(uint32 i)      if(!unitTarget)          return; -    // Fill possible dispel list -    std::vector <Aura *> dispel_list; +    //std::vector <DispelEntry> dispel_list; +    DispelSet dispel_list; +    DispelEntry entry;      // Create dispel mask by dispel type      uint32 dispel_type = m_spellInfo->EffectMiscValue[i]; @@ -3489,43 +3490,36 @@ void Spell::EffectDispel(uint32 i)                  if(positive == unitTarget->IsFriendlyTo(m_caster))                      continue;              } -            // Add every aura stack to dispel list -            for(uint32 stack_amount = 0; stack_amount < aur->GetStackAmount(); ++stack_amount) -                dispel_list.push_back(aur); +            entry.casterGuid = itr->second->GetCasterGUID(); +            entry.spellId = itr->second->GetId(); +            entry.caster = itr->second->GetCaster(); +            entry.stackAmount = itr->second->GetStackAmount(); +            dispel_list.insert (entry);          }      }      // Ok if exist some buffs for dispel try dispel it -    if (!dispel_list.empty()) +    if (uint32 list_size = dispel_list.size())      {          std::list < std::pair<uint32,uint64> > success_list;// (spell_id,casterGuid)          std::list < uint32 > fail_list;                     // spell_id -        int32 list_size = dispel_list.size(); +          // dispel N = damage buffs (or while exist buffs for dispel)          for (int32 count=0; count < damage && list_size > 0; ++count)          {              // Random select buff for dispel -            Aura *aur = dispel_list[urand(0, list_size-1)]; +            DispelSet::iterator itr=dispel_list.begin(); +            for (uint32 i=urand(0, list_size-1);i!=0;--i) +                itr++; -            SpellEntry const* spellInfo = aur->GetSpellProto(); -            // Base dispel chance -            // TODO: possible chance depend from spell level?? -            if (aur->GetDispelChance(this)) -                success_list.push_back(std::pair<uint32,uint64>(aur->GetId(),aur->GetCasterGUID())); -            else -                fail_list.push_back(aur->GetId()); -            // Remove buff from list for prevent doubles -            for (std::vector<Aura *>::iterator j = dispel_list.begin(); j != dispel_list.end(); ) +            if (GetDispelChance(this, itr->caster, itr->spellId))              { -                Aura *dispelled = *j; -                if (dispelled->GetId() == aur->GetId() && dispelled->GetCasterGUID() == aur->GetCasterGUID()) -                { -                    j = dispel_list.erase(j); -                    --list_size; -                    break; -                } -                else -                    ++j; +                entry.stackAmount-=1; +                if (!itr->stackAmount) +                    dispel_list.erase(itr); +                success_list.push_back(std::pair<uint32,uint64>(itr->spellId,itr->casterGuid));              } +            else +                fail_list.push_back(itr->spellId);          }          // Send success log and really remove auras          if (!success_list.empty()) @@ -6024,21 +6018,26 @@ void Spell::EffectDispelMechanic(uint32 i)      uint32 mechanic = m_spellInfo->EffectMiscValue[i]; -    std::deque <Aura *> dispel_list; +    DispelSet dispel_list; +    DispelEntry entry;      Unit::AuraMap& Auras = unitTarget->GetAuras(); -    for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter++) +    for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); iter++)      { -        if (!iter->second->GetDispelChance(this)) -            continue;          SpellEntry const *spell = iter->second->GetSpellProto(); -        if(spell->Mechanic == mechanic || spell->EffectMechanic[iter->second->GetEffIndex()] == mechanic) -            dispel_list.push_back(iter->second); +        if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & (1<<(mechanic-1))) +        { +            entry.casterGuid = iter->second->GetCasterGUID(); +            entry.spellId = iter->second->GetId(); +            entry.caster = iter->second->GetCaster(); +            dispel_list.insert (entry); +        }      } -    for(;!dispel_list.empty();) +    for(DispelSet::iterator itr = dispel_list.begin(); itr != dispel_list.end();++itr)      { -        unitTarget->RemoveAurasDueToSpell(dispel_list.front()->GetId()); -        dispel_list.pop_front(); +        entry = *itr; +        if (GetDispelChance(this, entry.caster, entry.spellId)) +            unitTarget->RemoveAurasByCasterSpell(entry.spellId, entry.casterGuid);      }  } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index e42e5dc4488..c9f804bdc18 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -236,6 +236,21 @@ int32 GetSpellMaxDuration(SpellEntry const *spellInfo)      return (du->Duration[2] == -1) ? -1 : abs(du->Duration[2]);  } +bool GetDispelChance(Spell* spell, Unit* caster, uint32 spellId) +{ +    // we assume that aura dispel chance is 100% on start +    // need formula for level difference based chance +    int32 miss_chance = 100; +    // Apply dispel mod from aura caster +    if (caster) +    { +        if ( Player* modOwner = caster->GetSpellModOwner() ) +            modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_DISPEL_CHANCE, miss_chance, spell); +    } +    // Try dispel +    return roll_chance_i(miss_chance); +} +  uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell)  {      SpellCastTimesEntry const *spellCastTimeEntry = sSpellCastTimesStore.LookupEntry(spellInfo->CastingTimeIndex); diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index e55ff3c89d2..190059f81c4 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -152,6 +152,7 @@ SpellSpecific GetSpellSpecific(uint32 spellId);  inline float GetSpellRadiusForHostile(SpellRadiusEntry const *radius) { return (radius ? radius->radiusHostile : 0); }  inline float GetSpellRadiusForFriend(SpellRadiusEntry const *radius) { return (radius ? radius->radiusFriend : 0); }  uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL); +bool GetDispelChance(Spell* spell, Unit* caster, uint32 spellId);  inline float GetSpellMinRangeForHostile(SpellRangeEntry const *range) { return (range ? range->minRangeHostile : 0); }  inline float GetSpellMaxRangeForHostile(SpellRangeEntry const *range) { return (range ? range->maxRangeHostile : 0); }  inline float GetSpellMinRangeForFriend(SpellRangeEntry const *range) { return (range ? range->minRangeFriend : 0); } @@ -161,6 +162,21 @@ inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { return spellIn  int32 GetSpellDuration(SpellEntry const *spellInfo);  int32 GetSpellMaxDuration(SpellEntry const *spellInfo); +struct DispelEntry +{ +    uint64 casterGuid; +    uint32 spellId; +    Unit * caster; +    uint8 stackAmount; + +    bool operator < (const DispelEntry & _Right) const +    { +        return (spellId != _Right.spellId ? spellId < _Right.spellId : casterGuid < _Right.casterGuid); +    } +}; + +typedef std::set < DispelEntry > DispelSet; +  inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect)  {      for(int i= 0; i < 3; ++i) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 720bcc55a0d..4fdb5b06d94 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -505,37 +505,22 @@ void Unit::RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID)  void Unit::RemoveSpellsCausingAuraWithDispel(AuraType auraType, Spell * spell)  {      if (auraType >= TOTAL_AURAS) return; +    DispelEntry entry; +    DispelSet dispel_list;      AuraList::iterator iter, next;      for (iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); iter = next)      { -        next = iter; -        ++next; - -        if (*iter) -        { -            if (!(*iter)->GetDispelChance( spell)) -                continue; -            RemoveAurasDueToSpell((*iter)->GetId()); -            if (!m_modAuras[auraType].empty()) -                next = m_modAuras[auraType].begin(); -            else -                return; -        } -    }     - -    std::deque <Aura *> dispel_list; - -    AuraList const& dispelAuras = GetAurasByType(auraType); -    for(AuraList::const_iterator itr = dispelAuras.begin(); itr != dispelAuras.end(); ++itr) -    { -        if (!(*iter)->GetDispelChance( spell)) -            continue; -        dispel_list.push_back(*iter); +        entry.casterGuid = (*iter)->GetCasterGUID(); +        entry.spellId = (*iter)->GetId(); +        entry.caster = (*iter)->GetCaster(); +        dispel_list.insert (entry);      } -    for(;!dispel_list.empty();) + +    for(DispelSet::iterator itr = dispel_list.begin(); itr != dispel_list.end();++itr)      { -        RemoveAurasDueToSpell(dispel_list.front()->GetId()); -        dispel_list.pop_front(); +        entry = *itr; +        if (GetDispelChance(spell, entry.caster, entry.spellId)) +            RemoveAurasByCasterSpell(entry.spellId, entry.casterGuid);      }  } @@ -4341,7 +4326,6 @@ void Unit::RemoveNotOwnSingleTargetAuras()          else              ++iter;      } -  }  void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)  | 
