*Make range check dependent from target.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-02-14 15:56:04 +01:00
parent f506fde01e
commit 14d85a183e
15 changed files with 198 additions and 131 deletions
+6 -6
View File
@@ -508,13 +508,13 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mech
continue; continue;
//Check if the spell meets our range requirements //Check if the spell meets our range requirements
if (RangeMin && TempRange->maxRange < RangeMin) if (RangeMin && m_creature->GetSpellMinRangeForTarget(Target, TempRange) < RangeMin)
continue; continue;
if (RangeMax && TempRange->maxRange > RangeMax) if (RangeMax && m_creature->GetSpellMaxRangeForTarget(Target, TempRange) > RangeMax)
continue; continue;
//Check if our target is in range //Check if our target is in range
if (m_creature->IsWithinDistInMap(Target, TempRange->minRange) || !m_creature->IsWithinDistInMap(Target, TempRange->maxRange)) if (m_creature->IsWithinDistInMap(Target, m_creature->GetSpellMinRangeForTarget(Target, TempRange)) || !m_creature->IsWithinDistInMap(Target, m_creature->GetSpellMaxRangeForTarget(Target, TempRange)))
continue; continue;
//All good so lets add it to the spell list //All good so lets add it to the spell list
@@ -552,20 +552,20 @@ bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)
return false; return false;
//Unit is out of range of this spell //Unit is out of range of this spell
if (m_creature->GetDistance(Target) > TempRange->maxRange || m_creature->GetDistance(Target) < TempRange->minRange) if (m_creature->GetDistance(Target) > m_creature->GetSpellMaxRangeForTarget(Target, TempRange) || m_creature->GetDistance(Target) < m_creature->GetSpellMinRangeForTarget(Target, TempRange))
return false; return false;
return true; return true;
} }
float GetSpellMaxRange(uint32 id) float GetSpellMaxRangeForHostile(uint32 id)
{ {
SpellEntry const *spellInfo = GetSpellStore()->LookupEntry(id); SpellEntry const *spellInfo = GetSpellStore()->LookupEntry(id);
if(!spellInfo) return 0; if(!spellInfo) return 0;
SpellRangeEntry const *range = GetSpellRangeStore()->LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const *range = GetSpellRangeStore()->LookupEntry(spellInfo->rangeIndex);
if(!range) return 0; if(!range) return 0;
return range->maxRange; return range->maxRangeHostile;
} }
void FillSpellSummary() void FillSpellSummary()
+1 -1
View File
@@ -11,7 +11,7 @@
#include "CreatureAI.h" #include "CreatureAI.h"
#include "Creature.h" #include "Creature.h"
float GetSpellMaxRange(uint32 id); float GetSpellMaxRangeForHostile(uint32 id);
class SummonList : std::list<uint64> class SummonList : std::list<uint64>
{ {
@@ -333,7 +333,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
if(Charge_Timer < diff) if(Charge_Timer < diff)
{ {
Unit *target= SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRange(SPELL_CHARGE), true); Unit *target= SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRangeForHostile(SPELL_CHARGE), true);
DoCast(target, SPELL_CHARGE); DoCast(target, SPELL_CHARGE);
Charge_Timer = 30000; Charge_Timer = 30000;
}else Charge_Timer -= diff; }else Charge_Timer -= diff;
@@ -407,7 +407,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
{ {
DoYell(YELL_SURGE, LANG_UNIVERSAL, NULL); DoYell(YELL_SURGE, LANG_UNIVERSAL, NULL);
DoPlaySoundToSet(m_creature, SOUND_YELL_SURGE); DoPlaySoundToSet(m_creature, SOUND_YELL_SURGE);
Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRange(SPELL_SURGE), true); Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRangeForHostile(SPELL_SURGE), true);
DoCast(target, SPELL_SURGE); DoCast(target, SPELL_SURGE);
Surge_Timer = 15000 + rand()%5000; Surge_Timer = 15000 + rand()%5000;
}else Surge_Timer -= diff; }else Surge_Timer -= diff;
+4 -4
View File
@@ -1776,8 +1776,8 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
if(spellInfo->manaCost > GetPower(POWER_MANA)) if(spellInfo->manaCost > GetPower(POWER_MANA))
continue; continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange); float range = GetSpellMaxRangeForHostile(srange);
float minrange = GetSpellMinRange(srange); float minrange = GetSpellMinRangeForHostile(srange);
float dist = GetDistance(pVictim); float dist = GetDistance(pVictim);
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue; // continue;
@@ -1822,8 +1822,8 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
if(spellInfo->manaCost > GetPower(POWER_MANA)) if(spellInfo->manaCost > GetPower(POWER_MANA))
continue; continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange); float range = GetSpellMaxRangeForFriend(srange);
float minrange = GetSpellMinRange(srange); float minrange = GetSpellMinRangeForFriend( srange);
float dist = GetDistance(pVictim); float dist = GetDistance(pVictim);
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue; // continue;
+14 -1
View File
@@ -826,7 +826,20 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
if(!trapSpell) // checked at load already if(!trapSpell) // checked at load already
return; return;
float range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex)); float range;
SpellRangeEntry const * srentry = sSpellRangeStore.LookupEntry(trapSpell->rangeIndex);
//get owner to check hostility of GameObject
if (GetSpellMaxRangeForHostile(srentry) == GetSpellMaxRangeForHostile(srentry))
range = GetSpellMaxRangeForHostile(srentry);
else
{
Unit * owner=GetOwner();
if (owner)
range = owner->GetSpellMaxRangeForTarget(target, srentry);
else
//if no owner assume that object is hostile to target
range = GetSpellMaxRangeForHostile(srentry);
}
// search nearest linked GO // search nearest linked GO
GameObject* trapGO = NULL; GameObject* trapGO = NULL;
+40 -33
View File
@@ -474,7 +474,7 @@ void Spell::FillTargetMap()
{ {
// non-standard target selection // non-standard target selection
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
float max_range = GetSpellMaxRange(srange); float max_range = GetSpellMaxRangeForHostile(srange);
WorldObject* result = NULL; WorldObject* result = NULL;
Trinity::CannibalizeObjectCheck u_check(m_caster, max_range); Trinity::CannibalizeObjectCheck u_check(m_caster, max_range);
@@ -1438,11 +1438,17 @@ Unit* Spell::SearchNearbyTarget(float radius, SpellTargets TargetType, uint32 en
void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
{ {
float radius; float radius_h, radius_f;
if (m_spellInfo->EffectRadiusIndex[i]) if (m_spellInfo->EffectRadiusIndex[i])
radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); {
radius_h = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
radius_f = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
}
else else
radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); {
radius_h = GetSpellMaxRangeForHostile(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
radius_f = GetSpellMaxRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
}
//Chain: 2, 6, 22, 25, 45, 77 //Chain: 2, 6, 22, 25, 45, 77
uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i];
@@ -1459,7 +1465,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
{ {
if(Player* modOwner = m_originalCaster->GetSpellModOwner()) if(Player* modOwner = m_originalCaster->GetSpellModOwner())
{ {
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius,this); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius_f,this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius_h,this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this);
} }
} }
@@ -1490,13 +1497,13 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
TagUnitMap.push_back(pet); TagUnitMap.push_back(pet);
break; break;
case TARGET_UNIT_PARTY_CASTER: case TARGET_UNIT_PARTY_CASTER:
m_caster->GetPartyMember(TagUnitMap, radius); m_caster->GetPartyMember(TagUnitMap, radius_f);
break; break;
case TARGET_UNIT_RAID: case TARGET_UNIT_RAID:
//if(Unit *target = m_targets.getUnitTarget()) //if(Unit *target = m_targets.getUnitTarget())
// TagUnitMap.push_back(target); // TagUnitMap.push_back(target);
//else //else
m_caster->GetRaidMember(TagUnitMap, radius); m_caster->GetRaidMember(TagUnitMap, radius_f);
TagUnitMap.push_back(m_caster); TagUnitMap.push_back(m_caster);
break; break;
} }
@@ -1524,19 +1531,19 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
TagUnitMap.push_back(target); TagUnitMap.push_back(target);
break; break;
case TARGET_UNIT_PARTY_TARGET: case TARGET_UNIT_PARTY_TARGET:
target->GetPartyMember(TagUnitMap, radius); target->GetPartyMember(TagUnitMap, radius_f);
break; break;
case TARGET_UNIT_TARGET_ENEMY: case TARGET_UNIT_TARGET_ENEMY:
if(EffectChainTarget <= 1) if(EffectChainTarget <= 1)
TagUnitMap.push_back(SelectMagnetTarget()); TagUnitMap.push_back(SelectMagnetTarget());
else if(SelectMagnetTarget()) //TODO: chain target should also use magnet target else if(SelectMagnetTarget()) //TODO: chain target should also use magnet target
SearchChainTarget(TagUnitMap, radius, EffectChainTarget, SPELL_TARGETS_ENEMY); SearchChainTarget(TagUnitMap, radius_h, EffectChainTarget, SPELL_TARGETS_ENEMY);
break; break;
case TARGET_UNIT_CHAINHEAL: case TARGET_UNIT_CHAINHEAL:
if(EffectChainTarget <= 1) if(EffectChainTarget <= 1)
TagUnitMap.push_back(target); TagUnitMap.push_back(target);
else else
SearchChainTarget(TagUnitMap, radius, EffectChainTarget, SPELL_TARGETS_CHAINHEAL); SearchChainTarget(TagUnitMap, radius_f, EffectChainTarget, SPELL_TARGETS_CHAINHEAL);
break; break;
} }
}break; }break;
@@ -1583,17 +1590,17 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
case TARGET_UNIT_AREA_ENEMY_GROUND: case TARGET_UNIT_AREA_ENEMY_GROUND:
m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;
case TARGET_UNIT_AREA_ENEMY: case TARGET_UNIT_AREA_ENEMY:
SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ENEMY); SearchAreaTarget(TagUnitMap, radius_h, PUSH_DEST_CENTER, SPELL_TARGETS_ENEMY);
break; break;
case TARGET_UNIT_AREA_ALLY_GROUND: case TARGET_UNIT_AREA_ALLY_GROUND:
m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;
case TARGET_UNIT_AREA_ALLY: case TARGET_UNIT_AREA_ALLY:
SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ALLY); SearchAreaTarget(TagUnitMap, radius_f, PUSH_DEST_CENTER, SPELL_TARGETS_ALLY);
break; break;
case TARGET_UNIT_AREA_PARTY_GROUND: case TARGET_UNIT_AREA_PARTY_GROUND:
m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;
case TARGET_UNIT_AREA_PARTY: case TARGET_UNIT_AREA_PARTY:
m_caster->GetPartyMember(TagUnitMap, radius); m_caster->GetPartyMember(TagUnitMap, radius_f);
break; break;
case TARGET_UNIT_AREA_ENTRY_GROUND: case TARGET_UNIT_AREA_ENTRY_GROUND:
m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;
@@ -1603,7 +1610,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id); SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id);
if(lower==upper) if(lower==upper)
{ {
SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ENEMY); SearchAreaTarget(TagUnitMap, radius_h, PUSH_DEST_CENTER, SPELL_TARGETS_ENEMY);
sLog.outErrorDb("Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", m_spellInfo->Id, m_caster->GetEntry()); sLog.outErrorDb("Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", m_spellInfo->Id, m_caster->GetEntry());
break; break;
} }
@@ -1615,7 +1622,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
sLog.outError( "SPELL: spell ID %u requires non-creature target\n", m_spellInfo->Id ); sLog.outError( "SPELL: spell ID %u requires non-creature target\n", m_spellInfo->Id );
continue; continue;
} }
SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ENTRY, i_spellST->second.targetEntry); SearchAreaTarget(TagUnitMap, radius_f, PUSH_DEST_CENTER, SPELL_TARGETS_ENTRY, i_spellST->second.targetEntry);
} }
} }
break; break;
@@ -1662,38 +1669,38 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
case TARGET_IN_FRONT_OF_CASTER: case TARGET_IN_FRONT_OF_CASTER:
case TARGET_UNIT_CONE_ENEMY_UNKNOWN: case TARGET_UNIT_CONE_ENEMY_UNKNOWN:
if(m_customAttr & SPELL_ATTR_CU_CONE_BACK) if(m_customAttr & SPELL_ATTR_CU_CONE_BACK)
SearchAreaTarget(TagUnitMap, radius, PUSH_IN_BACK, SPELL_TARGETS_ENEMY); SearchAreaTarget(TagUnitMap, radius_h, PUSH_IN_BACK, SPELL_TARGETS_ENEMY);
else if(m_customAttr & SPELL_ATTR_CU_CONE_LINE) else if(m_customAttr & SPELL_ATTR_CU_CONE_LINE)
SearchAreaTarget(TagUnitMap, radius, PUSH_IN_LINE, SPELL_TARGETS_ENEMY); SearchAreaTarget(TagUnitMap, radius_h, PUSH_IN_LINE, SPELL_TARGETS_ENEMY);
else else
SearchAreaTarget(TagUnitMap, radius, PUSH_IN_FRONT, SPELL_TARGETS_ENEMY); SearchAreaTarget(TagUnitMap, radius_h, PUSH_IN_FRONT, SPELL_TARGETS_ENEMY);
break; break;
case TARGET_UNIT_CONE_ALLY: case TARGET_UNIT_CONE_ALLY:
SearchAreaTarget(TagUnitMap, radius, PUSH_IN_FRONT, SPELL_TARGETS_ALLY); SearchAreaTarget(TagUnitMap, radius_f, PUSH_IN_FRONT, SPELL_TARGETS_ALLY);
break; break;
// nearby target // nearby target
case TARGET_UNIT_NEARBY_ALLY: case TARGET_UNIT_NEARBY_ALLY:
case TARGET_UNIT_NEARBY_ALLY_UNK: case TARGET_UNIT_NEARBY_ALLY_UNK:
if(!m_targets.getUnitTarget()) if(!m_targets.getUnitTarget())
m_targets.setUnitTarget(SearchNearbyTarget(radius, SPELL_TARGETS_ALLY)); m_targets.setUnitTarget(SearchNearbyTarget(radius_f, SPELL_TARGETS_ALLY));
if(m_targets.getUnitTarget()) if(m_targets.getUnitTarget())
{ {
if(EffectChainTarget <= 1) if(EffectChainTarget <= 1)
TagUnitMap.push_back(m_targets.getUnitTarget()); TagUnitMap.push_back(m_targets.getUnitTarget());
else else
SearchChainTarget(TagUnitMap, radius, EffectChainTarget, SPELL_TARGETS_ALLY); SearchChainTarget(TagUnitMap, radius_f, EffectChainTarget, SPELL_TARGETS_ALLY);
} }
break; break;
case TARGET_UNIT_NEARBY_ENEMY: case TARGET_UNIT_NEARBY_ENEMY:
if(!m_targets.getUnitTarget()) if(!m_targets.getUnitTarget())
m_targets.setUnitTarget(SearchNearbyTarget(radius, SPELL_TARGETS_ENEMY)); m_targets.setUnitTarget(SearchNearbyTarget(radius_h, SPELL_TARGETS_ENEMY));
if(m_targets.getUnitTarget()) if(m_targets.getUnitTarget())
{ {
if(EffectChainTarget <= 1) if(EffectChainTarget <= 1)
TagUnitMap.push_back(m_targets.getUnitTarget()); TagUnitMap.push_back(m_targets.getUnitTarget());
else else
SearchChainTarget(TagUnitMap, radius, EffectChainTarget, SPELL_TARGETS_ENEMY); SearchChainTarget(TagUnitMap, radius_h, EffectChainTarget, SPELL_TARGETS_ENEMY);
} }
break; break;
case TARGET_SCRIPT: case TARGET_SCRIPT:
@@ -1710,7 +1717,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
} }
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange); float range = GetSpellMaxRangeForHostile(srange);
Creature* creatureScriptTarget = NULL; Creature* creatureScriptTarget = NULL;
GameObject* goScriptTarget = NULL; GameObject* goScriptTarget = NULL;
@@ -1805,7 +1812,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
Player* Target = itr->getSource(); Player* Target = itr->getSource();
// IsHostileTo check duel and controlled by enemy // IsHostileTo check duel and controlled by enemy
if( Target && targetPlayer->IsWithinDistInMap(Target, radius) && if( Target && targetPlayer->IsWithinDistInMap(Target, radius_f) &&
targetPlayer->getClass() == Target->getClass() && targetPlayer->getClass() == Target->getClass() &&
!m_caster->IsHostileTo(Target) ) !m_caster->IsHostileTo(Target) )
{ {
@@ -1836,7 +1843,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
float x, y, z, angle, dist; float x, y, z, angle, dist;
float objSize = m_caster->GetObjectSize(); float objSize = m_caster->GetObjectSize();
dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); dist = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(dist < objSize) if(dist < objSize)
dist = objSize; dist = objSize;
else if(cur == TARGET_DEST_CASTER_RANDOM) else if(cur == TARGET_DEST_CASTER_RANDOM)
@@ -1884,7 +1891,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
float x, y, z, angle, dist; float x, y, z, angle, dist;
float objSize = target->GetObjectSize(); float objSize = target->GetObjectSize();
dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); dist = target->GetSpellRadiusForTarget(target, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(dist < objSize) if(dist < objSize)
dist = objSize; dist = objSize;
else if(cur == TARGET_DEST_CASTER_RANDOM) else if(cur == TARGET_DEST_CASTER_RANDOM)
@@ -1920,7 +1927,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
float x, y, z, angle, dist; float x, y, z, angle, dist;
dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); dist = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if (cur == TARGET_DEST_DEST_RANDOM) if (cur == TARGET_DEST_DEST_RANDOM)
dist *= rand_norm(); dist *= rand_norm();
@@ -4325,7 +4332,7 @@ uint8 Spell::CanCast(bool strict)
case SPELL_EFFECT_LEAP: case SPELL_EFFECT_LEAP:
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER: case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
{ {
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float dis = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation()); float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation());
float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation()); float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation());
// teleport a bit above terrain level to avoid falling below it // teleport a bit above terrain level to avoid falling below it
@@ -4674,15 +4681,15 @@ uint8 Spell::CheckRange(bool strict)
range_mod = 6.25;*/ range_mod = 6.25;*/
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
float max_range = GetSpellMaxRange(srange); // + range_mod;
float min_range = GetSpellMinRange(srange); Unit *target = m_targets.getUnitTarget();
float max_range = m_caster->GetSpellMaxRangeForTarget(target, srange); // + range_mod;
float min_range = m_caster->GetSpellMinRangeForTarget(target, srange);
uint32 range_type = GetSpellRangeType(srange); uint32 range_type = GetSpellRangeType(srange);
if(Player* modOwner = m_caster->GetSpellModOwner()) if(Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this);
Unit *target = m_targets.getUnitTarget();
if(target && target != m_caster) if(target && target != m_caster)
{ {
if(range_type == SPELL_RANGE_MELEE) if(range_type == SPELL_RANGE_MELEE)
+8 -4
View File
@@ -464,7 +464,11 @@ Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target,
// caster==NULL in constructor args if target==caster in fact // caster==NULL in constructor args if target==caster in fact
Unit* caster_ptr = caster ? caster : target; Unit* caster_ptr = caster ? caster : target;
m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex])); if (spellproto->Effect[eff]==SPELL_EFFECT_APPLY_AREA_AURA_ENEMY)
m_radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
else
m_radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
if(Player* modOwner = caster_ptr->GetSpellModOwner()) if(Player* modOwner = caster_ptr->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius); modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
@@ -588,12 +592,12 @@ void Aura::Update(uint32 diff)
SpellModOp mod; SpellModOp mod;
if (m_spellProto->EffectRadiusIndex[GetEffIndex()]) if (m_spellProto->EffectRadiusIndex[GetEffIndex()])
{ {
radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()])); radius = caster->GetSpellRadiusForTarget(m_target, sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()]));
mod = SPELLMOD_RADIUS; mod = SPELLMOD_RADIUS;
} }
else else
{ {
radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); radius = caster->GetSpellMaxRangeForTarget(m_target, sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)) ;
mod = SPELLMOD_RANGE; mod = SPELLMOD_RANGE;
} }
@@ -1833,7 +1837,7 @@ void Aura::TriggerSpell()
} }
} }
} }
if(!GetSpellMaxRange(sSpellRangeStore.LookupEntry(triggeredSpellInfo->rangeIndex))) if(!caster->GetSpellMaxRangeForTarget(m_target,sSpellRangeStore.LookupEntry(triggeredSpellInfo->rangeIndex)))
target = m_target; //for druid dispel poison target = m_target; //for druid dispel poison
m_target->CastSpell(target, triggeredSpellInfo, true, 0, this, GetCasterGUID()); m_target->CastSpell(target, triggeredSpellInfo, true, 0, this, GetCasterGUID());
} }
+11 -10
View File
@@ -385,7 +385,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
if(unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) if(unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER)
return; return;
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0])); float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0]));
if(!radius) return; if(!radius) return;
float distance = m_caster->GetDistance2d(unitTarget); float distance = m_caster->GetDistance2d(unitTarget);
damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius)); damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius));
@@ -2798,7 +2798,7 @@ void Spell::EffectCreateItem2(uint32 i)
void Spell::EffectPersistentAA(uint32 i) void Spell::EffectPersistentAA(uint32 i)
{ {
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(Player* modOwner = m_originalCaster->GetSpellModOwner()) if(Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
@@ -3665,7 +3665,7 @@ void Spell::EffectAddFarsight(uint32 i)
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (m_caster->GetTypeId() != TYPEID_PLAYER)
return; return;
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 duration = GetSpellDuration(m_spellInfo); int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject; DynamicObject* dynObj = new DynamicObject;
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
@@ -3715,7 +3715,7 @@ void Spell::EffectSummonWild(uint32 i)
float center_y = m_targets.m_destY; float center_y = m_targets.m_destY;
float center_z = m_targets.m_destZ; float center_z = m_targets.m_destZ;
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 amount = damage > 0 ? damage : 1; int32 amount = damage > 0 ? damage : 1;
@@ -3804,7 +3804,7 @@ void Spell::EffectSummonGuardian(uint32 i)
float center_y = m_targets.m_destY; float center_y = m_targets.m_destY;
float center_z = m_targets.m_destZ; float center_z = m_targets.m_destZ;
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 amount = damage > 0 ? damage : 1; int32 amount = damage > 0 ? damage : 1;
@@ -3908,7 +3908,7 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i)
return; return;
uint32 mapid = m_caster->GetMapId(); uint32 mapid = m_caster->GetMapId();
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float dis = m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float fx,fy,fz; float fx,fy,fz;
m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis);
@@ -6002,7 +6002,7 @@ void Spell::EffectMomentMove(uint32 i)
return; return;
uint32 mapid = m_caster->GetMapId(); uint32 mapid = m_caster->GetMapId();
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float dis = m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
// src point // src point
float *fx = new float[11], *fy = new float[11], *fz = new float[11]; float *fx = new float[11], *fy = new float[11], *fz = new float[11];
@@ -6520,13 +6520,14 @@ void Spell::EffectTransmitted(uint32 effIndex)
//FIXME: this can be better check for most objects but still hack //FIXME: this can be better check for most objects but still hack
else if(m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed==0) else if(m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed==0)
{ {
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); float dis = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex]));
m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis);
} }
else else
{ {
float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); //GO is always friendly to it's creator, get range for friends
float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); float min_dis = GetSpellMinRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float max_dis = GetSpellMaxRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float dis = rand_norm() * (max_dis - min_dis) + min_dis; float dis = rand_norm() * (max_dis - min_dis) + min_dis;
m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis);
+6 -3
View File
@@ -325,10 +325,13 @@ enum SpellLinkedType
SpellSpecific GetSpellSpecific(uint32 spellId); SpellSpecific GetSpellSpecific(uint32 spellId);
// Different spell properties // Different spell properties
inline float GetSpellRadius(SpellRadiusEntry const *radius) { return (radius ? radius->Radius : 0); } 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); uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL);
inline float GetSpellMinRange(SpellRangeEntry const *range) { return (range ? range->minRange : 0); } inline float GetSpellMinRangeForHostile(SpellRangeEntry const *range) { return (range ? range->minRangeHostile : 0); }
inline float GetSpellMaxRange(SpellRangeEntry const *range) { return (range ? range->maxRange : 0); } inline float GetSpellMaxRangeForHostile(SpellRangeEntry const *range) { return (range ? range->maxRangeHostile : 0); }
inline float GetSpellMinRangeForFriend(SpellRangeEntry const *range) { return (range ? range->minRangeFriend : 0); }
inline float GetSpellMaxRangeForFriend(SpellRangeEntry const *range) { return (range ? range->maxRangeFriend : 0); }
inline uint32 GetSpellRangeType(SpellRangeEntry const *range) { return (range ? range->type : 0); } inline uint32 GetSpellRangeType(SpellRangeEntry const *range) { return (range ? range->type : 0); }
inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { return spellInfo->RecoveryTime > spellInfo->CategoryRecoveryTime ? spellInfo->RecoveryTime : spellInfo->CategoryRecoveryTime; } inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { return spellInfo->RecoveryTime > spellInfo->CategoryRecoveryTime ? spellInfo->RecoveryTime : spellInfo->CategoryRecoveryTime; }
int32 GetSpellDuration(SpellEntry const *spellInfo); int32 GetSpellDuration(SpellEntry const *spellInfo);
+2 -2
View File
@@ -68,9 +68,9 @@ TotemAI::UpdateAI(const uint32 /*diff*/)
if (!spellInfo) if (!spellInfo)
return; return;
// Get spell rangy // Get spell range
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float max_range = GetSpellMaxRange(srange); float max_range = GetSpellMaxRangeForHostile(srange);
// SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems // SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems
+87 -60
View File
@@ -421,9 +421,9 @@ void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z,
// sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry()); // sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry());
combat_reach = DEFAULT_COMBAT_REACH; combat_reach = DEFAULT_COMBAT_REACH;
} }
uint32 attacker_number = getAttackers().size(); uint32 attacker_number = getAttackers().size();
if(attacker_number > 0) --attacker_number; if(attacker_number > 0) --attacker_number;
GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm() GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm()
, GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0)); , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0));
} }
@@ -543,34 +543,34 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
//Script Event damage taken //Script Event damage taken
if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() )
{ {
((Creature *)pVictim)->AI()->DamageTaken(this, damage); ((Creature *)pVictim)->AI()->DamageTaken(this, damage);
// Set tagging // Set tagging
if(!pVictim->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER) && !((Creature*)pVictim)->isPet()) if(!pVictim->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER) && !((Creature*)pVictim)->isPet())
{ {
//Set Loot //Set Loot
switch(GetTypeId()) switch(GetTypeId())
{ {
case TYPEID_PLAYER: case TYPEID_PLAYER:
{ {
((Creature *)pVictim)->SetLootRecipient(this); ((Creature *)pVictim)->SetLootRecipient(this);
//Set tagged //Set tagged
((Creature *)pVictim)->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); ((Creature *)pVictim)->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER);
break; break;
} }
case TYPEID_UNIT: case TYPEID_UNIT:
{ {
if(((Creature*)this)->isPet()) if(((Creature*)this)->isPet())
{ {
((Creature *)pVictim)->SetLootRecipient(this->GetOwner()); ((Creature *)pVictim)->SetLootRecipient(this->GetOwner());
((Creature *)pVictim)->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); ((Creature *)pVictim)->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER);
} }
break; break;
} }
} }
} }
} }
if (damagetype != NODAMAGE) if (damagetype != NODAMAGE)
{ {
@@ -3064,7 +3064,7 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target)
if(attType != BASE_ATTACK && !item ) if(attType != BASE_ATTACK && !item )
{ {
if(attType == RANGED_ATTACK && getClass() == CLASS_PALADIN) //hammer if(attType == RANGED_ATTACK && getClass() == CLASS_PALADIN) //hammer
return GetMaxSkillValueForLevel(); return GetMaxSkillValueForLevel();
return 0; return 0;
} }
@@ -7132,6 +7132,8 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const
bool Unit::IsHostileTo(Unit const* unit) const bool Unit::IsHostileTo(Unit const* unit) const
{ {
if(!unit)
return false;
// always non-hostile to self // always non-hostile to self
if(unit==this) if(unit==this)
return false; return false;
@@ -7868,22 +7870,22 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
/*switch(spellProto->SpellFamilyName) /*switch(spellProto->SpellFamilyName)
{ {
case SPELLFAMILY_GENERIC: case SPELLFAMILY_GENERIC:
// Siphon Essence - 0% // Siphon Essence - 0%
if(spellProto->AttributesEx == 268435456 && spellProto->SpellIconID == 2027) if(spellProto->AttributesEx == 268435456 && spellProto->SpellIconID == 2027)
{ {
CastingTime = 0; CastingTime = 0;
} }
// Goblin Rocket Launcher - 0% // Goblin Rocket Launcher - 0%
else if (spellProto->SpellIconID == 184 && spellProto->Attributes == 4259840) else if (spellProto->SpellIconID == 184 && spellProto->Attributes == 4259840)
{ {
CastingTime = 0; CastingTime = 0;
} }
// Darkmoon Card: Vengeance - 0.1% // Darkmoon Card: Vengeance - 0.1%
else if (spellProto->SpellVisual[0] == 9850 && spellProto->SpellIconID == 2230) else if (spellProto->SpellVisual[0] == 9850 && spellProto->SpellIconID == 2230)
{ {
CastingTime = 3.5; CastingTime = 3.5;
} }
case SPELLFAMILY_MAGE: case SPELLFAMILY_MAGE:
// Ignite - do not modify, it is (8*Rank)% damage of procing Spell // Ignite - do not modify, it is (8*Rank)% damage of procing Spell
if(spellProto->Id==12654) if(spellProto->Id==12654)
@@ -8465,7 +8467,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
if (spellProto->Id == 15290 || spellProto->Id == 39373 || if (spellProto->Id == 15290 || spellProto->Id == 39373 ||
spellProto->Id == 33778 || spellProto->Id == 379 || spellProto->Id == 33778 || spellProto->Id == 379 ||
spellProto->Id == 38395 || spellProto->Id == 40972 || spellProto->Id == 38395 || spellProto->Id == 40972 ||
spellProto->Id == 22845 || spellProto->Id == 33504 || spellProto->Id == 22845 || spellProto->Id == 33504 ||
spellProto->Id == 34299) spellProto->Id == 34299)
return healamount; return healamount;
@@ -8575,12 +8577,12 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
DotFactor = damagetype == DOT ? 0.705f : 1.0f; DotFactor = damagetype == DOT ? 0.705f : 1.0f;
CastingTime = damagetype == DOT ? 3500 : 1010; CastingTime = damagetype == DOT ? 3500 : 1010;
} }
// Improved Leader of the Pack // Improved Leader of the Pack
else if (spellProto->AttributesEx2 == 536870912 && spellProto->SpellIconID == 312 else if (spellProto->AttributesEx2 == 536870912 && spellProto->SpellIconID == 312
&& spellProto->AttributesEx3 == 33554432) && spellProto->AttributesEx3 == 33554432)
{ {
CastingTime = 0; CastingTime = 0;
} }
break; break;
case SPELLFAMILY_PRIEST: case SPELLFAMILY_PRIEST:
// Holy Nova - 14% // Holy Nova - 14%
@@ -10158,13 +10160,13 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un
if(duration == -1 || group == DIMINISHING_NONE || caster->IsFriendlyTo(this) ) if(duration == -1 || group == DIMINISHING_NONE || caster->IsFriendlyTo(this) )
return; return;
// test pet/charm masters instead pets/charmeds
Unit const* targetOwner = GetCharmerOrOwner();
Unit const* casterOwner = caster->GetCharmerOrOwner();
// Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0) // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
if(duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group)) if(duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group))
{ {
// test pet/charm masters instead pets/charmeds
Unit const* targetOwner = GetCharmerOrOwner();
Unit const* casterOwner = caster->GetCharmerOrOwner();
Unit const* target = targetOwner ? targetOwner : this; Unit const* target = targetOwner ? targetOwner : this;
Unit const* source = casterOwner ? casterOwner : caster; Unit const* source = casterOwner ? casterOwner : caster;
@@ -10175,7 +10177,7 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un
float mod = 1.0f; float mod = 1.0f;
// Some diminishings applies to mobs too (for example, Stun) // Some diminishings applies to mobs too (for example, Stun)
if((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (targetOwner ? targetOwner->GetTypeId():GetTypeId()) == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) if((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
{ {
DiminishingLevels diminish = Level; DiminishingLevels diminish = Level;
switch(diminish) switch(diminish)
@@ -10212,6 +10214,31 @@ void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply )
} }
} }
uint32 Unit::GetSpellMaxRangeForTarget(Unit* target,const SpellRangeEntry * rangeEntry)
{
if (rangeEntry->maxRangeHostile == rangeEntry->maxRangeFriend)
return rangeEntry->maxRangeFriend;
if (IsHostileTo(target))
return rangeEntry->maxRangeHostile;
return rangeEntry->maxRangeFriend;
};
uint32 Unit::GetSpellMinRangeForTarget(Unit* target,const SpellRangeEntry * rangeEntry)
{
if (rangeEntry->minRangeHostile == rangeEntry->minRangeFriend)
return rangeEntry->minRangeFriend;
if (IsHostileTo(target))
return rangeEntry->minRangeHostile;
return rangeEntry->minRangeFriend;
};
uint32 Unit::GetSpellRadiusForTarget(Unit* target,const SpellRadiusEntry * radiusEntry)
{
if (radiusEntry->radiusHostile == radiusEntry->radiusFriend)
return radiusEntry->radiusFriend;
if (IsHostileTo(target))
return radiusEntry->radiusHostile;
return radiusEntry->radiusFriend;
};
Unit* Unit::GetUnit(WorldObject& object, uint64 guid) Unit* Unit::GetUnit(WorldObject& object, uint64 guid)
{ {
return ObjectAccessor::GetUnit(object,guid); return ObjectAccessor::GetUnit(object,guid);
@@ -11923,9 +11950,9 @@ bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura )
{ {
float radius; float radius;
if (spellProto->EffectRadiusIndex[effIdx]) if (spellProto->EffectRadiusIndex[effIdx])
radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); radius = GetSpellRadiusForTarget(triggeredByAura->GetCaster(), sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx]));
else else
radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); radius = GetSpellMaxRangeForTarget(triggeredByAura->GetCaster() ,sSpellRangeStore.LookupEntry(spellProto->rangeIndex));
if(Player* caster = ((Player*)triggeredByAura->GetCaster())) if(Player* caster = ((Player*)triggeredByAura->GetCaster()))
{ {
+5
View File
@@ -844,6 +844,11 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void ApplyDiminishingAura(DiminishingGroup group, bool apply); void ApplyDiminishingAura(DiminishingGroup group, bool apply);
void ClearDiminishings() { m_Diminishing.clear(); } void ClearDiminishings() { m_Diminishing.clear(); }
//target dependent range checks
uint32 GetSpellMaxRangeForTarget(Unit* target,const SpellRangeEntry * rangeEntry);
uint32 GetSpellMinRangeForTarget(Unit* target,const SpellRangeEntry * rangeEntry);
uint32 GetSpellRadiusForTarget(Unit* target,const SpellRadiusEntry * radiusEntry);
virtual void Update( uint32 time ); virtual void Update( uint32 time );
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
+11 -4
View File
@@ -1228,16 +1228,23 @@ struct SpellThreatEntry
struct SpellRadiusEntry struct SpellRadiusEntry
{ {
uint32 ID; uint32 ID;
float Radius; float radiusHostile;
float Radius2; //uint32 Unk //always 0
float radiusFriend;
}; };
struct SpellRangeEntry struct SpellRangeEntry
{ {
uint32 ID; uint32 ID;
float minRange; float minRangeHostile;
float maxRange; float minRangeFriend;
float maxRangeHostile;
float maxRangeFriend; //friend means unattackable unit here
uint32 type; uint32 type;
//char* Name[16]; // 7-23 unused
// 24 string flags, unused
//char* Name2[16]; // 25-40 unused
// 41 string flags, unused
}; };
struct SpellRuneCostEntry struct SpellRuneCostEntry
+1 -1
View File
@@ -79,7 +79,7 @@ const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixx"; const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixx";
const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX"; const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
const char SpellRadiusfmt[]="nfxf"; const char SpellRadiusfmt[]="nfxf";
const char SpellRangefmt[]="nfxfxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char SpellRangefmt[]="nffffixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char SpellRuneCostfmt[]="niiii"; const char SpellRuneCostfmt[]="niiii";
const char SpellShapeshiftfmt[]="nxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxx"; const char SpellShapeshiftfmt[]="nxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxx";
const char StableSlotPricesfmt[] = "ni"; const char StableSlotPricesfmt[] = "ni";