refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -33,7 +33,7 @@ Corpse::~Corpse()
|
||||
}
|
||||
|
||||
void Corpse::AddToWorld()
|
||||
{
|
||||
{
|
||||
///- Register the corpse for guid lookup
|
||||
if (!IsInWorld())
|
||||
sObjectAccessor->AddObject(this);
|
||||
@@ -42,7 +42,7 @@ void Corpse::AddToWorld()
|
||||
}
|
||||
|
||||
void Corpse::RemoveFromWorld()
|
||||
{
|
||||
{
|
||||
///- Remove the corpse from the accessor
|
||||
if (IsInWorld())
|
||||
sObjectAccessor->RemoveObject(this);
|
||||
@@ -51,14 +51,14 @@ void Corpse::RemoveFromWorld()
|
||||
}
|
||||
|
||||
bool Corpse::Create(uint32 guidlow, Map* map)
|
||||
{
|
||||
{
|
||||
SetMap(map);
|
||||
Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Corpse::Create(uint32 guidlow, Player* owner)
|
||||
{
|
||||
{
|
||||
ASSERT(owner);
|
||||
|
||||
Relocate(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation());
|
||||
@@ -66,7 +66,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
sLog->outError("Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
|
||||
guidlow, owner->GetName().c_str(), owner->GetPositionX(), owner->GetPositionY());
|
||||
guidlow, owner->GetName().c_str(), owner->GetPositionX(), owner->GetPositionY());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
|
||||
}
|
||||
|
||||
void Corpse::SaveToDB()
|
||||
{
|
||||
{
|
||||
// prevent DB data inconsistence problems and duplicates
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
DeleteFromDB(trans);
|
||||
@@ -115,7 +115,7 @@ void Corpse::SaveToDB()
|
||||
}
|
||||
|
||||
void Corpse::DeleteFromDB(SQLTransaction& trans)
|
||||
{
|
||||
{
|
||||
PreparedStatement* stmt = nullptr;
|
||||
if (GetType() == CORPSE_BONES)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ void Corpse::DeleteFromDB(SQLTransaction& trans)
|
||||
}
|
||||
|
||||
bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
|
||||
{
|
||||
{
|
||||
uint32 ownerGuid = fields[17].GetUInt32();
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0
|
||||
@@ -169,7 +169,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
sLog->outError("Corpse (guid: %u, owner: %u) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
|
||||
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ);
|
||||
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
|
||||
}
|
||||
|
||||
bool Corpse::IsExpired(time_t t) const
|
||||
{
|
||||
{
|
||||
if (m_type == CORPSE_BONES)
|
||||
return m_time < t - 60 * MINUTE;
|
||||
else
|
||||
|
||||
@@ -36,38 +36,38 @@ enum CorpseFlags
|
||||
|
||||
class Corpse : public WorldObject, public GridObject<Corpse>
|
||||
{
|
||||
public:
|
||||
explicit Corpse(CorpseType type = CORPSE_BONES);
|
||||
~Corpse();
|
||||
public:
|
||||
explicit Corpse(CorpseType type = CORPSE_BONES);
|
||||
~Corpse();
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
bool Create(uint32 guidlow, Map* map);
|
||||
bool Create(uint32 guidlow, Player* owner);
|
||||
bool Create(uint32 guidlow, Map* map);
|
||||
bool Create(uint32 guidlow, Player* owner);
|
||||
|
||||
void SaveToDB();
|
||||
bool LoadCorpseFromDB(uint32 guid, Field* fields);
|
||||
void SaveToDB();
|
||||
bool LoadCorpseFromDB(uint32 guid, Field* fields);
|
||||
|
||||
void DeleteFromDB(SQLTransaction& trans);
|
||||
void DeleteFromDB(SQLTransaction& trans);
|
||||
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
|
||||
|
||||
time_t const& GetGhostTime() const { return m_time; }
|
||||
void ResetGhostTime() { m_time = time(nullptr); }
|
||||
CorpseType GetType() const { return m_type; }
|
||||
time_t const& GetGhostTime() const { return m_time; }
|
||||
void ResetGhostTime() { m_time = time(nullptr); }
|
||||
CorpseType GetType() const { return m_type; }
|
||||
|
||||
GridCoord const& GetGridCoord() const { return _gridCoord; }
|
||||
void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; }
|
||||
GridCoord const& GetGridCoord() const { return _gridCoord; }
|
||||
void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; }
|
||||
|
||||
Loot loot; // remove insignia ONLY at BG
|
||||
Player* lootRecipient;
|
||||
Loot loot; // remove insignia ONLY at BG
|
||||
Player* lootRecipient;
|
||||
|
||||
bool IsExpired(time_t t) const;
|
||||
bool IsExpired(time_t t) const;
|
||||
|
||||
private:
|
||||
CorpseType m_type;
|
||||
time_t m_time;
|
||||
GridCoord _gridCoord; // gride for corpse position for fast search
|
||||
private:
|
||||
CorpseType m_type;
|
||||
time_t m_time;
|
||||
GridCoord _gridCoord; // gride for corpse position for fast search
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,7 @@ uint32 CreatureTemplate::GetRandomValidModelId() const
|
||||
if (Modelid3) modelIDs[c++] = Modelid3;
|
||||
if (Modelid4) modelIDs[c++] = Modelid4;
|
||||
|
||||
return ((c>0) ? modelIDs[urand(0, c-1)] : 0);
|
||||
return ((c > 0) ? modelIDs[urand(0, c - 1)] : 0);
|
||||
}
|
||||
|
||||
uint32 CreatureTemplate::GetFirstValidModelId() const
|
||||
@@ -160,11 +160,11 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
}
|
||||
|
||||
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0),
|
||||
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
|
||||
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
|
||||
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
|
||||
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
|
||||
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(0)
|
||||
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
|
||||
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
|
||||
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
|
||||
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
|
||||
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(0)
|
||||
{
|
||||
m_regenTimer = CREATURE_REGEN_INTERVAL;
|
||||
m_valuesCount = UNIT_END;
|
||||
@@ -390,7 +390,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
|
||||
if (!m_wanderDistance && m_defaultMovementType == RANDOM_MOTION_TYPE)
|
||||
m_defaultMovementType = IDLE_MOTION_TYPE;
|
||||
|
||||
for (uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
m_spells[i] = GetCreatureTemplate()->spells[i];
|
||||
|
||||
return true;
|
||||
@@ -506,112 +506,112 @@ void Creature::Update(uint32 diff)
|
||||
sLog->outError("Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
|
||||
break;
|
||||
case DEAD:
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
if (m_respawnTime <= now)
|
||||
{
|
||||
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
|
||||
if (!allowed) // Will be rechecked on next Update call
|
||||
time_t now = time(nullptr);
|
||||
if (m_respawnTime <= now)
|
||||
{
|
||||
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
|
||||
if (!allowed) // Will be rechecked on next Update call
|
||||
break;
|
||||
|
||||
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
|
||||
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
|
||||
if (!linkedRespawntime) // Can respawn
|
||||
Respawn();
|
||||
else // the master is dead
|
||||
{
|
||||
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
|
||||
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
|
||||
SetRespawnTime(DAY);
|
||||
else
|
||||
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
|
||||
SaveRespawnTime(); // also save to DB immediately
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CORPSE:
|
||||
{
|
||||
Unit::Update(diff);
|
||||
// deathstate changed on spells update, prevent problems
|
||||
if (m_deathState != CORPSE)
|
||||
break;
|
||||
|
||||
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
|
||||
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
|
||||
if (!linkedRespawntime) // Can respawn
|
||||
Respawn();
|
||||
else // the master is dead
|
||||
if (m_groupLootTimer && lootingGroupLowGUID)
|
||||
{
|
||||
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
|
||||
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
|
||||
SetRespawnTime(DAY);
|
||||
else
|
||||
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime)+urand(5, MINUTE); // else copy time from master and add a little
|
||||
SaveRespawnTime(); // also save to DB immediately
|
||||
if (m_groupLootTimer <= diff)
|
||||
{
|
||||
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
|
||||
if (group)
|
||||
group->EndRoll(&loot, GetMap());
|
||||
m_groupLootTimer = 0;
|
||||
lootingGroupLowGUID = 0;
|
||||
}
|
||||
else m_groupLootTimer -= diff;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CORPSE:
|
||||
{
|
||||
Unit::Update(diff);
|
||||
// deathstate changed on spells update, prevent problems
|
||||
if (m_deathState != CORPSE)
|
||||
break;
|
||||
|
||||
if (m_groupLootTimer && lootingGroupLowGUID)
|
||||
{
|
||||
if (m_groupLootTimer <= diff)
|
||||
else if (m_corpseRemoveTime <= time(nullptr))
|
||||
{
|
||||
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
|
||||
if (group)
|
||||
group->EndRoll(&loot, GetMap());
|
||||
m_groupLootTimer = 0;
|
||||
lootingGroupLowGUID = 0;
|
||||
}
|
||||
else m_groupLootTimer -= diff;
|
||||
}
|
||||
else if (m_corpseRemoveTime <= time(nullptr))
|
||||
{
|
||||
RemoveCorpse(false);
|
||||
RemoveCorpse(false);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outStaticDebug("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
|
||||
sLog->outStaticDebug("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ALIVE:
|
||||
{
|
||||
Unit::Update(diff);
|
||||
{
|
||||
Unit::Update(diff);
|
||||
|
||||
// creature can be dead after Unit::Update call
|
||||
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
|
||||
if (!IsAlive())
|
||||
// creature can be dead after Unit::Update call
|
||||
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
|
||||
if (!IsAlive())
|
||||
break;
|
||||
|
||||
// if creature is charmed, switch to charmed AI
|
||||
if (NeedChangeAI)
|
||||
{
|
||||
UpdateCharmAI();
|
||||
NeedChangeAI = false;
|
||||
IsAIEnabled = true;
|
||||
|
||||
// xinef: update combat state, if npc is not in combat - return to spawn correctly by calling EnterEvadeMode
|
||||
SelectVictim();
|
||||
}
|
||||
|
||||
Unit* owner = GetCharmerOrOwner();
|
||||
if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()))
|
||||
{
|
||||
RemoveCharmAuras();
|
||||
}
|
||||
|
||||
if (!IsInEvadeMode() && IsAIEnabled)
|
||||
{
|
||||
// do not allow the AI to be changed during update
|
||||
m_AI_locked = true;
|
||||
i_AI->UpdateAI(diff);
|
||||
m_AI_locked = false;
|
||||
}
|
||||
|
||||
// creature can be dead after UpdateAI call
|
||||
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
|
||||
if (!IsAlive())
|
||||
break;
|
||||
|
||||
m_regenTimer -= diff;
|
||||
if (m_regenTimer <= 0)
|
||||
{
|
||||
if (!IsInEvadeMode() && (!IsInCombat() || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
|
||||
RegenerateHealth();
|
||||
|
||||
if (getPowerType() == POWER_ENERGY)
|
||||
Regenerate(POWER_ENERGY);
|
||||
else
|
||||
Regenerate(POWER_MANA);
|
||||
|
||||
m_regenTimer += CREATURE_REGEN_INTERVAL;
|
||||
}
|
||||
break;
|
||||
|
||||
// if creature is charmed, switch to charmed AI
|
||||
if (NeedChangeAI)
|
||||
{
|
||||
UpdateCharmAI();
|
||||
NeedChangeAI = false;
|
||||
IsAIEnabled = true;
|
||||
|
||||
// xinef: update combat state, if npc is not in combat - return to spawn correctly by calling EnterEvadeMode
|
||||
SelectVictim();
|
||||
}
|
||||
|
||||
Unit* owner = GetCharmerOrOwner();
|
||||
if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()))
|
||||
{
|
||||
RemoveCharmAuras();
|
||||
}
|
||||
|
||||
if (!IsInEvadeMode() && IsAIEnabled)
|
||||
{
|
||||
// do not allow the AI to be changed during update
|
||||
m_AI_locked = true;
|
||||
i_AI->UpdateAI(diff);
|
||||
m_AI_locked = false;
|
||||
}
|
||||
|
||||
// creature can be dead after UpdateAI call
|
||||
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
|
||||
if (!IsAlive())
|
||||
break;
|
||||
|
||||
m_regenTimer -= diff;
|
||||
if (m_regenTimer <= 0)
|
||||
{
|
||||
if (!IsInEvadeMode() && (!IsInCombat() || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
|
||||
RegenerateHealth();
|
||||
|
||||
if (getPowerType() == POWER_ENERGY)
|
||||
Regenerate(POWER_ENERGY);
|
||||
else
|
||||
Regenerate(POWER_MANA);
|
||||
|
||||
m_regenTimer += CREATURE_REGEN_INTERVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -660,38 +660,38 @@ void Creature::Regenerate(Powers power)
|
||||
switch (power)
|
||||
{
|
||||
case POWER_FOCUS:
|
||||
{
|
||||
// For hunter pets.
|
||||
addvalue = 24 * sWorld->getRate(RATE_POWER_FOCUS);
|
||||
break;
|
||||
}
|
||||
case POWER_ENERGY:
|
||||
{
|
||||
// For deathknight's ghoul.
|
||||
addvalue = 20;
|
||||
break;
|
||||
}
|
||||
case POWER_MANA:
|
||||
{
|
||||
// Combat and any controlled creature
|
||||
if (IsInCombat() || GetCharmerOrOwnerGUID())
|
||||
{
|
||||
if (GetEntry() == NPC_IMP || GetEntry() == NPC_WATER_ELEMENTAL_TEMP || GetEntry() == NPC_WATER_ELEMENTAL_PERM)
|
||||
{
|
||||
addvalue = uint32((GetStat(STAT_SPIRIT) / (IsUnderLastManaUseEffect() ? 8.0f : 5.0f) + 17.0f));
|
||||
}
|
||||
else if (!IsUnderLastManaUseEffect())
|
||||
{
|
||||
float ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA);
|
||||
float Spirit = GetStat(STAT_SPIRIT);
|
||||
|
||||
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
|
||||
}
|
||||
// For hunter pets.
|
||||
addvalue = 24 * sWorld->getRate(RATE_POWER_FOCUS);
|
||||
break;
|
||||
}
|
||||
case POWER_ENERGY:
|
||||
{
|
||||
// For deathknight's ghoul.
|
||||
addvalue = 20;
|
||||
break;
|
||||
}
|
||||
case POWER_MANA:
|
||||
{
|
||||
// Combat and any controlled creature
|
||||
if (IsInCombat() || GetCharmerOrOwnerGUID())
|
||||
{
|
||||
if (GetEntry() == NPC_IMP || GetEntry() == NPC_WATER_ELEMENTAL_TEMP || GetEntry() == NPC_WATER_ELEMENTAL_PERM)
|
||||
{
|
||||
addvalue = uint32((GetStat(STAT_SPIRIT) / (IsUnderLastManaUseEffect() ? 8.0f : 5.0f) + 17.0f));
|
||||
}
|
||||
else if (!IsUnderLastManaUseEffect())
|
||||
{
|
||||
float ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA);
|
||||
float Spirit = GetStat(STAT_SPIRIT);
|
||||
|
||||
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
|
||||
}
|
||||
}
|
||||
else
|
||||
addvalue = maxValue / 3;
|
||||
break;
|
||||
}
|
||||
else
|
||||
addvalue = maxValue / 3;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -723,7 +723,7 @@ void Creature::RegenerateHealth()
|
||||
// Not only pet, but any controlled creature
|
||||
// Xinef: fix polymorph rapid regen
|
||||
if (!GetCharmerOrOwnerGUID() || IsPolymorphed())
|
||||
addvalue = maxValue/3;
|
||||
addvalue = maxValue / 3;
|
||||
else //if (GetCharmerOrOwnerGUID())
|
||||
{
|
||||
float HealthIncreaseRate = sWorld->getRate(RATE_HEALTH);
|
||||
@@ -755,7 +755,7 @@ void Creature::DoFleeToGetAssistance()
|
||||
return;
|
||||
|
||||
float radius = sWorld->getFloatConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS);
|
||||
if (radius >0)
|
||||
if (radius > 0)
|
||||
{
|
||||
Creature* creature = nullptr;
|
||||
|
||||
@@ -864,7 +864,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
|
||||
case CREATURE_ELITE_WORLDBOSS:
|
||||
// Xinef: Reduce corpse delay for bossess outside of instance
|
||||
if (!GetInstanceId())
|
||||
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_ELITE)*2;
|
||||
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_ELITE) * 2;
|
||||
else
|
||||
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_WORLDBOSS);
|
||||
break;
|
||||
@@ -918,9 +918,15 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
|
||||
ClearGossipMenuFor(player);
|
||||
switch (bgTypeId)
|
||||
{
|
||||
case BATTLEGROUND_AV: SendGossipMenuFor(player, 7616, this); break;
|
||||
case BATTLEGROUND_WS: SendGossipMenuFor(player, 7599, this); break;
|
||||
case BATTLEGROUND_AB: SendGossipMenuFor(player, 7642, this); break;
|
||||
case BATTLEGROUND_AV:
|
||||
SendGossipMenuFor(player, 7616, this);
|
||||
break;
|
||||
case BATTLEGROUND_WS:
|
||||
SendGossipMenuFor(player, 7599, this);
|
||||
break;
|
||||
case BATTLEGROUND_AB:
|
||||
SendGossipMenuFor(player, 7642, this);
|
||||
break;
|
||||
case BATTLEGROUND_EY:
|
||||
case BATTLEGROUND_NA:
|
||||
case BATTLEGROUND_BE:
|
||||
@@ -928,8 +934,11 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
|
||||
case BATTLEGROUND_RL:
|
||||
case BATTLEGROUND_SA:
|
||||
case BATTLEGROUND_DS:
|
||||
case BATTLEGROUND_RV: SendGossipMenuFor(player, 10024, this); break;
|
||||
default: break;
|
||||
case BATTLEGROUND_RV:
|
||||
SendGossipMenuFor(player, 10024, this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -939,8 +948,8 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
|
||||
bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const
|
||||
{
|
||||
return player->getLevel() >= 10
|
||||
&& GetCreatureTemplate()->trainer_type == TRAINER_TYPE_CLASS
|
||||
&& player->getClass() == GetCreatureTemplate()->trainer_class;
|
||||
&& GetCreatureTemplate()->trainer_type == TRAINER_TYPE_CLASS
|
||||
&& player->getClass() == GetCreatureTemplate()->trainer_class;
|
||||
}
|
||||
|
||||
Player* Creature::GetLootRecipient() const
|
||||
@@ -967,7 +976,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
|
||||
{
|
||||
m_lootRecipient = 0;
|
||||
m_lootRecipientGroup = 0;
|
||||
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
|
||||
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1045,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
if (cinfo)
|
||||
{
|
||||
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
|
||||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
|
||||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
|
||||
displayId = 0;
|
||||
|
||||
if (npcflag == cinfo->npcflag)
|
||||
@@ -1078,7 +1087,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
data.curmana = GetPower(POWER_MANA);
|
||||
// prevent add data integrity problems
|
||||
data.movementType = !m_wanderDistance && GetDefaultMovementType() == RANDOM_MOTION_TYPE
|
||||
? IDLE_MOTION_TYPE : GetDefaultMovementType();
|
||||
? IDLE_MOTION_TYPE : GetDefaultMovementType();
|
||||
data.spawnMask = spawnMask;
|
||||
data.npcflag = npcflag;
|
||||
data.unit_flags = unit_flags;
|
||||
@@ -1320,9 +1329,9 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
|
||||
// xinef: fix shitness from db
|
||||
if ((addToMap || gridLoad) && !data->overwrittenZ)
|
||||
{
|
||||
float tz = map->GetHeight(data->posX, data->posY, data->posZ+1.0f, true);
|
||||
float tz = map->GetHeight(data->posX, data->posY, data->posZ + 1.0f, true);
|
||||
if (tz >= data->posZ && tz - data->posZ <= 1.0f)
|
||||
const_cast<CreatureData*>(data)->posZ = tz+0.1f;
|
||||
const_cast<CreatureData*>(data)->posZ = tz + 0.1f;
|
||||
|
||||
const_cast<CreatureData*>(data)->overwrittenZ = true;
|
||||
}
|
||||
@@ -1371,7 +1380,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
|
||||
curhealth = data->curhealth;
|
||||
if (curhealth)
|
||||
{
|
||||
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
|
||||
curhealth = uint32(curhealth * _GetHealthMod(GetCreatureTemplate()->rank));
|
||||
if (curhealth < 1)
|
||||
curhealth = 1;
|
||||
}
|
||||
@@ -1501,7 +1510,7 @@ bool Creature::CanStartAttack(Unit const* who) const
|
||||
|
||||
// This set of checks is should be done only for creatures
|
||||
if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) || // flag is valid only for non player characters
|
||||
(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
|
||||
(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
|
||||
return false;
|
||||
|
||||
if (Unit* owner = who->GetOwner())
|
||||
@@ -1755,7 +1764,7 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
|
||||
if (!victim)
|
||||
return nullptr;
|
||||
|
||||
for (uint32 i=0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
{
|
||||
if (!m_spells[i])
|
||||
continue;
|
||||
@@ -1770,10 +1779,10 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
|
||||
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
|
||||
{
|
||||
if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
)
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
)
|
||||
{
|
||||
bcontinue = false;
|
||||
break;
|
||||
@@ -1803,7 +1812,7 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
|
||||
if (!victim)
|
||||
return nullptr;
|
||||
|
||||
for (uint32 i=0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
{
|
||||
if (!m_spells[i])
|
||||
continue;
|
||||
@@ -2066,8 +2075,8 @@ bool Creature::_CanDetectFeignDeathOf(const Unit* target) const
|
||||
void Creature::UpdateMoveInLineOfSightState()
|
||||
{
|
||||
// xinef: pets, guardians and units with scripts / smartAI should be skipped
|
||||
if (IsPet() || HasUnitTypeMask(UNIT_MASK_MINION|UNIT_MASK_SUMMON|UNIT_MASK_GUARDIAN|UNIT_MASK_CONTROLABLE_GUARDIAN) ||
|
||||
GetScriptId() || GetAIName() == "SmartAI")
|
||||
if (IsPet() || HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_SUMMON | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) ||
|
||||
GetScriptId() || GetAIName() == "SmartAI")
|
||||
{
|
||||
m_moveInLineOfSightStrictlyDisabled = false;
|
||||
m_moveInLineOfSightDisabled = false;
|
||||
@@ -2137,7 +2146,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
|
||||
return true;
|
||||
|
||||
// xinef: added size factor for huge npcs
|
||||
float dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize()*2, 150.0f);
|
||||
float dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize() * 2, 150.0f);
|
||||
|
||||
if (Unit* unit = GetCharmerOrOwner())
|
||||
return victim->IsWithinDist(unit, dist);
|
||||
@@ -2279,7 +2288,7 @@ void Creature::SetInCombatWithZone()
|
||||
return;
|
||||
}
|
||||
|
||||
Map::PlayerList const &PlList = map->GetPlayers();
|
||||
Map::PlayerList const& PlList = map->GetPlayers();
|
||||
|
||||
if (PlList.isEmpty())
|
||||
return;
|
||||
@@ -2324,7 +2333,7 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS()+end_time;
|
||||
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS() + end_time;
|
||||
}
|
||||
|
||||
void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool /*needSendToClient*/, bool /*forceSendToSpectator*/)
|
||||
@@ -2390,7 +2399,7 @@ bool Creature::HasSpell(uint32 spellID) const
|
||||
}
|
||||
|
||||
time_t Creature::GetRespawnTimeEx() const
|
||||
{
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
|
||||
if (m_respawnTime > now)
|
||||
@@ -2399,7 +2408,7 @@ time_t Creature::GetRespawnTimeEx() const
|
||||
return now;
|
||||
}
|
||||
|
||||
void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
|
||||
void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
{
|
||||
@@ -2517,7 +2526,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
|
||||
{
|
||||
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
|
||||
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
|
||||
{
|
||||
m_vendorItemCounts.erase(itr);
|
||||
@@ -2543,7 +2552,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
|
||||
|
||||
if (itr == m_vendorItemCounts.end())
|
||||
{
|
||||
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
|
||||
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount - used_count : 0;
|
||||
m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count));
|
||||
return new_count;
|
||||
}
|
||||
@@ -2556,14 +2565,14 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
|
||||
{
|
||||
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
|
||||
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
|
||||
vCount->count += diff * pProto->BuyCount;
|
||||
else
|
||||
vCount->count = vItem->maxcount;
|
||||
}
|
||||
|
||||
vCount->count = vCount->count > used_count ? vCount->count-used_count : 0;
|
||||
vCount->count = vCount->count > used_count ? vCount->count - used_count : 0;
|
||||
vCount->lastIncrementTime = ptime;
|
||||
return vCount->count;
|
||||
}
|
||||
@@ -2867,5 +2876,5 @@ float Creature::GetAttackDistance(Unit const* player) const
|
||||
if (retDistance < 5.0f)
|
||||
retDistance = 5.0f;
|
||||
|
||||
return (retDistance*aggroRate);
|
||||
return (retDistance * aggroRate);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ struct CreatureTemplate
|
||||
{
|
||||
return (type_flags & CREATURE_TYPE_FLAG_EXOTIC_PET) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsTameable(bool exotic) const
|
||||
{
|
||||
if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
|
||||
@@ -252,9 +252,9 @@ typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfo
|
||||
struct CreatureData
|
||||
{
|
||||
CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
|
||||
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
|
||||
wander_distance(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
|
||||
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
|
||||
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
|
||||
wander_distance(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
|
||||
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
|
||||
uint32 id; // entry in creature_template
|
||||
uint16 mapid;
|
||||
uint32 phaseMask;
|
||||
@@ -414,7 +414,7 @@ struct TrainerSpellData
|
||||
|
||||
TrainerSpellMap spellList;
|
||||
uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
|
||||
// req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
|
||||
// req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
|
||||
TrainerSpell const* Find(uint32 spell_id) const;
|
||||
};
|
||||
|
||||
@@ -427,389 +427,389 @@ typedef std::map<uint32, time_t> CreatureSpellCooldowns;
|
||||
|
||||
class Creature : public Unit, public GridObject<Creature>, public MovableMapObject
|
||||
{
|
||||
public:
|
||||
|
||||
explicit Creature(bool isWorldObject = false);
|
||||
virtual ~Creature();
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
void SetObjectScale(float scale) override;
|
||||
void SetDisplayId(uint32 modelId) override;
|
||||
|
||||
void DisappearAndDie();
|
||||
|
||||
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
|
||||
bool LoadCreaturesAddon(bool reload = false);
|
||||
void SelectLevel(bool changelevel = true);
|
||||
void LoadEquipment(int8 id = 1, bool force = false);
|
||||
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
|
||||
void Update(uint32 time) override; // overwrited Unit::Update
|
||||
void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
||||
|
||||
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
||||
uint32 GetCorpseDelay() const { return m_corpseDelay; }
|
||||
bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
|
||||
bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
|
||||
bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
|
||||
bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
|
||||
bool CanWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; }
|
||||
bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); }
|
||||
bool CanFly() const override { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; }
|
||||
|
||||
void SetReactState(ReactStates st) { m_reactState = st; }
|
||||
ReactStates GetReactState() const { return m_reactState; }
|
||||
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
|
||||
void InitializeReactState();
|
||||
|
||||
///// TODO RENAME THIS!!!!!
|
||||
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool isCanTrainingAndResetTalentsOf(Player* player) const;
|
||||
bool CanCreatureAttack(Unit const* victim, bool skipDistCheck = false) const;
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo) override;
|
||||
|
||||
bool HasMechanicTemplateImmunity(uint32 mask) const;
|
||||
// redefine Unit::IsImmunedToSpell
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
|
||||
// redefine Unit::IsImmunedToSpellEffect
|
||||
bool isElite() const
|
||||
{
|
||||
if (IsPet())
|
||||
return false;
|
||||
|
||||
uint32 rank = GetCreatureTemplate()->rank;
|
||||
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
|
||||
}
|
||||
|
||||
bool isWorldBoss() const
|
||||
{
|
||||
if (IsPet())
|
||||
return false;
|
||||
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB;
|
||||
}
|
||||
|
||||
bool IsDungeonBoss() const;
|
||||
bool IsImmuneToKnockback() const;
|
||||
bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; }
|
||||
|
||||
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
|
||||
|
||||
bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); }
|
||||
|
||||
bool AIM_Initialize(CreatureAI* ai = nullptr);
|
||||
void Motion_Initialize();
|
||||
|
||||
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
|
||||
|
||||
bool SetWalk(bool enable) override;
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false) override;
|
||||
bool SetSwim(bool enable) override;
|
||||
bool SetCanFly(bool enable, bool packetOnly = false) override;
|
||||
bool SetWaterWalking(bool enable, bool packetOnly = false) override;
|
||||
bool SetFeatherFall(bool enable, bool packetOnly = false) override;
|
||||
bool SetHover(bool enable, bool packetOnly = false) override;
|
||||
|
||||
uint32 GetShieldBlockValue() const override
|
||||
{
|
||||
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
|
||||
}
|
||||
|
||||
SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
|
||||
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
|
||||
|
||||
void _AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time);
|
||||
virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
|
||||
virtual bool HasSpellCooldown(uint32 spell_id) const override;
|
||||
uint32 GetSpellCooldown(uint32 spell_id) const;
|
||||
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const;
|
||||
|
||||
bool HasSpell(uint32 spellID) const override;
|
||||
|
||||
bool UpdateEntry(uint32 entry, const CreatureData* data=NULL, bool changelevel=true );
|
||||
bool UpdateStats(Stats stat) override;
|
||||
bool UpdateAllStats() override;
|
||||
void UpdateResistances(uint32 school) override;
|
||||
void UpdateArmor() override;
|
||||
void UpdateMaxHealth() override;
|
||||
void UpdateMaxPower(Powers power) override;
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false) override;
|
||||
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
|
||||
|
||||
void SetCanDualWield(bool value) override;
|
||||
int8 GetOriginalEquipmentId() const { return m_originalEquipmentId; }
|
||||
uint8 GetCurrentEquipmentId() { return m_equipmentId; }
|
||||
void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
|
||||
|
||||
float GetSpellDamageMod(int32 Rank);
|
||||
|
||||
VendorItemData const* GetVendorItems() const;
|
||||
uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
|
||||
uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
|
||||
|
||||
TrainerSpellData const* GetTrainerSpells() const;
|
||||
|
||||
CreatureTemplate const* GetCreatureTemplate() const { return m_creatureInfo; }
|
||||
CreatureData const* GetCreatureData() const { return m_creatureData; }
|
||||
CreatureAddon const* GetCreatureAddon() const;
|
||||
|
||||
std::string GetAIName() const;
|
||||
std::string GetScriptName() const;
|
||||
uint32 GetScriptId() const;
|
||||
|
||||
// override WorldObject function for proper name localization
|
||||
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
|
||||
|
||||
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
|
||||
|
||||
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); }
|
||||
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false);
|
||||
void SaveToDB();
|
||||
// overriden in Pet
|
||||
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||
virtual void DeleteFromDB(); // overriden in Pet
|
||||
|
||||
Loot loot;
|
||||
uint64 GetLootRecipientGUID() const { return m_lootRecipient; }
|
||||
Player* GetLootRecipient() const;
|
||||
Group* GetLootRecipientGroup() const;
|
||||
bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
|
||||
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
|
||||
bool CanGeneratePickPocketLoot() const { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(nullptr); }
|
||||
void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(nullptr) + MINUTE + GetCorpseDelay() + GetRespawnTime(); }
|
||||
void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; }
|
||||
|
||||
void SetLootRecipient (Unit* unit, bool withGroup = true);
|
||||
void AllLootRemovedFromCorpse();
|
||||
|
||||
uint16 GetLootMode() const { return m_LootMode; }
|
||||
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
|
||||
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
|
||||
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
|
||||
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
|
||||
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
|
||||
|
||||
SpellInfo const* reachWithSpellAttack(Unit* victim);
|
||||
SpellInfo const* reachWithSpellCure(Unit* victim);
|
||||
|
||||
uint32 m_spells[CREATURE_MAX_SPELLS];
|
||||
CreatureSpellCooldowns m_CreatureSpellCooldowns;
|
||||
uint32 m_ProhibitSchoolTime[7];
|
||||
|
||||
bool CanStartAttack(Unit const* u) const;
|
||||
float GetAggroRange(Unit const* target) const;
|
||||
float GetAttackDistance(Unit const* player) const;
|
||||
|
||||
void SendAIReaction(AiReaction reactionType);
|
||||
|
||||
Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
|
||||
Unit* SelectNearestTargetInAttackDistance(float dist) const;
|
||||
|
||||
void DoFleeToGetAssistance();
|
||||
void CallForHelp(float fRadius);
|
||||
void CallAssistance();
|
||||
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
|
||||
void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
|
||||
bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
|
||||
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
|
||||
bool _IsTargetAcceptable(const Unit* target) const;
|
||||
bool _CanDetectFeignDeathOf(const Unit* target) const; // pussywizard
|
||||
|
||||
// pussywizard: updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
|
||||
void UpdateMoveInLineOfSightState();
|
||||
bool IsMoveInLineOfSightDisabled() { return m_moveInLineOfSightDisabled; }
|
||||
bool IsMoveInLineOfSightStrictlyDisabled() { return m_moveInLineOfSightStrictlyDisabled; }
|
||||
|
||||
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
|
||||
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
|
||||
public:
|
||||
|
||||
explicit Creature(bool isWorldObject = false);
|
||||
virtual ~Creature();
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
void SetObjectScale(float scale) override;
|
||||
void SetDisplayId(uint32 modelId) override;
|
||||
|
||||
void DisappearAndDie();
|
||||
|
||||
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
|
||||
bool LoadCreaturesAddon(bool reload = false);
|
||||
void SelectLevel(bool changelevel = true);
|
||||
void LoadEquipment(int8 id = 1, bool force = false);
|
||||
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
|
||||
void Update(uint32 time) override; // overwrited Unit::Update
|
||||
void GetRespawnPosition(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
|
||||
|
||||
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
||||
uint32 GetCorpseDelay() const { return m_corpseDelay; }
|
||||
bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
|
||||
bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
|
||||
bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
|
||||
bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
|
||||
bool CanWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; }
|
||||
bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); }
|
||||
bool CanFly() const override { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; }
|
||||
|
||||
void SetReactState(ReactStates st) { m_reactState = st; }
|
||||
ReactStates GetReactState() const { return m_reactState; }
|
||||
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
|
||||
void InitializeReactState();
|
||||
|
||||
///// TODO RENAME THIS!!!!!
|
||||
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool isCanTrainingAndResetTalentsOf(Player* player) const;
|
||||
bool CanCreatureAttack(Unit const* victim, bool skipDistCheck = false) const;
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo) override;
|
||||
|
||||
bool HasMechanicTemplateImmunity(uint32 mask) const;
|
||||
// redefine Unit::IsImmunedToSpell
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
|
||||
// redefine Unit::IsImmunedToSpellEffect
|
||||
bool isElite() const
|
||||
{
|
||||
if (IsPet())
|
||||
return false;
|
||||
|
||||
uint32 rank = GetCreatureTemplate()->rank;
|
||||
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
|
||||
}
|
||||
|
||||
bool isWorldBoss() const
|
||||
{
|
||||
if (IsPet())
|
||||
return false;
|
||||
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB;
|
||||
}
|
||||
|
||||
bool IsDungeonBoss() const;
|
||||
bool IsImmuneToKnockback() const;
|
||||
bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; }
|
||||
|
||||
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
|
||||
|
||||
bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); }
|
||||
|
||||
bool AIM_Initialize(CreatureAI* ai = nullptr);
|
||||
void Motion_Initialize();
|
||||
|
||||
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
|
||||
|
||||
bool SetWalk(bool enable) override;
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false) override;
|
||||
bool SetSwim(bool enable) override;
|
||||
bool SetCanFly(bool enable, bool packetOnly = false) override;
|
||||
bool SetWaterWalking(bool enable, bool packetOnly = false) override;
|
||||
bool SetFeatherFall(bool enable, bool packetOnly = false) override;
|
||||
bool SetHover(bool enable, bool packetOnly = false) override;
|
||||
|
||||
uint32 GetShieldBlockValue() const override
|
||||
{
|
||||
return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20));
|
||||
}
|
||||
|
||||
SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
|
||||
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
|
||||
|
||||
void _AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time);
|
||||
virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
|
||||
virtual bool HasSpellCooldown(uint32 spell_id) const override;
|
||||
uint32 GetSpellCooldown(uint32 spell_id) const;
|
||||
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const;
|
||||
|
||||
bool HasSpell(uint32 spellID) const override;
|
||||
|
||||
bool UpdateEntry(uint32 entry, const CreatureData* data = NULL, bool changelevel = true );
|
||||
bool UpdateStats(Stats stat) override;
|
||||
bool UpdateAllStats() override;
|
||||
void UpdateResistances(uint32 school) override;
|
||||
void UpdateArmor() override;
|
||||
void UpdateMaxHealth() override;
|
||||
void UpdateMaxPower(Powers power) override;
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false) override;
|
||||
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
|
||||
|
||||
void SetCanDualWield(bool value) override;
|
||||
int8 GetOriginalEquipmentId() const { return m_originalEquipmentId; }
|
||||
uint8 GetCurrentEquipmentId() { return m_equipmentId; }
|
||||
void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
|
||||
|
||||
float GetSpellDamageMod(int32 Rank);
|
||||
|
||||
VendorItemData const* GetVendorItems() const;
|
||||
uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
|
||||
uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
|
||||
|
||||
TrainerSpellData const* GetTrainerSpells() const;
|
||||
|
||||
CreatureTemplate const* GetCreatureTemplate() const { return m_creatureInfo; }
|
||||
CreatureData const* GetCreatureData() const { return m_creatureData; }
|
||||
CreatureAddon const* GetCreatureAddon() const;
|
||||
|
||||
std::string GetAIName() const;
|
||||
std::string GetScriptName() const;
|
||||
uint32 GetScriptId() const;
|
||||
|
||||
// override WorldObject function for proper name localization
|
||||
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
|
||||
|
||||
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
|
||||
|
||||
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); }
|
||||
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false);
|
||||
void SaveToDB();
|
||||
// overriden in Pet
|
||||
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||
virtual void DeleteFromDB(); // overriden in Pet
|
||||
|
||||
Loot loot;
|
||||
uint64 GetLootRecipientGUID() const { return m_lootRecipient; }
|
||||
Player* GetLootRecipient() const;
|
||||
Group* GetLootRecipientGroup() const;
|
||||
bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
|
||||
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
|
||||
bool CanGeneratePickPocketLoot() const { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(nullptr); }
|
||||
void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(nullptr) + MINUTE + GetCorpseDelay() + GetRespawnTime(); }
|
||||
void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; }
|
||||
|
||||
void SetLootRecipient (Unit* unit, bool withGroup = true);
|
||||
void AllLootRemovedFromCorpse();
|
||||
|
||||
uint16 GetLootMode() const { return m_LootMode; }
|
||||
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
|
||||
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
|
||||
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
|
||||
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
|
||||
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
|
||||
|
||||
SpellInfo const* reachWithSpellAttack(Unit* victim);
|
||||
SpellInfo const* reachWithSpellCure(Unit* victim);
|
||||
|
||||
uint32 m_spells[CREATURE_MAX_SPELLS];
|
||||
CreatureSpellCooldowns m_CreatureSpellCooldowns;
|
||||
uint32 m_ProhibitSchoolTime[7];
|
||||
|
||||
bool CanStartAttack(Unit const* u) const;
|
||||
float GetAggroRange(Unit const* target) const;
|
||||
float GetAttackDistance(Unit const* player) const;
|
||||
|
||||
void SendAIReaction(AiReaction reactionType);
|
||||
|
||||
Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
|
||||
Unit* SelectNearestTargetInAttackDistance(float dist) const;
|
||||
|
||||
void DoFleeToGetAssistance();
|
||||
void CallForHelp(float fRadius);
|
||||
void CallAssistance();
|
||||
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
|
||||
void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
|
||||
bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
|
||||
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
|
||||
bool _IsTargetAcceptable(const Unit* target) const;
|
||||
bool _CanDetectFeignDeathOf(const Unit* target) const; // pussywizard
|
||||
|
||||
// pussywizard: updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
|
||||
void UpdateMoveInLineOfSightState();
|
||||
bool IsMoveInLineOfSightDisabled() { return m_moveInLineOfSightDisabled; }
|
||||
bool IsMoveInLineOfSightStrictlyDisabled() { return m_moveInLineOfSightStrictlyDisabled; }
|
||||
|
||||
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
|
||||
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
|
||||
|
||||
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
|
||||
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
|
||||
|
||||
time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||
time_t GetRespawnTimeEx() const;
|
||||
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; }
|
||||
void Respawn(bool force = false);
|
||||
void SaveRespawnTime() override;
|
||||
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelay; }
|
||||
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
|
||||
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
|
||||
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
|
||||
|
||||
time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||
time_t GetRespawnTimeEx() const;
|
||||
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; }
|
||||
void Respawn(bool force = false);
|
||||
void SaveRespawnTime() override;
|
||||
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelay; }
|
||||
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
|
||||
|
||||
float GetWanderDistance() const { return m_wanderDistance; }
|
||||
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
|
||||
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
|
||||
|
||||
void SendZoneUnderAttackMessage(Player* attacker);
|
||||
|
||||
void SetInCombatWithZone();
|
||||
|
||||
bool hasQuest(uint32 quest_id) const override;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const override;
|
||||
|
||||
bool isRegeneratingHealth() { return m_regenHealth; }
|
||||
void SetRegeneratingHealth(bool c) { m_regenHealth = c; }
|
||||
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
||||
{
|
||||
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
|
||||
return 0;
|
||||
else
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
|
||||
|
||||
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
|
||||
void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); }
|
||||
void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); }
|
||||
Position const& GetHomePosition() const { return m_homePosition; }
|
||||
|
||||
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
|
||||
void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); }
|
||||
void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); }
|
||||
Position const& GetTransportHomePosition() const { return m_transportHomePosition; }
|
||||
|
||||
uint32 GetWaypointPath() const { return m_path_id; }
|
||||
void LoadPath(uint32 pathid) { m_path_id = pathid; }
|
||||
float GetWanderDistance() const { return m_wanderDistance; }
|
||||
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
|
||||
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
|
||||
|
||||
void SendZoneUnderAttackMessage(Player* attacker);
|
||||
|
||||
void SetInCombatWithZone();
|
||||
|
||||
bool hasQuest(uint32 quest_id) const override;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const override;
|
||||
|
||||
bool isRegeneratingHealth() { return m_regenHealth; }
|
||||
void SetRegeneratingHealth(bool c) { m_regenHealth = c; }
|
||||
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
||||
{
|
||||
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
|
||||
return 0;
|
||||
else
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(const Position& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
|
||||
|
||||
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
|
||||
void SetHomePosition(const Position& pos) { m_homePosition.Relocate(pos); }
|
||||
void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); }
|
||||
Position const& GetHomePosition() const { return m_homePosition; }
|
||||
|
||||
uint32 GetCurrentWaypointID() const { return m_waypointID; }
|
||||
void UpdateWaypointID(uint32 wpID){ m_waypointID = wpID; }
|
||||
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
|
||||
void SetTransportHomePosition(const Position& pos) { m_transportHomePosition.Relocate(pos); }
|
||||
void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); }
|
||||
Position const& GetTransportHomePosition() const { return m_transportHomePosition; }
|
||||
|
||||
void SearchFormation();
|
||||
CreatureGroup* GetFormation() const { return m_formation; }
|
||||
void SetFormation(CreatureGroup* formation) { m_formation = formation; }
|
||||
uint32 GetWaypointPath() const { return m_path_id; }
|
||||
void LoadPath(uint32 pathid) { m_path_id = pathid; }
|
||||
|
||||
Unit* SelectVictim();
|
||||
uint32 GetCurrentWaypointID() const { return m_waypointID; }
|
||||
void UpdateWaypointID(uint32 wpID) { m_waypointID = wpID; }
|
||||
|
||||
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
|
||||
bool IsReputationGainDisabled() const { return DisableReputationGain; }
|
||||
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
|
||||
void LowerPlayerDamageReq(uint32 unDamage)
|
||||
{
|
||||
if (m_PlayerDamageReq)
|
||||
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
|
||||
}
|
||||
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
|
||||
uint32 m_PlayerDamageReq;
|
||||
void SearchFormation();
|
||||
CreatureGroup* GetFormation() const { return m_formation; }
|
||||
void SetFormation(CreatureGroup* formation) { m_formation = formation; }
|
||||
|
||||
uint32 GetOriginalEntry() const { return m_originalEntry; }
|
||||
void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
|
||||
Unit* SelectVictim();
|
||||
|
||||
static float _GetDamageMod(int32 Rank);
|
||||
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
|
||||
bool IsReputationGainDisabled() const { return DisableReputationGain; }
|
||||
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
|
||||
void LowerPlayerDamageReq(uint32 unDamage)
|
||||
{
|
||||
if (m_PlayerDamageReq)
|
||||
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
|
||||
}
|
||||
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
|
||||
uint32 m_PlayerDamageReq;
|
||||
|
||||
float m_SightDistance, m_CombatDistance;
|
||||
uint32 GetOriginalEntry() const { return m_originalEntry; }
|
||||
void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
|
||||
|
||||
bool m_isTempWorldObject; //true when possessed
|
||||
static float _GetDamageMod(int32 Rank);
|
||||
|
||||
// Handling caster facing during spellcast
|
||||
void SetTarget(uint64 guid) override;
|
||||
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
|
||||
void ReleaseFocus(Spell const* focusSpell);
|
||||
float m_SightDistance, m_CombatDistance;
|
||||
|
||||
// Part of Evade mechanics
|
||||
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
|
||||
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
|
||||
bool m_isTempWorldObject; //true when possessed
|
||||
|
||||
protected:
|
||||
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
|
||||
bool InitEntry(uint32 entry, const CreatureData* data=NULL);
|
||||
// Handling caster facing during spellcast
|
||||
void SetTarget(uint64 guid) override;
|
||||
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
|
||||
void ReleaseFocus(Spell const* focusSpell);
|
||||
|
||||
// vendor items
|
||||
VendorItemCounts m_vendorItemCounts;
|
||||
// Part of Evade mechanics
|
||||
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
|
||||
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
|
||||
|
||||
static float _GetHealthMod(int32 Rank);
|
||||
protected:
|
||||
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
|
||||
bool InitEntry(uint32 entry, const CreatureData* data = NULL);
|
||||
|
||||
uint64 m_lootRecipient;
|
||||
uint32 m_lootRecipientGroup;
|
||||
// vendor items
|
||||
VendorItemCounts m_vendorItemCounts;
|
||||
|
||||
/// Timers
|
||||
time_t m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
|
||||
time_t m_respawnTime; // (secs) time of next respawn
|
||||
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
|
||||
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
|
||||
float m_wanderDistance;
|
||||
uint16 m_transportCheckTimer;
|
||||
uint32 lootPickPocketRestoreTime;
|
||||
static float _GetHealthMod(int32 Rank);
|
||||
|
||||
ReactStates m_reactState; // for AI, not charmInfo
|
||||
void RegenerateHealth();
|
||||
void Regenerate(Powers power);
|
||||
MovementGeneratorType m_defaultMovementType;
|
||||
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
|
||||
uint8 m_equipmentId;
|
||||
int8 m_originalEquipmentId; // can be -1
|
||||
uint64 m_lootRecipient;
|
||||
uint32 m_lootRecipientGroup;
|
||||
|
||||
bool m_AlreadyCallAssistance;
|
||||
bool m_AlreadySearchedAssistance;
|
||||
bool m_regenHealth;
|
||||
bool m_AI_locked;
|
||||
/// Timers
|
||||
time_t m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
|
||||
time_t m_respawnTime; // (secs) time of next respawn
|
||||
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
|
||||
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
|
||||
float m_wanderDistance;
|
||||
uint16 m_transportCheckTimer;
|
||||
uint32 lootPickPocketRestoreTime;
|
||||
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
uint32 m_originalEntry;
|
||||
|
||||
bool m_moveInLineOfSightDisabled;
|
||||
bool m_moveInLineOfSightStrictlyDisabled;
|
||||
ReactStates m_reactState; // for AI, not charmInfo
|
||||
void RegenerateHealth();
|
||||
void Regenerate(Powers power);
|
||||
MovementGeneratorType m_defaultMovementType;
|
||||
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
|
||||
uint8 m_equipmentId;
|
||||
int8 m_originalEquipmentId; // can be -1
|
||||
|
||||
Position m_homePosition;
|
||||
Position m_transportHomePosition;
|
||||
bool m_AlreadyCallAssistance;
|
||||
bool m_AlreadySearchedAssistance;
|
||||
bool m_regenHealth;
|
||||
bool m_AI_locked;
|
||||
|
||||
bool DisableReputationGain;
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
uint32 m_originalEntry;
|
||||
|
||||
CreatureTemplate const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->GetCreatureTemplate(GetEntry())
|
||||
CreatureData const* m_creatureData;
|
||||
bool m_moveInLineOfSightDisabled;
|
||||
bool m_moveInLineOfSightStrictlyDisabled;
|
||||
|
||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||
Position m_homePosition;
|
||||
Position m_transportHomePosition;
|
||||
|
||||
bool IsInvisibleDueToDespawn() const override;
|
||||
bool CanAlwaysSee(WorldObject const* obj) const override;
|
||||
bool DisableReputationGain;
|
||||
|
||||
private:
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0);
|
||||
CreatureTemplate const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->GetCreatureTemplate(GetEntry())
|
||||
CreatureData const* m_creatureData;
|
||||
|
||||
//WaypointMovementGenerator vars
|
||||
uint32 m_waypointID;
|
||||
uint32 m_path_id;
|
||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||
|
||||
//Formation var
|
||||
CreatureGroup* m_formation;
|
||||
bool TriggerJustRespawned;
|
||||
bool IsInvisibleDueToDespawn() const override;
|
||||
bool CanAlwaysSee(WorldObject const* obj) const override;
|
||||
|
||||
time_t _lastDamagedTime; // Part of Evade mechanics
|
||||
private:
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0);
|
||||
|
||||
Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
|
||||
//WaypointMovementGenerator vars
|
||||
uint32 m_waypointID;
|
||||
uint32 m_path_id;
|
||||
|
||||
//Formation var
|
||||
CreatureGroup* m_formation;
|
||||
bool TriggerJustRespawned;
|
||||
|
||||
time_t _lastDamagedTime; // Part of Evade mechanics
|
||||
|
||||
Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
|
||||
};
|
||||
|
||||
class AssistDelayEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
|
||||
public:
|
||||
AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
|
||||
|
||||
bool Execute(uint64 e_time, uint32 p_time);
|
||||
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
|
||||
private:
|
||||
AssistDelayEvent();
|
||||
bool Execute(uint64 e_time, uint32 p_time);
|
||||
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
|
||||
private:
|
||||
AssistDelayEvent();
|
||||
|
||||
uint64 m_victim;
|
||||
std::list<uint64> m_assistants;
|
||||
Unit& m_owner;
|
||||
uint64 m_victim;
|
||||
std::list<uint64> m_assistants;
|
||||
Unit& m_owner;
|
||||
};
|
||||
|
||||
class ForcedDespawnDelayEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
|
||||
bool Execute(uint64 e_time, uint32 p_time);
|
||||
public:
|
||||
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
|
||||
bool Execute(uint64 e_time, uint32 p_time);
|
||||
|
||||
private:
|
||||
Creature& m_owner;
|
||||
private:
|
||||
Creature& m_owner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -136,8 +136,7 @@ void FormationMgr::LoadCreatureFormations()
|
||||
|
||||
CreatureGroupMap[memberGUID] = group_member;
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u creatures in formations in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
@@ -248,7 +247,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z, bool run)
|
||||
continue;
|
||||
|
||||
// Xinef: this should be automatized, if turn angle is greater than PI/2 (90�) we should swap formation angle
|
||||
if (M_PI - fabs(fabs(m_leader->GetOrientation() - pathAngle) - M_PI) > M_PI*0.50f)
|
||||
if (M_PI - fabs(fabs(m_leader->GetOrientation() - pathAngle) - M_PI) > M_PI * 0.50f)
|
||||
{
|
||||
// pussywizard: in both cases should be 2*M_PI - follow_angle
|
||||
// pussywizard: also, GetCurrentWaypointID() returns 0..n-1, while point_1 must be > 0, so +1
|
||||
|
||||
@@ -28,47 +28,47 @@ typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGro
|
||||
|
||||
class FormationMgr
|
||||
{
|
||||
public:
|
||||
FormationMgr() { }
|
||||
~FormationMgr();
|
||||
|
||||
static FormationMgr* instance();
|
||||
|
||||
void AddCreatureToGroup(uint32 group_id, Creature* creature);
|
||||
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
|
||||
void LoadCreatureFormations();
|
||||
CreatureGroupInfoType CreatureGroupMap;
|
||||
public:
|
||||
FormationMgr() { }
|
||||
~FormationMgr();
|
||||
|
||||
static FormationMgr* instance();
|
||||
|
||||
void AddCreatureToGroup(uint32 group_id, Creature* creature);
|
||||
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
|
||||
void LoadCreatureFormations();
|
||||
CreatureGroupInfoType CreatureGroupMap;
|
||||
};
|
||||
|
||||
class CreatureGroup
|
||||
{
|
||||
public:
|
||||
// pussywizard: moved public to the top so it compiles and typedef is public
|
||||
typedef std::map<Creature*, FormationInfo*> CreatureGroupMemberType;
|
||||
public:
|
||||
// pussywizard: moved public to the top so it compiles and typedef is public
|
||||
typedef std::map<Creature*, FormationInfo*> CreatureGroupMemberType;
|
||||
|
||||
//Group cannot be created empty
|
||||
explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {}
|
||||
~CreatureGroup() {}
|
||||
//Group cannot be created empty
|
||||
explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {}
|
||||
~CreatureGroup() {}
|
||||
|
||||
Creature* getLeader() const { return m_leader; }
|
||||
uint32 GetId() const { return m_groupID; }
|
||||
bool isEmpty() const { return m_members.empty(); }
|
||||
bool isFormed() const { return m_Formed; }
|
||||
const CreatureGroupMemberType& GetMembers() const { return m_members; }
|
||||
Creature* getLeader() const { return m_leader; }
|
||||
uint32 GetId() const { return m_groupID; }
|
||||
bool isEmpty() const { return m_members.empty(); }
|
||||
bool isFormed() const { return m_Formed; }
|
||||
const CreatureGroupMemberType& GetMembers() const { return m_members; }
|
||||
|
||||
void AddMember(Creature* member);
|
||||
void RemoveMember(Creature* member);
|
||||
void FormationReset(bool dismiss);
|
||||
void AddMember(Creature* member);
|
||||
void RemoveMember(Creature* member);
|
||||
void FormationReset(bool dismiss);
|
||||
|
||||
void LeaderMoveTo(float x, float y, float z, bool run);
|
||||
void MemberAttackStart(Creature* member, Unit* target);
|
||||
void LeaderMoveTo(float x, float y, float z, bool run);
|
||||
void MemberAttackStart(Creature* member, Unit* target);
|
||||
|
||||
private:
|
||||
Creature* m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
|
||||
CreatureGroupMemberType m_members;
|
||||
private:
|
||||
Creature* m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
|
||||
CreatureGroupMemberType m_members;
|
||||
|
||||
uint32 m_groupID;
|
||||
bool m_Formed;
|
||||
uint32 m_groupID;
|
||||
bool m_Formed;
|
||||
};
|
||||
|
||||
#define sFormationMgr FormationMgr::instance()
|
||||
|
||||
@@ -160,7 +160,7 @@ void GossipMenu::ClearMenu()
|
||||
|
||||
PlayerMenu::PlayerMenu(WorldSession* session) : _session(session)
|
||||
{
|
||||
_gossipMenu.SetLocale(session->GetSessionDbLocaleIndex());
|
||||
_gossipMenu.SetLocale(session->GetSessionDbLocaleIndex());
|
||||
}
|
||||
|
||||
PlayerMenu::~PlayerMenu()
|
||||
@@ -179,7 +179,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock1(_gossipMenu.GetLock());
|
||||
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock2(_questMenu.GetLock());
|
||||
|
||||
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount()*100 + _questMenu.GetMenuItemCount()*75); // guess size
|
||||
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size
|
||||
data << uint64(objectGUID);
|
||||
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
|
||||
data << uint32(titleTextId);
|
||||
@@ -198,7 +198,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
|
||||
data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20
|
||||
uint32 count = 0;
|
||||
|
||||
|
||||
for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI)
|
||||
{
|
||||
++count;
|
||||
@@ -216,8 +216,8 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
|
||||
data << title;
|
||||
}
|
||||
data << title;
|
||||
}
|
||||
}
|
||||
|
||||
_session->SendPacket(&data);
|
||||
@@ -299,7 +299,7 @@ void QuestMenu::ClearMenu()
|
||||
|
||||
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID)
|
||||
{
|
||||
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount()*75); // guess size
|
||||
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount() * 75); // guess size
|
||||
data << uint64(npcGUID);
|
||||
data << Title;
|
||||
data << uint32(eEmote._Delay); // player emote
|
||||
@@ -322,7 +322,7 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
|
||||
|
||||
|
||||
data << uint32(questID);
|
||||
data << uint32(qmi.QuestIcon);
|
||||
data << int32(quest->GetQuestLevel());
|
||||
@@ -353,12 +353,12 @@ void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const
|
||||
|
||||
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const
|
||||
{
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string questDetails = quest->GetDetails();
|
||||
std::string questObjectives = quest->GetObjectives();
|
||||
std::string questAreaDescription = quest->GetAreaDescription();
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string questDetails = quest->GetDetails();
|
||||
std::string questObjectives = quest->GetObjectives();
|
||||
std::string questAreaDescription = quest->GetAreaDescription();
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
{
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
|
||||
@@ -366,7 +366,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
|
||||
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
|
||||
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
|
||||
}
|
||||
|
||||
|
||||
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size
|
||||
data << uint64(npcGUID);
|
||||
data << uint64(_session->GetPlayer()->GetDivider());
|
||||
@@ -389,7 +389,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
|
||||
else
|
||||
{
|
||||
data << uint32(quest->GetRewChoiceItemsCount());
|
||||
for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
|
||||
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
|
||||
{
|
||||
if (!quest->RewardChoiceItemId[i])
|
||||
continue;
|
||||
@@ -405,7 +405,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
|
||||
|
||||
data << uint32(quest->GetRewItemsCount());
|
||||
|
||||
for (uint32 i=0; i < QUEST_REWARDS_COUNT; ++i)
|
||||
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
|
||||
{
|
||||
if (!quest->RewardItemId[i])
|
||||
continue;
|
||||
@@ -573,11 +573,11 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
data << uint32(0); // req source count?
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
data << uint32(quest->RequiredItemId[i]);
|
||||
data << uint32(quest->RequiredItemCount[i]);
|
||||
}
|
||||
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
data << uint32(quest->RequiredItemId[i]);
|
||||
data << uint32(quest->RequiredItemCount[i]);
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
data << questObjectiveText[i];
|
||||
@@ -590,16 +590,16 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
|
||||
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
|
||||
{
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string RewardText = quest->GetOfferRewardText();
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
|
||||
|
||||
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
|
||||
|
||||
|
||||
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
|
||||
data << uint64(npcGUID);
|
||||
data << uint32(quest->GetQuestId());
|
||||
@@ -626,7 +626,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
|
||||
}
|
||||
|
||||
data << uint32(quest->GetRewChoiceItemsCount());
|
||||
for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i)
|
||||
for (uint32 i = 0; i < quest->GetRewChoiceItemsCount(); ++i)
|
||||
{
|
||||
data << uint32(quest->RewardChoiceItemId[i]);
|
||||
data << uint32(quest->RewardChoiceItemCount[i]);
|
||||
@@ -683,10 +683,10 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
|
||||
// We can always call to RequestItems, but this packet only goes out if there are actually
|
||||
// items. Otherwise, we'll skip straight to the OfferReward
|
||||
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string requestItemsText = quest->GetRequestItemsText();
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string requestItemsText = quest->GetRequestItemsText();
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
|
||||
|
||||
@@ -704,7 +704,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
|
||||
QuestStatusMap::iterator qsitr = _player->getQuestStatusMap().find(quest->GetQuestId());
|
||||
if (qsitr != _player->getQuestStatusMap().end() && qsitr->second.Status == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
for (uint8 i=0; i<6; ++i)
|
||||
for (uint8 i = 0; i < 6; ++i)
|
||||
if (quest->RequiredItemId[i] && qsitr->second.ItemCount[i] < quest->RequiredItemCount[i])
|
||||
if (_player->GetItemCount(quest->RequiredItemId[i], false) >= quest->RequiredItemCount[i])
|
||||
qsitr->second.ItemCount[i] = quest->RequiredItemCount[i];
|
||||
|
||||
@@ -147,132 +147,132 @@ typedef std::vector<QuestMenuItem> QuestMenuItemList;
|
||||
|
||||
class GossipMenu
|
||||
{
|
||||
public:
|
||||
GossipMenu();
|
||||
~GossipMenu();
|
||||
public:
|
||||
GossipMenu();
|
||||
~GossipMenu();
|
||||
|
||||
void AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded = false);
|
||||
void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
|
||||
|
||||
void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
|
||||
uint32 GetMenuId() const { return _menuId; }
|
||||
void SetLocale(LocaleConstant locale) { _locale = locale; }
|
||||
LocaleConstant GetLocale() const { return _locale; }
|
||||
void AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded = false);
|
||||
void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
|
||||
|
||||
void AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi);
|
||||
void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
|
||||
uint32 GetMenuId() const { return _menuId; }
|
||||
void SetLocale(LocaleConstant locale) { _locale = locale; }
|
||||
LocaleConstant GetLocale() const { return _locale; }
|
||||
|
||||
uint32 GetMenuItemCount() const
|
||||
{
|
||||
return _menuItems.size();
|
||||
}
|
||||
void AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi);
|
||||
|
||||
bool Empty() const
|
||||
{
|
||||
return _menuItems.empty();
|
||||
}
|
||||
uint32 GetMenuItemCount() const
|
||||
{
|
||||
return _menuItems.size();
|
||||
}
|
||||
|
||||
GossipMenuItem const* GetItem(uint32 id) const
|
||||
{
|
||||
GossipMenuItemContainer::const_iterator itr = _menuItems.find(id);
|
||||
if (itr != _menuItems.end())
|
||||
return &itr->second;
|
||||
bool Empty() const
|
||||
{
|
||||
return _menuItems.empty();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
GossipMenuItem const* GetItem(uint32 id) const
|
||||
{
|
||||
GossipMenuItemContainer::const_iterator itr = _menuItems.find(id);
|
||||
if (itr != _menuItems.end())
|
||||
return &itr->second;
|
||||
|
||||
GossipMenuItemData const* GetItemData(uint32 indexId) const
|
||||
{
|
||||
GossipMenuItemDataContainer::const_iterator itr = _menuItemData.find(indexId);
|
||||
if (itr != _menuItemData.end())
|
||||
return &itr->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
GossipMenuItemData const* GetItemData(uint32 indexId) const
|
||||
{
|
||||
GossipMenuItemDataContainer::const_iterator itr = _menuItemData.find(indexId);
|
||||
if (itr != _menuItemData.end())
|
||||
return &itr->second;
|
||||
|
||||
uint32 GetMenuItemSender(uint32 menuItemId) const;
|
||||
uint32 GetMenuItemAction(uint32 menuItemId) const;
|
||||
bool IsMenuItemCoded(uint32 menuItemId) const;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ClearMenu();
|
||||
uint32 GetMenuItemSender(uint32 menuItemId) const;
|
||||
uint32 GetMenuItemAction(uint32 menuItemId) const;
|
||||
bool IsMenuItemCoded(uint32 menuItemId) const;
|
||||
|
||||
GossipMenuItemContainer const& GetMenuItems() const
|
||||
{
|
||||
return _menuItems;
|
||||
}
|
||||
void ClearMenu();
|
||||
|
||||
private:
|
||||
GossipMenuItemContainer _menuItems;
|
||||
GossipMenuItemDataContainer _menuItemData;
|
||||
uint32 _menuId;
|
||||
LocaleConstant _locale;
|
||||
GossipMenuItemContainer const& GetMenuItems() const
|
||||
{
|
||||
return _menuItems;
|
||||
}
|
||||
|
||||
private:
|
||||
GossipMenuItemContainer _menuItems;
|
||||
GossipMenuItemDataContainer _menuItemData;
|
||||
uint32 _menuId;
|
||||
LocaleConstant _locale;
|
||||
};
|
||||
|
||||
class QuestMenu
|
||||
{
|
||||
public:
|
||||
QuestMenu();
|
||||
~QuestMenu();
|
||||
public:
|
||||
QuestMenu();
|
||||
~QuestMenu();
|
||||
|
||||
void AddMenuItem(uint32 QuestId, uint8 Icon);
|
||||
void ClearMenu();
|
||||
void AddMenuItem(uint32 QuestId, uint8 Icon);
|
||||
void ClearMenu();
|
||||
|
||||
uint8 GetMenuItemCount() const
|
||||
{
|
||||
return _questMenuItems.size();
|
||||
}
|
||||
uint8 GetMenuItemCount() const
|
||||
{
|
||||
return _questMenuItems.size();
|
||||
}
|
||||
|
||||
bool Empty() const
|
||||
{
|
||||
return _questMenuItems.empty();
|
||||
}
|
||||
bool Empty() const
|
||||
{
|
||||
return _questMenuItems.empty();
|
||||
}
|
||||
|
||||
bool HasItem(uint32 questId) const;
|
||||
bool HasItem(uint32 questId) const;
|
||||
|
||||
QuestMenuItem const& GetItem(uint16 index) const
|
||||
{
|
||||
return _questMenuItems[index];
|
||||
}
|
||||
QuestMenuItem const& GetItem(uint16 index) const
|
||||
{
|
||||
return _questMenuItems[index];
|
||||
}
|
||||
|
||||
private:
|
||||
QuestMenuItemList _questMenuItems;
|
||||
private:
|
||||
QuestMenuItemList _questMenuItems;
|
||||
};
|
||||
|
||||
class PlayerMenu
|
||||
{
|
||||
public:
|
||||
explicit PlayerMenu(WorldSession* session);
|
||||
~PlayerMenu();
|
||||
public:
|
||||
explicit PlayerMenu(WorldSession* session);
|
||||
~PlayerMenu();
|
||||
|
||||
GossipMenu& GetGossipMenu() { return _gossipMenu; }
|
||||
QuestMenu& GetQuestMenu() { return _questMenu; }
|
||||
GossipMenu& GetGossipMenu() { return _gossipMenu; }
|
||||
QuestMenu& GetQuestMenu() { return _questMenu; }
|
||||
|
||||
bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
|
||||
bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
|
||||
|
||||
void ClearMenus();
|
||||
uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
|
||||
uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
|
||||
bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
|
||||
void ClearMenus();
|
||||
uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
|
||||
uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
|
||||
bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
|
||||
|
||||
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const;
|
||||
void SendCloseGossip() const;
|
||||
void SendPointOfInterest(uint32 poiId) const;
|
||||
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const;
|
||||
void SendCloseGossip() const;
|
||||
void SendPointOfInterest(uint32 poiId) const;
|
||||
|
||||
/*********************************************************/
|
||||
/*** QUEST SYSTEM ***/
|
||||
/*********************************************************/
|
||||
void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const;
|
||||
/*********************************************************/
|
||||
/*** QUEST SYSTEM ***/
|
||||
/*********************************************************/
|
||||
void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const;
|
||||
|
||||
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
|
||||
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
|
||||
|
||||
void SendQuestQueryResponse(Quest const* quest) const;
|
||||
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
|
||||
void SendQuestQueryResponse(Quest const* quest) const;
|
||||
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
|
||||
|
||||
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
|
||||
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
|
||||
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
|
||||
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
|
||||
|
||||
private:
|
||||
GossipMenu _gossipMenu;
|
||||
QuestMenu _questMenu;
|
||||
WorldSession* _session;
|
||||
private:
|
||||
GossipMenu _gossipMenu;
|
||||
QuestMenu _questMenu;
|
||||
WorldSession* _session;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -14,20 +14,20 @@
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
TempSummon::TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) :
|
||||
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
||||
m_timer(0), m_lifetime(0)
|
||||
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
||||
m_timer(0), m_lifetime(0)
|
||||
{
|
||||
m_summonerGUID = owner;
|
||||
m_unitTypeMask |= UNIT_MASK_SUMMON;
|
||||
}
|
||||
|
||||
Unit* TempSummon::GetSummoner() const
|
||||
{
|
||||
{
|
||||
return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : nullptr;
|
||||
}
|
||||
|
||||
void TempSummon::Update(uint32 diff)
|
||||
{
|
||||
{
|
||||
Creature::Update(diff);
|
||||
|
||||
if (m_deathState == DEAD)
|
||||
@@ -41,19 +41,6 @@ void TempSummon::Update(uint32 diff)
|
||||
case TEMPSUMMON_DESPAWNED:
|
||||
break;
|
||||
case TEMPSUMMON_TIMED_DESPAWN:
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
break;
|
||||
}
|
||||
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
|
||||
{
|
||||
if (!IsInCombat())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
@@ -62,81 +49,94 @@ void TempSummon::Update(uint32 diff)
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
break;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
|
||||
{
|
||||
if (!IsInCombat())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
m_timer -= diff;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TEMPSUMMON_CORPSE_TIMED_DESPAWN:
|
||||
{
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
m_timer -= diff;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TEMPSUMMON_CORPSE_DESPAWN:
|
||||
{
|
||||
// if m_deathState is DEAD, CORPSE was skipped
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
// if m_deathState is DEAD, CORPSE was skipped
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TEMPSUMMON_DEAD_DESPAWN:
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:
|
||||
{
|
||||
// if m_deathState is DEAD, CORPSE was skipped
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
// if m_deathState is DEAD, CORPSE was skipped
|
||||
if (m_deathState == CORPSE)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsInCombat())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (!IsInCombat())
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
break;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
break;
|
||||
}
|
||||
case TEMPSUMMON_TIMED_OR_DEAD_DESPAWN:
|
||||
{
|
||||
if (!IsInCombat() && IsAlive())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (!IsInCombat() && IsAlive())
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
if (m_timer <= diff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
break;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UnSummon();
|
||||
sLog->outError("Temporary summoned creature (entry: %u) have unknown type %u of ", GetEntry(), m_type);
|
||||
@@ -145,7 +145,7 @@ void TempSummon::Update(uint32 diff)
|
||||
}
|
||||
|
||||
void TempSummon::InitStats(uint32 duration)
|
||||
{
|
||||
{
|
||||
ASSERT(!IsPet());
|
||||
|
||||
Unit* owner = GetSummoner();
|
||||
@@ -197,7 +197,7 @@ void TempSummon::InitStats(uint32 duration)
|
||||
}
|
||||
|
||||
void TempSummon::InitSummon()
|
||||
{
|
||||
{
|
||||
Unit* owner = GetSummoner();
|
||||
if (owner)
|
||||
{
|
||||
@@ -211,12 +211,12 @@ void TempSummon::InitSummon()
|
||||
}
|
||||
|
||||
void TempSummon::SetTempSummonType(TempSummonType type)
|
||||
{
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
void TempSummon::UnSummon(uint32 msTime)
|
||||
{
|
||||
{
|
||||
if (msTime)
|
||||
{
|
||||
ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);
|
||||
@@ -252,7 +252,7 @@ bool ForcedUnsummonDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
}
|
||||
|
||||
void TempSummon::RemoveFromWorld()
|
||||
{
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
@@ -269,7 +269,7 @@ void TempSummon::RemoveFromWorld()
|
||||
}
|
||||
|
||||
Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject)
|
||||
, m_owner(owner)
|
||||
, m_owner(owner)
|
||||
{
|
||||
ASSERT(m_owner);
|
||||
m_unitTypeMask |= UNIT_MASK_MINION;
|
||||
@@ -277,12 +277,12 @@ Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWor
|
||||
}
|
||||
|
||||
void Minion::InitStats(uint32 duration)
|
||||
{
|
||||
{
|
||||
TempSummon::InitStats(duration);
|
||||
|
||||
SetReactState(REACT_PASSIVE);
|
||||
|
||||
Unit *m_owner = GetOwner();
|
||||
Unit* m_owner = GetOwner();
|
||||
SetCreatorGUID(m_owner->GetGUID());
|
||||
setFaction(m_owner->getFaction());
|
||||
|
||||
@@ -290,11 +290,11 @@ void Minion::InitStats(uint32 duration)
|
||||
}
|
||||
|
||||
void Minion::RemoveFromWorld()
|
||||
{
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
if (Unit *owner = GetOwner())
|
||||
if (Unit* owner = GetOwner())
|
||||
owner->SetMinion(this, false);
|
||||
|
||||
TempSummon::RemoveFromWorld();
|
||||
@@ -306,12 +306,12 @@ Unit* Minion::GetOwner() const
|
||||
}
|
||||
|
||||
bool Minion::IsGuardianPet() const
|
||||
{
|
||||
{
|
||||
return IsPet() || (m_Properties && m_Properties->Category == SUMMON_CATEGORY_PET);
|
||||
}
|
||||
|
||||
void Minion::setDeathState(DeathState s, bool despawn)
|
||||
{
|
||||
{
|
||||
Creature::setDeathState(s, despawn);
|
||||
if (s == JUST_DIED && IsGuardianPet())
|
||||
if (Unit* owner = GetOwner())
|
||||
@@ -336,10 +336,10 @@ Guardian::Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool i
|
||||
}
|
||||
|
||||
void Guardian::InitStats(uint32 duration)
|
||||
{
|
||||
{
|
||||
Minion::InitStats(duration);
|
||||
|
||||
Unit *m_owner = GetOwner();
|
||||
Unit* m_owner = GetOwner();
|
||||
InitStatsForLevel(m_owner->getLevel());
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER && HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
|
||||
@@ -349,13 +349,13 @@ void Guardian::InitStats(uint32 duration)
|
||||
}
|
||||
|
||||
void Guardian::InitSummon()
|
||||
{
|
||||
{
|
||||
TempSummon::InitSummon();
|
||||
|
||||
Unit *m_owner = GetOwner();
|
||||
Unit* m_owner = GetOwner();
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER
|
||||
&& m_owner->GetMinionGUID() == GetGUID()
|
||||
&& !m_owner->GetCharmGUID())
|
||||
&& m_owner->GetMinionGUID() == GetGUID()
|
||||
&& !m_owner->GetCharmGUID())
|
||||
m_owner->ToPlayer()->CharmSpellInitialize();
|
||||
}
|
||||
|
||||
@@ -366,14 +366,14 @@ Puppet::Puppet(SummonPropertiesEntry const* properties, uint64 owner) : Minion(p
|
||||
}
|
||||
|
||||
void Puppet::InitStats(uint32 duration)
|
||||
{
|
||||
{
|
||||
Minion::InitStats(duration);
|
||||
SetLevel(GetOwner()->getLevel());
|
||||
SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
void Puppet::InitSummon()
|
||||
{
|
||||
{
|
||||
Minion::InitSummon();
|
||||
if (!SetCharmedBy(GetOwner(), CHARM_TYPE_POSSESS))
|
||||
{
|
||||
@@ -388,7 +388,7 @@ void Puppet::InitSummon()
|
||||
}
|
||||
|
||||
void Puppet::Update(uint32 time)
|
||||
{
|
||||
{
|
||||
Minion::Update(time);
|
||||
//check if caster is channelling?
|
||||
if (IsInWorld())
|
||||
@@ -402,7 +402,7 @@ void Puppet::Update(uint32 time)
|
||||
}
|
||||
|
||||
void Puppet::RemoveFromWorld()
|
||||
{
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
|
||||
@@ -27,75 +27,75 @@ struct TempSummonData
|
||||
|
||||
class TempSummon : public Creature
|
||||
{
|
||||
public:
|
||||
explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
virtual ~TempSummon() {}
|
||||
void Update(uint32 time);
|
||||
virtual void InitStats(uint32 lifetime);
|
||||
virtual void InitSummon();
|
||||
virtual void UnSummon(uint32 msTime = 0);
|
||||
void RemoveFromWorld();
|
||||
void SetTempSummonType(TempSummonType type);
|
||||
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) {}
|
||||
Unit* GetSummoner() const;
|
||||
uint64 GetSummonerGUID() { return m_summonerGUID; }
|
||||
TempSummonType const& GetSummonType() { return m_type; }
|
||||
uint32 GetTimer() { return m_timer; }
|
||||
void SetTimer(uint32 t) { m_timer = t; }
|
||||
public:
|
||||
explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
virtual ~TempSummon() {}
|
||||
void Update(uint32 time);
|
||||
virtual void InitStats(uint32 lifetime);
|
||||
virtual void InitSummon();
|
||||
virtual void UnSummon(uint32 msTime = 0);
|
||||
void RemoveFromWorld();
|
||||
void SetTempSummonType(TempSummonType type);
|
||||
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) {}
|
||||
Unit* GetSummoner() const;
|
||||
uint64 GetSummonerGUID() { return m_summonerGUID; }
|
||||
TempSummonType const& GetSummonType() { return m_type; }
|
||||
uint32 GetTimer() { return m_timer; }
|
||||
void SetTimer(uint32 t) { m_timer = t; }
|
||||
|
||||
const SummonPropertiesEntry* const m_Properties;
|
||||
private:
|
||||
TempSummonType m_type;
|
||||
uint32 m_timer;
|
||||
uint32 m_lifetime;
|
||||
uint64 m_summonerGUID;
|
||||
const SummonPropertiesEntry* const m_Properties;
|
||||
private:
|
||||
TempSummonType m_type;
|
||||
uint32 m_timer;
|
||||
uint32 m_lifetime;
|
||||
uint64 m_summonerGUID;
|
||||
};
|
||||
|
||||
class Minion : public TempSummon
|
||||
{
|
||||
public:
|
||||
Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
void InitStats(uint32 duration);
|
||||
void RemoveFromWorld();
|
||||
Unit* GetOwner() const;
|
||||
float GetFollowAngle() const { return m_followAngle; }
|
||||
void SetFollowAngle(float angle) { m_followAngle = angle; }
|
||||
bool IsPetGhoul() const {return GetEntry() == 26125 /*normal ghoul*/ || GetEntry() == 30230 /*Raise Ally ghoul*/;} // Ghoul may be guardian or pet
|
||||
bool IsGuardianPet() const;
|
||||
void setDeathState(DeathState s, bool despawn = false); // override virtual Unit::setDeathState
|
||||
protected:
|
||||
const uint64 m_owner;
|
||||
float m_followAngle;
|
||||
public:
|
||||
Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
void InitStats(uint32 duration);
|
||||
void RemoveFromWorld();
|
||||
Unit* GetOwner() const;
|
||||
float GetFollowAngle() const { return m_followAngle; }
|
||||
void SetFollowAngle(float angle) { m_followAngle = angle; }
|
||||
bool IsPetGhoul() const {return GetEntry() == 26125 /*normal ghoul*/ || GetEntry() == 30230 /*Raise Ally ghoul*/;} // Ghoul may be guardian or pet
|
||||
bool IsGuardianPet() const;
|
||||
void setDeathState(DeathState s, bool despawn = false); // override virtual Unit::setDeathState
|
||||
protected:
|
||||
const uint64 m_owner;
|
||||
float m_followAngle;
|
||||
};
|
||||
|
||||
class Guardian : public Minion
|
||||
{
|
||||
public:
|
||||
Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
void InitStats(uint32 duration);
|
||||
bool InitStatsForLevel(uint8 level);
|
||||
void InitSummon();
|
||||
public:
|
||||
Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
|
||||
void InitStats(uint32 duration);
|
||||
bool InitStatsForLevel(uint8 level);
|
||||
void InitSummon();
|
||||
|
||||
bool UpdateStats(Stats stat);
|
||||
bool UpdateAllStats();
|
||||
void UpdateArmor();
|
||||
void UpdateMaxHealth();
|
||||
void UpdateMaxPower(Powers power);
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false);
|
||||
void UpdateDamagePhysical(WeaponAttackType attType);
|
||||
bool UpdateStats(Stats stat);
|
||||
bool UpdateAllStats();
|
||||
void UpdateArmor();
|
||||
void UpdateMaxHealth();
|
||||
void UpdateMaxPower(Powers power);
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false);
|
||||
void UpdateDamagePhysical(WeaponAttackType attType);
|
||||
};
|
||||
|
||||
class Puppet : public Minion
|
||||
{
|
||||
public:
|
||||
Puppet(SummonPropertiesEntry const* properties, uint64 owner);
|
||||
void InitStats(uint32 duration);
|
||||
void InitSummon();
|
||||
void Update(uint32 time);
|
||||
void RemoveFromWorld();
|
||||
protected:
|
||||
Player* GetOwner() const;
|
||||
const uint64 m_owner;
|
||||
public:
|
||||
Puppet(SummonPropertiesEntry const* properties, uint64 owner);
|
||||
void InitStats(uint32 duration);
|
||||
void InitSummon();
|
||||
void Update(uint32 time);
|
||||
void RemoveFromWorld();
|
||||
protected:
|
||||
Player* GetOwner() const;
|
||||
const uint64 m_owner;
|
||||
};
|
||||
|
||||
class ForcedUnsummonDelayEvent : public BasicEvent
|
||||
|
||||
@@ -35,7 +35,7 @@ DynamicObject::~DynamicObject()
|
||||
ASSERT(!_isViewpoint);
|
||||
delete _removedAura;
|
||||
}
|
||||
|
||||
|
||||
void DynamicObject::CleanupsBeforeDelete(bool finalCleanup /* = true */)
|
||||
{
|
||||
if (Transport* transport = GetTransport())
|
||||
@@ -50,7 +50,7 @@ void DynamicObject::CleanupsBeforeDelete(bool finalCleanup /* = true */)
|
||||
}
|
||||
|
||||
void DynamicObject::AddToWorld()
|
||||
{
|
||||
{
|
||||
///- Register the dynamicObject for guid lookup and for caster
|
||||
if (!IsInWorld())
|
||||
{
|
||||
@@ -61,7 +61,7 @@ void DynamicObject::AddToWorld()
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveFromWorld()
|
||||
{
|
||||
{
|
||||
///- Remove the dynamicObject from the accessor and from all lists of objects in world
|
||||
if (IsInWorld())
|
||||
{
|
||||
@@ -84,7 +84,7 @@ void DynamicObject::RemoveFromWorld()
|
||||
}
|
||||
|
||||
bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type)
|
||||
{
|
||||
{
|
||||
SetMap(caster->GetMap());
|
||||
Relocate(pos);
|
||||
if (!IsPositionValid())
|
||||
@@ -122,7 +122,7 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spe
|
||||
}
|
||||
|
||||
void DynamicObject::Update(uint32 p_time)
|
||||
{
|
||||
{
|
||||
// caster has to be always available and in the same map
|
||||
ASSERT(_caster);
|
||||
ASSERT(_caster->GetMap() == GetMap());
|
||||
@@ -153,7 +153,7 @@ void DynamicObject::Update(uint32 p_time)
|
||||
}
|
||||
|
||||
void DynamicObject::Remove()
|
||||
{
|
||||
{
|
||||
if (IsInWorld())
|
||||
{
|
||||
SendObjectDeSpawnAnim(GetGUID());
|
||||
@@ -163,7 +163,7 @@ void DynamicObject::Remove()
|
||||
}
|
||||
|
||||
int32 DynamicObject::GetDuration() const
|
||||
{
|
||||
{
|
||||
if (!_aura)
|
||||
return _duration;
|
||||
else
|
||||
@@ -171,7 +171,7 @@ int32 DynamicObject::GetDuration() const
|
||||
}
|
||||
|
||||
void DynamicObject::SetDuration(int32 newDuration)
|
||||
{
|
||||
{
|
||||
if (!_aura)
|
||||
_duration = newDuration;
|
||||
else
|
||||
@@ -179,18 +179,18 @@ void DynamicObject::SetDuration(int32 newDuration)
|
||||
}
|
||||
|
||||
void DynamicObject::Delay(int32 delaytime)
|
||||
{
|
||||
{
|
||||
SetDuration(GetDuration() - delaytime);
|
||||
}
|
||||
|
||||
void DynamicObject::SetAura(Aura* aura)
|
||||
{
|
||||
{
|
||||
ASSERT(!_aura && aura);
|
||||
_aura = aura;
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveAura()
|
||||
{
|
||||
{
|
||||
ASSERT(_aura && !_removedAura);
|
||||
_removedAura = _aura;
|
||||
_aura = nullptr;
|
||||
@@ -199,7 +199,7 @@ void DynamicObject::RemoveAura()
|
||||
}
|
||||
|
||||
void DynamicObject::SetCasterViewpoint()
|
||||
{
|
||||
{
|
||||
if (Player* caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, true);
|
||||
@@ -208,7 +208,7 @@ void DynamicObject::SetCasterViewpoint()
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveCasterViewpoint()
|
||||
{
|
||||
{
|
||||
if (Player* caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, false);
|
||||
@@ -217,7 +217,7 @@ void DynamicObject::RemoveCasterViewpoint()
|
||||
}
|
||||
|
||||
void DynamicObject::BindToCaster()
|
||||
{
|
||||
{
|
||||
ASSERT(!_caster);
|
||||
_caster = ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
ASSERT(_caster);
|
||||
@@ -226,7 +226,7 @@ void DynamicObject::BindToCaster()
|
||||
}
|
||||
|
||||
void DynamicObject::UnbindFromCaster()
|
||||
{
|
||||
{
|
||||
ASSERT(_caster);
|
||||
_caster->_UnregisterDynObject(this);
|
||||
_caster = nullptr;
|
||||
|
||||
@@ -22,38 +22,38 @@ enum DynamicObjectType
|
||||
|
||||
class DynamicObject : public WorldObject, public GridObject<DynamicObject>, public MovableMapObject
|
||||
{
|
||||
public:
|
||||
DynamicObject(bool isWorldObject);
|
||||
~DynamicObject();
|
||||
public:
|
||||
DynamicObject(bool isWorldObject);
|
||||
~DynamicObject();
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true) override;
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type);
|
||||
void Update(uint32 p_time) override;
|
||||
void Remove();
|
||||
void SetDuration(int32 newDuration);
|
||||
int32 GetDuration() const;
|
||||
void Delay(int32 delaytime);
|
||||
void SetAura(Aura* aura);
|
||||
void RemoveAura();
|
||||
void SetCasterViewpoint();
|
||||
void RemoveCasterViewpoint();
|
||||
Unit* GetCaster() const { return _caster; }
|
||||
void BindToCaster();
|
||||
void UnbindFromCaster();
|
||||
uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); }
|
||||
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
|
||||
float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); }
|
||||
bool IsViewpoint() const { return _isViewpoint; }
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true) override;
|
||||
|
||||
protected:
|
||||
Aura* _aura;
|
||||
Aura* _removedAura;
|
||||
Unit* _caster;
|
||||
int32 _duration; // for non-aura dynobjects
|
||||
bool _isViewpoint;
|
||||
bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type);
|
||||
void Update(uint32 p_time) override;
|
||||
void Remove();
|
||||
void SetDuration(int32 newDuration);
|
||||
int32 GetDuration() const;
|
||||
void Delay(int32 delaytime);
|
||||
void SetAura(Aura* aura);
|
||||
void RemoveAura();
|
||||
void SetCasterViewpoint();
|
||||
void RemoveCasterViewpoint();
|
||||
Unit* GetCaster() const { return _caster; }
|
||||
void BindToCaster();
|
||||
void UnbindFromCaster();
|
||||
uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); }
|
||||
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
|
||||
float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); }
|
||||
bool IsViewpoint() const { return _isViewpoint; }
|
||||
|
||||
protected:
|
||||
Aura* _aura;
|
||||
Aura* _removedAura;
|
||||
Unit* _caster;
|
||||
int32 _duration; // for non-aura dynobjects
|
||||
bool _isViewpoint;
|
||||
};
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -396,9 +396,12 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_CHEST: return chest.consumable;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.consumable;
|
||||
default: return false;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
return chest.consumable;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.consumable;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,11 +409,16 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.allowMounted;
|
||||
case GAMEOBJECT_TYPE_TEXT: return text.allowMounted;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.allowMounted;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER: return spellcaster.allowMounted;
|
||||
default: return false;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
return questgiver.allowMounted;
|
||||
case GAMEOBJECT_TYPE_TEXT:
|
||||
return text.allowMounted;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.allowMounted;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER:
|
||||
return spellcaster.allowMounted;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,18 +426,30 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_DOOR: return door.lockId;
|
||||
case GAMEOBJECT_TYPE_BUTTON: return button.lockId;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.lockId;
|
||||
case GAMEOBJECT_TYPE_CHEST: return chest.lockId;
|
||||
case GAMEOBJECT_TYPE_TRAP: return trap.lockId;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.lockId;
|
||||
case GAMEOBJECT_TYPE_AREADAMAGE: return areadamage.lockId;
|
||||
case GAMEOBJECT_TYPE_CAMERA: return camera.lockId;
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND: return flagstand.lockId;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:return fishinghole.lockId;
|
||||
case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.lockId;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_DOOR:
|
||||
return door.lockId;
|
||||
case GAMEOBJECT_TYPE_BUTTON:
|
||||
return button.lockId;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
return questgiver.lockId;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
return chest.lockId;
|
||||
case GAMEOBJECT_TYPE_TRAP:
|
||||
return trap.lockId;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.lockId;
|
||||
case GAMEOBJECT_TYPE_AREADAMAGE:
|
||||
return areadamage.lockId;
|
||||
case GAMEOBJECT_TYPE_CAMERA:
|
||||
return camera.lockId;
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND:
|
||||
return flagstand.lockId;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
return fishinghole.lockId;
|
||||
case GAMEOBJECT_TYPE_FLAGDROP:
|
||||
return flagdrop.lockId;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,13 +457,20 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_DOOR: return door.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_BUTTON: return button.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND: return flagstand.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.noDamageImmune;
|
||||
default: return true;
|
||||
case GAMEOBJECT_TYPE_DOOR:
|
||||
return door.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_BUTTON:
|
||||
return button.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
return questgiver.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND:
|
||||
return flagstand.noDamageImmune;
|
||||
case GAMEOBJECT_TYPE_FLAGDROP:
|
||||
return flagdrop.noDamageImmune;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,9 +479,12 @@ struct GameObjectTemplate
|
||||
switch (type)
|
||||
{
|
||||
//case GAMEOBJECT_TYPE_TRAP: return trap.charges;
|
||||
case GAMEOBJECT_TYPE_GUARDPOST: return guardpost.charges;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER: return spellcaster.charges;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_GUARDPOST:
|
||||
return guardpost.charges;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER:
|
||||
return spellcaster.charges;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,10 +492,14 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId;
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.linkedTrapId;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.linkedTrapId;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
return chest.linkedTrapId;
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS:
|
||||
return spellFocus.linkedTrapId;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.linkedTrapId;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,13 +508,26 @@ struct GameObjectTemplate
|
||||
uint32 autoCloseTime = 0;
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_DOOR: autoCloseTime = door.autoCloseTime; break;
|
||||
case GAMEOBJECT_TYPE_BUTTON: autoCloseTime = button.autoCloseTime; break;
|
||||
case GAMEOBJECT_TYPE_TRAP: autoCloseTime = trap.autoCloseTime; break;
|
||||
case GAMEOBJECT_TYPE_GOOBER: autoCloseTime = goober.autoCloseTime; break;
|
||||
case GAMEOBJECT_TYPE_TRANSPORT: autoCloseTime = transport.autoCloseTime; break;
|
||||
case GAMEOBJECT_TYPE_AREADAMAGE: autoCloseTime = areadamage.autoCloseTime; break;
|
||||
default: break;
|
||||
case GAMEOBJECT_TYPE_DOOR:
|
||||
autoCloseTime = door.autoCloseTime;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_BUTTON:
|
||||
autoCloseTime = button.autoCloseTime;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_TRAP:
|
||||
autoCloseTime = trap.autoCloseTime;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
autoCloseTime = goober.autoCloseTime;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_TRANSPORT:
|
||||
autoCloseTime = transport.autoCloseTime;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_AREADAMAGE:
|
||||
autoCloseTime = areadamage.autoCloseTime;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return autoCloseTime /* xinef: changed to milliseconds/ IN_MILLISECONDS*/; // prior to 3.0.3, conversion was / 0x10000;
|
||||
}
|
||||
@@ -489,9 +536,12 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_CHEST: return chest.lootId;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lootId;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
return chest.lootId;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
return fishinghole.lootId;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,9 +549,12 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.gossipID;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.gossipID;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
return questgiver.gossipID;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.gossipID;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,10 +562,14 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.eventId;
|
||||
case GAMEOBJECT_TYPE_CHEST: return chest.eventId;
|
||||
case GAMEOBJECT_TYPE_CAMERA: return camera.eventID;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.eventId;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
return chest.eventId;
|
||||
case GAMEOBJECT_TYPE_CAMERA:
|
||||
return camera.eventID;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,9 +577,12 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_TRAP: return trap.cooldown;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.cooldown;
|
||||
default: return 0;
|
||||
case GAMEOBJECT_TYPE_TRAP:
|
||||
return trap.cooldown;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.cooldown;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,15 +590,24 @@ struct GameObjectTemplate
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_BUTTON: return button.large != 0;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.large != 0;
|
||||
case GAMEOBJECT_TYPE_GENERIC: return _generic.large != 0;
|
||||
case GAMEOBJECT_TYPE_TRAP: return trap.large != 0;
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.large != 0;
|
||||
case GAMEOBJECT_TYPE_GOOBER: return goober.large != 0;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER: return spellcaster.large != 0;
|
||||
case GAMEOBJECT_TYPE_CAPTURE_POINT: return capturePoint.large != 0;
|
||||
default: return false;
|
||||
case GAMEOBJECT_TYPE_BUTTON:
|
||||
return button.large != 0;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
return questgiver.large != 0;
|
||||
case GAMEOBJECT_TYPE_GENERIC:
|
||||
return _generic.large != 0;
|
||||
case GAMEOBJECT_TYPE_TRAP:
|
||||
return trap.large != 0;
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS:
|
||||
return spellFocus.large != 0;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
return goober.large != 0;
|
||||
case GAMEOBJECT_TYPE_SPELLCASTER:
|
||||
return spellcaster.large != 0;
|
||||
case GAMEOBJECT_TYPE_CAPTURE_POINT:
|
||||
return capturePoint.large != 0;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +650,7 @@ union GameObjectValue
|
||||
//29 GAMEOBJECT_TYPE_CAPTURE_POINT
|
||||
struct
|
||||
{
|
||||
OPvPCapturePoint *OPvPObj;
|
||||
OPvPCapturePoint* OPvPObj;
|
||||
} CapturePoint;
|
||||
//33 GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
|
||||
struct
|
||||
@@ -620,7 +689,7 @@ enum GOState
|
||||
struct GameObjectData
|
||||
{
|
||||
explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
|
||||
animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), dbData(true) { }
|
||||
animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), dbData(true) { }
|
||||
uint32 id; // entry in gamobject_template
|
||||
uint16 mapid;
|
||||
uint32 phaseMask;
|
||||
@@ -660,276 +729,276 @@ class GameObjectModel;
|
||||
|
||||
class GameObject : public WorldObject, public GridObject<GameObject>, public MovableMapObject
|
||||
{
|
||||
public:
|
||||
explicit GameObject();
|
||||
~GameObject();
|
||||
public:
|
||||
explicit GameObject();
|
||||
~GameObject();
|
||||
|
||||
void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override;
|
||||
void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override;
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true) override;
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true) override;
|
||||
|
||||
virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);
|
||||
void Update(uint32 p_time) override;
|
||||
GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
|
||||
GameObjectTemplateAddon const* GetTemplateAddon() const;
|
||||
GameObjectData const* GetGOData() const { return m_goData; }
|
||||
GameObjectValue const* GetGOValue() const { return &m_goValue; }
|
||||
virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);
|
||||
void Update(uint32 p_time) override;
|
||||
GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
|
||||
GameObjectTemplateAddon const* GetTemplateAddon() const;
|
||||
GameObjectData const* GetGOData() const { return m_goData; }
|
||||
GameObjectValue const* GetGOValue() const { return &m_goValue; }
|
||||
|
||||
bool IsTransport() const;
|
||||
bool IsDestructibleBuilding() const;
|
||||
bool IsTransport() const;
|
||||
bool IsDestructibleBuilding() const;
|
||||
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
|
||||
// z_rot, y_rot, x_rot - rotation angles around z, y and x axes
|
||||
void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
|
||||
void SetWorldRotation(G3D::Quat const& rot);
|
||||
void SetTransportPathRotation(float qx, float qy, float qz, float qw);
|
||||
int64 GetPackedWorldRotation() const { return m_packedRotation; }
|
||||
// z_rot, y_rot, x_rot - rotation angles around z, y and x axes
|
||||
void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
|
||||
void SetWorldRotation(G3D::Quat const& rot);
|
||||
void SetTransportPathRotation(float qx, float qy, float qz, float qw);
|
||||
int64 GetPackedWorldRotation() const { return m_packedRotation; }
|
||||
|
||||
// overwrite WorldObject function for proper name localization
|
||||
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
|
||||
// overwrite WorldObject function for proper name localization
|
||||
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
|
||||
|
||||
void SaveToDB();
|
||||
void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||
bool LoadFromDB(uint32 guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
|
||||
bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true);
|
||||
void DeleteFromDB();
|
||||
void SaveToDB();
|
||||
void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||
bool LoadFromDB(uint32 guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
|
||||
bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true);
|
||||
void DeleteFromDB();
|
||||
|
||||
void SetOwnerGUID(uint64 owner)
|
||||
void SetOwnerGUID(uint64 owner)
|
||||
{
|
||||
// Owner already found and different than expected owner - remove object from old owner
|
||||
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
|
||||
{
|
||||
// Owner already found and different than expected owner - remove object from old owner
|
||||
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
|
||||
{
|
||||
ABORT();
|
||||
}
|
||||
m_spawnedByDefault = false; // all object with owner is despawned after delay
|
||||
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
|
||||
ABORT();
|
||||
}
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
|
||||
Unit* GetOwner() const;
|
||||
m_spawnedByDefault = false; // all object with owner is despawned after delay
|
||||
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
|
||||
}
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
|
||||
Unit* GetOwner() const;
|
||||
|
||||
void SetSpellId(uint32 id)
|
||||
{
|
||||
m_spawnedByDefault = false; // all summoned object is despawned after delay
|
||||
m_spellId = id;
|
||||
}
|
||||
uint32 GetSpellId() const { return m_spellId;}
|
||||
void SetSpellId(uint32 id)
|
||||
{
|
||||
m_spawnedByDefault = false; // all summoned object is despawned after delay
|
||||
m_spellId = id;
|
||||
}
|
||||
uint32 GetSpellId() const { return m_spellId;}
|
||||
|
||||
time_t GetRespawnTime() const { return m_respawnTime; }
|
||||
time_t GetRespawnTimeEx() const
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
if (m_respawnTime > now)
|
||||
return m_respawnTime;
|
||||
else
|
||||
return now;
|
||||
}
|
||||
time_t GetRespawnTime() const { return m_respawnTime; }
|
||||
time_t GetRespawnTimeEx() const
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
if (m_respawnTime > now)
|
||||
return m_respawnTime;
|
||||
else
|
||||
return now;
|
||||
}
|
||||
|
||||
void SetRespawnTime(int32 respawn)
|
||||
{
|
||||
m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0;
|
||||
m_respawnDelayTime = respawn > 0 ? respawn : 0;
|
||||
}
|
||||
void Respawn();
|
||||
bool isSpawned() const
|
||||
{
|
||||
return m_respawnDelayTime == 0 ||
|
||||
(m_respawnTime > 0 && !m_spawnedByDefault) ||
|
||||
(m_respawnTime == 0 && m_spawnedByDefault);
|
||||
}
|
||||
bool isSpawnedByDefault() const { return m_spawnedByDefault; }
|
||||
void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
|
||||
void Refresh();
|
||||
void Delete();
|
||||
void getFishLoot(Loot* loot, Player* loot_owner);
|
||||
void getFishLootJunk(Loot* loot, Player* loot_owner);
|
||||
GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
|
||||
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
|
||||
GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
|
||||
void SetGoState(GOState state);
|
||||
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
|
||||
void SetGoArtKit(uint8 artkit);
|
||||
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
|
||||
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
|
||||
static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0);
|
||||
void SetRespawnTime(int32 respawn)
|
||||
{
|
||||
m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0;
|
||||
m_respawnDelayTime = respawn > 0 ? respawn : 0;
|
||||
}
|
||||
void Respawn();
|
||||
bool isSpawned() const
|
||||
{
|
||||
return m_respawnDelayTime == 0 ||
|
||||
(m_respawnTime > 0 && !m_spawnedByDefault) ||
|
||||
(m_respawnTime == 0 && m_spawnedByDefault);
|
||||
}
|
||||
bool isSpawnedByDefault() const { return m_spawnedByDefault; }
|
||||
void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
|
||||
void Refresh();
|
||||
void Delete();
|
||||
void getFishLoot(Loot* loot, Player* loot_owner);
|
||||
void getFishLootJunk(Loot* loot, Player* loot_owner);
|
||||
GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
|
||||
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
|
||||
GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
|
||||
void SetGoState(GOState state);
|
||||
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
|
||||
void SetGoArtKit(uint8 artkit);
|
||||
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
|
||||
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
|
||||
static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0);
|
||||
|
||||
void SetPhaseMask(uint32 newPhaseMask, bool update) override;
|
||||
void EnableCollision(bool enable);
|
||||
void SetPhaseMask(uint32 newPhaseMask, bool update) override;
|
||||
void EnableCollision(bool enable);
|
||||
|
||||
void Use(Unit* user);
|
||||
void Use(Unit* user);
|
||||
|
||||
LootState getLootState() const { return m_lootState; }
|
||||
// Note: unit is only used when s = GO_ACTIVATED
|
||||
void SetLootState(LootState s, Unit* unit = nullptr);
|
||||
LootState getLootState() const { return m_lootState; }
|
||||
// Note: unit is only used when s = GO_ACTIVATED
|
||||
void SetLootState(LootState s, Unit* unit = nullptr);
|
||||
|
||||
uint16 GetLootMode() const { return m_LootMode; }
|
||||
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
|
||||
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
|
||||
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
|
||||
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
|
||||
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
|
||||
uint16 GetLootMode() const { return m_LootMode; }
|
||||
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
|
||||
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
|
||||
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
|
||||
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
|
||||
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
|
||||
|
||||
void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
|
||||
bool IsInSkillupList(uint32 PlayerGuidLow) const
|
||||
{
|
||||
for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
|
||||
if (*i == PlayerGuidLow)
|
||||
return true;
|
||||
void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
|
||||
bool IsInSkillupList(uint32 PlayerGuidLow) const
|
||||
{
|
||||
for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
|
||||
if (*i == PlayerGuidLow)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
void ClearSkillupList() { m_SkillupList.clear(); }
|
||||
return false;
|
||||
}
|
||||
void ClearSkillupList() { m_SkillupList.clear(); }
|
||||
|
||||
void AddUniqueUse(Player* player);
|
||||
void AddUse() { ++m_usetimes; }
|
||||
void AddUniqueUse(Player* player);
|
||||
void AddUse() { ++m_usetimes; }
|
||||
|
||||
uint32 GetUseCount() const { return m_usetimes; }
|
||||
uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
|
||||
uint32 GetUseCount() const { return m_usetimes; }
|
||||
uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
|
||||
|
||||
void SaveRespawnTime() override;
|
||||
void SaveRespawnTime() override;
|
||||
|
||||
Loot loot;
|
||||
Loot loot;
|
||||
|
||||
Player* GetLootRecipient() const;
|
||||
Group* GetLootRecipientGroup() const;
|
||||
void SetLootRecipient(Unit* unit);
|
||||
bool IsLootAllowedFor(Player const* player) const;
|
||||
bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting
|
||||
void SetLootGenerationTime() { m_lootGenerationTime = time(nullptr); }
|
||||
uint32 GetLootGenerationTime() const { return m_lootGenerationTime; }
|
||||
Player* GetLootRecipient() const;
|
||||
Group* GetLootRecipientGroup() const;
|
||||
void SetLootRecipient(Unit* unit);
|
||||
bool IsLootAllowedFor(Player const* player) const;
|
||||
bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting
|
||||
void SetLootGenerationTime() { m_lootGenerationTime = time(nullptr); }
|
||||
uint32 GetLootGenerationTime() const { return m_lootGenerationTime; }
|
||||
|
||||
bool hasQuest(uint32 quest_id) const override;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const override;
|
||||
bool ActivateToQuest(Player* target) const;
|
||||
void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = nullptr);
|
||||
// 0 = use `gameobject`.`spawntimesecs`
|
||||
void ResetDoorOrButton();
|
||||
bool hasQuest(uint32 quest_id) const override;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const override;
|
||||
bool ActivateToQuest(Player* target) const;
|
||||
void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = nullptr);
|
||||
// 0 = use `gameobject`.`spawntimesecs`
|
||||
void ResetDoorOrButton();
|
||||
|
||||
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
|
||||
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
|
||||
|
||||
bool IsNeverVisible() const override;
|
||||
bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
|
||||
bool IsInvisibleDueToDespawn() const override;
|
||||
bool IsNeverVisible() const override;
|
||||
bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
|
||||
bool IsInvisibleDueToDespawn() const override;
|
||||
|
||||
uint8 getLevelForTarget(WorldObject const* target) const override
|
||||
{
|
||||
if (Unit* owner = GetOwner())
|
||||
return owner->getLevelForTarget(target);
|
||||
uint8 getLevelForTarget(WorldObject const* target) const override
|
||||
{
|
||||
if (Unit* owner = GetOwner())
|
||||
return owner->getLevelForTarget(target);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
GameObject* LookupFishingHoleAround(float range);
|
||||
GameObject* LookupFishingHoleAround(float range);
|
||||
|
||||
void CastSpell(Unit* target, uint32 spell);
|
||||
void SendCustomAnim(uint32 anim);
|
||||
bool IsInRange(float x, float y, float z, float radius) const;
|
||||
void CastSpell(Unit* target, uint32 spell);
|
||||
void SendCustomAnim(uint32 anim);
|
||||
bool IsInRange(float x, float y, float z, float radius) const;
|
||||
|
||||
void SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = nullptr) override; // pussywizard!
|
||||
void SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = nullptr) override; // pussywizard!
|
||||
|
||||
void ModifyHealth(int32 change, Unit* attackerOrHealer = NULL, uint32 spellId = 0);
|
||||
void SetDestructibleBuildingModifyState(bool allow) { m_allowModifyDestructibleBuilding = allow; }
|
||||
// sets GameObject type 33 destruction flags and optionally default health for that state
|
||||
void SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker = NULL, bool setHealth = false);
|
||||
GameObjectDestructibleState GetDestructibleState() const
|
||||
{
|
||||
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED))
|
||||
return GO_DESTRUCTIBLE_DESTROYED;
|
||||
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED))
|
||||
return GO_DESTRUCTIBLE_DAMAGED;
|
||||
return GO_DESTRUCTIBLE_INTACT;
|
||||
}
|
||||
void ModifyHealth(int32 change, Unit* attackerOrHealer = NULL, uint32 spellId = 0);
|
||||
void SetDestructibleBuildingModifyState(bool allow) { m_allowModifyDestructibleBuilding = allow; }
|
||||
// sets GameObject type 33 destruction flags and optionally default health for that state
|
||||
void SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker = NULL, bool setHealth = false);
|
||||
GameObjectDestructibleState GetDestructibleState() const
|
||||
{
|
||||
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED))
|
||||
return GO_DESTRUCTIBLE_DESTROYED;
|
||||
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED))
|
||||
return GO_DESTRUCTIBLE_DAMAGED;
|
||||
return GO_DESTRUCTIBLE_INTACT;
|
||||
}
|
||||
|
||||
void EventInform(uint32 eventId);
|
||||
void EventInform(uint32 eventId);
|
||||
|
||||
virtual uint32 GetScriptId() const { return GetGOInfo()->ScriptId; }
|
||||
GameObjectAI* AI() const { return m_AI; }
|
||||
virtual uint32 GetScriptId() const { return GetGOInfo()->ScriptId; }
|
||||
GameObjectAI* AI() const { return m_AI; }
|
||||
|
||||
std::string GetAIName() const;
|
||||
void SetDisplayId(uint32 displayid);
|
||||
uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
|
||||
std::string GetAIName() const;
|
||||
void SetDisplayId(uint32 displayid);
|
||||
uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
|
||||
|
||||
GameObjectModel* m_model;
|
||||
void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr) const;
|
||||
GameObjectModel* m_model;
|
||||
void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr) const;
|
||||
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(const Position& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
|
||||
|
||||
bool IsStaticTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT; }
|
||||
bool IsMotionTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT; }
|
||||
bool IsStaticTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT; }
|
||||
bool IsMotionTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT; }
|
||||
|
||||
Transport* ToTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport*>(this); else return nullptr; }
|
||||
Transport const* ToTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return nullptr; }
|
||||
Transport* ToTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport*>(this); else return nullptr; }
|
||||
Transport const* ToTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return nullptr; }
|
||||
|
||||
StaticTransport* ToStaticTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport*>(this); else return nullptr; }
|
||||
StaticTransport const* ToStaticTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport const*>(this); else return nullptr; }
|
||||
StaticTransport* ToStaticTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport*>(this); else return nullptr; }
|
||||
StaticTransport const* ToStaticTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport const*>(this); else return nullptr; }
|
||||
|
||||
MotionTransport* ToMotionTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport*>(this); else return nullptr; }
|
||||
MotionTransport const* ToMotionTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport const*>(this); else return nullptr; }
|
||||
MotionTransport* ToMotionTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport*>(this); else return nullptr; }
|
||||
MotionTransport const* ToMotionTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport const*>(this); else return nullptr; }
|
||||
|
||||
float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); }
|
||||
float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); }
|
||||
float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); }
|
||||
float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); }
|
||||
float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); }
|
||||
float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); }
|
||||
float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); }
|
||||
float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); }
|
||||
|
||||
float GetInteractionDistance();
|
||||
|
||||
void UpdateModelPosition();
|
||||
float GetInteractionDistance();
|
||||
|
||||
static std::unordered_map<int, goEventFlag> gameObjectToEventFlag; // Gameobject -> event flag
|
||||
void UpdateModelPosition();
|
||||
|
||||
protected:
|
||||
bool AIM_Initialize();
|
||||
void UpdateModel(); // updates model in case displayId were changed
|
||||
uint32 m_spellId;
|
||||
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
|
||||
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
|
||||
LootState m_lootState;
|
||||
bool m_spawnedByDefault;
|
||||
uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
|
||||
// For traps this: spell casting cooldown, for doors/buttons: reset time.
|
||||
std::list<uint32> m_SkillupList;
|
||||
static std::unordered_map<int, goEventFlag> gameObjectToEventFlag; // Gameobject -> event flag
|
||||
|
||||
uint32 m_ritualOwnerGUIDLow; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
|
||||
std::set<uint64> m_unique_users;
|
||||
uint32 m_usetimes;
|
||||
protected:
|
||||
bool AIM_Initialize();
|
||||
void UpdateModel(); // updates model in case displayId were changed
|
||||
uint32 m_spellId;
|
||||
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
|
||||
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
|
||||
LootState m_lootState;
|
||||
bool m_spawnedByDefault;
|
||||
uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
|
||||
// For traps this: spell casting cooldown, for doors/buttons: reset time.
|
||||
std::list<uint32> m_SkillupList;
|
||||
|
||||
typedef std::map<uint32, uint64> ChairSlotAndUser;
|
||||
ChairSlotAndUser ChairListSlots;
|
||||
uint32 m_ritualOwnerGUIDLow; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
|
||||
std::set<uint64> m_unique_users;
|
||||
uint32 m_usetimes;
|
||||
|
||||
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
|
||||
GameObjectTemplate const* m_goInfo;
|
||||
GameObjectData const* m_goData;
|
||||
GameObjectValue m_goValue;
|
||||
bool m_allowModifyDestructibleBuilding;
|
||||
typedef std::map<uint32, uint64> ChairSlotAndUser;
|
||||
ChairSlotAndUser ChairListSlots;
|
||||
|
||||
int64 m_packedRotation;
|
||||
G3D::Quat m_worldRotation;
|
||||
Position m_stationaryPosition;
|
||||
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
|
||||
GameObjectTemplate const* m_goInfo;
|
||||
GameObjectData const* m_goData;
|
||||
GameObjectValue m_goValue;
|
||||
bool m_allowModifyDestructibleBuilding;
|
||||
|
||||
uint64 m_lootRecipient;
|
||||
uint32 m_lootRecipientGroup;
|
||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||
uint32 m_lootGenerationTime;
|
||||
private:
|
||||
void CheckRitualList();
|
||||
void ClearRitualList();
|
||||
void RemoveFromOwner();
|
||||
void SwitchDoorOrButton(bool activate, bool alternative = false);
|
||||
void UpdatePackedRotation();
|
||||
int64 m_packedRotation;
|
||||
G3D::Quat m_worldRotation;
|
||||
Position m_stationaryPosition;
|
||||
|
||||
//! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.
|
||||
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const override
|
||||
{
|
||||
//! Following check does check 3d distance
|
||||
dist2compare += obj->GetObjectSize();
|
||||
return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
|
||||
}
|
||||
GameObjectAI* m_AI;
|
||||
uint64 m_lootRecipient;
|
||||
uint32 m_lootRecipientGroup;
|
||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||
uint32 m_lootGenerationTime;
|
||||
private:
|
||||
void CheckRitualList();
|
||||
void ClearRitualList();
|
||||
void RemoveFromOwner();
|
||||
void SwitchDoorOrButton(bool activate, bool alternative = false);
|
||||
void UpdatePackedRotation();
|
||||
|
||||
//! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.
|
||||
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const override
|
||||
{
|
||||
//! Following check does check 3d distance
|
||||
dist2compare += obj->GetObjectSize();
|
||||
return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
|
||||
}
|
||||
GameObjectAI* m_AI;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -31,8 +31,8 @@ Bag::~Bag()
|
||||
if (item->IsInWorld())
|
||||
{
|
||||
sLog->outCrash("Item %u (slot %u, bag slot %u) in bag %u (slot %u, bag slot %u, m_bagslot %u) is to be deleted but is still in world.",
|
||||
item->GetEntry(), (uint32)item->GetSlot(), (uint32)item->GetBagSlot(),
|
||||
GetEntry(), (uint32)GetSlot(), (uint32)GetBagSlot(), (uint32)i);
|
||||
item->GetEntry(), (uint32)item->GetSlot(), (uint32)item->GetBagSlot(),
|
||||
GetEntry(), (uint32)GetSlot(), (uint32)GetBagSlot(), (uint32)i);
|
||||
item->RemoveFromWorld();
|
||||
}
|
||||
delete m_bagslot[i];
|
||||
@@ -82,7 +82,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
// Cleaning 20 slots
|
||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
{
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
|
||||
m_bagslot[i] = nullptr;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry
|
||||
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
|
||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
{
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
|
||||
delete m_bagslot[i];
|
||||
m_bagslot[i] = nullptr;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void Bag::DeleteFromDB(SQLTransaction& trans)
|
||||
uint32 Bag::GetFreeSlots() const
|
||||
{
|
||||
uint32 slots = 0;
|
||||
for (uint32 i=0; i < GetBagSize(); ++i)
|
||||
for (uint32 i = 0; i < GetBagSize(); ++i)
|
||||
if (!m_bagslot[i])
|
||||
++slots;
|
||||
|
||||
@@ -180,7 +180,7 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
|
||||
{
|
||||
Item* pItem;
|
||||
uint32 count = 0;
|
||||
for (uint32 i=0; i < GetBagSize(); ++i)
|
||||
for (uint32 i = 0; i < GetBagSize(); ++i)
|
||||
{
|
||||
pItem = m_bagslot[i];
|
||||
if (pItem && pItem != eItem && pItem->GetEntry() == item)
|
||||
@@ -189,7 +189,7 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
|
||||
|
||||
if (eItem && eItem->GetTemplate()->GemProperties)
|
||||
{
|
||||
for (uint32 i=0; i < GetBagSize(); ++i)
|
||||
for (uint32 i = 0; i < GetBagSize(); ++i)
|
||||
{
|
||||
pItem = m_bagslot[i];
|
||||
if (pItem && pItem != eItem && pItem->GetTemplate()->Socket[0].Color)
|
||||
|
||||
@@ -15,43 +15,43 @@
|
||||
|
||||
class Bag : public Item
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
Bag();
|
||||
~Bag();
|
||||
Bag();
|
||||
~Bag();
|
||||
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
|
||||
void Clear();
|
||||
void StoreItem(uint8 slot, Item* pItem, bool update);
|
||||
void RemoveItem(uint8 slot, bool update);
|
||||
void Clear();
|
||||
void StoreItem(uint8 slot, Item* pItem, bool update);
|
||||
void RemoveItem(uint8 slot, bool update);
|
||||
|
||||
Item* GetItemByPos(uint8 slot) const;
|
||||
uint32 GetItemCount(uint32 item, Item* eItem = nullptr) const;
|
||||
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
|
||||
Item* GetItemByPos(uint8 slot) const;
|
||||
uint32 GetItemCount(uint32 item, Item* eItem = nullptr) const;
|
||||
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
|
||||
|
||||
uint8 GetSlotByItemGUID(uint64 guid) const;
|
||||
bool IsEmpty() const;
|
||||
uint32 GetFreeSlots() const;
|
||||
uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
|
||||
uint8 GetSlotByItemGUID(uint64 guid) const;
|
||||
bool IsEmpty() const;
|
||||
uint32 GetFreeSlots() const;
|
||||
uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
|
||||
|
||||
// DB operations
|
||||
// overwrite virtual Item::SaveToDB
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
// overwrite virtual Item::LoadFromDB
|
||||
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
|
||||
// overwrite virtual Item::DeleteFromDB
|
||||
void DeleteFromDB(SQLTransaction& trans);
|
||||
// DB operations
|
||||
// overwrite virtual Item::SaveToDB
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
// overwrite virtual Item::LoadFromDB
|
||||
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
|
||||
// overwrite virtual Item::DeleteFromDB
|
||||
void DeleteFromDB(SQLTransaction& trans);
|
||||
|
||||
void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const;
|
||||
void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
// Bag Storage space
|
||||
Item* m_bagslot[MAX_BAG_SIZE];
|
||||
// Bag Storage space
|
||||
Item* m_bagslot[MAX_BAG_SIZE];
|
||||
};
|
||||
|
||||
inline Item* NewItemOrBag(ItemTemplate const* proto)
|
||||
|
||||
@@ -55,7 +55,7 @@ void AddItemsSetItem(Player* player, Item* item)
|
||||
break;
|
||||
|
||||
if (x < player->ItemSetEff.size())
|
||||
player->ItemSetEff[x]=eff;
|
||||
player->ItemSetEff[x] = eff;
|
||||
else
|
||||
player->ItemSetEff.push_back(eff);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void AddItemsSetItem(Player* player, Item* item)
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveItemsSetItem(Player*player, ItemTemplate const* proto)
|
||||
void RemoveItemsSetItem(Player* player, ItemTemplate const* proto)
|
||||
{
|
||||
uint32 setid = proto->ItemSet;
|
||||
|
||||
@@ -143,7 +143,7 @@ void RemoveItemsSetItem(Player*player, ItemTemplate const* proto)
|
||||
{
|
||||
// spell can be not active if not fit form requirement
|
||||
player->ApplyEquipSpell(eff->spells[z], NULL, false);
|
||||
eff->spells[z]=NULL;
|
||||
eff->spells[z] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -309,68 +309,68 @@ void Item::SaveToDB(SQLTransaction& trans)
|
||||
{
|
||||
case ITEM_NEW:
|
||||
case ITEM_CHANGED:
|
||||
{
|
||||
uint8 index = 0;
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
|
||||
stmt->setUInt32( index, GetEntry());
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
|
||||
stmt->setUInt32(++index, GetCount());
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
|
||||
std::ostringstream ssSpells;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
ssSpells << GetSpellCharges(i) << ' ';
|
||||
stmt->setString(++index, ssSpells.str());
|
||||
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
|
||||
std::ostringstream ssEnchants;
|
||||
for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
|
||||
{
|
||||
ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
|
||||
ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
|
||||
ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
|
||||
}
|
||||
stmt->setString(++index, ssEnchants.str());
|
||||
uint8 index = 0;
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
|
||||
stmt->setUInt32( index, GetEntry());
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
|
||||
stmt->setUInt32(++index, GetCount());
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
|
||||
stmt->setInt16 (++index, GetItemRandomPropertyId());
|
||||
stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
||||
stmt->setString(++index, m_text);
|
||||
stmt->setUInt32(++index, guid);
|
||||
std::ostringstream ssSpells;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
ssSpells << GetSpellCharges(i) << ' ';
|
||||
stmt->setString(++index, ssSpells.str());
|
||||
|
||||
trans->Append(stmt);
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
|
||||
std::ostringstream ssEnchants;
|
||||
for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
|
||||
{
|
||||
ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
|
||||
ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
|
||||
ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
|
||||
}
|
||||
stmt->setString(++index, ssEnchants.str());
|
||||
|
||||
stmt->setInt16 (++index, GetItemRandomPropertyId());
|
||||
stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
||||
stmt->setString(++index, m_text);
|
||||
stmt->setUInt32(++index, guid);
|
||||
|
||||
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
|
||||
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(1, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_REMOVED:
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, guid);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
|
||||
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(1, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_REMOVED:
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, guid);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
||||
stmt->setUInt32(0, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
if (!isInTransaction)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInTransaction)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
case ITEM_UNCHANGED:
|
||||
break;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
|
||||
/*static*/
|
||||
void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
{
|
||||
sScriptMgr->OnGlobalItemDelFromDB(trans,itemGuid);
|
||||
sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, itemGuid);
|
||||
trans->Append(stmt);
|
||||
@@ -516,32 +516,54 @@ uint32 Item::GetSpell()
|
||||
case ITEM_CLASS_WEAPON:
|
||||
switch (proto->SubClass)
|
||||
{
|
||||
case ITEM_SUBCLASS_WEAPON_AXE: return 196;
|
||||
case ITEM_SUBCLASS_WEAPON_AXE2: return 197;
|
||||
case ITEM_SUBCLASS_WEAPON_BOW: return 264;
|
||||
case ITEM_SUBCLASS_WEAPON_GUN: return 266;
|
||||
case ITEM_SUBCLASS_WEAPON_MACE: return 198;
|
||||
case ITEM_SUBCLASS_WEAPON_MACE2: return 199;
|
||||
case ITEM_SUBCLASS_WEAPON_POLEARM: return 200;
|
||||
case ITEM_SUBCLASS_WEAPON_SWORD: return 201;
|
||||
case ITEM_SUBCLASS_WEAPON_SWORD2: return 202;
|
||||
case ITEM_SUBCLASS_WEAPON_STAFF: return 227;
|
||||
case ITEM_SUBCLASS_WEAPON_DAGGER: return 1180;
|
||||
case ITEM_SUBCLASS_WEAPON_THROWN: return 2567;
|
||||
case ITEM_SUBCLASS_WEAPON_SPEAR: return 3386;
|
||||
case ITEM_SUBCLASS_WEAPON_CROSSBOW:return 5011;
|
||||
case ITEM_SUBCLASS_WEAPON_WAND: return 5009;
|
||||
default: return 0;
|
||||
case ITEM_SUBCLASS_WEAPON_AXE:
|
||||
return 196;
|
||||
case ITEM_SUBCLASS_WEAPON_AXE2:
|
||||
return 197;
|
||||
case ITEM_SUBCLASS_WEAPON_BOW:
|
||||
return 264;
|
||||
case ITEM_SUBCLASS_WEAPON_GUN:
|
||||
return 266;
|
||||
case ITEM_SUBCLASS_WEAPON_MACE:
|
||||
return 198;
|
||||
case ITEM_SUBCLASS_WEAPON_MACE2:
|
||||
return 199;
|
||||
case ITEM_SUBCLASS_WEAPON_POLEARM:
|
||||
return 200;
|
||||
case ITEM_SUBCLASS_WEAPON_SWORD:
|
||||
return 201;
|
||||
case ITEM_SUBCLASS_WEAPON_SWORD2:
|
||||
return 202;
|
||||
case ITEM_SUBCLASS_WEAPON_STAFF:
|
||||
return 227;
|
||||
case ITEM_SUBCLASS_WEAPON_DAGGER:
|
||||
return 1180;
|
||||
case ITEM_SUBCLASS_WEAPON_THROWN:
|
||||
return 2567;
|
||||
case ITEM_SUBCLASS_WEAPON_SPEAR:
|
||||
return 3386;
|
||||
case ITEM_SUBCLASS_WEAPON_CROSSBOW:
|
||||
return 5011;
|
||||
case ITEM_SUBCLASS_WEAPON_WAND:
|
||||
return 5009;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case ITEM_CLASS_ARMOR:
|
||||
switch (proto->SubClass)
|
||||
{
|
||||
case ITEM_SUBCLASS_ARMOR_CLOTH: return 9078;
|
||||
case ITEM_SUBCLASS_ARMOR_LEATHER: return 9077;
|
||||
case ITEM_SUBCLASS_ARMOR_MAIL: return 8737;
|
||||
case ITEM_SUBCLASS_ARMOR_PLATE: return 750;
|
||||
case ITEM_SUBCLASS_ARMOR_SHIELD: return 9116;
|
||||
default: return 0;
|
||||
case ITEM_SUBCLASS_ARMOR_CLOTH:
|
||||
return 9078;
|
||||
case ITEM_SUBCLASS_ARMOR_LEATHER:
|
||||
return 9077;
|
||||
case ITEM_SUBCLASS_ARMOR_MAIL:
|
||||
return 8737;
|
||||
case ITEM_SUBCLASS_ARMOR_PLATE:
|
||||
return 750;
|
||||
case ITEM_SUBCLASS_ARMOR_SHIELD:
|
||||
return 9116;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -618,7 +640,7 @@ void Item::SetItemRandomProperties(int32 randomPropId)
|
||||
if (item_rand)
|
||||
{
|
||||
if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) ||
|
||||
!GetItemSuffixFactor())
|
||||
!GetItemSuffixFactor())
|
||||
{
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, -int32(item_rand->ID));
|
||||
UpdateItemSuffixFactor();
|
||||
@@ -688,7 +710,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
||||
return;
|
||||
|
||||
player->m_itemUpdateQueue.push_back(this);
|
||||
uQueuePos = player->m_itemUpdateQueue.size()-1;
|
||||
uQueuePos = player->m_itemUpdateQueue.size() - 1;
|
||||
}
|
||||
|
||||
void Item::RemoveFromUpdateQueueOf(Player* player)
|
||||
@@ -763,7 +785,7 @@ bool Item::HasEnchantRequiredSkill(const Player* player) const
|
||||
if (enchantEntry->requiredSkill && player->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 Item::GetEnchantRequiredLevel() const
|
||||
@@ -825,7 +847,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
|
||||
{
|
||||
// Special case - accept vellum for armor/weapon requirements
|
||||
if ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && proto->IsArmorVellum())
|
||||
||(spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && proto->IsWeaponVellum()))
|
||||
|| (spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && proto->IsWeaponVellum()))
|
||||
if (spellInfo->IsAbilityOfSkillType(SKILL_ENCHANTING)) // only for enchanting spells
|
||||
return true;
|
||||
|
||||
@@ -843,8 +865,8 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
|
||||
{
|
||||
// Special case - accept weapon type for main and offhand requirements
|
||||
if (proto->InventoryType == INVTYPE_WEAPON &&
|
||||
(spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONMAINHAND) ||
|
||||
spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND)))
|
||||
(spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONMAINHAND) ||
|
||||
spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND)))
|
||||
return true;
|
||||
else if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
|
||||
return false; // inventory type not present in mask
|
||||
@@ -869,9 +891,9 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
|
||||
}
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET, id);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET, id);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetState(ITEM_CHANGED, owner);
|
||||
}
|
||||
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner)
|
||||
@@ -879,7 +901,7 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player*
|
||||
if (GetEnchantmentDuration(slot) == duration)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetState(ITEM_CHANGED, owner);
|
||||
// Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
|
||||
}
|
||||
@@ -889,7 +911,7 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
if (GetEnchantmentCharges(slot) == charges)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
@@ -899,15 +921,15 @@ void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
return;
|
||||
|
||||
for (uint8 x = 0; x < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; ++x)
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
bool Item::GemsFitSockets() const
|
||||
{
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint8 SocketColor = GetTemplate()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color;
|
||||
uint8 SocketColor = GetTemplate()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color;
|
||||
|
||||
if (!SocketColor) // no socket slot
|
||||
continue;
|
||||
@@ -943,7 +965,7 @@ bool Item::GemsFitSockets() const
|
||||
uint8 Item::GetGemCountWithID(uint32 GemID) const
|
||||
{
|
||||
uint8 count = 0;
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if (!enchant_id)
|
||||
@@ -962,7 +984,7 @@ uint8 Item::GetGemCountWithID(uint32 GemID) const
|
||||
uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const
|
||||
{
|
||||
uint8 count = 0;
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if (!enchant_id)
|
||||
@@ -990,7 +1012,7 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
|
||||
|
||||
void Item::SendUpdateSockets()
|
||||
{
|
||||
WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8+4+4+4+4);
|
||||
WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4);
|
||||
data << uint64(GetGUID());
|
||||
for (uint32 i = SOCK_ENCHANTMENT_SLOT; i <= BONUS_ENCHANTMENT_SLOT; ++i)
|
||||
data << uint32(GetEnchantmentId(EnchantmentSlot(i)));
|
||||
@@ -1007,7 +1029,7 @@ void Item::SendTimeUpdate(Player* owner)
|
||||
if (!duration)
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8+4));
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
|
||||
data << uint64(GetGUID());
|
||||
data << uint32(duration);
|
||||
owner->GetSession()->SendPacket(&data);
|
||||
@@ -1024,7 +1046,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
|
||||
if (count > pProto->GetMaxStackSize())
|
||||
count = pProto->GetMaxStackSize();
|
||||
|
||||
ASSERT(count !=0 && "pProto->Stackable == 0 but checked at loading already");
|
||||
ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
|
||||
|
||||
Item* pItem = NewItemOrBag(pProto);
|
||||
if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player))
|
||||
@@ -1032,9 +1054,8 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
|
||||
pItem->SetCount(count);
|
||||
if (!clone)
|
||||
pItem->SetItemRandomProperties(randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item));
|
||||
else
|
||||
if (randomPropertyId)
|
||||
pItem->SetItemRandomProperties(randomPropertyId);
|
||||
else if (randomPropertyId)
|
||||
pItem->SetItemRandomProperties(randomPropertyId);
|
||||
return pItem;
|
||||
}
|
||||
else
|
||||
@@ -1048,7 +1069,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
|
||||
Item* Item::CloneItem(uint32 count, Player const* player) const
|
||||
{
|
||||
// player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
|
||||
Item * newItem = CreateItem(GetEntry(), count, player, true, player ? GetItemRandomPropertyId() : 0);
|
||||
Item* newItem = CreateItem(GetEntry(), count, player, true, player ? GetItemRandomPropertyId() : 0);
|
||||
if (!newItem)
|
||||
return nullptr;
|
||||
|
||||
@@ -1147,7 +1168,7 @@ void Item::UpdatePlayedTime(Player* owner)
|
||||
uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
|
||||
uint32 new_playtime = current_playtime + elapsed;
|
||||
// Check if the refund timer has expired yet
|
||||
if (new_playtime <= 2*HOUR)
|
||||
if (new_playtime <= 2 * HOUR)
|
||||
{
|
||||
// No? Proceed.
|
||||
// Update the data field
|
||||
@@ -1171,7 +1192,7 @@ uint32 Item::GetPlayedTime()
|
||||
|
||||
bool Item::IsRefundExpired()
|
||||
{
|
||||
return (GetPlayedTime() > 2*HOUR);
|
||||
return (GetPlayedTime() > 2 * HOUR);
|
||||
}
|
||||
|
||||
void Item::SetSoulboundTradeable(AllowedLooterSet& allowedLooters)
|
||||
@@ -1196,7 +1217,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
|
||||
bool Item::CheckSoulboundTradeExpire()
|
||||
{
|
||||
// called from owner's update - GetOwner() MUST be valid
|
||||
if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2*HOUR < GetOwner()->GetTotalPlayedTime())
|
||||
if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2 * HOUR < GetOwner()->GetTotalPlayedTime())
|
||||
{
|
||||
ClearSoulboundTradeable(GetOwner());
|
||||
return true; // remove from tradeable list
|
||||
|
||||
@@ -195,154 +195,154 @@ bool ItemCanGoIntoBag(ItemTemplate const* proto, ItemTemplate const* pBagProto);
|
||||
|
||||
class Item : public Object
|
||||
{
|
||||
public:
|
||||
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, bool clone = false, uint32 randomPropertyId = 0);
|
||||
Item* CloneItem(uint32 count, Player const* player = nullptr) const;
|
||||
public:
|
||||
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, bool clone = false, uint32 randomPropertyId = 0);
|
||||
Item* CloneItem(uint32 count, Player const* player = nullptr) const;
|
||||
|
||||
Item();
|
||||
Item();
|
||||
|
||||
virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
|
||||
ItemTemplate const* GetTemplate() const;
|
||||
ItemTemplate const* GetTemplate() const;
|
||||
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
|
||||
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
|
||||
Player* GetOwner() const;
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
|
||||
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
|
||||
Player* GetOwner() const;
|
||||
|
||||
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); }
|
||||
bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND); }
|
||||
bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_FLAG_IS_BOUND_TO_ACCOUNT) != 0; }
|
||||
bool IsBindedNotWith(Player const* player) const;
|
||||
bool IsBoundByEnchant() const;
|
||||
bool IsBoundByTempEnchant() const;
|
||||
virtual void SaveToDB(SQLTransaction& trans);
|
||||
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
|
||||
static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
virtual void DeleteFromDB(SQLTransaction& trans);
|
||||
static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
void DeleteFromInventoryDB(SQLTransaction& trans);
|
||||
void SaveRefundDataToDB();
|
||||
void DeleteRefundDataFromDB(SQLTransaction* trans);
|
||||
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); }
|
||||
bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND); }
|
||||
bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_FLAG_IS_BOUND_TO_ACCOUNT) != 0; }
|
||||
bool IsBindedNotWith(Player const* player) const;
|
||||
bool IsBoundByEnchant() const;
|
||||
bool IsBoundByTempEnchant() const;
|
||||
virtual void SaveToDB(SQLTransaction& trans);
|
||||
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
|
||||
static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
virtual void DeleteFromDB(SQLTransaction& trans);
|
||||
static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
void DeleteFromInventoryDB(SQLTransaction& trans);
|
||||
void SaveRefundDataToDB();
|
||||
void DeleteRefundDataFromDB(SQLTransaction* trans);
|
||||
|
||||
Bag* ToBag() { if (IsBag()) return reinterpret_cast<Bag*>(this); else return nullptr; }
|
||||
const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return nullptr; }
|
||||
Bag* ToBag() { if (IsBag()) return reinterpret_cast<Bag*>(this); else return nullptr; }
|
||||
const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return nullptr; }
|
||||
|
||||
bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_UNLOCKED); }
|
||||
bool IsBag() const { return GetTemplate()->InventoryType == INVTYPE_BAG; }
|
||||
bool IsCurrencyToken() const { return GetTemplate()->IsCurrencyToken(); }
|
||||
bool IsNotEmptyBag() const;
|
||||
bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
|
||||
bool CanBeTraded(bool mail = false, bool trade = false) const;
|
||||
void SetInTrade(bool b = true) { mb_in_trade = b; }
|
||||
bool IsInTrade() const { return mb_in_trade; }
|
||||
bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_UNLOCKED); }
|
||||
bool IsBag() const { return GetTemplate()->InventoryType == INVTYPE_BAG; }
|
||||
bool IsCurrencyToken() const { return GetTemplate()->IsCurrencyToken(); }
|
||||
bool IsNotEmptyBag() const;
|
||||
bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
|
||||
bool CanBeTraded(bool mail = false, bool trade = false) const;
|
||||
void SetInTrade(bool b = true) { mb_in_trade = b; }
|
||||
bool IsInTrade() const { return mb_in_trade; }
|
||||
|
||||
bool HasEnchantRequiredSkill(const Player* player) const;
|
||||
uint32 GetEnchantRequiredLevel() const;
|
||||
bool HasEnchantRequiredSkill(const Player* player) const;
|
||||
uint32 GetEnchantRequiredLevel() const;
|
||||
|
||||
bool IsFitToSpellRequirements(SpellInfo const* spellInfo) const;
|
||||
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const;
|
||||
bool GemsFitSockets() const;
|
||||
bool IsFitToSpellRequirements(SpellInfo const* spellInfo) const;
|
||||
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const;
|
||||
bool GemsFitSockets() const;
|
||||
|
||||
uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
|
||||
void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); }
|
||||
uint32 GetMaxStackCount() const { return GetTemplate()->GetMaxStackSize(); }
|
||||
uint8 GetGemCountWithID(uint32 GemID) const;
|
||||
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
|
||||
InventoryResult CanBeMergedPartlyWith(ItemTemplate const* proto) const;
|
||||
uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
|
||||
void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); }
|
||||
uint32 GetMaxStackCount() const { return GetTemplate()->GetMaxStackSize(); }
|
||||
uint8 GetGemCountWithID(uint32 GemID) const;
|
||||
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
|
||||
InventoryResult CanBeMergedPartlyWith(ItemTemplate const* proto) const;
|
||||
|
||||
uint8 GetSlot() const {return m_slot;}
|
||||
Bag* GetContainer() { return m_container; }
|
||||
uint8 GetBagSlot() const;
|
||||
void SetSlot(uint8 slot) { m_slot = slot; }
|
||||
uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); }
|
||||
void SetContainer(Bag* container) { m_container = container; }
|
||||
uint8 GetSlot() const {return m_slot;}
|
||||
Bag* GetContainer() { return m_container; }
|
||||
uint8 GetBagSlot() const;
|
||||
void SetSlot(uint8 slot) { m_slot = slot; }
|
||||
uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); }
|
||||
void SetContainer(Bag* container) { m_container = container; }
|
||||
|
||||
bool IsInBag() const { return m_container != nullptr; }
|
||||
bool IsEquipped() const;
|
||||
bool IsInBag() const { return m_container != nullptr; }
|
||||
bool IsEquipped() const;
|
||||
|
||||
uint32 GetSkill();
|
||||
uint32 GetSpell();
|
||||
uint32 GetSkill();
|
||||
uint32 GetSpell();
|
||||
|
||||
// RandomPropertyId (signed but stored as unsigned)
|
||||
int32 GetItemRandomPropertyId() const { return GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID); }
|
||||
uint32 GetItemSuffixFactor() const { return GetUInt32Value(ITEM_FIELD_PROPERTY_SEED); }
|
||||
void SetItemRandomProperties(int32 randomPropId);
|
||||
void UpdateItemSuffixFactor();
|
||||
static int32 GenerateItemRandomPropertyId(uint32 item_id);
|
||||
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0);
|
||||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
|
||||
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
|
||||
void ClearEnchantment(EnchantmentSlot slot);
|
||||
uint32 GetEnchantmentId(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET);}
|
||||
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET);}
|
||||
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET);}
|
||||
// RandomPropertyId (signed but stored as unsigned)
|
||||
int32 GetItemRandomPropertyId() const { return GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID); }
|
||||
uint32 GetItemSuffixFactor() const { return GetUInt32Value(ITEM_FIELD_PROPERTY_SEED); }
|
||||
void SetItemRandomProperties(int32 randomPropId);
|
||||
void UpdateItemSuffixFactor();
|
||||
static int32 GenerateItemRandomPropertyId(uint32 item_id);
|
||||
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0);
|
||||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
|
||||
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
|
||||
void ClearEnchantment(EnchantmentSlot slot);
|
||||
uint32 GetEnchantmentId(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET);}
|
||||
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET);}
|
||||
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET);}
|
||||
|
||||
std::string const& GetText() const { return m_text; }
|
||||
void SetText(std::string const& text) { m_text = text; }
|
||||
std::string const& GetText() const { return m_text; }
|
||||
void SetText(std::string const& text) { m_text = text; }
|
||||
|
||||
void SendUpdateSockets();
|
||||
void SendUpdateSockets();
|
||||
|
||||
void SendTimeUpdate(Player* owner);
|
||||
void UpdateDuration(Player* owner, uint32 diff);
|
||||
void SendTimeUpdate(Player* owner);
|
||||
void UpdateDuration(Player* owner, uint32 diff);
|
||||
|
||||
// spell charges (signed but stored as unsigned)
|
||||
int32 GetSpellCharges(uint8 index/*0..5*/ = 0) const { return GetInt32Value(ITEM_FIELD_SPELL_CHARGES + index); }
|
||||
void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index, value); }
|
||||
// spell charges (signed but stored as unsigned)
|
||||
int32 GetSpellCharges(uint8 index/*0..5*/ = 0) const { return GetInt32Value(ITEM_FIELD_SPELL_CHARGES + index); }
|
||||
void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index, value); }
|
||||
|
||||
Loot loot;
|
||||
bool m_lootGenerated;
|
||||
Loot loot;
|
||||
bool m_lootGenerated;
|
||||
|
||||
// Update States
|
||||
ItemUpdateState GetState() const { return uState; }
|
||||
void SetState(ItemUpdateState state, Player* forplayer = nullptr);
|
||||
void AddToUpdateQueueOf(Player* player);
|
||||
void RemoveFromUpdateQueueOf(Player* player);
|
||||
bool IsInUpdateQueue() const { return uQueuePos != -1; }
|
||||
uint32 GetQueuePos() const { return uQueuePos; }
|
||||
void FSetState(ItemUpdateState state) // forced
|
||||
{
|
||||
uState = state;
|
||||
}
|
||||
// Update States
|
||||
ItemUpdateState GetState() const { return uState; }
|
||||
void SetState(ItemUpdateState state, Player* forplayer = nullptr);
|
||||
void AddToUpdateQueueOf(Player* player);
|
||||
void RemoveFromUpdateQueueOf(Player* player);
|
||||
bool IsInUpdateQueue() const { return uQueuePos != -1; }
|
||||
uint32 GetQueuePos() const { return uQueuePos; }
|
||||
void FSetState(ItemUpdateState state) // forced
|
||||
{
|
||||
uState = state;
|
||||
}
|
||||
|
||||
bool hasQuest(uint32 quest_id) const { return GetTemplate()->StartQuest == quest_id; }
|
||||
bool hasInvolvedQuest(uint32 /*quest_id*/) const { return false; }
|
||||
bool IsPotion() const { return GetTemplate()->IsPotion(); }
|
||||
bool IsWeaponVellum() const { return GetTemplate()->IsWeaponVellum(); }
|
||||
bool IsArmorVellum() const { return GetTemplate()->IsArmorVellum(); }
|
||||
bool IsConjuredConsumable() const { return GetTemplate()->IsConjuredConsumable(); }
|
||||
bool hasQuest(uint32 quest_id) const { return GetTemplate()->StartQuest == quest_id; }
|
||||
bool hasInvolvedQuest(uint32 /*quest_id*/) const { return false; }
|
||||
bool IsPotion() const { return GetTemplate()->IsPotion(); }
|
||||
bool IsWeaponVellum() const { return GetTemplate()->IsWeaponVellum(); }
|
||||
bool IsArmorVellum() const { return GetTemplate()->IsArmorVellum(); }
|
||||
bool IsConjuredConsumable() const { return GetTemplate()->IsConjuredConsumable(); }
|
||||
|
||||
// Item Refund system
|
||||
void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = nullptr);
|
||||
void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; }
|
||||
void SetPaidMoney(uint32 money) { m_paidMoney = money; }
|
||||
void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; }
|
||||
uint32 GetRefundRecipient() { return m_refundRecipient; }
|
||||
uint32 GetPaidMoney() { return m_paidMoney; }
|
||||
uint32 GetPaidExtendedCost() { return m_paidExtendedCost; }
|
||||
// Item Refund system
|
||||
void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = nullptr);
|
||||
void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; }
|
||||
void SetPaidMoney(uint32 money) { m_paidMoney = money; }
|
||||
void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; }
|
||||
uint32 GetRefundRecipient() { return m_refundRecipient; }
|
||||
uint32 GetPaidMoney() { return m_paidMoney; }
|
||||
uint32 GetPaidExtendedCost() { return m_paidExtendedCost; }
|
||||
|
||||
void UpdatePlayedTime(Player* owner);
|
||||
uint32 GetPlayedTime();
|
||||
bool IsRefundExpired();
|
||||
void UpdatePlayedTime(Player* owner);
|
||||
uint32 GetPlayedTime();
|
||||
bool IsRefundExpired();
|
||||
|
||||
// Soulbound trade system
|
||||
void SetSoulboundTradeable(AllowedLooterSet& allowedLooters);
|
||||
void ClearSoulboundTradeable(Player* currentOwner);
|
||||
bool CheckSoulboundTradeExpire();
|
||||
// Soulbound trade system
|
||||
void SetSoulboundTradeable(AllowedLooterSet& allowedLooters);
|
||||
void ClearSoulboundTradeable(Player* currentOwner);
|
||||
bool CheckSoulboundTradeExpire();
|
||||
|
||||
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&);
|
||||
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&);
|
||||
|
||||
uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
|
||||
private:
|
||||
std::string m_text;
|
||||
uint8 m_slot;
|
||||
Bag* m_container;
|
||||
ItemUpdateState uState;
|
||||
int32 uQueuePos;
|
||||
bool mb_in_trade; // true if item is currently in trade-window
|
||||
time_t m_lastPlayedTimeUpdate;
|
||||
uint32 m_refundRecipient;
|
||||
uint32 m_paidMoney;
|
||||
uint32 m_paidExtendedCost;
|
||||
AllowedLooterSet allowedGUIDs;
|
||||
uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
|
||||
private:
|
||||
std::string m_text;
|
||||
uint8 m_slot;
|
||||
Bag* m_container;
|
||||
ItemUpdateState uState;
|
||||
int32 uQueuePos;
|
||||
bool mb_in_trade; // true if item is currently in trade-window
|
||||
time_t m_lastPlayedTimeUpdate;
|
||||
uint32 m_refundRecipient;
|
||||
uint32 m_paidMoney;
|
||||
uint32 m_paidExtendedCost;
|
||||
AllowedLooterSet allowedGUIDs;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -134,7 +134,7 @@ uint32 GenerateEnchSuffixFactor(uint32 item_id)
|
||||
case INVTYPE_QUIVER:
|
||||
case INVTYPE_RELIC:
|
||||
return 0;
|
||||
// Select point coefficient
|
||||
// Select point coefficient
|
||||
case INVTYPE_HEAD:
|
||||
case INVTYPE_BODY:
|
||||
case INVTYPE_CHEST:
|
||||
|
||||
@@ -555,9 +555,12 @@ inline uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemS
|
||||
{
|
||||
switch (ItemClass)
|
||||
{
|
||||
case ITEM_CLASS_WEAPON: return ItemSubClass;
|
||||
case ITEM_CLASS_ARMOR: return ItemSubClass + 21;
|
||||
default: return 0;
|
||||
case ITEM_CLASS_WEAPON:
|
||||
return ItemSubClass;
|
||||
case ITEM_CLASS_ARMOR:
|
||||
return ItemSubClass + 21;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,10 +695,10 @@ struct ItemTemplate
|
||||
bool HasSignature() const
|
||||
{
|
||||
return GetMaxStackSize() == 1 &&
|
||||
Class != ITEM_CLASS_CONSUMABLE &&
|
||||
Class != ITEM_CLASS_QUEST &&
|
||||
(Flags & ITEM_FLAG_NO_CREATOR) == 0 &&
|
||||
ItemId != 6948; /*Hearthstone*/
|
||||
Class != ITEM_CLASS_CONSUMABLE &&
|
||||
Class != ITEM_CLASS_QUEST &&
|
||||
(Flags & ITEM_FLAG_NO_CREATOR) == 0 &&
|
||||
ItemId != 6948; /*Hearthstone*/
|
||||
}
|
||||
|
||||
bool CanChangeEquipStateInCombat() const
|
||||
@@ -722,7 +725,7 @@ struct ItemTemplate
|
||||
|
||||
uint32 GetMaxStackSize() const
|
||||
{
|
||||
return (Stackable == 2147483647 || Stackable <= 0) ? uint32(0x7FFFFFFF-1) : uint32(Stackable);
|
||||
return (Stackable == 2147483647 || Stackable <= 0) ? uint32(0x7FFFFFFF - 1) : uint32(Stackable);
|
||||
}
|
||||
|
||||
float getDPS() const
|
||||
@@ -731,16 +734,16 @@ struct ItemTemplate
|
||||
return 0;
|
||||
float temp = 0;
|
||||
for (auto i : Damage)
|
||||
temp+=i.DamageMin + i.DamageMax;
|
||||
return temp*500/Delay;
|
||||
temp += i.DamageMin + i.DamageMax;
|
||||
return temp * 500 / Delay;
|
||||
}
|
||||
|
||||
int32 getFeralBonus(int32 extraDPS = 0) const
|
||||
{
|
||||
// 0x02A5F3 - is mask for Melee weapon from ItemSubClassMask.dbc
|
||||
if (Class == ITEM_CLASS_WEAPON && (1<<SubClass)&0x02A5F3)
|
||||
if (Class == ITEM_CLASS_WEAPON && (1 << SubClass) & 0x02A5F3)
|
||||
{
|
||||
int32 bonus = int32((extraDPS + getDPS())*14.0f) - 767;
|
||||
int32 bonus = int32((extraDPS + getDPS()) * 14.0f) - 767;
|
||||
if (bonus < 0)
|
||||
return 0;
|
||||
return bonus;
|
||||
@@ -762,7 +765,7 @@ struct ItemTemplate
|
||||
itemLevel -= 13.0f;
|
||||
break;
|
||||
case ITEM_QUALITY_HEIRLOOM:
|
||||
itemLevel = pLevel*2.33f;
|
||||
itemLevel = pLevel * 2.33f;
|
||||
break;
|
||||
case ITEM_QUALITY_ARTIFACT:
|
||||
case ITEM_QUALITY_EPIC:
|
||||
|
||||
@@ -51,21 +51,30 @@ uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
{
|
||||
switch (guid_hi)
|
||||
{
|
||||
case HIGHGUID_ITEM: return TYPEID_ITEM;
|
||||
case HIGHGUID_ITEM:
|
||||
return TYPEID_ITEM;
|
||||
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently
|
||||
case HIGHGUID_UNIT: return TYPEID_UNIT;
|
||||
case HIGHGUID_PET: return TYPEID_UNIT;
|
||||
case HIGHGUID_PLAYER: return TYPEID_PLAYER;
|
||||
case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_DYNAMICOBJECT:return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_CORPSE: return TYPEID_CORPSE;
|
||||
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
|
||||
case HIGHGUID_UNIT:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PET:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PLAYER:
|
||||
return TYPEID_PLAYER;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_CORPSE:
|
||||
return TYPEID_CORPSE;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_VEHICLE:
|
||||
return TYPEID_UNIT;
|
||||
}
|
||||
return NUM_CLIENT_OBJECT_TYPES; // unknown
|
||||
}
|
||||
|
||||
Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
||||
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||
{
|
||||
m_objectTypeId = TYPEID_OBJECT;
|
||||
m_objectType = TYPEMASK_OBJECT;
|
||||
@@ -124,7 +133,7 @@ Object::~Object()
|
||||
void Object::_InitValues()
|
||||
{
|
||||
m_uint32Values = new uint32[m_valuesCount];
|
||||
memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32));
|
||||
memset(m_uint32Values, 0, m_valuesCount * sizeof(uint32));
|
||||
|
||||
_changesMask.SetCount(m_valuesCount);
|
||||
|
||||
@@ -221,7 +230,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
break;
|
||||
default:
|
||||
if (((GameObject*)this)->GetOwner())
|
||||
updatetype = UPDATETYPE_CREATE_OBJECT2;
|
||||
updatetype = UPDATETYPE_CREATE_OBJECT2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -328,7 +337,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
// 0x08000000
|
||||
if (unit->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_SPLINE_ENABLED)
|
||||
{
|
||||
const G3D::Vector3 * p = &unit->movespline->_Spline().getPoints(true)[0];
|
||||
const G3D::Vector3* p = &unit->movespline->_Spline().getPoints(true)[0];
|
||||
if (unit->movespline->_Spline().getPoints(true).empty() || (!unit->movespline->_Spline().getPoints(true).empty() && !p))
|
||||
const_cast<Unit*>(unit)->DisableSpline();
|
||||
else
|
||||
@@ -469,7 +478,7 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if (_fieldNotifyFlags & flags[index] ||
|
||||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)))
|
||||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)))
|
||||
{
|
||||
updateMask.SetBit(index);
|
||||
fieldBuffer << m_uint32Values[index];
|
||||
@@ -524,20 +533,20 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const
|
||||
break;
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
flags = UnitUpdateFieldFlags;
|
||||
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
|
||||
visibleFlag |= UF_FLAG_OWNER;
|
||||
{
|
||||
Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
flags = UnitUpdateFieldFlags;
|
||||
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
|
||||
visibleFlag |= UF_FLAG_OWNER;
|
||||
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
|
||||
if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
|
||||
visibleFlag |= UF_FLAG_SPECIAL_INFO;
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
|
||||
if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
|
||||
visibleFlag |= UF_FLAG_SPECIAL_INFO;
|
||||
|
||||
if (plr && plr->IsInSameRaidWith(target))
|
||||
visibleFlag |= UF_FLAG_PARTY_MEMBER;
|
||||
break;
|
||||
}
|
||||
if (plr && plr->IsInSameRaidWith(target))
|
||||
visibleFlag |= UF_FLAG_PARTY_MEMBER;
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
flags = GameObjectUpdateFieldFlags;
|
||||
if (ToGameObject()->GetOwnerGUID() == target->GetGUID())
|
||||
@@ -622,7 +631,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
|
||||
void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (*((uint64*)&(m_uint32Values[index])) != value)
|
||||
if (*((uint64*) & (m_uint32Values[index])) != value)
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
m_uint32Values[index + 1] = PAIR64_HIPART(value);
|
||||
@@ -640,7 +649,7 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && !*((uint64*)&(m_uint32Values[index])))
|
||||
if (value && !*((uint64*) & (m_uint32Values[index])))
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
m_uint32Values[index + 1] = PAIR64_HIPART(value);
|
||||
@@ -662,7 +671,7 @@ bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::RemoveUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && *((uint64*)&(m_uint32Values[index])) == value)
|
||||
if (value && *((uint64*) & (m_uint32Values[index])) == value)
|
||||
{
|
||||
m_uint32Values[index] = 0;
|
||||
m_uint32Values[index + 1] = 0;
|
||||
@@ -976,11 +985,11 @@ void MovementInfo::OutDebug()
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
|
||||
#ifdef ELUNA
|
||||
elunaEvents(nullptr),
|
||||
elunaEvents(nullptr),
|
||||
#endif
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
m_transport(nullptr), m_currMap(nullptr), m_InstanceId(0),
|
||||
m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
m_transport(nullptr), m_currMap(nullptr), m_InstanceId(0),
|
||||
m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||
{
|
||||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
||||
@@ -1118,11 +1127,11 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
|
||||
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
if (is3D)
|
||||
{
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
distsq += dz*dz;
|
||||
distsq += dz * dz;
|
||||
}
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
@@ -1178,20 +1187,20 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o
|
||||
{
|
||||
float dx1 = GetPositionX() - obj1->GetPositionX();
|
||||
float dy1 = GetPositionY() - obj1->GetPositionY();
|
||||
float distsq1 = dx1*dx1 + dy1*dy1;
|
||||
float distsq1 = dx1 * dx1 + dy1 * dy1;
|
||||
if (is3D)
|
||||
{
|
||||
float dz1 = GetPositionZ() - obj1->GetPositionZ();
|
||||
distsq1 += dz1*dz1;
|
||||
distsq1 += dz1 * dz1;
|
||||
}
|
||||
|
||||
float dx2 = GetPositionX() - obj2->GetPositionX();
|
||||
float dy2 = GetPositionY() - obj2->GetPositionY();
|
||||
float distsq2 = dx2*dx2 + dy2*dy2;
|
||||
float distsq2 = dx2 * dx2 + dy2 * dy2;
|
||||
if (is3D)
|
||||
{
|
||||
float dz2 = GetPositionZ() - obj2->GetPositionZ();
|
||||
distsq2 += dz2*dz2;
|
||||
distsq2 += dz2 * dz2;
|
||||
}
|
||||
|
||||
return distsq1 < distsq2;
|
||||
@@ -1201,11 +1210,11 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
if (is3D)
|
||||
{
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
distsq += dz*dz;
|
||||
distsq += dz * dz;
|
||||
}
|
||||
|
||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||
@@ -1226,7 +1235,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange)
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
|
||||
float sizefactor = GetObjectSize();
|
||||
|
||||
@@ -1247,7 +1256,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float dz = GetPositionZ() - z;
|
||||
float distsq = dx*dx + dy*dy + dz*dz;
|
||||
float distsq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
float sizefactor = GetObjectSize();
|
||||
|
||||
@@ -1263,7 +1272,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
void Position::RelocateOffset(const Position & offset)
|
||||
void Position::RelocateOffset(const Position& offset)
|
||||
{
|
||||
m_positionX = GetPositionX() + (offset.GetPositionX() * cos(GetOrientation()) + offset.GetPositionY() * sin(GetOrientation() + M_PI));
|
||||
m_positionY = GetPositionY() + (offset.GetPositionY() * cos(GetOrientation()) + offset.GetPositionX() * sin(GetOrientation()));
|
||||
@@ -1271,7 +1280,7 @@ void Position::RelocateOffset(const Position & offset)
|
||||
m_orientation = GetOrientation() + offset.GetOrientation();
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
|
||||
void Position::GetPositionOffsetTo(const Position& endPos, Position& retOffset) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
float dy = endPos.GetPositionY() - GetPositionY();
|
||||
@@ -1301,20 +1310,20 @@ float Position::GetAngle(const float x, const float y) const
|
||||
return ang;
|
||||
}
|
||||
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
void Position::GetSinCos(const float x, const float y, float& vsin, float& vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
|
||||
if (fabs(dx) < 0.001f && fabs(dy) < 0.001f)
|
||||
{
|
||||
float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
|
||||
float angle = (float)rand_norm() * static_cast<float>(2 * M_PI);
|
||||
vcos = cos(angle);
|
||||
vsin = sin(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dist = sqrt((dx*dx) + (dy*dy));
|
||||
float dist = sqrt((dx * dx) + (dy * dy));
|
||||
vcos = dx / dist;
|
||||
vsin = dy / dist;
|
||||
}
|
||||
@@ -1333,16 +1342,16 @@ bool Position::IsWithinBox(const Position& center, float xradius, float yradius,
|
||||
float BoxDistX = GetPositionX() - center.GetPositionX();
|
||||
float BoxDistY = GetPositionY() - center.GetPositionY();
|
||||
|
||||
float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY*sinVal);
|
||||
float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX*sinVal);
|
||||
float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY * sinVal);
|
||||
float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX * sinVal);
|
||||
|
||||
// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
|
||||
float dz = GetPositionZ() - center.GetPositionZ();
|
||||
float dx = rotX - center.GetPositionX();
|
||||
float dy = rotY - center.GetPositionY();
|
||||
if ((std::fabs(dx) > xradius) ||
|
||||
(std::fabs(dy) > yradius) ||
|
||||
(std::fabs(dz) > zradius))
|
||||
(std::fabs(dy) > yradius) ||
|
||||
(std::fabs(dz) > zradius))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1363,17 +1372,17 @@ bool Position::HasInArc(float arc, const Position* obj, float targetRadius) cons
|
||||
// move angle to range -pi ... +pi
|
||||
angle = Position::NormalizeOrientation(angle);
|
||||
if (angle > M_PI)
|
||||
angle -= 2.0f*M_PI;
|
||||
angle -= 2.0f * M_PI;
|
||||
|
||||
float lborder = -1 * (arc/2.0f); // in range -pi..0
|
||||
float rborder = (arc/2.0f); // in range 0..pi
|
||||
float lborder = -1 * (arc / 2.0f); // in range -pi..0
|
||||
float rborder = (arc / 2.0f); // in range 0..pi
|
||||
|
||||
// pussywizard: take into consideration target size
|
||||
if (targetRadius > 0.0f)
|
||||
{
|
||||
float distSq = GetExactDist2dSq(obj);
|
||||
// pussywizard: at least a part of target's model is in every direction
|
||||
if (distSq < targetRadius*targetRadius)
|
||||
if (distSq < targetRadius * targetRadius)
|
||||
return true;
|
||||
float angularRadius = 2.0f * atan(targetRadius / (2.0f * sqrt(distSq)));
|
||||
lborder -= angularRadius;
|
||||
@@ -1396,12 +1405,12 @@ bool WorldObject::IsInBetween(const WorldObject* obj1, const WorldObject* obj2,
|
||||
return false;
|
||||
|
||||
if (G3D::fuzzyEq(obj1->GetPositionX(), obj2->GetPositionX()))
|
||||
return GetPositionX() >= obj1->GetPositionX()-size && GetPositionX() <= obj1->GetPositionX()+size;
|
||||
return GetPositionX() >= obj1->GetPositionX() - size && GetPositionX() <= obj1->GetPositionX() + size;
|
||||
|
||||
float A = (obj2->GetPositionY()-obj1->GetPositionY())/(obj2->GetPositionX()-obj1->GetPositionX());
|
||||
float A = (obj2->GetPositionY() - obj1->GetPositionY()) / (obj2->GetPositionX() - obj1->GetPositionX());
|
||||
float B = -1;
|
||||
float C = obj1->GetPositionY() - A*obj1->GetPositionX();
|
||||
float dist = fabs(A*GetPositionX()+B*GetPositionY()+C)/sqrt(A*A+B*B);
|
||||
float C = obj1->GetPositionY() - A * obj1->GetPositionX();
|
||||
float dist = fabs(A * GetPositionX() + B * GetPositionY() + C) / sqrt(A * A + B * B);
|
||||
return dist <= size;
|
||||
}
|
||||
|
||||
@@ -1415,7 +1424,7 @@ bool WorldObject::isInBack(WorldObject const* target, float arc) const
|
||||
return !HasInArc(2 * M_PI - arc, target);
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomPoint(const Position &pos, float distance, float &rand_x, float &rand_y, float &rand_z) const
|
||||
void WorldObject::GetRandomPoint(const Position& pos, float distance, float& rand_x, float& rand_y, float& rand_z) const
|
||||
{
|
||||
if (!distance)
|
||||
{
|
||||
@@ -1424,8 +1433,8 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran
|
||||
}
|
||||
|
||||
// angle to face `obj` to `this`
|
||||
float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
|
||||
float new_dist = (float)rand_norm()*static_cast<float>(distance);
|
||||
float angle = (float)rand_norm() * static_cast<float>(2 * M_PI);
|
||||
float new_dist = (float)rand_norm() * static_cast<float>(distance);
|
||||
|
||||
rand_x = pos.m_positionX + new_dist * cos(angle);
|
||||
rand_y = pos.m_positionY + new_dist * sin(angle);
|
||||
@@ -1436,14 +1445,14 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran
|
||||
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
|
||||
}
|
||||
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
|
||||
{
|
||||
float new_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z /*+ 2.0f*/, true); // pussywizard: +2.0f is added in all inner functions
|
||||
if (new_z > INVALID_HEIGHT)
|
||||
z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface
|
||||
}
|
||||
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
||||
{
|
||||
// TODO: Allow transports to be part of dynamic vmap tree
|
||||
//if (GetTransport())
|
||||
@@ -1452,62 +1461,62 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
switch (GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
{
|
||||
// non fly unit don't must be in air
|
||||
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
|
||||
if (!ToCreature()->CanFly())
|
||||
{
|
||||
bool canSwim = ToCreature()->CanSwim();
|
||||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
// non fly unit don't must be in air
|
||||
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
|
||||
if (!ToCreature()->CanFly())
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
bool canSwim = ToCreature()->CanSwim();
|
||||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
if (!ToPlayer()->CanFly())
|
||||
{
|
||||
float ground_z = z;
|
||||
float max_z = GetMap()->GetWaterOrGroundLevel(GetPhaseMask(),x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
if (!ToPlayer()->CanFly())
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
float ground_z = z;
|
||||
float max_z = GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
default:
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,11 +1544,11 @@ float WorldObject::GetVisibilityRange() const
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (IsInWintergrasp())
|
||||
return VISIBILITY_DIST_WINTERGRASP+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
else if (IsVisibilityOverridden())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else
|
||||
return GetMap()->GetVisibilityRange()+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
else
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1558,11 +1567,11 @@ float WorldObject::GetSightRange(const WorldObject* target) const
|
||||
else if (target->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (IsInWintergrasp() && target->IsInWintergrasp())
|
||||
return VISIBILITY_DIST_WINTERGRASP+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
else if (target->IsVisibilityOverridden())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else
|
||||
return GetMap()->GetVisibilityRange()+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
|
||||
return IsInWintergrasp() && target->IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1607,7 +1616,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
if (Player const* thisPlayer = ToPlayer())
|
||||
{
|
||||
if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
|
||||
!(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST))
|
||||
!(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST))
|
||||
{
|
||||
if (Corpse* corpse = thisPlayer->GetCorpse())
|
||||
{
|
||||
@@ -1879,51 +1888,51 @@ void Object::ForceValuesUpdateAtIndex(uint32 i)
|
||||
|
||||
namespace acore
|
||||
{
|
||||
class MonsterChatBuilder
|
||||
class MonsterChatBuilder
|
||||
{
|
||||
public:
|
||||
MonsterChatBuilder(WorldObject const* obj, ChatMsg msgtype, int32 textId, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
public:
|
||||
MonsterChatBuilder(WorldObject const* obj, ChatMsg msgtype, int32 textId, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
|
||||
{
|
||||
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
|
||||
{
|
||||
uint8 gender = GENDER_MALE;
|
||||
if (Unit const* unit = i_object->ToUnit())
|
||||
gender = unit->getGender();
|
||||
uint8 gender = GENDER_MALE;
|
||||
if (Unit const* unit = i_object->ToUnit())
|
||||
gender = unit->getGender();
|
||||
|
||||
std::string text = broadcastText->GetText(loc_idx, gender);
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
|
||||
}
|
||||
else
|
||||
sLog->outError("MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
|
||||
std::string text = broadcastText->GetText(loc_idx, gender);
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
|
||||
}
|
||||
else
|
||||
sLog->outError("MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
int32 i_textId;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
int32 i_textId;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
};
|
||||
|
||||
class MonsterCustomChatBuilder
|
||||
{
|
||||
public:
|
||||
MonsterCustomChatBuilder(WorldObject const* obj, ChatMsg msgtype, const char* text, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(Language(language)), i_target(target)
|
||||
{}
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, i_text, 0, "", loc_idx);
|
||||
}
|
||||
public:
|
||||
MonsterCustomChatBuilder(WorldObject const* obj, ChatMsg msgtype, const char* text, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(Language(language)), i_target(target)
|
||||
{}
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, i_text, 0, "", loc_idx);
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
const char* i_text;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
const char* i_text;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
};
|
||||
} // namespace acore
|
||||
|
||||
@@ -2142,33 +2151,33 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
case SUMMON_CATEGORY_WILD:
|
||||
case SUMMON_CATEGORY_ALLY:
|
||||
case SUMMON_CATEGORY_UNK:
|
||||
{
|
||||
switch (properties->Type)
|
||||
{
|
||||
case SUMMON_TYPE_MINION:
|
||||
case SUMMON_TYPE_GUARDIAN:
|
||||
case SUMMON_TYPE_GUARDIAN2:
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
case SUMMON_TYPE_TOTEM:
|
||||
case SUMMON_TYPE_LIGHTWELL:
|
||||
mask = UNIT_MASK_TOTEM;
|
||||
break;
|
||||
case SUMMON_TYPE_VEHICLE:
|
||||
case SUMMON_TYPE_VEHICLE2:
|
||||
mask = UNIT_MASK_SUMMON;
|
||||
break;
|
||||
case SUMMON_TYPE_MINIPET:
|
||||
case SUMMON_TYPE_JEEVES:
|
||||
mask = UNIT_MASK_MINION;
|
||||
break;
|
||||
default:
|
||||
if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
switch (properties->Type)
|
||||
{
|
||||
case SUMMON_TYPE_MINION:
|
||||
case SUMMON_TYPE_GUARDIAN:
|
||||
case SUMMON_TYPE_GUARDIAN2:
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
case SUMMON_TYPE_TOTEM:
|
||||
case SUMMON_TYPE_LIGHTWELL:
|
||||
mask = UNIT_MASK_TOTEM;
|
||||
break;
|
||||
case SUMMON_TYPE_VEHICLE:
|
||||
case SUMMON_TYPE_VEHICLE2:
|
||||
mask = UNIT_MASK_SUMMON;
|
||||
break;
|
||||
case SUMMON_TYPE_MINIPET:
|
||||
case SUMMON_TYPE_JEEVES:
|
||||
mask = UNIT_MASK_MINION;
|
||||
break;
|
||||
default:
|
||||
if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2282,7 +2291,7 @@ void WorldObject::SetZoneScript()
|
||||
}
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const *properties) const
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position& pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const* properties) const
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
@@ -2331,7 +2340,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
|
||||
return go;
|
||||
}
|
||||
|
||||
Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, bool setLevel, CreatureAI* (*GetAI)(Creature*))
|
||||
Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, bool setLevel, CreatureAI * (*GetAI)(Creature*))
|
||||
{
|
||||
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
|
||||
Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration);
|
||||
@@ -2512,7 +2521,7 @@ namespace acore
|
||||
|
||||
//===================================================================================================
|
||||
|
||||
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const
|
||||
void WorldObject::GetNearPoint2D(float& x, float& y, float distance2d, float absAngle) const
|
||||
{
|
||||
x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
|
||||
y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle);
|
||||
@@ -2521,9 +2530,9 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs
|
||||
acore::NormalizeMapCoord(y);
|
||||
}
|
||||
|
||||
void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ) const
|
||||
void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_size, float distance2d, float absAngle, float controlZ) const
|
||||
{
|
||||
GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
|
||||
GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
|
||||
z = GetPositionZ();
|
||||
if (searcher)
|
||||
searcher->UpdateAllowedPositionZ(x, y, z);
|
||||
@@ -2568,12 +2577,12 @@ void WorldObject::GetVoidClosePoint(float& x, float& y, float& z, float size, fl
|
||||
GetNearPoint(nullptr, x, y, z, size, distance2d, GetOrientation() + relAngle, controlZ);
|
||||
}
|
||||
|
||||
bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d, float angle, const WorldObject* forWho, bool force) const
|
||||
bool WorldObject::GetClosePoint(float& x, float& y, float& z, float size, float distance2d, float angle, const WorldObject* forWho, bool force) const
|
||||
{
|
||||
// angle calculated from current orientation
|
||||
GetNearPoint(forWho, x, y, z, size, distance2d, GetOrientation() + angle);
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2583,7 +2592,7 @@ bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float
|
||||
u->UpdateAllowedPositionZ(x, y, z);
|
||||
}
|
||||
float maxDist = GetObjectSize() + size + distance2d + 1.0f;
|
||||
if (GetExactDistSq(x, y, z) >= maxDist*maxDist)
|
||||
if (GetExactDistSq(x, y, z) >= maxDist * maxDist)
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
@@ -2597,12 +2606,12 @@ bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d) const
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2612,12 +2621,12 @@ void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, fl
|
||||
}
|
||||
|
||||
|
||||
void WorldObject::GetChargeContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d) const
|
||||
void WorldObject::GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2626,7 +2635,7 @@ void WorldObject::GetChargeContactPoint(const WorldObject* obj, float &x, float
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
void WorldObject::MovePosition(Position& pos, float dist, float angle)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz, ground, floor;
|
||||
@@ -2644,7 +2653,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
|
||||
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
|
||||
|
||||
float step = dist/10.0f;
|
||||
float step = dist / 10.0f;
|
||||
|
||||
for (uint8 j = 0; j < 10; ++j)
|
||||
{
|
||||
@@ -2670,14 +2679,14 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
pos.m_orientation = m_orientation;
|
||||
}
|
||||
|
||||
void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle)
|
||||
void WorldObject::MovePositionToFirstCollision(Position& pos, float dist, float angle)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz;
|
||||
destx = pos.m_positionX + dist * cos(angle);
|
||||
desty = pos.m_positionY + dist * sin(angle);
|
||||
destz = pos.m_positionZ;
|
||||
if (isType(TYPEMASK_UNIT|TYPEMASK_PLAYER) && !ToUnit()->IsInWater())
|
||||
if (isType(TYPEMASK_UNIT | TYPEMASK_PLAYER) && !ToUnit()->IsInWater())
|
||||
destz += 2.0f;
|
||||
|
||||
// Prevent invalid coordinates here, position is unchanged
|
||||
@@ -2700,7 +2709,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
else
|
||||
UpdateAllowedPositionZ(destx, desty, destz);
|
||||
|
||||
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+selfAddition, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + selfAddition, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// collision occured
|
||||
if (col)
|
||||
@@ -2712,11 +2721,11 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
|
||||
newDist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
newDist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
// check dynamic collision
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+selfAddition, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + selfAddition, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// Collided with a gameobject
|
||||
if (col)
|
||||
@@ -2727,7 +2736,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
destx -= CONTACT_DISTANCE * cos(angle);
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
newDist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
newDist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
float step = newDist / 10.0f;
|
||||
@@ -2771,7 +2780,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
pos.m_orientation = m_orientation;
|
||||
}
|
||||
|
||||
void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist, float angle, bool forGameObject)
|
||||
void WorldObject::MovePositionToFirstCollisionForTotem(Position& pos, float dist, float angle, bool forGameObject)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz, ground, floor;
|
||||
@@ -2799,11 +2808,11 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
|
||||
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
// check dynamic collision
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+0.5f, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// Collided with a gameobject
|
||||
if (col)
|
||||
@@ -2814,7 +2823,7 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
destx -= CONTACT_DISTANCE * cos(angle);
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
float prevdx = destx, prevdy = desty, prevdz = destz;
|
||||
@@ -2829,7 +2838,7 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
if (forGameObject)
|
||||
prevdz = destz;
|
||||
|
||||
float step = dist/10.0f;
|
||||
float step = dist / 10.0f;
|
||||
for (uint8 j = 0; j < 10; ++j)
|
||||
{
|
||||
// do not allow too big z changes
|
||||
@@ -2875,7 +2884,7 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
|
||||
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4+8);
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << uint64(GetGUID());
|
||||
if (target)
|
||||
@@ -2915,9 +2924,9 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
return;
|
||||
|
||||
std::list<Player*> targets;
|
||||
acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange()+VISIBILITY_COMPENSATION, false);
|
||||
acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false);
|
||||
acore::PlayerListSearcherWithSharedVision<acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
|
||||
VisitNearbyWorldObject(GetVisibilityRange()+VISIBILITY_COMPENSATION, searcher);
|
||||
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, searcher);
|
||||
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
{
|
||||
Player* player = (*iter);
|
||||
@@ -2940,7 +2949,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/)
|
||||
{
|
||||
//updates object's visibility for nearby players
|
||||
acore::VisibleChangesNotifier notifier(*this);
|
||||
VisitNearbyWorldObject(GetVisibilityRange()+VISIBILITY_COMPENSATION, notifier);
|
||||
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, notifier);
|
||||
}
|
||||
|
||||
void WorldObject::AddToNotify(uint16 f)
|
||||
@@ -2953,12 +2962,12 @@ void WorldObject::AddToNotify(uint16 f)
|
||||
uint32 EVENT_VISIBILITY_DELAY = u->FindMap() ? DynamicVisibilityMgr::GetVisibilityNotifyDelay(u->FindMap()->GetEntry()->map_type) : 1000;
|
||||
|
||||
uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, World::GetGameTimeMS());
|
||||
if (diff >= EVENT_VISIBILITY_DELAY/2)
|
||||
if (diff >= EVENT_VISIBILITY_DELAY / 2)
|
||||
EVENT_VISIBILITY_DELAY /= 2;
|
||||
else
|
||||
EVENT_VISIBILITY_DELAY -= diff;
|
||||
u->m_delayed_unit_relocation_timer = EVENT_VISIBILITY_DELAY;
|
||||
u->m_last_notify_mstime = World::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1;
|
||||
u->m_last_notify_mstime = World::GetGameTimeMS() + EVENT_VISIBILITY_DELAY - 1;
|
||||
}
|
||||
else if (f & NOTIFY_AI_RELOCATION)
|
||||
{
|
||||
@@ -2974,11 +2983,11 @@ struct WorldObjectChangeAccumulator
|
||||
UpdateDataMapType& i_updateDatas;
|
||||
UpdatePlayerSet& i_playerSet;
|
||||
WorldObject& i_object;
|
||||
WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d, UpdatePlayerSet &p) : i_updateDatas(d), i_playerSet(p), i_object(obj)
|
||||
WorldObjectChangeAccumulator(WorldObject& obj, UpdateDataMapType& d, UpdatePlayerSet& p) : i_updateDatas(d), i_playerSet(p), i_object(obj)
|
||||
{
|
||||
i_playerSet.clear();
|
||||
}
|
||||
void Visit(PlayerMapType &m)
|
||||
void Visit(PlayerMapType& m)
|
||||
{
|
||||
Player* source = nullptr;
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -2996,7 +3005,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
void Visit(CreatureMapType &m)
|
||||
void Visit(CreatureMapType& m)
|
||||
{
|
||||
Creature* source = nullptr;
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -3011,7 +3020,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
void Visit(DynamicObjectMapType &m)
|
||||
void Visit(DynamicObjectMapType& m)
|
||||
{
|
||||
DynamicObject* source = nullptr;
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -3039,7 +3048,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
|
||||
};
|
||||
|
||||
void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set)
|
||||
@@ -3051,12 +3060,12 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& play
|
||||
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
|
||||
Map& map = *GetMap();
|
||||
//we must build packets for all visible players
|
||||
cell.Visit(p, player_notifier, map, *this, GetVisibilityRange()+VISIBILITY_COMPENSATION);
|
||||
cell.Visit(p, player_notifier, map, *this, GetVisibilityRange() + VISIBILITY_COMPENSATION);
|
||||
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*> &creatureList, float radius, uint32 entry)
|
||||
void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry)
|
||||
{
|
||||
CellCoord pair(acore::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -187,15 +187,15 @@ uint32 GUID_HIPART(uint64 guid)
|
||||
uint32 GUID_ENPART(uint64 x)
|
||||
{
|
||||
return IsGuidHaveEnPart(x)
|
||||
? (uint32)((x >> 24) & UI64LIT(0x0000000000FFFFFF))
|
||||
: 0;
|
||||
? (uint32)((x >> 24) & UI64LIT(0x0000000000FFFFFF))
|
||||
: 0;
|
||||
}
|
||||
|
||||
uint32 GUID_LOPART(uint64 x)
|
||||
{
|
||||
return IsGuidHaveEnPart(x)
|
||||
? (uint32)(x & UI64LIT(0x0000000000FFFFFF))
|
||||
: (uint32)(x & UI64LIT(0x00000000FFFFFFFF));
|
||||
? (uint32)(x & UI64LIT(0x0000000000FFFFFF))
|
||||
: (uint32)(x & UI64LIT(0x00000000FFFFFFFF));
|
||||
}
|
||||
|
||||
bool IsGuidHaveEnPart(uint64 guid)
|
||||
@@ -223,17 +223,28 @@ char const* GetLogNameForGuid(uint64 guid)
|
||||
{
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_ITEM: return "item";
|
||||
case HIGHGUID_PLAYER: return guid ? "player" : "none";
|
||||
case HIGHGUID_GAMEOBJECT: return "gameobject";
|
||||
case HIGHGUID_TRANSPORT: return "transport";
|
||||
case HIGHGUID_UNIT: return "creature";
|
||||
case HIGHGUID_PET: return "pet";
|
||||
case HIGHGUID_VEHICLE: return "vehicle";
|
||||
case HIGHGUID_DYNAMICOBJECT:return "dynobject";
|
||||
case HIGHGUID_CORPSE: return "corpse";
|
||||
case HIGHGUID_MO_TRANSPORT: return "mo_transport";
|
||||
case HIGHGUID_GROUP: return "group";
|
||||
case HIGHGUID_ITEM:
|
||||
return "item";
|
||||
case HIGHGUID_PLAYER:
|
||||
return guid ? "player" : "none";
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return "gameobject";
|
||||
case HIGHGUID_TRANSPORT:
|
||||
return "transport";
|
||||
case HIGHGUID_UNIT:
|
||||
return "creature";
|
||||
case HIGHGUID_PET:
|
||||
return "pet";
|
||||
case HIGHGUID_VEHICLE:
|
||||
return "vehicle";
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return "dynobject";
|
||||
case HIGHGUID_CORPSE:
|
||||
return "corpse";
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
return "mo_transport";
|
||||
case HIGHGUID_GROUP:
|
||||
return "group";
|
||||
default:
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "ObjectPosSelector.h"
|
||||
|
||||
ObjectPosSelector::ObjectPosSelector(float x, float y, float size, float dist)
|
||||
: m_center_x(x), m_center_y(y), m_size(size), m_dist(dist)
|
||||
: m_center_x(x), m_center_y(y), m_size(size), m_dist(dist)
|
||||
{
|
||||
m_anglestep = acos(m_dist/(m_dist+2*m_size));
|
||||
m_anglestep = acos(m_dist / (m_dist + 2 * m_size));
|
||||
|
||||
m_nextUsedPos[USED_POS_PLUS] = m_UsedPosLists[USED_POS_PLUS].end();
|
||||
m_nextUsedPos[USED_POS_MINUS] = m_UsedPosLists[USED_POS_MINUS].end();
|
||||
@@ -27,10 +27,10 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float size, float dist)
|
||||
ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos(UsedPosType uptype)
|
||||
{
|
||||
UsedPosList::const_iterator itr = m_nextUsedPos[uptype];
|
||||
if (itr!=m_UsedPosLists[uptype].end())
|
||||
if (itr != m_UsedPosLists[uptype].end())
|
||||
++itr;
|
||||
|
||||
if (itr==m_UsedPosLists[uptype].end())
|
||||
if (itr == m_UsedPosLists[uptype].end())
|
||||
{
|
||||
if (!m_UsedPosLists[~uptype].empty())
|
||||
return &*m_UsedPosLists[~uptype].rbegin();
|
||||
@@ -73,9 +73,9 @@ bool ObjectPosSelector::FirstAngle(float& angle)
|
||||
|
||||
bool ObjectPosSelector::NextAngle(float& angle)
|
||||
{
|
||||
while (m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() ||
|
||||
m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end() ||
|
||||
m_smallStepOk[USED_POS_PLUS] || m_smallStepOk[USED_POS_MINUS] )
|
||||
while (m_nextUsedPos[USED_POS_PLUS] != m_UsedPosLists[USED_POS_PLUS].end() ||
|
||||
m_nextUsedPos[USED_POS_MINUS] != m_UsedPosLists[USED_POS_MINUS].end() ||
|
||||
m_smallStepOk[USED_POS_PLUS] || m_smallStepOk[USED_POS_MINUS] )
|
||||
{
|
||||
// calculate next possible angle
|
||||
if (NextPosibleAngle(angle))
|
||||
@@ -87,8 +87,8 @@ bool ObjectPosSelector::NextAngle(float& angle)
|
||||
|
||||
bool ObjectPosSelector::NextUsedAngle(float& angle)
|
||||
{
|
||||
while (m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() ||
|
||||
m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end())
|
||||
while (m_nextUsedPos[USED_POS_PLUS] != m_UsedPosLists[USED_POS_PLUS].end() ||
|
||||
m_nextUsedPos[USED_POS_MINUS] != m_UsedPosLists[USED_POS_MINUS].end())
|
||||
{
|
||||
// calculate next possible angle
|
||||
if (!NextPosibleAngle(angle))
|
||||
@@ -101,8 +101,8 @@ bool ObjectPosSelector::NextUsedAngle(float& angle)
|
||||
bool ObjectPosSelector::NextPosibleAngle(float& angle)
|
||||
{
|
||||
// ++ direction less updated
|
||||
if (m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() &&
|
||||
(m_nextUsedPos[USED_POS_MINUS]==m_UsedPosLists[USED_POS_MINUS].end() || m_nextUsedPos[USED_POS_PLUS]->first <= m_nextUsedPos[USED_POS_MINUS]->first))
|
||||
if (m_nextUsedPos[USED_POS_PLUS] != m_UsedPosLists[USED_POS_PLUS].end() &&
|
||||
(m_nextUsedPos[USED_POS_MINUS] == m_UsedPosLists[USED_POS_MINUS].end() || m_nextUsedPos[USED_POS_PLUS]->first <= m_nextUsedPos[USED_POS_MINUS]->first))
|
||||
{
|
||||
bool ok;
|
||||
if (m_smallStepOk[USED_POS_PLUS])
|
||||
@@ -115,7 +115,7 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle)
|
||||
return ok;
|
||||
}
|
||||
// -- direction less updated
|
||||
else if (m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end())
|
||||
else if (m_nextUsedPos[USED_POS_MINUS] != m_UsedPosLists[USED_POS_MINUS].end())
|
||||
{
|
||||
bool ok;
|
||||
if (m_smallStepOk[USED_POS_MINUS])
|
||||
|
||||
@@ -15,7 +15,7 @@ enum UsedPosType { USED_POS_PLUS, USED_POS_MINUS };
|
||||
|
||||
inline UsedPosType operator ~(UsedPosType uptype)
|
||||
{
|
||||
return uptype==USED_POS_PLUS ? USED_POS_MINUS : USED_POS_PLUS;
|
||||
return uptype == USED_POS_PLUS ? USED_POS_MINUS : USED_POS_PLUS;
|
||||
}
|
||||
|
||||
struct ObjectPosSelector
|
||||
@@ -49,20 +49,20 @@ struct ObjectPosSelector
|
||||
|
||||
float next_angle = nextUsedPos.first;
|
||||
if (nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha)
|
||||
next_angle = 2*M_PI-next_angle; // move to positive
|
||||
next_angle = 2 * M_PI - next_angle; // move to positive
|
||||
|
||||
return fabs(angle)+angle_step2 <= next_angle;
|
||||
return fabs(angle) + angle_step2 <= next_angle;
|
||||
}
|
||||
|
||||
bool CheckOriginal() const
|
||||
{
|
||||
return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0f, 0)) &&
|
||||
(m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0f, 0));
|
||||
(m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0f, 0));
|
||||
}
|
||||
|
||||
bool IsNonBalanced() const { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); }
|
||||
|
||||
bool NextAngleFor(UsedPosList::value_type const& usedPos, float sign, UsedPosType uptype, float &angle)
|
||||
bool NextAngleFor(UsedPosList::value_type const& usedPos, float sign, UsedPosType uptype, float& angle)
|
||||
{
|
||||
float angle_step = GetAngle(usedPos.second);
|
||||
|
||||
@@ -88,7 +88,7 @@ struct ObjectPosSelector
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NextSmallStepAngle(float sign, UsedPosType uptype, float &angle)
|
||||
bool NextSmallStepAngle(float sign, UsedPosType uptype, float& angle)
|
||||
{
|
||||
// next possible angle
|
||||
angle = m_smallStepAngle[uptype] + m_anglestep * sign;
|
||||
@@ -124,7 +124,7 @@ struct ObjectPosSelector
|
||||
UsedPosList::value_type const* nextUsedPos(UsedPosType uptype);
|
||||
|
||||
// angle from used pos to next possible free pos
|
||||
float GetAngle(UsedPos const& usedPos) const { return acos(m_dist/(usedPos.dist+usedPos.size+m_size)); }
|
||||
float GetAngle(UsedPos const& usedPos) const { return acos(m_dist / (usedPos.dist + usedPos.size + m_size)); }
|
||||
|
||||
float m_center_x;
|
||||
float m_center_y;
|
||||
|
||||
@@ -23,19 +23,19 @@ void UpdateData::AddOutOfRangeGUID(uint64 guid)
|
||||
m_outOfRangeGUIDs.push_back(guid);
|
||||
}
|
||||
|
||||
void UpdateData::AddUpdateBlock(const ByteBuffer &block)
|
||||
void UpdateData::AddUpdateBlock(const ByteBuffer& block)
|
||||
{
|
||||
m_data.append(block);
|
||||
++m_blockCount;
|
||||
}
|
||||
|
||||
void UpdateData::AddUpdateBlock(const UpdateData &block)
|
||||
void UpdateData::AddUpdateBlock(const UpdateData& block)
|
||||
{
|
||||
m_data.append(block.m_data);
|
||||
m_blockCount += block.m_blockCount;
|
||||
}
|
||||
|
||||
void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size)
|
||||
void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size)
|
||||
{
|
||||
z_stream c_stream;
|
||||
|
||||
|
||||
@@ -37,22 +37,22 @@ enum OBJECT_UPDATE_FLAGS
|
||||
|
||||
class UpdateData
|
||||
{
|
||||
public:
|
||||
UpdateData();
|
||||
public:
|
||||
UpdateData();
|
||||
|
||||
void AddOutOfRangeGUID(uint64 guid);
|
||||
void AddUpdateBlock(const ByteBuffer &block);
|
||||
void AddUpdateBlock(const UpdateData &block);
|
||||
bool BuildPacket(WorldPacket* packet);
|
||||
bool HasData() const { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); }
|
||||
void Clear();
|
||||
void AddOutOfRangeGUID(uint64 guid);
|
||||
void AddUpdateBlock(const ByteBuffer& block);
|
||||
void AddUpdateBlock(const UpdateData& block);
|
||||
bool BuildPacket(WorldPacket* packet);
|
||||
bool HasData() const { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); }
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
uint32 m_blockCount;
|
||||
std::vector<uint64> m_outOfRangeGUIDs;
|
||||
ByteBuffer m_data;
|
||||
protected:
|
||||
uint32 m_blockCount;
|
||||
std::vector<uint64> m_outOfRangeGUIDs;
|
||||
ByteBuffer m_data;
|
||||
|
||||
void Compress(void* dst, uint32 *dst_size, void* src, int src_size);
|
||||
void Compress(void* dst, uint32* dst_size, void* src, int src_size);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,101 +13,101 @@
|
||||
|
||||
class UpdateMask
|
||||
{
|
||||
public:
|
||||
/// Type representing how client reads update mask
|
||||
typedef uint32 ClientUpdateMaskType;
|
||||
public:
|
||||
/// Type representing how client reads update mask
|
||||
typedef uint32 ClientUpdateMaskType;
|
||||
|
||||
enum UpdateMaskCount
|
||||
enum UpdateMaskCount
|
||||
{
|
||||
CLIENT_UPDATE_MASK_BITS = sizeof(ClientUpdateMaskType) * 8,
|
||||
};
|
||||
|
||||
UpdateMask() : _fieldCount(0), _blockCount(0), _bits(nullptr) { }
|
||||
|
||||
UpdateMask(UpdateMask const& right) : _bits(nullptr)
|
||||
{
|
||||
SetCount(right.GetCount());
|
||||
memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * 32);
|
||||
}
|
||||
|
||||
~UpdateMask() { delete[] _bits; }
|
||||
|
||||
void SetBit(uint32 index) { _bits[index] = 1; }
|
||||
void UnsetBit(uint32 index) { _bits[index] = 0; }
|
||||
bool GetBit(uint32 index) const { return _bits[index] != 0; }
|
||||
|
||||
void AppendToPacket(ByteBuffer* data)
|
||||
{
|
||||
for (uint32 i = 0; i < GetBlockCount(); ++i)
|
||||
{
|
||||
CLIENT_UPDATE_MASK_BITS = sizeof(ClientUpdateMaskType) * 8,
|
||||
};
|
||||
ClientUpdateMaskType maskPart = 0;
|
||||
for (uint32 j = 0; j < CLIENT_UPDATE_MASK_BITS; ++j)
|
||||
if (_bits[CLIENT_UPDATE_MASK_BITS * i + j])
|
||||
maskPart |= 1 << j;
|
||||
|
||||
UpdateMask() : _fieldCount(0), _blockCount(0), _bits(nullptr) { }
|
||||
|
||||
UpdateMask(UpdateMask const& right) : _bits(nullptr)
|
||||
{
|
||||
SetCount(right.GetCount());
|
||||
memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * 32);
|
||||
*data << maskPart;
|
||||
}
|
||||
}
|
||||
|
||||
~UpdateMask() { delete[] _bits; }
|
||||
uint32 GetBlockCount() const { return _blockCount; }
|
||||
uint32 GetCount() const { return _fieldCount; }
|
||||
|
||||
void SetBit(uint32 index) { _bits[index] = 1; }
|
||||
void UnsetBit(uint32 index) { _bits[index] = 0; }
|
||||
bool GetBit(uint32 index) const { return _bits[index] != 0; }
|
||||
void SetCount(uint32 valuesCount)
|
||||
{
|
||||
delete[] _bits;
|
||||
|
||||
void AppendToPacket(ByteBuffer* data)
|
||||
{
|
||||
for (uint32 i = 0; i < GetBlockCount(); ++i)
|
||||
{
|
||||
ClientUpdateMaskType maskPart = 0;
|
||||
for (uint32 j = 0; j < CLIENT_UPDATE_MASK_BITS; ++j)
|
||||
if (_bits[CLIENT_UPDATE_MASK_BITS * i + j])
|
||||
maskPart |= 1 << j;
|
||||
_fieldCount = valuesCount;
|
||||
_blockCount = (valuesCount + CLIENT_UPDATE_MASK_BITS - 1) / CLIENT_UPDATE_MASK_BITS;
|
||||
|
||||
*data << maskPart;
|
||||
}
|
||||
}
|
||||
_bits = new uint8[_blockCount * CLIENT_UPDATE_MASK_BITS];
|
||||
memset(_bits, 0, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
|
||||
}
|
||||
|
||||
uint32 GetBlockCount() const { return _blockCount; }
|
||||
uint32 GetCount() const { return _fieldCount; }
|
||||
|
||||
void SetCount(uint32 valuesCount)
|
||||
{
|
||||
delete[] _bits;
|
||||
|
||||
_fieldCount = valuesCount;
|
||||
_blockCount = (valuesCount + CLIENT_UPDATE_MASK_BITS - 1) / CLIENT_UPDATE_MASK_BITS;
|
||||
|
||||
_bits = new uint8[_blockCount * CLIENT_UPDATE_MASK_BITS];
|
||||
void Clear()
|
||||
{
|
||||
if (_bits)
|
||||
memset(_bits, 0, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
|
||||
}
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (_bits)
|
||||
memset(_bits, 0, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
|
||||
}
|
||||
|
||||
UpdateMask& operator=(UpdateMask const& right)
|
||||
{
|
||||
if (this == &right)
|
||||
return *this;
|
||||
|
||||
SetCount(right.GetCount());
|
||||
memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
|
||||
UpdateMask& operator=(UpdateMask const& right)
|
||||
{
|
||||
if (this == &right)
|
||||
return *this;
|
||||
}
|
||||
|
||||
UpdateMask& operator&=(UpdateMask const& right)
|
||||
{
|
||||
ASSERT(right.GetCount() <= GetCount());
|
||||
for (uint32 i = 0; i < _fieldCount; ++i)
|
||||
_bits[i] &= right._bits[i];
|
||||
SetCount(right.GetCount());
|
||||
memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
|
||||
return *this;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
UpdateMask& operator&=(UpdateMask const& right)
|
||||
{
|
||||
ASSERT(right.GetCount() <= GetCount());
|
||||
for (uint32 i = 0; i < _fieldCount; ++i)
|
||||
_bits[i] &= right._bits[i];
|
||||
|
||||
UpdateMask& operator|=(UpdateMask const& right)
|
||||
{
|
||||
ASSERT(right.GetCount() <= GetCount());
|
||||
for (uint32 i = 0; i < _fieldCount; ++i)
|
||||
_bits[i] |= right._bits[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
UpdateMask& operator|=(UpdateMask const& right)
|
||||
{
|
||||
ASSERT(right.GetCount() <= GetCount());
|
||||
for (uint32 i = 0; i < _fieldCount; ++i)
|
||||
_bits[i] |= right._bits[i];
|
||||
|
||||
UpdateMask operator|(UpdateMask const& right)
|
||||
{
|
||||
UpdateMask ret(*this);
|
||||
ret |= right;
|
||||
return ret;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 _fieldCount;
|
||||
uint32 _blockCount;
|
||||
uint8* _bits;
|
||||
UpdateMask operator|(UpdateMask const& right)
|
||||
{
|
||||
UpdateMask ret(*this);
|
||||
ret |= right;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 _fieldCount;
|
||||
uint32 _blockCount;
|
||||
uint8* _bits;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+123
-123
@@ -24,16 +24,16 @@ struct PetSpell
|
||||
|
||||
class AsynchPetSummon
|
||||
{
|
||||
public:
|
||||
AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID) :
|
||||
m_entry(entry), pos(position), m_petType(petType),
|
||||
m_duration(duration), m_createdBySpell(createdBySpell), m_casterGUID(casterGUID) { }
|
||||
public:
|
||||
AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID) :
|
||||
m_entry(entry), pos(position), m_petType(petType),
|
||||
m_duration(duration), m_createdBySpell(createdBySpell), m_casterGUID(casterGUID) { }
|
||||
|
||||
uint32 m_entry;
|
||||
Position pos;
|
||||
PetType m_petType;
|
||||
uint32 m_duration, m_createdBySpell;
|
||||
uint64 m_casterGUID;
|
||||
uint32 m_entry;
|
||||
Position pos;
|
||||
PetType m_petType;
|
||||
uint32 m_duration, m_createdBySpell;
|
||||
uint64 m_casterGUID;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, PetSpell> PetSpellMap;
|
||||
@@ -43,148 +43,148 @@ class Player;
|
||||
|
||||
class Pet : public Guardian
|
||||
{
|
||||
public:
|
||||
explicit Pet(Player* owner, PetType type = MAX_PET_TYPE);
|
||||
virtual ~Pet();
|
||||
public:
|
||||
explicit Pet(Player* owner, PetType type = MAX_PET_TYPE);
|
||||
virtual ~Pet();
|
||||
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
void SetDisplayId(uint32 modelId) override;
|
||||
void SetDisplayId(uint32 modelId) override;
|
||||
|
||||
PetType getPetType() const { return m_petType; }
|
||||
void setPetType(PetType type) { m_petType = type; }
|
||||
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
|
||||
bool isTemporarySummoned() const { return m_duration > 0; }
|
||||
PetType getPetType() const { return m_petType; }
|
||||
void setPetType(PetType type) { m_petType = type; }
|
||||
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
|
||||
bool isTemporarySummoned() const { return m_duration > 0; }
|
||||
|
||||
bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
|
||||
bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
|
||||
|
||||
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
|
||||
bool CreateBaseAtCreature(Creature* creature);
|
||||
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
||||
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
||||
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE);
|
||||
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = nullptr);
|
||||
bool isBeingLoaded() const override { return m_loading;}
|
||||
void SavePetToDB(PetSaveMode mode, bool logout);
|
||||
void Remove(PetSaveMode mode, bool returnreagent = false);
|
||||
static void DeleteFromDB(uint32 guidlow);
|
||||
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
|
||||
bool CreateBaseAtCreature(Creature* creature);
|
||||
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
||||
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
||||
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE);
|
||||
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = nullptr);
|
||||
bool isBeingLoaded() const override { return m_loading;}
|
||||
void SavePetToDB(PetSaveMode mode, bool logout);
|
||||
void Remove(PetSaveMode mode, bool returnreagent = false);
|
||||
static void DeleteFromDB(uint32 guidlow);
|
||||
|
||||
void setDeathState(DeathState s, bool despawn = false) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState
|
||||
void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update
|
||||
void setDeathState(DeathState s, bool despawn = false) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState
|
||||
void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update
|
||||
|
||||
uint8 GetPetAutoSpellSize() const override { return m_autospells.size(); }
|
||||
uint32 GetPetAutoSpellOnPos(uint8 pos) const override
|
||||
{
|
||||
if (pos >= m_autospells.size())
|
||||
return 0;
|
||||
else
|
||||
return m_autospells[pos];
|
||||
}
|
||||
uint8 GetPetAutoSpellSize() const override { return m_autospells.size(); }
|
||||
uint32 GetPetAutoSpellOnPos(uint8 pos) const override
|
||||
{
|
||||
if (pos >= m_autospells.size())
|
||||
return 0;
|
||||
else
|
||||
return m_autospells[pos];
|
||||
}
|
||||
|
||||
void LoseHappiness();
|
||||
HappinessState GetHappinessState();
|
||||
void GivePetXP(uint32 xp);
|
||||
void GivePetLevel(uint8 level);
|
||||
void SynchronizeLevelWithOwner();
|
||||
bool HaveInDiet(ItemTemplate const* item) const;
|
||||
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const;
|
||||
void SetDuration(int32 dur) { m_duration = dur; }
|
||||
int32 GetDuration() const { return m_duration; }
|
||||
void LoseHappiness();
|
||||
HappinessState GetHappinessState();
|
||||
void GivePetXP(uint32 xp);
|
||||
void GivePetLevel(uint8 level);
|
||||
void SynchronizeLevelWithOwner();
|
||||
bool HaveInDiet(ItemTemplate const* item) const;
|
||||
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const;
|
||||
void SetDuration(int32 dur) { m_duration = dur; }
|
||||
int32 GetDuration() const { return m_duration; }
|
||||
|
||||
/*
|
||||
bool UpdateStats(Stats stat);
|
||||
bool UpdateAllStats();
|
||||
void UpdateResistances(uint32 school);
|
||||
void UpdateArmor();
|
||||
void UpdateMaxHealth();
|
||||
void UpdateMaxPower(Powers power);
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false);
|
||||
void UpdateDamagePhysical(WeaponAttackType attType);
|
||||
*/
|
||||
/*
|
||||
bool UpdateStats(Stats stat);
|
||||
bool UpdateAllStats();
|
||||
void UpdateResistances(uint32 school);
|
||||
void UpdateArmor();
|
||||
void UpdateMaxHealth();
|
||||
void UpdateMaxPower(Powers power);
|
||||
void UpdateAttackPowerAndDamage(bool ranged = false);
|
||||
void UpdateDamagePhysical(WeaponAttackType attType);
|
||||
*/
|
||||
|
||||
void ToggleAutocast(SpellInfo const* spellInfo, bool apply);
|
||||
void ToggleAutocast(SpellInfo const* spellInfo, bool apply);
|
||||
|
||||
bool HasSpell(uint32 spell) const override;
|
||||
bool HasSpell(uint32 spell) const override;
|
||||
|
||||
void LearnPetPassives();
|
||||
void CastPetAuras(bool current);
|
||||
void LearnPetPassives();
|
||||
void CastPetAuras(bool current);
|
||||
|
||||
void CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, Unit* oldTarget, bool spellIsPositive = false);
|
||||
void ClearCastWhenWillAvailable();
|
||||
void RemoveSpellCooldown(uint32 spell_id, bool update /* = false */);
|
||||
void CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, Unit* oldTarget, bool spellIsPositive = false);
|
||||
void ClearCastWhenWillAvailable();
|
||||
void RemoveSpellCooldown(uint32 spell_id, bool update /* = false */);
|
||||
|
||||
void _SaveSpellCooldowns(SQLTransaction& trans, bool logout);
|
||||
void _SaveAuras(SQLTransaction& trans, bool logout);
|
||||
void _SaveSpells(SQLTransaction& trans);
|
||||
void _SaveSpellCooldowns(SQLTransaction& trans, bool logout);
|
||||
void _SaveAuras(SQLTransaction& trans, bool logout);
|
||||
void _SaveSpells(SQLTransaction& trans);
|
||||
|
||||
void _LoadSpellCooldowns(PreparedQueryResult result);
|
||||
void _LoadAuras(PreparedQueryResult result, uint32 timediff);
|
||||
void _LoadSpells(PreparedQueryResult result);
|
||||
void _LoadSpellCooldowns(PreparedQueryResult result);
|
||||
void _LoadAuras(PreparedQueryResult result, uint32 timediff);
|
||||
void _LoadSpells(PreparedQueryResult result);
|
||||
|
||||
bool addSpell(uint32 spellId, ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL);
|
||||
bool learnSpell(uint32 spell_id);
|
||||
void learnSpellHighRank(uint32 spellid);
|
||||
void InitLevelupSpellsForLevel();
|
||||
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
void CleanupActionBar();
|
||||
bool addSpell(uint32 spellId, ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL);
|
||||
bool learnSpell(uint32 spell_id);
|
||||
void learnSpellHighRank(uint32 spellid);
|
||||
void InitLevelupSpellsForLevel();
|
||||
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
void CleanupActionBar();
|
||||
|
||||
PetSpellMap m_spells;
|
||||
AutoSpellList m_autospells;
|
||||
PetSpellMap m_spells;
|
||||
AutoSpellList m_autospells;
|
||||
|
||||
void InitPetCreateSpells();
|
||||
void InitPetCreateSpells();
|
||||
|
||||
bool resetTalents();
|
||||
static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = nullptr);
|
||||
void InitTalentForLevel();
|
||||
bool resetTalents();
|
||||
static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = nullptr);
|
||||
void InitTalentForLevel();
|
||||
|
||||
uint8 GetMaxTalentPointsForLevel(uint8 level);
|
||||
uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); }
|
||||
void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); }
|
||||
uint8 GetMaxTalentPointsForLevel(uint8 level);
|
||||
uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); }
|
||||
void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); }
|
||||
|
||||
uint32 m_usedTalentCount;
|
||||
uint32 m_usedTalentCount;
|
||||
|
||||
uint64 GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; }
|
||||
void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); }
|
||||
void ResetAuraUpdateMaskForRaid() { m_auraRaidUpdateMask = 0; }
|
||||
uint64 GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; }
|
||||
void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); }
|
||||
void ResetAuraUpdateMaskForRaid() { m_auraRaidUpdateMask = 0; }
|
||||
|
||||
DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
|
||||
DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
|
||||
|
||||
bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved)
|
||||
bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved)
|
||||
|
||||
Player* GetOwner() const { return m_owner; }
|
||||
void SetLoading(bool load) { m_loading = load; }
|
||||
void HandleAsynchLoadSucceed();
|
||||
static void HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 asynchLoadType, uint8 loadResult);
|
||||
uint8 GetAsynchLoadType() const { return asynchLoadType; }
|
||||
void SetAsynchLoadType(uint8 type) { asynchLoadType = type; }
|
||||
protected:
|
||||
Player* m_owner;
|
||||
int32 m_happinessTimer;
|
||||
PetType m_petType;
|
||||
int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
|
||||
uint64 m_auraRaidUpdateMask;
|
||||
bool m_loading;
|
||||
int32 m_petRegenTimer; // xinef: used for focus regeneration
|
||||
Player* GetOwner() const { return m_owner; }
|
||||
void SetLoading(bool load) { m_loading = load; }
|
||||
void HandleAsynchLoadSucceed();
|
||||
static void HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 asynchLoadType, uint8 loadResult);
|
||||
uint8 GetAsynchLoadType() const { return asynchLoadType; }
|
||||
void SetAsynchLoadType(uint8 type) { asynchLoadType = type; }
|
||||
protected:
|
||||
Player* m_owner;
|
||||
int32 m_happinessTimer;
|
||||
PetType m_petType;
|
||||
int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
|
||||
uint64 m_auraRaidUpdateMask;
|
||||
bool m_loading;
|
||||
int32 m_petRegenTimer; // xinef: used for focus regeneration
|
||||
|
||||
DeclinedName *m_declinedname;
|
||||
DeclinedName* m_declinedname;
|
||||
|
||||
Unit* m_tempspellTarget;
|
||||
Unit* m_tempoldTarget;
|
||||
bool m_tempspellIsPositive;
|
||||
uint32 m_tempspell;
|
||||
Unit* m_tempspellTarget;
|
||||
Unit* m_tempoldTarget;
|
||||
bool m_tempspellIsPositive;
|
||||
uint32 m_tempspell;
|
||||
|
||||
uint8 asynchLoadType;
|
||||
uint8 asynchLoadType;
|
||||
|
||||
private:
|
||||
void SaveToDB(uint32, uint8, uint32) override // override of Creature::SaveToDB - must not be called
|
||||
{
|
||||
ABORT();
|
||||
}
|
||||
void DeleteFromDB() override // override of Creature::DeleteFromDB - must not be called
|
||||
{
|
||||
ABORT();
|
||||
}
|
||||
private:
|
||||
void SaveToDB(uint32, uint8, uint32) override // override of Creature::SaveToDB - must not be called
|
||||
{
|
||||
ABORT();
|
||||
}
|
||||
void DeleteFromDB() override // override of Creature::DeleteFromDB - must not be called
|
||||
{
|
||||
ABORT();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
+1459
-1351
File diff suppressed because it is too large
Load Diff
+1878
-1878
File diff suppressed because it is too large
Load Diff
@@ -143,7 +143,7 @@ void PlayerSocial::SendSocialList(Player* player)
|
||||
|
||||
uint32 size = m_playerSocialMap.size();
|
||||
|
||||
WorldPacket data(SMSG_CONTACT_LIST, (4+4+size*25)); // just can guess size
|
||||
WorldPacket data(SMSG_CONTACT_LIST, (4 + 4 + size * 25)); // just can guess size
|
||||
data << uint32(7); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update.
|
||||
data << uint32(size); // friends count
|
||||
|
||||
@@ -202,7 +202,7 @@ SocialMgr* SocialMgr::instance()
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo)
|
||||
void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo& friendInfo)
|
||||
{
|
||||
if (!player)
|
||||
return;
|
||||
@@ -311,7 +311,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
|
||||
|
||||
PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid)
|
||||
{
|
||||
PlayerSocial *social = &m_socialMap[guid];
|
||||
PlayerSocial* social = &m_socialMap[guid];
|
||||
social->SetPlayerGUID(guid);
|
||||
|
||||
if (!result)
|
||||
@@ -334,8 +334,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid)
|
||||
// client's friends list and ignore list limit
|
||||
if (social->m_playerSocialMap.size() >= (SOCIALMGR_FRIEND_LIMIT + SOCIALMGR_IGNORE_LIMIT))
|
||||
break;
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
|
||||
return social;
|
||||
}
|
||||
|
||||
@@ -89,47 +89,47 @@ enum FriendsResult
|
||||
class PlayerSocial
|
||||
{
|
||||
friend class SocialMgr;
|
||||
public:
|
||||
PlayerSocial();
|
||||
~PlayerSocial();
|
||||
// adding/removing
|
||||
bool AddToSocialList(uint32 friend_guid, bool ignore);
|
||||
void RemoveFromSocialList(uint32 friend_guid, bool ignore);
|
||||
void SetFriendNote(uint32 friendGuid, std::string note);
|
||||
// Packet send's
|
||||
void SendSocialList(Player* player);
|
||||
// Misc
|
||||
bool HasFriend(uint32 friend_guid) const;
|
||||
bool HasIgnore(uint32 ignore_guid) const;
|
||||
uint32 GetPlayerGUID() const { return m_playerGUID; }
|
||||
void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; }
|
||||
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag) const;
|
||||
private:
|
||||
PlayerSocialMap m_playerSocialMap;
|
||||
uint32 m_playerGUID;
|
||||
public:
|
||||
PlayerSocial();
|
||||
~PlayerSocial();
|
||||
// adding/removing
|
||||
bool AddToSocialList(uint32 friend_guid, bool ignore);
|
||||
void RemoveFromSocialList(uint32 friend_guid, bool ignore);
|
||||
void SetFriendNote(uint32 friendGuid, std::string note);
|
||||
// Packet send's
|
||||
void SendSocialList(Player* player);
|
||||
// Misc
|
||||
bool HasFriend(uint32 friend_guid) const;
|
||||
bool HasIgnore(uint32 ignore_guid) const;
|
||||
uint32 GetPlayerGUID() const { return m_playerGUID; }
|
||||
void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; }
|
||||
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag) const;
|
||||
private:
|
||||
PlayerSocialMap m_playerSocialMap;
|
||||
uint32 m_playerGUID;
|
||||
};
|
||||
|
||||
class SocialMgr
|
||||
{
|
||||
private:
|
||||
SocialMgr();
|
||||
~SocialMgr();
|
||||
private:
|
||||
SocialMgr();
|
||||
~SocialMgr();
|
||||
|
||||
public:
|
||||
static SocialMgr* instance();
|
||||
public:
|
||||
static SocialMgr* instance();
|
||||
|
||||
// Misc
|
||||
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }
|
||||
// Misc
|
||||
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }
|
||||
|
||||
void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo);
|
||||
// Packet management
|
||||
void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data);
|
||||
void SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast);
|
||||
void BroadcastToFriendListers(Player* player, WorldPacket* packet);
|
||||
// Loading
|
||||
PlayerSocial *LoadFromDB(PreparedQueryResult result, uint32 guid);
|
||||
private:
|
||||
SocialMap m_socialMap;
|
||||
void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo& friendInfo);
|
||||
// Packet management
|
||||
void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data);
|
||||
void SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast);
|
||||
void BroadcastToFriendListers(Player* player, WorldPacket* packet);
|
||||
// Loading
|
||||
PlayerSocial* LoadFromDB(PreparedQueryResult result, uint32 guid);
|
||||
private:
|
||||
SocialMap m_socialMap;
|
||||
};
|
||||
|
||||
#define sSocialMgr SocialMgr::instance()
|
||||
|
||||
@@ -23,7 +23,7 @@ Totem::Totem(SummonPropertiesEntry const* properties, uint64 owner) : Minion(pro
|
||||
}
|
||||
|
||||
void Totem::Update(uint32 time)
|
||||
{
|
||||
{
|
||||
if (!GetOwner()->IsAlive() || !IsAlive())
|
||||
{
|
||||
UnSummon(); // remove self
|
||||
@@ -42,7 +42,7 @@ void Totem::Update(uint32 time)
|
||||
}
|
||||
|
||||
void Totem::InitStats(uint32 duration)
|
||||
{
|
||||
{
|
||||
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
|
||||
// Xinef: Set level for Unit totems
|
||||
if (Unit* owner = ObjectAccessor::FindUnit(m_owner))
|
||||
@@ -75,7 +75,7 @@ void Totem::InitStats(uint32 duration)
|
||||
}
|
||||
|
||||
void Totem::InitSummon()
|
||||
{
|
||||
{
|
||||
if (m_type == TOTEM_PASSIVE && GetSpell())
|
||||
CastSpell(this, GetSpell(), true);
|
||||
|
||||
@@ -94,7 +94,7 @@ void Totem::InitSummon()
|
||||
}
|
||||
|
||||
void Totem::UnSummon(uint32 msTime)
|
||||
{
|
||||
{
|
||||
if (msTime)
|
||||
{
|
||||
m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(msTime));
|
||||
@@ -104,7 +104,7 @@ void Totem::UnSummon(uint32 msTime)
|
||||
CombatStop();
|
||||
RemoveAurasDueToSpell(GetSpell(), GetGUID());
|
||||
|
||||
Unit *owner = GetOwner();
|
||||
Unit* owner = GetOwner();
|
||||
// clear owner's totem slot
|
||||
for (uint8 i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i)
|
||||
{
|
||||
@@ -144,13 +144,13 @@ void Totem::UnSummon(uint32 msTime)
|
||||
}
|
||||
|
||||
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
{
|
||||
{
|
||||
// xinef: immune to all positive spells, except of stoneclaw totem absorb and sentry totem bind sight
|
||||
// totems positive spells have unit_caster target
|
||||
if (spellInfo->Effects[index].Effect != SPELL_EFFECT_DUMMY &&
|
||||
spellInfo->Effects[index].Effect != SPELL_EFFECT_SCRIPT_EFFECT &&
|
||||
spellInfo->IsPositive() && spellInfo->Effects[index].TargetA.GetTarget() != TARGET_UNIT_CASTER &&
|
||||
spellInfo->Effects[index].TargetA.GetCheckType() != TARGET_CHECK_ENTRY && spellInfo->Id != 55277 && spellInfo->Id != 6277)
|
||||
if (spellInfo->Effects[index].Effect != SPELL_EFFECT_DUMMY &&
|
||||
spellInfo->Effects[index].Effect != SPELL_EFFECT_SCRIPT_EFFECT &&
|
||||
spellInfo->IsPositive() && spellInfo->Effects[index].TargetA.GetTarget() != TARGET_UNIT_CASTER &&
|
||||
spellInfo->Effects[index].TargetA.GetCheckType() != TARGET_CHECK_ENTRY && spellInfo->Id != 55277 && spellInfo->Id != 6277)
|
||||
return true;
|
||||
|
||||
switch (spellInfo->Effects[index].ApplyAuraName)
|
||||
|
||||
@@ -23,31 +23,31 @@ enum TotemType
|
||||
|
||||
class Totem : public Minion
|
||||
{
|
||||
public:
|
||||
explicit Totem(SummonPropertiesEntry const *properties, uint64 owner);
|
||||
virtual ~Totem(){};
|
||||
void Update(uint32 time);
|
||||
void InitStats(uint32 duration);
|
||||
void InitSummon();
|
||||
void UnSummon(uint32 msTime = 0);
|
||||
uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; }
|
||||
uint32 GetTotemDuration() const { return m_duration; }
|
||||
void SetTotemDuration(uint32 duration) { m_duration = duration; }
|
||||
TotemType GetTotemType() const { return m_type; }
|
||||
public:
|
||||
explicit Totem(SummonPropertiesEntry const* properties, uint64 owner);
|
||||
virtual ~Totem() {};
|
||||
void Update(uint32 time);
|
||||
void InitStats(uint32 duration);
|
||||
void InitSummon();
|
||||
void UnSummon(uint32 msTime = 0);
|
||||
uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; }
|
||||
uint32 GetTotemDuration() const { return m_duration; }
|
||||
void SetTotemDuration(uint32 duration) { m_duration = duration; }
|
||||
TotemType GetTotemType() const { return m_type; }
|
||||
|
||||
bool UpdateStats(Stats /*stat*/) { return true; }
|
||||
bool UpdateAllStats() { return true; }
|
||||
void UpdateResistances(uint32 /*school*/) {}
|
||||
void UpdateArmor() {}
|
||||
void UpdateMaxHealth() {}
|
||||
void UpdateMaxPower(Powers /*power*/) {}
|
||||
void UpdateAttackPowerAndDamage(bool /*ranged*/) {}
|
||||
void UpdateDamagePhysical(WeaponAttackType /*attType*/) {}
|
||||
bool UpdateStats(Stats /*stat*/) { return true; }
|
||||
bool UpdateAllStats() { return true; }
|
||||
void UpdateResistances(uint32 /*school*/) {}
|
||||
void UpdateArmor() {}
|
||||
void UpdateMaxHealth() {}
|
||||
void UpdateMaxPower(Powers /*power*/) {}
|
||||
void UpdateAttackPowerAndDamage(bool /*ranged*/) {}
|
||||
void UpdateDamagePhysical(WeaponAttackType /*attType*/) {}
|
||||
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const;
|
||||
|
||||
protected:
|
||||
TotemType m_type;
|
||||
uint32 m_duration;
|
||||
protected:
|
||||
TotemType m_type;
|
||||
uint32 m_duration;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -33,13 +33,13 @@ MotionTransport::~MotionTransport()
|
||||
}
|
||||
|
||||
bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
|
||||
{
|
||||
{
|
||||
Relocate(x, y, z, ang);
|
||||
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
sLog->outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
|
||||
guidlow, x, y);
|
||||
guidlow, x, y);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid,
|
||||
}
|
||||
|
||||
void MotionTransport::CleanupsBeforeDelete(bool finalCleanup /*= true*/)
|
||||
{
|
||||
{
|
||||
UnloadStaticPassengers();
|
||||
while (!_passengers.empty())
|
||||
{
|
||||
@@ -111,7 +111,7 @@ void MotionTransport::CleanupsBeforeDelete(bool finalCleanup /*= true*/)
|
||||
}
|
||||
|
||||
void MotionTransport::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&)
|
||||
{
|
||||
{
|
||||
Map::PlayerList const& players = GetMap()->GetPlayers();
|
||||
if (players.isEmpty())
|
||||
return;
|
||||
@@ -123,7 +123,7 @@ void MotionTransport::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&)
|
||||
}
|
||||
|
||||
void MotionTransport::Update(uint32 diff)
|
||||
{
|
||||
{
|
||||
uint32 const positionUpdateDelay = 1;
|
||||
|
||||
if (AI())
|
||||
@@ -223,7 +223,7 @@ void MotionTransport::Update(uint32 diff)
|
||||
|
||||
sScriptMgr->OnTransportUpdate(this, diff);
|
||||
}
|
||||
|
||||
|
||||
void MotionTransport::DelayedUpdate(uint32 /*diff*/)
|
||||
{
|
||||
if (GetKeyFrames().size() <= 1)
|
||||
@@ -233,7 +233,7 @@ void MotionTransport::DelayedUpdate(uint32 /*diff*/)
|
||||
}
|
||||
|
||||
void MotionTransport::UpdatePosition(float x, float y, float z, float o)
|
||||
{
|
||||
{
|
||||
if (!GetMap()->IsGridLoaded(x, y)) // pussywizard: should not happen, but just in case
|
||||
GetMap()->LoadGrid(x, y);
|
||||
|
||||
@@ -274,7 +274,7 @@ void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
|
||||
}
|
||||
|
||||
void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
|
||||
{
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
if (_passengers.erase(passenger) || _staticPassengers.erase(passenger))
|
||||
{
|
||||
@@ -295,7 +295,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
|
||||
}
|
||||
|
||||
Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* data)
|
||||
{
|
||||
{
|
||||
Map* map = GetMap();
|
||||
Creature* creature = new Creature();
|
||||
|
||||
@@ -325,7 +325,7 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d
|
||||
|
||||
if (!creature->IsPositionValid())
|
||||
{
|
||||
sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
|
||||
sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY());
|
||||
delete creature;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d
|
||||
}
|
||||
|
||||
GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const* data)
|
||||
{
|
||||
{
|
||||
Map* map = GetMap();
|
||||
GameObject* go = new GameObject();
|
||||
ASSERT(!sObjectMgr->IsGameObjectStaticTransport(data->id));
|
||||
@@ -382,7 +382,7 @@ GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const
|
||||
}
|
||||
|
||||
void MotionTransport::LoadStaticPassengers()
|
||||
{
|
||||
{
|
||||
if (PassengersLoaded())
|
||||
return;
|
||||
SetPassengersLoaded(true);
|
||||
@@ -406,7 +406,7 @@ void MotionTransport::LoadStaticPassengers()
|
||||
}
|
||||
|
||||
void MotionTransport::UnloadStaticPassengers()
|
||||
{
|
||||
{
|
||||
SetPassengersLoaded(false);
|
||||
while (!_staticPassengers.empty())
|
||||
{
|
||||
@@ -416,7 +416,7 @@ void MotionTransport::UnloadStaticPassengers()
|
||||
}
|
||||
|
||||
void MotionTransport::UnloadNonStaticPassengers()
|
||||
{
|
||||
{
|
||||
for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); )
|
||||
{
|
||||
if ((*itr)->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -430,7 +430,7 @@ void MotionTransport::UnloadNonStaticPassengers()
|
||||
}
|
||||
|
||||
void MotionTransport::EnableMovement(bool enabled)
|
||||
{
|
||||
{
|
||||
if (!GetGOInfo()->moTransport.canBeStopped)
|
||||
return;
|
||||
|
||||
@@ -438,7 +438,7 @@ void MotionTransport::EnableMovement(bool enabled)
|
||||
}
|
||||
|
||||
void MotionTransport::MoveToNextWaypoint()
|
||||
{
|
||||
{
|
||||
// Clear events flagging
|
||||
_triggeredArrivalEvent = false;
|
||||
_triggeredDepartureEvent = false;
|
||||
@@ -450,12 +450,12 @@ void MotionTransport::MoveToNextWaypoint()
|
||||
}
|
||||
|
||||
float MotionTransport::CalculateSegmentPos(float now)
|
||||
{
|
||||
{
|
||||
KeyFrame const& frame = *_currentFrame;
|
||||
const float speed = float(m_goInfo->moTransport.moveSpeed);
|
||||
const float accel = float(m_goInfo->moTransport.accelRate);
|
||||
float timeSinceStop = frame.TimeFrom + (now - (1.0f/IN_MILLISECONDS) * frame.DepartureTime);
|
||||
float timeUntilStop = frame.TimeTo - (now - (1.0f/IN_MILLISECONDS) * frame.DepartureTime);
|
||||
float timeSinceStop = frame.TimeFrom + (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
|
||||
float timeUntilStop = frame.TimeTo - (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
|
||||
float segmentPos, dist;
|
||||
float accelTime = _transportInfo->accelTime;
|
||||
float accelDist = _transportInfo->accelDist;
|
||||
@@ -481,7 +481,7 @@ float MotionTransport::CalculateSegmentPos(float now)
|
||||
}
|
||||
|
||||
bool MotionTransport::TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
|
||||
{
|
||||
{
|
||||
Map const* oldMap = GetMap();
|
||||
|
||||
if (oldMap->GetId() != newMapid)
|
||||
@@ -521,7 +521,7 @@ void MotionTransport::DelayedTeleportTransport()
|
||||
float x = _nextFrame->Node->x,
|
||||
y = _nextFrame->Node->y,
|
||||
z = _nextFrame->Node->z,
|
||||
o =_nextFrame->InitialOrientation;
|
||||
o = _nextFrame->InitialOrientation;
|
||||
|
||||
PassengerSet _passengersCopy = _passengers;
|
||||
for (PassengerSet::iterator itr = _passengersCopy.begin(); itr != _passengersCopy.end(); )
|
||||
@@ -580,7 +580,7 @@ void MotionTransport::DelayedTeleportTransport()
|
||||
}
|
||||
|
||||
void MotionTransport::UpdatePassengerPositions(PassengerSet& passengers)
|
||||
{
|
||||
{
|
||||
for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
|
||||
{
|
||||
WorldObject* passenger = *itr;
|
||||
@@ -631,7 +631,7 @@ void MotionTransport::UpdatePassengerPositions(PassengerSet& passengers)
|
||||
}
|
||||
|
||||
void MotionTransport::DoEventIfAny(KeyFrame const& node, bool departure)
|
||||
{
|
||||
{
|
||||
if (uint32 eventid = departure ? node.Node->departureEventID : node.Node->arrivalEventID)
|
||||
{
|
||||
//TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.Node->index, GetName().c_str());
|
||||
@@ -763,7 +763,7 @@ void StaticTransport::CleanupsBeforeDelete(bool finalCleanup /*= true*/)
|
||||
}
|
||||
|
||||
void StaticTransport::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&)
|
||||
{
|
||||
{
|
||||
Map::PlayerList const& players = GetMap()->GetPlayers();
|
||||
if (players.isEmpty())
|
||||
return;
|
||||
@@ -829,7 +829,7 @@ void StaticTransport::Update(uint32 diff)
|
||||
|
||||
void StaticTransport::RelocateToProgress(uint32 progress)
|
||||
{
|
||||
TransportAnimationEntry const *curr = NULL, *next = nullptr;
|
||||
TransportAnimationEntry const* curr = NULL, *next = nullptr;
|
||||
float percPos;
|
||||
if (m_goValue.Transport.AnimationInfo->GetAnimNode(progress, curr, next, percPos))
|
||||
{
|
||||
@@ -845,7 +845,7 @@ void StaticTransport::RelocateToProgress(uint32 progress)
|
||||
float sign = GetFloatValue(GAMEOBJECT_PARENTROTATION + 2) >= 0.0f ? 1.0f : -1.0f;
|
||||
float pathRotAngle = sign * 2.0f * acos(GetFloatValue(GAMEOBJECT_PARENTROTATION + 3));
|
||||
float cs = cos(pathRotAngle), sn = sin(pathRotAngle);
|
||||
float nx = pos.x * cs - pos.y * sn;
|
||||
float nx = pos.x * cs - pos.y * sn;
|
||||
float ny = pos.x * sn + pos.y * cs;
|
||||
pos.x = nx;
|
||||
pos.y = ny;
|
||||
@@ -875,7 +875,7 @@ void StaticTransport::RelocateToProgress(uint32 progress)
|
||||
}
|
||||
|
||||
void StaticTransport::UpdatePosition(float x, float y, float z, float o)
|
||||
{
|
||||
{
|
||||
if (!GetMap()->IsGridLoaded(x, y)) // pussywizard: should not happen, but just in case
|
||||
GetMap()->LoadGrid(x, y);
|
||||
|
||||
@@ -884,7 +884,7 @@ void StaticTransport::UpdatePosition(float x, float y, float z, float o)
|
||||
}
|
||||
|
||||
void StaticTransport::UpdatePassengerPositions()
|
||||
{
|
||||
{
|
||||
for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
|
||||
{
|
||||
WorldObject* passenger = *itr;
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
uint32 GetPauseTime() const { return GetUInt32Value(GAMEOBJECT_LEVEL); }
|
||||
void SetPauseTime(uint32 val) { SetUInt32Value(GAMEOBJECT_LEVEL, val); }
|
||||
uint32 GetPeriod() const { return m_goValue.Transport.AnimationInfo ? m_goValue.Transport.AnimationInfo->TotalTime : GetPauseTime()+2; }
|
||||
uint32 GetPeriod() const { return m_goValue.Transport.AnimationInfo ? m_goValue.Transport.AnimationInfo->TotalTime : GetPauseTime() + 2; }
|
||||
private:
|
||||
bool _needDoInitialRelocation;
|
||||
};
|
||||
|
||||
@@ -41,13 +41,13 @@ inline bool _ModifyUInt32(bool apply, uint32& baseValue, int32& amount)
|
||||
#######################################*/
|
||||
|
||||
void Unit::UpdateAllResistances()
|
||||
{
|
||||
{
|
||||
for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
|
||||
UpdateResistances(i);
|
||||
}
|
||||
|
||||
void Unit::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
{
|
||||
{
|
||||
float minDamage = 0.0f;
|
||||
float maxDamage = 0.0f;
|
||||
|
||||
@@ -78,7 +78,7 @@ void Unit::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
#######################################*/
|
||||
|
||||
bool Player::UpdateStats(Stats stat)
|
||||
{
|
||||
{
|
||||
if (stat > STAT_SPIRIT)
|
||||
return false;
|
||||
|
||||
@@ -97,7 +97,9 @@ bool Player::UpdateStats(Stats stat)
|
||||
UpdateAllCritPercentages();
|
||||
UpdateDodgePercentage();
|
||||
break;
|
||||
case STAT_STAMINA: UpdateMaxHealth(); break;
|
||||
case STAT_STAMINA:
|
||||
UpdateMaxHealth();
|
||||
break;
|
||||
case STAT_INTELLECT:
|
||||
UpdateMaxPower(POWER_MANA);
|
||||
UpdateAllSpellCritChances();
|
||||
@@ -146,7 +148,7 @@ bool Player::UpdateStats(Stats stat)
|
||||
}
|
||||
|
||||
void Player::ApplySpellPowerBonus(int32 amount, bool apply)
|
||||
{
|
||||
{
|
||||
apply = _ModifyUInt32(apply, m_baseSpellPower, amount);
|
||||
|
||||
// For speed just update for client
|
||||
@@ -156,18 +158,18 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply)
|
||||
}
|
||||
|
||||
void Player::UpdateSpellDamageAndHealingBonus()
|
||||
{
|
||||
{
|
||||
// Magic damage modifiers implemented in Unit::SpellDamageBonusDone
|
||||
// This information for client side use only
|
||||
// Get healing bonus for all schools
|
||||
SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL));
|
||||
// Get damage bonus for all schools
|
||||
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
|
||||
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
|
||||
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
|
||||
}
|
||||
|
||||
bool Player::UpdateAllStats()
|
||||
{
|
||||
{
|
||||
for (int8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
|
||||
{
|
||||
float value = GetTotalStatValue(Stats(i));
|
||||
@@ -198,13 +200,13 @@ bool Player::UpdateAllStats()
|
||||
}
|
||||
|
||||
void Player::ApplySpellPenetrationBonus(int32 amount, bool apply)
|
||||
{
|
||||
{
|
||||
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -amount, apply);
|
||||
m_spellPenetrationItemMod += apply ? amount : -amount;
|
||||
}
|
||||
|
||||
void Player::UpdateResistances(uint32 school)
|
||||
{
|
||||
{
|
||||
if (school > SPELL_SCHOOL_NORMAL)
|
||||
{
|
||||
// cant use GetTotalAuraModValue because of total pct multiplier :P
|
||||
@@ -216,9 +218,9 @@ void Player::UpdateResistances(uint32 school)
|
||||
value += GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
|
||||
AuraEffectList const& mResbyIntellect = GetAuraEffectsByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT);
|
||||
for(AuraEffectList::const_iterator i = mResbyIntellect.begin();i != mResbyIntellect.end(); ++i)
|
||||
for(AuraEffectList::const_iterator i = mResbyIntellect.begin(); i != mResbyIntellect.end(); ++i)
|
||||
{
|
||||
if((*i)->GetMiscValue() & (1 << (school-1)) )
|
||||
if((*i)->GetMiscValue() & (1 << (school - 1)) )
|
||||
value += int32(GetStat(Stats((*i)->GetMiscValueB())) * (*i)->GetAmount() / 100.0f);
|
||||
}
|
||||
|
||||
@@ -231,7 +233,7 @@ void Player::UpdateResistances(uint32 school)
|
||||
}
|
||||
|
||||
void Player::UpdateArmor()
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UNIT_MOD_ARMOR;
|
||||
|
||||
float value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items)
|
||||
@@ -255,27 +257,27 @@ void Player::UpdateArmor()
|
||||
}
|
||||
|
||||
float Player::GetHealthBonusFromStamina()
|
||||
{
|
||||
{
|
||||
float stamina = GetStat(STAT_STAMINA);
|
||||
|
||||
float baseStam = stamina < 20 ? stamina : 20;
|
||||
float moreStam = stamina - baseStam;
|
||||
|
||||
return baseStam + (moreStam*10.0f);
|
||||
return baseStam + (moreStam * 10.0f);
|
||||
}
|
||||
|
||||
float Player::GetManaBonusFromIntellect()
|
||||
{
|
||||
{
|
||||
float intellect = GetStat(STAT_INTELLECT);
|
||||
|
||||
float baseInt = intellect < 20 ? intellect : 20;
|
||||
float moreInt = intellect - baseInt;
|
||||
|
||||
return baseInt + (moreInt*15.0f);
|
||||
return baseInt + (moreInt * 15.0f);
|
||||
}
|
||||
|
||||
void Player::UpdateMaxHealth()
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UNIT_MOD_HEALTH;
|
||||
|
||||
float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth();
|
||||
@@ -288,7 +290,7 @@ void Player::UpdateMaxHealth()
|
||||
}
|
||||
|
||||
void Player::UpdateMaxPower(Powers power)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float bonusPower = (power == POWER_MANA && GetCreatePowers(power) > 0) ? GetManaBonusFromIntellect() : 0;
|
||||
@@ -303,16 +305,16 @@ void Player::UpdateMaxPower(Powers power)
|
||||
}
|
||||
|
||||
void Player::ApplyFeralAPBonus(int32 amount, bool apply)
|
||||
{
|
||||
{
|
||||
_ModifyUInt32(apply, m_baseFeralAP, amount);
|
||||
UpdateAttackPowerAndDamage();
|
||||
}
|
||||
|
||||
void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
{
|
||||
float val2 = 0.0f;
|
||||
float level = float(getLevel());
|
||||
|
||||
|
||||
sScriptMgr->OnBeforeUpdateAttackPowerAndDamage(this, level, val2, ranged);
|
||||
|
||||
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
|
||||
@@ -342,12 +344,16 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
case FORM_CAT:
|
||||
case FORM_BEAR:
|
||||
case FORM_DIREBEAR:
|
||||
val2 = 0.0f; break;
|
||||
val2 = 0.0f;
|
||||
break;
|
||||
default:
|
||||
val2 = GetStat(STAT_AGILITY) - 10.0f; break;
|
||||
val2 = GetStat(STAT_AGILITY) - 10.0f;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default: val2 = GetStat(STAT_AGILITY) - 10.0f; break;
|
||||
default:
|
||||
val2 = GetStat(STAT_AGILITY) - 10.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -365,87 +371,87 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
|
||||
break;
|
||||
case CLASS_DRUID:
|
||||
{
|
||||
// Check if Predatory Strikes is skilled
|
||||
float mLevelMult = 0.0f;
|
||||
float weapon_bonus = 0.0f;
|
||||
if (IsInFeralForm())
|
||||
{
|
||||
Unit::AuraEffectList const& mDummy = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
for (Unit::AuraEffectList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
|
||||
// Check if Predatory Strikes is skilled
|
||||
float mLevelMult = 0.0f;
|
||||
float weapon_bonus = 0.0f;
|
||||
if (IsInFeralForm())
|
||||
{
|
||||
AuraEffect* aurEff = *itr;
|
||||
if (aurEff->GetSpellInfo()->SpellIconID == 1563)
|
||||
Unit::AuraEffectList const& mDummy = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
for (Unit::AuraEffectList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
|
||||
{
|
||||
switch (aurEff->GetEffIndex())
|
||||
AuraEffect* aurEff = *itr;
|
||||
if (aurEff->GetSpellInfo()->SpellIconID == 1563)
|
||||
{
|
||||
case 0: // Predatory Strikes (effect 0)
|
||||
mLevelMult = CalculatePct(1.0f, aurEff->GetAmount());
|
||||
break;
|
||||
case 1: // Predatory Strikes (effect 1)
|
||||
if (Item* mainHand = m_items[EQUIPMENT_SLOT_MAINHAND])
|
||||
{
|
||||
// also gains % attack power from equipped weapon
|
||||
ItemTemplate const* proto = mainHand->GetTemplate();
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
uint32 ap = proto->getFeralBonus();
|
||||
// Get AP Bonuses from weapon
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
|
||||
switch (aurEff->GetEffIndex())
|
||||
{
|
||||
case 0: // Predatory Strikes (effect 0)
|
||||
mLevelMult = CalculatePct(1.0f, aurEff->GetAmount());
|
||||
break;
|
||||
case 1: // Predatory Strikes (effect 1)
|
||||
if (Item* mainHand = m_items[EQUIPMENT_SLOT_MAINHAND])
|
||||
{
|
||||
if (i >= proto->StatsCount)
|
||||
break;
|
||||
|
||||
if (proto->ItemStat[i].ItemStatType == ITEM_MOD_ATTACK_POWER)
|
||||
ap += proto->ItemStat[i].ItemStatValue;
|
||||
}
|
||||
|
||||
// Get AP Bonuses from weapon spells
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
{
|
||||
// no spell
|
||||
if (!proto->Spells[i].SpellId || proto->Spells[i].SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
|
||||
// also gains % attack power from equipped weapon
|
||||
ItemTemplate const* proto = mainHand->GetTemplate();
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
// check if it is valid spell
|
||||
SpellInfo const* spellproto = sSpellMgr->GetSpellInfo(proto->Spells[i].SpellId);
|
||||
if (!spellproto)
|
||||
continue;
|
||||
uint32 ap = proto->getFeralBonus();
|
||||
// Get AP Bonuses from weapon
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
|
||||
{
|
||||
if (i >= proto->StatsCount)
|
||||
break;
|
||||
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
if (spellproto->Effects[j].ApplyAuraName == SPELL_AURA_MOD_ATTACK_POWER)
|
||||
ap += spellproto->Effects[j].CalcValue();
|
||||
if (proto->ItemStat[i].ItemStatType == ITEM_MOD_ATTACK_POWER)
|
||||
ap += proto->ItemStat[i].ItemStatValue;
|
||||
}
|
||||
|
||||
// Get AP Bonuses from weapon spells
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
{
|
||||
// no spell
|
||||
if (!proto->Spells[i].SpellId || proto->Spells[i].SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
|
||||
continue;
|
||||
|
||||
// check if it is valid spell
|
||||
SpellInfo const* spellproto = sSpellMgr->GetSpellInfo(proto->Spells[i].SpellId);
|
||||
if (!spellproto)
|
||||
continue;
|
||||
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
if (spellproto->Effects[j].ApplyAuraName == SPELL_AURA_MOD_ATTACK_POWER)
|
||||
ap += spellproto->Effects[j].CalcValue();
|
||||
}
|
||||
|
||||
weapon_bonus = CalculatePct(float(ap), aurEff->GetAmount());
|
||||
}
|
||||
|
||||
weapon_bonus = CalculatePct(float(ap), aurEff->GetAmount());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (GetShapeshiftForm())
|
||||
{
|
||||
case FORM_CAT:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + weapon_bonus + m_baseFeralAP;
|
||||
break;
|
||||
case FORM_BEAR:
|
||||
case FORM_DIREBEAR:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + weapon_bonus + m_baseFeralAP;
|
||||
break;
|
||||
case FORM_MOONKIN:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
|
||||
break;
|
||||
default:
|
||||
val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
|
||||
break;
|
||||
switch (GetShapeshiftForm())
|
||||
{
|
||||
case FORM_CAT:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + weapon_bonus + m_baseFeralAP;
|
||||
break;
|
||||
case FORM_BEAR:
|
||||
case FORM_DIREBEAR:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + weapon_bonus + m_baseFeralAP;
|
||||
break;
|
||||
case FORM_MOONKIN:
|
||||
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
|
||||
break;
|
||||
default:
|
||||
val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLASS_MAGE:
|
||||
case CLASS_PRIEST:
|
||||
case CLASS_WARLOCK:
|
||||
@@ -504,12 +510,12 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
|
||||
void Player::UpdateShieldBlockValue()
|
||||
{
|
||||
{
|
||||
SetUInt32Value(PLAYER_SHIELD_BLOCK, GetShieldBlockValue());
|
||||
}
|
||||
|
||||
void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod;
|
||||
|
||||
switch (attType)
|
||||
@@ -576,14 +582,14 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
|
||||
}
|
||||
|
||||
void Player::UpdateDefenseBonusesMod()
|
||||
{
|
||||
{
|
||||
UpdateBlockPercentage();
|
||||
UpdateParryPercentage();
|
||||
UpdateDodgePercentage();
|
||||
}
|
||||
|
||||
void Player::UpdateBlockPercentage()
|
||||
{
|
||||
{
|
||||
// No block
|
||||
float value = 0.0f;
|
||||
if (CanBlock())
|
||||
@@ -602,7 +608,7 @@ void Player::UpdateBlockPercentage()
|
||||
}
|
||||
|
||||
void Player::UpdateCritPercentage(WeaponAttackType attType)
|
||||
{
|
||||
{
|
||||
BaseModGroup modGroup;
|
||||
uint16 index;
|
||||
CombatRating cr;
|
||||
@@ -635,7 +641,7 @@ void Player::UpdateCritPercentage(WeaponAttackType attType)
|
||||
}
|
||||
|
||||
void Player::UpdateAllCritPercentages()
|
||||
{
|
||||
{
|
||||
float value = GetMeleeCritFromAgility();
|
||||
|
||||
SetBaseModValue(CRIT_PERCENTAGE, PCT_MOD, value);
|
||||
@@ -663,7 +669,7 @@ const float m_diminishing_k[MAX_CLASSES] =
|
||||
};
|
||||
|
||||
float Player::GetMissPercentageFromDefence() const
|
||||
{
|
||||
{
|
||||
float const miss_cap[MAX_CLASSES] =
|
||||
{
|
||||
16.00f, // Warrior //correct
|
||||
@@ -685,12 +691,12 @@ float Player::GetMissPercentageFromDefence() const
|
||||
diminishing += (int32(GetRatingBonusValue(CR_DEFENSE_SKILL))) * 0.04f;
|
||||
|
||||
// apply diminishing formula to diminishing miss chance
|
||||
uint32 pclass = getClass()-1;
|
||||
uint32 pclass = getClass() - 1;
|
||||
return nondiminishing + (diminishing * miss_cap[pclass] / (diminishing + miss_cap[pclass] * m_diminishing_k[pclass]));
|
||||
}
|
||||
|
||||
void Player::UpdateParryPercentage()
|
||||
{
|
||||
{
|
||||
const float parry_cap[MAX_CLASSES] =
|
||||
{
|
||||
47.003525f, // Warrior
|
||||
@@ -709,7 +715,7 @@ void Player::UpdateParryPercentage()
|
||||
// No parry
|
||||
float value = 0.0f;
|
||||
m_realParry = 0.0f;
|
||||
uint32 pclass = getClass()-1;
|
||||
uint32 pclass = getClass() - 1;
|
||||
if (CanParry() && parry_cap[pclass] > 0.0f)
|
||||
{
|
||||
float nondiminishing = 5.0f;
|
||||
@@ -731,7 +737,7 @@ void Player::UpdateParryPercentage()
|
||||
}
|
||||
|
||||
void Player::UpdateDodgePercentage()
|
||||
{
|
||||
{
|
||||
const float dodge_cap[MAX_CLASSES] =
|
||||
{
|
||||
88.129021f, // Warrior
|
||||
@@ -757,9 +763,9 @@ void Player::UpdateDodgePercentage()
|
||||
// Dodge from rating
|
||||
diminishing += GetRatingBonusValue(CR_DODGE);
|
||||
// apply diminishing formula to diminishing dodge chance
|
||||
uint32 pclass = getClass()-1;
|
||||
uint32 pclass = getClass() - 1;
|
||||
m_realDodge = nondiminishing + (diminishing * dodge_cap[pclass] / (diminishing + dodge_cap[pclass] * m_diminishing_k[pclass]));
|
||||
|
||||
|
||||
m_realDodge = m_realDodge < 0.0f ? 0.0f : m_realDodge;
|
||||
float value = std::max(diminishing + nondiminishing, 0.0f);
|
||||
|
||||
@@ -767,7 +773,7 @@ void Player::UpdateDodgePercentage()
|
||||
}
|
||||
|
||||
void Player::UpdateSpellCritChance(uint32 school)
|
||||
{
|
||||
{
|
||||
// For normal school set zero crit chance
|
||||
if (school == SPELL_SCHOOL_NORMAL)
|
||||
{
|
||||
@@ -783,7 +789,7 @@ void Player::UpdateSpellCritChance(uint32 school)
|
||||
// Increase crit from SPELL_AURA_MOD_CRIT_PCT
|
||||
crit += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
|
||||
// Increase crit by school from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
|
||||
crit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1<<school);
|
||||
crit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1 << school);
|
||||
// Increase crit from spell crit ratings
|
||||
crit += GetRatingBonusValue(CR_CRIT_SPELL);
|
||||
|
||||
@@ -792,37 +798,37 @@ void Player::UpdateSpellCritChance(uint32 school)
|
||||
}
|
||||
|
||||
void Player::UpdateArmorPenetration(int32 amount)
|
||||
{
|
||||
{
|
||||
// Store Rating Value
|
||||
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_ARMOR_PENETRATION, amount);
|
||||
}
|
||||
|
||||
void Player::UpdateMeleeHitChances()
|
||||
{
|
||||
{
|
||||
m_modMeleeHitChance = (float)GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
|
||||
m_modMeleeHitChance += GetRatingBonusValue(CR_HIT_MELEE);
|
||||
}
|
||||
|
||||
void Player::UpdateRangedHitChances()
|
||||
{
|
||||
{
|
||||
m_modRangedHitChance = (float)GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
|
||||
m_modRangedHitChance += GetRatingBonusValue(CR_HIT_RANGED);
|
||||
}
|
||||
|
||||
void Player::UpdateSpellHitChances()
|
||||
{
|
||||
{
|
||||
m_modSpellHitChance = (float)GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
|
||||
m_modSpellHitChance += GetRatingBonusValue(CR_HIT_SPELL);
|
||||
}
|
||||
|
||||
void Player::UpdateAllSpellCritChances()
|
||||
{
|
||||
{
|
||||
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
|
||||
UpdateSpellCritChance(i);
|
||||
}
|
||||
|
||||
void Player::UpdateExpertise(WeaponAttackType attack)
|
||||
{
|
||||
{
|
||||
if (attack == RANGED_ATTACK)
|
||||
return;
|
||||
|
||||
@@ -858,19 +864,19 @@ void Player::UpdateExpertise(WeaponAttackType attack)
|
||||
}
|
||||
|
||||
void Player::ApplyManaRegenBonus(int32 amount, bool apply)
|
||||
{
|
||||
{
|
||||
_ModifyUInt32(apply, m_baseManaRegen, amount);
|
||||
UpdateManaRegen();
|
||||
}
|
||||
|
||||
void Player::ApplyHealthRegenBonus(int32 amount, bool apply)
|
||||
{
|
||||
{
|
||||
_ModifyUInt32(apply, m_baseHealthRegen, amount);
|
||||
}
|
||||
|
||||
void Player::UpdateManaRegen()
|
||||
{
|
||||
if( HasAuraTypeWithMiscvalue(SPELL_AURA_PREVENT_REGENERATE_POWER, POWER_MANA+1) )
|
||||
{
|
||||
if( HasAuraTypeWithMiscvalue(SPELL_AURA_PREVENT_REGENERATE_POWER, POWER_MANA + 1) )
|
||||
{
|
||||
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, 0);
|
||||
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, 0);
|
||||
@@ -903,7 +909,7 @@ void Player::UpdateManaRegen()
|
||||
}
|
||||
|
||||
void Player::UpdateRuneRegen(RuneType rune)
|
||||
{
|
||||
{
|
||||
if (rune >= NUM_RUNE_TYPES)
|
||||
return;
|
||||
|
||||
@@ -924,7 +930,7 @@ void Player::UpdateRuneRegen(RuneType rune)
|
||||
}
|
||||
|
||||
void Player::_ApplyAllStatBonuses()
|
||||
{
|
||||
{
|
||||
SetCanModifyStats(false);
|
||||
|
||||
_ApplyAllAuraStatMods();
|
||||
@@ -936,7 +942,7 @@ void Player::_ApplyAllStatBonuses()
|
||||
}
|
||||
|
||||
void Player::_RemoveAllStatBonuses()
|
||||
{
|
||||
{
|
||||
SetCanModifyStats(false);
|
||||
|
||||
_RemoveAllItemMods();
|
||||
@@ -954,12 +960,12 @@ void Player::_RemoveAllStatBonuses()
|
||||
#######################################*/
|
||||
|
||||
bool Creature::UpdateStats(Stats /*stat*/)
|
||||
{
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Creature::UpdateAllStats()
|
||||
{
|
||||
{
|
||||
UpdateMaxHealth();
|
||||
UpdateAttackPowerAndDamage();
|
||||
UpdateAttackPowerAndDamage(true);
|
||||
@@ -973,7 +979,7 @@ bool Creature::UpdateAllStats()
|
||||
}
|
||||
|
||||
void Creature::UpdateResistances(uint32 school)
|
||||
{
|
||||
{
|
||||
if (school > SPELL_SCHOOL_NORMAL)
|
||||
{
|
||||
float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school));
|
||||
@@ -984,19 +990,19 @@ void Creature::UpdateResistances(uint32 school)
|
||||
}
|
||||
|
||||
void Creature::UpdateArmor()
|
||||
{
|
||||
{
|
||||
float value = GetTotalAuraModValue(UNIT_MOD_ARMOR);
|
||||
SetArmor(int32(value));
|
||||
}
|
||||
|
||||
void Creature::UpdateMaxHealth()
|
||||
{
|
||||
{
|
||||
float value = GetTotalAuraModValue(UNIT_MOD_HEALTH);
|
||||
SetMaxHealth(uint32(value));
|
||||
}
|
||||
|
||||
void Creature::UpdateMaxPower(Powers power)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float value = GetTotalAuraModValue(unitMod);
|
||||
@@ -1004,7 +1010,7 @@ void Creature::UpdateMaxPower(Powers power)
|
||||
}
|
||||
|
||||
void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
|
||||
|
||||
uint16 index = UNIT_FIELD_ATTACK_POWER;
|
||||
@@ -1037,7 +1043,7 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
|
||||
void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod;
|
||||
switch (attType)
|
||||
{
|
||||
@@ -1098,7 +1104,7 @@ void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized,
|
||||
|
||||
|
||||
bool Guardian::UpdateStats(Stats stat)
|
||||
{
|
||||
{
|
||||
if (stat >= MAX_STATS)
|
||||
return false;
|
||||
|
||||
@@ -1107,18 +1113,27 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
|
||||
switch (stat)
|
||||
{
|
||||
case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break;
|
||||
case STAT_AGILITY: UpdateArmor(); break;
|
||||
case STAT_STAMINA: UpdateMaxHealth(); break;
|
||||
case STAT_INTELLECT: UpdateMaxPower(POWER_MANA); break;
|
||||
case STAT_SPIRIT: break;
|
||||
case STAT_STRENGTH:
|
||||
UpdateAttackPowerAndDamage();
|
||||
break;
|
||||
case STAT_AGILITY:
|
||||
UpdateArmor();
|
||||
break;
|
||||
case STAT_STAMINA:
|
||||
UpdateMaxHealth();
|
||||
break;
|
||||
case STAT_INTELLECT:
|
||||
UpdateMaxPower(POWER_MANA);
|
||||
break;
|
||||
case STAT_SPIRIT:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Guardian::UpdateAllStats()
|
||||
{
|
||||
{
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
|
||||
UpdateStats(Stats(i));
|
||||
|
||||
@@ -1130,7 +1145,7 @@ bool Guardian::UpdateAllStats()
|
||||
}
|
||||
|
||||
void Guardian::UpdateArmor()
|
||||
{
|
||||
{
|
||||
float value = GetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE);
|
||||
value *= GetModifierValue(UNIT_MOD_ARMOR, BASE_PCT);
|
||||
value += std::max<float>(GetStat(STAT_AGILITY) - GetCreateStat(STAT_AGILITY), 0.0f) * 2.0f;
|
||||
@@ -1140,22 +1155,40 @@ void Guardian::UpdateArmor()
|
||||
}
|
||||
|
||||
void Guardian::UpdateMaxHealth()
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UNIT_MOD_HEALTH;
|
||||
float stamina = std::max<float>(GetStat(STAT_STAMINA) - GetCreateStat(STAT_STAMINA), 0.0f);
|
||||
|
||||
float multiplicator;
|
||||
switch (GetEntry())
|
||||
{
|
||||
case NPC_IMP: multiplicator = 8.4f; break;
|
||||
case NPC_WATER_ELEMENTAL_TEMP: multiplicator = 7.5f; break;
|
||||
case NPC_WATER_ELEMENTAL_PERM: multiplicator = 7.5f; break;
|
||||
case NPC_VOIDWALKER: multiplicator = 11.0f; break;
|
||||
case NPC_SUCCUBUS: multiplicator = 9.1f; break;
|
||||
case NPC_FELHUNTER: multiplicator = 9.5f; break;
|
||||
case NPC_FELGUARD: multiplicator = 11.0f; break;
|
||||
case NPC_BLOODWORM: multiplicator = 1.0f; break;
|
||||
default: multiplicator = 10.0f; break;
|
||||
case NPC_IMP:
|
||||
multiplicator = 8.4f;
|
||||
break;
|
||||
case NPC_WATER_ELEMENTAL_TEMP:
|
||||
multiplicator = 7.5f;
|
||||
break;
|
||||
case NPC_WATER_ELEMENTAL_PERM:
|
||||
multiplicator = 7.5f;
|
||||
break;
|
||||
case NPC_VOIDWALKER:
|
||||
multiplicator = 11.0f;
|
||||
break;
|
||||
case NPC_SUCCUBUS:
|
||||
multiplicator = 9.1f;
|
||||
break;
|
||||
case NPC_FELHUNTER:
|
||||
multiplicator = 9.5f;
|
||||
break;
|
||||
case NPC_FELGUARD:
|
||||
multiplicator = 11.0f;
|
||||
break;
|
||||
case NPC_BLOODWORM:
|
||||
multiplicator = 1.0f;
|
||||
break;
|
||||
default:
|
||||
multiplicator = 10.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
float value = GetModifierValue(unitMod, BASE_VALUE);// xinef: Do NOT add base health TWICE + GetCreateHealth();
|
||||
@@ -1167,7 +1200,7 @@ void Guardian::UpdateMaxHealth()
|
||||
}
|
||||
|
||||
void Guardian::UpdateMaxPower(Powers power)
|
||||
{
|
||||
{
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float addValue = (power == POWER_MANA) ? std::max<float>(GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT), 0.0f) : 0.0f;
|
||||
@@ -1175,7 +1208,7 @@ void Guardian::UpdateMaxPower(Powers power)
|
||||
|
||||
switch (GetEntry())
|
||||
{
|
||||
case NPC_IMP:
|
||||
case NPC_IMP:
|
||||
case NPC_WATER_ELEMENTAL_TEMP:
|
||||
case NPC_WATER_ELEMENTAL_PERM:
|
||||
multiplicator = 4.95f;
|
||||
@@ -1201,7 +1234,7 @@ void Guardian::UpdateMaxPower(Powers power)
|
||||
}
|
||||
|
||||
void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
{
|
||||
if (ranged)
|
||||
return;
|
||||
|
||||
@@ -1216,7 +1249,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
val = 2 * GetStat(STAT_STRENGTH) - 20.0f;
|
||||
|
||||
SetModifierValue(unitMod, BASE_VALUE, val);
|
||||
|
||||
|
||||
//in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB
|
||||
float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
|
||||
float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
@@ -1234,15 +1267,15 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
|
||||
void Guardian::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
{
|
||||
{
|
||||
if (attType > BASE_ATTACK)
|
||||
return;
|
||||
|
||||
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;
|
||||
|
||||
float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f;
|
||||
float att_speed = float(GetAttackTime(BASE_ATTACK)) / 1000.0f;
|
||||
|
||||
float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed;
|
||||
float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * att_speed;
|
||||
float base_pct = GetModifierValue(unitMod, BASE_PCT);
|
||||
float total_value = GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
float total_pct = GetModifierValue(unitMod, TOTAL_PCT);
|
||||
|
||||
+4276
-4004
File diff suppressed because it is too large
Load Diff
+1309
-1304
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@
|
||||
#include "BattlefieldWG.h"
|
||||
|
||||
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) :
|
||||
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
|
||||
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ Vehicle::~Vehicle()
|
||||
else
|
||||
sLog->outString("ZOMG! ~Vehicle(), unknown guid!");
|
||||
}
|
||||
//ASSERT(!itr->second.IsEmpty());
|
||||
//ASSERT(!itr->second.IsEmpty());
|
||||
}
|
||||
|
||||
void Vehicle::Install()
|
||||
@@ -96,7 +96,7 @@ void Vehicle::Uninstall()
|
||||
if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
{
|
||||
sLog->outError("Vehicle GuidLow: %u, Entry: %u attempts to uninstall, but already has STATUS_UNINSTALLING! "
|
||||
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry());
|
||||
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry());
|
||||
return;
|
||||
}
|
||||
_status = STATUS_UNINSTALLING;
|
||||
@@ -264,7 +264,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
|
||||
if (_status == STATUS_UNINSTALLING)
|
||||
{
|
||||
sLog->outError("Vehicle GuidLow: %u, Entry: %u attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! "
|
||||
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId);
|
||||
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
|
||||
seat->second.Passenger.Guid = unit->GetGUID();
|
||||
seat->second.Passenger.IsUnselectable = unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
|
||||
|
||||
if (seat->second.SeatInfo->CanEnterOrExit())
|
||||
{
|
||||
ASSERT(_usableSeatNum);
|
||||
@@ -384,13 +384,13 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
|
||||
// xinef: removed retarded seat->first == 0 check...
|
||||
if (_me->GetTypeId() == TYPEID_UNIT
|
||||
&& unit->GetTypeId() == TYPEID_PLAYER
|
||||
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
&& unit->GetTypeId() == TYPEID_PLAYER
|
||||
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
|
||||
ABORT();
|
||||
if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
|
||||
ABORT();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -411,7 +411,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
{
|
||||
unit->SendClearTarget(); // SMSG_BREAK_TARGET
|
||||
unit->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
|
||||
// also adds MOVEMENTFLAG_ROOT
|
||||
// also adds MOVEMENTFLAG_ROOT
|
||||
Movement::MoveSplineInit init(unit);
|
||||
init.DisableTransportPathTransformations();
|
||||
init.MoveTo(veSeat->m_attachmentOffsetX, veSeat->m_attachmentOffsetY, veSeat->m_attachmentOffsetZ);
|
||||
@@ -549,7 +549,7 @@ void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
|
||||
{
|
||||
_me->GetMap()->LoadGrid(x, y);
|
||||
_me->NearTeleportTo(x, y, z, ang, true);
|
||||
|
||||
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
|
||||
{
|
||||
|
||||
@@ -17,74 +17,74 @@ class Unit;
|
||||
|
||||
class Vehicle : public TransportBase
|
||||
{
|
||||
public:
|
||||
void Install();
|
||||
void Uninstall();
|
||||
void Reset(bool evading = false);
|
||||
void InstallAllAccessories(bool evading);
|
||||
void ApplyAllImmunities();
|
||||
void InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime); //! May be called from scripts
|
||||
public:
|
||||
void Install();
|
||||
void Uninstall();
|
||||
void Reset(bool evading = false);
|
||||
void InstallAllAccessories(bool evading);
|
||||
void ApplyAllImmunities();
|
||||
void InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime); //! May be called from scripts
|
||||
|
||||
Unit* GetBase() const { return _me; }
|
||||
VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; }
|
||||
uint32 GetCreatureEntry() const { return _creatureEntry; }
|
||||
Unit* GetBase() const { return _me; }
|
||||
VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; }
|
||||
uint32 GetCreatureEntry() const { return _creatureEntry; }
|
||||
|
||||
bool HasEmptySeat(int8 seatId) const;
|
||||
Unit* GetPassenger(int8 seatId) const;
|
||||
int8 GetNextEmptySeat(int8 seatId, bool next) const;
|
||||
uint8 GetAvailableSeatCount() const;
|
||||
bool HasEmptySeat(int8 seatId) const;
|
||||
Unit* GetPassenger(int8 seatId) const;
|
||||
int8 GetNextEmptySeat(int8 seatId, bool next) const;
|
||||
uint8 GetAvailableSeatCount() const;
|
||||
|
||||
bool AddPassenger(Unit* passenger, int8 seatId = -1);
|
||||
void EjectPassenger(Unit* passenger, Unit* controller);
|
||||
void RemovePassenger(Unit* passenger);
|
||||
void RelocatePassengers();
|
||||
void RemoveAllPassengers();
|
||||
void Dismiss();
|
||||
bool IsVehicleInUse();
|
||||
void TeleportVehicle(float x, float y, float z, float ang);
|
||||
bool AddPassenger(Unit* passenger, int8 seatId = -1);
|
||||
void EjectPassenger(Unit* passenger, Unit* controller);
|
||||
void RemovePassenger(Unit* passenger);
|
||||
void RelocatePassengers();
|
||||
void RemoveAllPassengers();
|
||||
void Dismiss();
|
||||
bool IsVehicleInUse();
|
||||
void TeleportVehicle(float x, float y, float z, float ang);
|
||||
|
||||
SeatMap Seats;
|
||||
SeatMap Seats;
|
||||
|
||||
VehicleSeatEntry const* GetSeatForPassenger(Unit const* passenger);
|
||||
SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger);
|
||||
VehicleSeatEntry const* GetSeatForPassenger(Unit const* passenger);
|
||||
SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger);
|
||||
|
||||
protected:
|
||||
friend bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry);
|
||||
Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry);
|
||||
friend void Unit::RemoveVehicleKit();
|
||||
~Vehicle();
|
||||
protected:
|
||||
friend bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry);
|
||||
Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry);
|
||||
friend void Unit::RemoveVehicleKit();
|
||||
~Vehicle();
|
||||
|
||||
private:
|
||||
enum Status
|
||||
{
|
||||
STATUS_NONE,
|
||||
STATUS_INSTALLED,
|
||||
STATUS_UNINSTALLING,
|
||||
};
|
||||
private:
|
||||
enum Status
|
||||
{
|
||||
STATUS_NONE,
|
||||
STATUS_INSTALLED,
|
||||
STATUS_UNINSTALLING,
|
||||
};
|
||||
|
||||
void InitMovementInfoForBase();
|
||||
void InitMovementInfoForBase();
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const
|
||||
{
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, o,
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const
|
||||
{
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, o,
|
||||
GetBase()->GetPositionX(), GetBase()->GetPositionY(),
|
||||
GetBase()->GetPositionZ(), GetBase()->GetOrientation());
|
||||
}
|
||||
}
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const
|
||||
{
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o,
|
||||
GetBase()->GetPositionX(), GetBase()->GetPositionY(),
|
||||
GetBase()->GetPositionZ(), GetBase()->GetOrientation());
|
||||
}
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const
|
||||
{
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o,
|
||||
GetBase()->GetPositionX(), GetBase()->GetPositionY(),
|
||||
GetBase()->GetPositionZ(), GetBase()->GetOrientation());
|
||||
}
|
||||
|
||||
Unit* _me;
|
||||
VehicleEntry const* _vehicleInfo;
|
||||
uint32 _usableSeatNum; // Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags
|
||||
uint32 _creatureEntry; // Can be different than me->GetBase()->GetEntry() in case of players
|
||||
Status _status;
|
||||
Unit* _me;
|
||||
VehicleEntry const* _vehicleInfo;
|
||||
uint32 _usableSeatNum; // Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags
|
||||
uint32 _creatureEntry; // Can be different than me->GetBase()->GetEntry() in case of players
|
||||
Status _status;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user