Core/Spells: Implemented CREATURE_TYPEFLAGS_PARTY_MEMBER, creature with this type_flag set can be targeted by spells that require target to be in caster's party/raid
This commit is contained in:
@@ -12199,7 +12199,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) co
|
|||||||
}
|
}
|
||||||
|
|
||||||
Creature const* creatureAttacker = ToCreature();
|
Creature const* creatureAttacker = ToCreature();
|
||||||
if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26)
|
if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : NULL;
|
Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : NULL;
|
||||||
@@ -12286,7 +12286,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
|||||||
// can't assist non-friendly targets
|
// can't assist non-friendly targets
|
||||||
if (GetReactionTo(target) <= REP_NEUTRAL
|
if (GetReactionTo(target) <= REP_NEUTRAL
|
||||||
&& target->GetReactionTo(this) <= REP_NEUTRAL
|
&& target->GetReactionTo(this) <= REP_NEUTRAL
|
||||||
&& (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26)))
|
&& (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// PvP case
|
// PvP case
|
||||||
@@ -12320,7 +12320,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
|||||||
&& !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)))
|
&& !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)))
|
||||||
{
|
{
|
||||||
if (Creature const* creatureTarget = target->ToCreature())
|
if (Creature const* creatureTarget = target->ToCreature())
|
||||||
return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26 || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS;
|
return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -16161,6 +16161,9 @@ bool Unit::IsInPartyWith(Unit const* unit) const
|
|||||||
|
|
||||||
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
|
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
|
||||||
return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer());
|
return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer());
|
||||||
|
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER) ||
|
||||||
|
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER))
|
||||||
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -16177,81 +16180,13 @@ bool Unit::IsInRaidWith(Unit const* unit) const
|
|||||||
|
|
||||||
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
|
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
|
||||||
return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer());
|
return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer());
|
||||||
|
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER) ||
|
||||||
|
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER))
|
||||||
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius)
|
|
||||||
{
|
|
||||||
Player* owner = GetCharmerOrOwnerPlayerOrPlayerItself();
|
|
||||||
if (!owner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Group* group = owner->GetGroup();
|
|
||||||
if (group)
|
|
||||||
{
|
|
||||||
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
|
|
||||||
{
|
|
||||||
Player* Target = itr->getSource();
|
|
||||||
|
|
||||||
if (Target && !IsHostileTo(Target))
|
|
||||||
{
|
|
||||||
if (Target->isAlive() && IsWithinDistInMap(Target, radius))
|
|
||||||
nearMembers.push_back(Target);
|
|
||||||
|
|
||||||
if (Guardian* pet = Target->GetGuardianPet())
|
|
||||||
if (pet->isAlive() && IsWithinDistInMap(pet, radius))
|
|
||||||
nearMembers.push_back(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius)))
|
|
||||||
nearMembers.push_back(owner);
|
|
||||||
if (Guardian* pet = owner->GetGuardianPet())
|
|
||||||
if (pet->isAlive() && (pet == this || IsWithinDistInMap(pet, radius)))
|
|
||||||
nearMembers.push_back(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Unit::GetPartyMemberInDist(std::list<Unit*> &TagUnitMap, float radius)
|
|
||||||
{
|
|
||||||
Unit* owner = GetCharmerOrOwnerOrSelf();
|
|
||||||
Group* group = NULL;
|
|
||||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
|
||||||
group = owner->ToPlayer()->GetGroup();
|
|
||||||
|
|
||||||
if (group)
|
|
||||||
{
|
|
||||||
uint8 subgroup = owner->ToPlayer()->GetSubGroup();
|
|
||||||
|
|
||||||
for (GroupReference* itr = group->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 (Guardian* pet = Target->GetGuardianPet())
|
|
||||||
if (pet->isAlive() && IsWithinDistInMap(pet, radius))
|
|
||||||
TagUnitMap.push_back(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius)))
|
|
||||||
TagUnitMap.push_back(owner);
|
|
||||||
if (Guardian* pet = owner->GetGuardianPet())
|
|
||||||
if (pet->isAlive() && (pet == this || IsWithinDistInMap(pet, radius)))
|
|
||||||
TagUnitMap.push_back(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
|
void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
|
||||||
{
|
{
|
||||||
Unit* owner = GetCharmerOrOwnerOrSelf();
|
Unit* owner = GetCharmerOrOwnerOrSelf();
|
||||||
|
|||||||
@@ -1398,9 +1398,7 @@ class Unit : public WorldObject
|
|||||||
bool IsNeutralToAll() const;
|
bool IsNeutralToAll() const;
|
||||||
bool IsInPartyWith(Unit const* unit) const;
|
bool IsInPartyWith(Unit const* unit) const;
|
||||||
bool IsInRaidWith(Unit const* unit) const;
|
bool IsInRaidWith(Unit const* unit) const;
|
||||||
void GetPartyMemberInDist(std::list<Unit*> &units, float dist);
|
|
||||||
void GetPartyMembers(std::list<Unit*> &units);
|
void GetPartyMembers(std::list<Unit*> &units);
|
||||||
void GetRaidMember(std::list<Unit*> &units, float dist);
|
|
||||||
bool IsContestedGuard() const
|
bool IsContestedGuard() const
|
||||||
{
|
{
|
||||||
if (FactionTemplateEntry const* entry = getFactionTemplateEntry())
|
if (FactionTemplateEntry const* entry = getFactionTemplateEntry())
|
||||||
|
|||||||
@@ -858,6 +858,30 @@ namespace Trinity
|
|||||||
float i_range;
|
float i_range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AnyGroupedUnitInObjectRangeCheck
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid) : _source(obj), _refUnit(funit), _range(range), _raid(raid) {}
|
||||||
|
bool operator()(Unit* u)
|
||||||
|
{
|
||||||
|
if (_raid)
|
||||||
|
{
|
||||||
|
if (!_refUnit->IsInRaidWith(u))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!_refUnit->IsInPartyWith(u))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !_refUnit->IsHostileTo(u) && u->isAlive() && _source->IsWithinDistInMap(u, _range);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
WorldObject const* _source;
|
||||||
|
Unit const* _refUnit;
|
||||||
|
float _range;
|
||||||
|
bool _raid;
|
||||||
|
};
|
||||||
|
|
||||||
class AnyUnitInObjectRangeCheck
|
class AnyUnitInObjectRangeCheck
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -2589,7 +2589,7 @@ enum CreatureTypeFlags
|
|||||||
CREATURE_TYPEFLAGS_UNK23 = 0x00800000, // ? First seen in 3.2.2. Related to banner/backpack of creature/companion?
|
CREATURE_TYPEFLAGS_UNK23 = 0x00800000, // ? First seen in 3.2.2. Related to banner/backpack of creature/companion?
|
||||||
CREATURE_TYPEFLAGS_UNK24 = 0x01000000,
|
CREATURE_TYPEFLAGS_UNK24 = 0x01000000,
|
||||||
CREATURE_TYPEFLAGS_UNK25 = 0x02000000,
|
CREATURE_TYPEFLAGS_UNK25 = 0x02000000,
|
||||||
CREATURE_TYPEFLAGS_UNK26 = 0x04000000,
|
CREATURE_TYPEFLAGS_PARTY_MEMBER = 0x04000000, //! Creature can be targeted by spells that require target to be in caster's party/raid
|
||||||
CREATURE_TYPEFLAGS_UNK27 = 0x08000000,
|
CREATURE_TYPEFLAGS_UNK27 = 0x08000000,
|
||||||
CREATURE_TYPEFLAGS_UNK28 = 0x10000000,
|
CREATURE_TYPEFLAGS_UNK28 = 0x10000000,
|
||||||
CREATURE_TYPEFLAGS_UNK29 = 0x20000000,
|
CREATURE_TYPEFLAGS_UNK29 = 0x20000000,
|
||||||
|
|||||||
@@ -2357,13 +2357,14 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster)
|
|||||||
switch (GetSpellInfo()->Effects[effIndex].Effect)
|
switch (GetSpellInfo()->Effects[effIndex].Effect)
|
||||||
{
|
{
|
||||||
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
|
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
|
||||||
targetList.push_back(GetUnitOwner());
|
|
||||||
GetUnitOwner()->GetPartyMemberInDist(targetList, radius);
|
|
||||||
break;
|
|
||||||
case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
|
case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
|
||||||
|
{
|
||||||
targetList.push_back(GetUnitOwner());
|
targetList.push_back(GetUnitOwner());
|
||||||
GetUnitOwner()->GetRaidMember(targetList, radius);
|
Trinity::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID);
|
||||||
|
Trinity::UnitListSearcher<Trinity::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
|
||||||
|
GetUnitOwner()->VisitNearbyObject(radius, searcher);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
|
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
|
||||||
{
|
{
|
||||||
targetList.push_back(GetUnitOwner());
|
targetList.push_back(GetUnitOwner());
|
||||||
|
|||||||
Reference in New Issue
Block a user