aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2008-12-23 20:01:05 -0600
committermegamage <none@none>2008-12-23 20:01:05 -0600
commitafc598bde2dff64a17a4b82f6e3b87d83a9a28da (patch)
treefaa0384d7f23cde474a5c646673fd4c200ba8e1f /src
parent5154f51633571460924f161940d18a23c8dfb1ee (diff)
*Spell target selection update.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/SharedDefines.h8
-rw-r--r--src/game/Spell.cpp171
-rw-r--r--src/game/SpellAuras.cpp47
-rw-r--r--src/game/SpellMgr.cpp2
-rw-r--r--src/game/Unit.cpp41
-rw-r--r--src/game/Unit.h2
6 files changed, 67 insertions, 204 deletions
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index 469fa9dddd2..bf23a724520 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -813,7 +813,7 @@ enum Targets
TARGET_EFFECT_SELECT = 18, // highly depends on the spell effect
TARGET_DEST_CASTER_GROUND = 18,
TARGET_ALL_PARTY_AROUND_CASTER = 20,
- //TARGET_UNIT_PARTY_CASTER
+ TARGET_UNIT_PARTY_CASTER = 20,
TARGET_SINGLE_FRIEND = 21,
TARGET_UNIT_TARGET_ALLY = 21,
TARGET_ALL_AROUND_CASTER = 22, // used only in TargetA, target selection dependent from TargetB
@@ -837,14 +837,14 @@ enum Targets
TARGET_MINION = 32,
//TARGET_DEST_SUMMON
TARGET_ALL_PARTY = 33,
- //TARGET_UNIT_AREA_PARTY
+ TARGET_UNIT_AREA_PARTY = 33,
TARGET_ALL_PARTY_AROUND_CASTER_2 = 34, // used in Tranquility
- //TARGET_UNIT_AREA_PARTY_GROUND
+ TARGET_UNIT_AREA_PARTY_GROUND = 34,
TARGET_SINGLE_PARTY = 35,
TARGET_UNIT_TARGET_PARTY = 35,
TARGET_DEST_CASTER_RANDOM_UNKNOWN = 36, //unknown
TARGET_AREAEFFECT_PARTY = 37,
- //TARGET_UNIT_PARTY_TARGET
+ TARGET_UNIT_PARTY_TARGET = 37,
TARGET_SCRIPT = 38,
//TARGET_UNIT_NEARBY_ENTRY
TARGET_UNIT_CASTER_FISHING = 39,
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index a8b6a222f18..743d5bc039d 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1491,9 +1491,13 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
case TARGET_UNIT_TARGET_ALLY:
case TARGET_UNIT_TARGET_RAID:
case TARGET_UNIT_TARGET_ANY: // SelectMagnetTarget()?
+ case TARGET_UNIT_TARGET_PARTY:
case TARGET_UNIT_SINGLE_UNKNOWN:
TagUnitMap.push_back(m_targets.getUnitTarget());
break;
+ case TARGET_UNIT_PARTY_TARGET:
+ m_caster->GetPartyMember(TagUnitMap, radius);
+ break;
case TARGET_UNIT_TARGET_ENEMY:
if(Unit* pUnitTarget = SelectMagnetTarget())
{
@@ -1748,170 +1752,18 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
break;
}
- case TARGET_ALL_PARTY_AROUND_CASTER:
- case TARGET_ALL_PARTY_AROUND_CASTER_2:
- case TARGET_ALL_PARTY:
- {
- Player *pTarget = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself();
- Group *pGroup = pTarget ? pTarget->GetGroup() : NULL;
-
- if(pGroup)
- {
- uint8 subgroup = pTarget->GetSubGroup();
-
- for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player* Target = itr->getSource();
-
- // IsHostileTo check duel and controlled by enemy
- if( Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target) )
- {
- if( m_caster->IsWithinDistInMap(Target, radius) )
- TagUnitMap.push_back(Target);
-
- if(Pet* pet = Target->GetPet())
- if( m_caster->IsWithinDistInMap(pet, radius) )
- TagUnitMap.push_back(pet);
- }
- }
- }
- else
- {
- Unit* ownerOrSelf = pTarget ? pTarget : m_caster->GetCharmerOrOwnerOrSelf();
- if(ownerOrSelf==m_caster || m_caster->IsWithinDistInMap(ownerOrSelf, radius))
- TagUnitMap.push_back(ownerOrSelf);
- if(Pet* pet = ownerOrSelf->GetPet())
- if( m_caster->IsWithinDistInMap(pet, radius) )
- TagUnitMap.push_back(pet);
- }
- }break;
+ case TARGET_UNIT_AREA_PARTY_GROUND:
+ m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;
+ case TARGET_UNIT_PARTY_CASTER:
+ case TARGET_UNIT_AREA_PARTY:
+ m_caster->GetPartyMember(TagUnitMap, radius);
+ break;
case TARGET_RANDOM_RAID_MEMBER:
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if(Player* target = ((Player*)m_caster)->GetNextRandomRaidMember(radius))
TagUnitMap.push_back(target);
}break;
- // TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..)
- case TARGET_SINGLE_PARTY:
- {
- Unit *target = m_targets.getUnitTarget();
- // Thoses spells apparently can't be casted on the caster.
- if( target && target != m_caster)
- {
- // Can only be casted on group's members or its pets
- Group *pGroup = NULL;
-
- Unit* owner = m_caster->GetCharmerOrOwner();
- Unit *targetOwner = target->GetCharmerOrOwner();
- if(owner)
- {
- if(owner->GetTypeId() == TYPEID_PLAYER)
- {
- if( target == owner )
- {
- TagUnitMap.push_back(target);
- break;
- }
- pGroup = ((Player*)owner)->GetGroup();
- }
- }
- else if (m_caster->GetTypeId() == TYPEID_PLAYER)
- {
- if( targetOwner == m_caster && target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isPet())
- {
- TagUnitMap.push_back(target);
- break;
- }
- pGroup = ((Player*)m_caster)->GetGroup();
- }
-
- if(pGroup)
- {
- // Our target can also be a player's pet who's grouped with us or our pet. But can't be controlled player
- if(targetOwner)
- {
- if( targetOwner->GetTypeId() == TYPEID_PLAYER &&
- target->GetTypeId()==TYPEID_UNIT && (((Creature*)target)->isPet()) &&
- target->GetOwnerGUID()==targetOwner->GetGUID() &&
- pGroup->IsMember(((Player*)targetOwner)->GetGUID()))
- {
- TagUnitMap.push_back(target);
- }
- }
- // 1Our target can be a player who is on our group
- else if (target->GetTypeId() == TYPEID_PLAYER && pGroup->IsMember(((Player*)target)->GetGUID()))
- {
- TagUnitMap.push_back(target);
- }
- }
- }
- }break;
- case TARGET_AREAEFFECT_PARTY:
- {
- Unit* owner = m_caster->GetCharmerOrOwner();
- Player *pTarget = NULL;
-
- if(owner)
- {
- TagUnitMap.push_back(m_caster);
- if(owner->GetTypeId() == TYPEID_PLAYER)
- pTarget = (Player*)owner;
- }
- else if (m_caster->GetTypeId() == TYPEID_PLAYER)
- {
- if(Unit* target = m_targets.getUnitTarget())
- {
- if( target->GetTypeId() != TYPEID_PLAYER)
- {
- if(((Creature*)target)->isPet())
- {
- Unit *targetOwner = target->GetOwner();
- if(targetOwner->GetTypeId() == TYPEID_PLAYER)
- pTarget = (Player*)targetOwner;
- }
- }
- else
- pTarget = (Player*)target;
- }
- }
-
- Group* pGroup = pTarget ? pTarget->GetGroup() : NULL;
-
- if(pGroup)
- {
- uint8 subgroup = pTarget->GetSubGroup();
-
- for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player* Target = itr->getSource();
-
- // IsHostileTo check duel and controlled by enemy
- if(Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target))
- {
- if( pTarget->IsWithinDistInMap(Target, radius) )
- TagUnitMap.push_back(Target);
-
- if(Pet* pet = Target->GetPet())
- if( pTarget->IsWithinDistInMap(pet, radius) )
- TagUnitMap.push_back(pet);
- }
- }
- }
- else if (owner)
- {
- if(m_caster->IsWithinDistInMap(owner, radius))
- TagUnitMap.push_back(owner);
- }
- else if(pTarget)
- {
- TagUnitMap.push_back(pTarget);
-
- if(Pet* pet = pTarget->GetPet())
- if( m_caster->IsWithinDistInMap(pet, radius) )
- TagUnitMap.push_back(pet);
- }
-
- }break;
case TARGET_CHAIN_HEAL:
{
Unit* pUnitTarget = m_targets.getUnitTarget();
@@ -5445,9 +5297,10 @@ bool Spell::IsValidSingleTargetEffect(Unit const* target, Targets type) const
case TARGET_UNIT_TARGET_ENEMY:
return !m_caster->IsFriendlyTo(target);
case TARGET_UNIT_TARGET_ALLY:
+ case TARGET_UNIT_PARTY_TARGET:
return m_caster->IsFriendlyTo(target);
case TARGET_UNIT_TARGET_PARTY:
- return m_caster->IsInPartyWith(target);
+ return m_caster != target && m_caster->IsInPartyWith(target);
case TARGET_UNIT_TARGET_RAID:
return m_caster->IsInRaidWith(target);
}
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index d5e904c5479..36feb9b9375 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -596,66 +596,31 @@ void AreaAura::Update(uint32 diff)
if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
{
- Unit* owner = caster->GetCharmerOrOwner();
- if (!owner)
- owner = caster;
std::list<Unit *> targets;
switch(m_areaAuraType)
{
case AREA_AURA_PARTY:
- {
- Group *pGroup = NULL;
-
- if (owner->GetTypeId() == TYPEID_PLAYER)
- pGroup = ((Player*)owner)->GetGroup();
-
- if( pGroup)
- {
- uint8 subgroup = ((Player*)owner)->GetSubGroup();
- for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player* Target = itr->getSource();
- if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
- {
- if(caster->IsWithinDistInMap(Target, m_radius))
- targets.push_back(Target);
- Pet *pet = Target->GetPet();
- if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
- targets.push_back(pet);
- }
- }
- }
- else
- {
- // add owner
- if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
- targets.push_back(owner);
- // add caster's pet
- Unit* pet = caster->GetPet();
- if( pet && caster->IsWithinDistInMap(pet, m_radius))
- targets.push_back(pet);
- }
+ caster->GetPartyMember(targets, m_radius);
break;
- }
case AREA_AURA_FRIEND:
{
- Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius);
+ Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(caster, caster, m_radius);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(targets, u_check);
- caster->GetMap()->VisitAll(caster->GetPositionX(), caster->GetPositionY(), m_radius, searcher);
+ caster->VisitNearbyObject(m_radius, searcher);
break;
}
case AREA_AURA_ENEMY:
{
- Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher
+ Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(caster, caster, m_radius); // No GetCharmer in searcher
Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(targets, u_check);
- caster->GetMap()->VisitAll(caster->GetPositionX(), caster->GetPositionY(), m_radius, searcher);
+ caster->VisitNearbyObject(m_radius, searcher);
break;
}
case AREA_AURA_OWNER:
case AREA_AURA_PET:
{
- if(owner != caster)
+ if(Unit *owner = caster->GetCharmerOrOwner())
targets.push_back(owner);
break;
}
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 48f63763911..88fe7cdb4d8 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -88,6 +88,8 @@ SpellMgr::SpellMgr()
case TARGET_UNIT_TARGET_ANY:
case TARGET_UNIT_SINGLE_UNKNOWN:
case TARGET_UNIT_TARGET_ENEMY:
+ case TARGET_UNIT_TARGET_PARTY:
+ case TARGET_UNIT_PARTY_TARGET:
SpellTargetType[i] = TARGET_TYPE_UNIT_TARGET;
break;
case TARGET_UNIT_CHANNEL:
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index d6f5b4e8dc1..e00b2446010 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -12943,6 +12943,47 @@ bool Unit::IsInRaidWith(Unit const *unit) const
return false;
}
+void Unit::GetRaidMember(std::list<Unit*> &TagUnitMap, float radius)
+{
+}
+
+void Unit::GetPartyMember(std::list<Unit*> &TagUnitMap, float radius)
+{
+ Unit *owner = GetCharmerOrOwnerOrSelf();
+ Group *pGroup = NULL;
+ if (owner->GetTypeId() == TYPEID_PLAYER)
+ pGroup = ((Player*)owner)->GetGroup();
+
+ if(pGroup)
+ {
+ uint8 subgroup = ((Player*)owner)->GetSubGroup();
+
+ for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+ {
+ Player* Target = itr->getSource();
+
+ // IsHostileTo check duel and controlled by enemy
+ if( Target && Target->GetSubGroup()==subgroup && !IsHostileTo(Target) )
+ {
+ if(Target->isAlive() && IsWithinDistInMap(Target, radius) )
+ TagUnitMap.push_back(Target);
+
+ if(Pet* pet = Target->GetPet())
+ if(pet->isAlive() && IsWithinDistInMap(pet, radius) )
+ TagUnitMap.push_back(pet);
+ }
+ }
+ }
+ else
+ {
+ if(owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius)))
+ TagUnitMap.push_back(owner);
+ if(Pet* pet = owner->GetPet())
+ if(pet->isAlive() && (pet == this && IsWithinDistInMap(pet, radius)))
+ TagUnitMap.push_back(pet);
+ }
+}
+
void Unit::AddAura(uint32 spellId, Unit* target)
{
if(!target)
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 4ef9fafe7b5..c3f5be3adb1 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -875,6 +875,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
bool IsNeutralToAll() const;
bool IsInPartyWith(Unit const* unit) const;
bool IsInRaidWith(Unit const* unit) const;
+ void GetPartyMember(std::list<Unit*> &units, float dist);
+ void GetRaidMember(std::list<Unit*> &units, float dist);
bool IsContestedGuard() const
{
if(FactionTemplateEntry const* entry = getFactionTemplateEntry())