mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Objects: added ToUnit(), ToGameObject() (will be used in future)
Core/Unit: - added SetFacing() function, using proper packet implementetion (spline type) - added GetAuraCount() function (will be used in future) Core/Creature: renamed one unknown type_flag --HG-- branch : trunk
This commit is contained in:
@@ -56,7 +56,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho)
|
||||
return false;
|
||||
|
||||
//experimental (unknown) flag not present
|
||||
if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13))
|
||||
if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
|
||||
return false;
|
||||
|
||||
//not a player
|
||||
|
||||
@@ -54,7 +54,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho)
|
||||
return false;
|
||||
|
||||
//experimental (unknown) flag not present
|
||||
if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13))
|
||||
if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
|
||||
return false;
|
||||
|
||||
//not a player
|
||||
|
||||
@@ -323,6 +323,10 @@ class Object
|
||||
Creature* ToCreature(){ if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; }
|
||||
const Creature* ToCreature() const {if (GetTypeId() == TYPEID_UNIT) return (const Creature*)((Creature*)this); else return NULL; }
|
||||
|
||||
Unit* ToUnit(){ if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Unit*>(this); else return NULL; }
|
||||
const Unit* ToUnit() const {if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return (const Unit*)((Unit*)this); else return NULL; }
|
||||
GameObject* ToGameObject(){ if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return NULL; }
|
||||
const GameObject* ToGameObject() const {if (GetTypeId() == TYPEID_GAMEOBJECT) return (const GameObject*)((GameObject*)this); else return NULL; }
|
||||
protected:
|
||||
|
||||
Object ();
|
||||
|
||||
@@ -315,6 +315,32 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim
|
||||
SendMonsterMove(x, y, z, transitTime, player);
|
||||
}
|
||||
|
||||
void Unit::SetFacing(float ori, WorldObject* obj)
|
||||
{
|
||||
SetOrientation(obj ? GetAngle(obj) : ori);
|
||||
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, (1+12+4+1+(obj ? 8 : 4)+4+4+4+12+GetPackGUID().size()));
|
||||
data.append(GetPackGUID());
|
||||
data << uint8(0);//unk
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
if (obj)
|
||||
{
|
||||
data << uint8(SPLINETYPE_FACING_TARGET);
|
||||
data << uint64(obj->GetGUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
data << uint8(SPLINETYPE_FACING_ANGLE);
|
||||
data << ori;
|
||||
}
|
||||
data << uint32(SPLINEFLAG_NONE);
|
||||
data << uint32(0);//move time 0
|
||||
data << uint32(1);//one point
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterStop(bool on_death)
|
||||
{
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, (17 + GetPackGUID().size()));
|
||||
@@ -4377,6 +4403,19 @@ bool Unit::HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 Unit::GetAuraCount(uint32 spellId) const
|
||||
{
|
||||
uint32 count = 0;
|
||||
for (AuraApplicationMap::const_iterator itr = m_appliedAuras.lower_bound(spellId); itr != m_appliedAuras.upper_bound(spellId); ++itr)
|
||||
{
|
||||
if (itr->second->GetBase()->GetStackAmount())
|
||||
count++;
|
||||
else
|
||||
count += (uint32)itr->second->GetBase()->GetStackAmount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool Unit::HasAura(uint32 spellId, uint64 caster, uint8 reqEffMask) const
|
||||
{
|
||||
if (GetAuraApplication(spellId, caster, reqEffMask))
|
||||
|
||||
@@ -1454,6 +1454,8 @@ class Unit : public WorldObject
|
||||
void JumpTo(float speedXY, float speedZ, bool forward = true);
|
||||
void JumpTo(WorldObject *obj, float speedZ);
|
||||
|
||||
void SetFacing(WorldObject* obj) { SetFacing(0, obj); }
|
||||
void SetFacing(float ori, WorldObject* obj);
|
||||
void SendMonsterStop(bool on_death = false);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player *player = NULL);
|
||||
@@ -1632,6 +1634,7 @@ class Unit : public WorldObject
|
||||
Aura * GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0) const;
|
||||
|
||||
bool HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster = 0) const;
|
||||
uint32 GetAuraCount(uint32 spellId) const;
|
||||
bool HasAura(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0) const;
|
||||
bool HasAuraType(AuraType auraType) const;
|
||||
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const;
|
||||
|
||||
@@ -2018,7 +2018,7 @@ enum CreatureTypeFlags
|
||||
CREATURE_TYPEFLAGS_MININGLOOT = 0x000200, // Can be looted by miner
|
||||
CREATURE_TYPEFLAGS_UNK11 = 0x000400,
|
||||
CREATURE_TYPEFLAGS_UNK12 = 0x000800, // ? Related to mounts in some way. If mounted, fight mounted, mount appear as independant when rider dies?
|
||||
CREATURE_TYPEFLAGS_UNK13 = 0x001000, // ? Can aid any player in combat if in range?
|
||||
CREATURE_TYPEFLAGS_AID_PLAYERS = 0x001000, // ? Can aid any player in combat if in range?
|
||||
CREATURE_TYPEFLAGS_UNK14 = 0x002000,
|
||||
CREATURE_TYPEFLAGS_UNK15 = 0x004000, // ? Possibly not in use
|
||||
CREATURE_TYPEFLAGS_ENGINEERLOOT = 0x008000, // Can be looted by engineer
|
||||
|
||||
Reference in New Issue
Block a user