[SD3] first commit with SD3 inplace - not complete yet

This commit is contained in:
Antz 2016-03-27 20:47:30 +01:00 committed by Antz
parent 35415eb738
commit afc2df2f7d
603 changed files with 222771 additions and 1729 deletions

View file

@ -55,6 +55,9 @@
#include "CellImpl.h"
#include "movement/MoveSplineInit.h"
#include "CreatureLinkingMgr.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */
// apply implementation of the singletons
#include "Policies/Singleton.h"
@ -69,7 +72,7 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
{
TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
if (itr != spellList.end())
return &itr->second;
{ return &itr->second; }
return NULL;
}
@ -165,7 +168,7 @@ Creature::Creature(CreatureSubtype subtype) : Unit(),
m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(5.0f),
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_regenHealth(true), m_AI_locked(false), m_IsDeadByDefault(false),
m_temporaryFactionFlags(TEMPFACTION_NONE),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0),
m_creatureInfo(NULL)
@ -175,10 +178,11 @@ Creature::Creature(CreatureSubtype subtype) : Unit(),
m_valuesCount = UNIT_END;
for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = 0;
{ m_spells[i] = 0; }
m_CreatureSpellCooldowns.clear();
m_CreatureCategoryCooldowns.clear();
DisableReputationGain = false;
SetWalk(true, true);
}
@ -195,18 +199,28 @@ Creature::~Creature()
void Creature::AddToWorld()
{
#ifdef ENABLE_ELUNA
if (!IsInWorld())
sEluna->OnAddToWorld(this);
#endif /* ENABLE_ELUNA */
///- Register the creature for guid lookup
if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().insert<Creature>(GetObjectGuid(), (Creature*)this);
{ GetMap()->GetObjectsStore().insert<Creature>(GetObjectGuid(), (Creature*)this); }
Unit::AddToWorld();
}
void Creature::RemoveFromWorld()
{
#ifdef ENABLE_ELUNA
if (IsInWorld())
sEluna->OnRemoveFromWorld(this);
#endif /* ENABLE_ELUNA */
///- Remove the creature from the accessor
if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().erase<Creature>(GetObjectGuid(), (Creature*)NULL);
{ GetMap()->GetObjectsStore().erase<Creature>(GetObjectGuid(), (Creature*)NULL); }
Unit::RemoveFromWorld();
}
@ -215,13 +229,13 @@ void Creature::RemoveCorpse()
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
if (uint16 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetGUIDLow()))
sPoolMgr.UpdatePool<Creature>(*GetMap()->GetPersistentState(), poolid, GetGUIDLow());
{ sPoolMgr.UpdatePool<Creature>(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); }
if (!IsInWorld()) // can be despawned by update pool
return;
if (!IsInWorld()) // can be despawned by update pool
{ return; }
if ((getDeathState() != CORPSE && !m_isDeadByDefault) || (getDeathState() != ALIVE && m_isDeadByDefault))
return;
if ((getDeathState() != CORPSE && !m_IsDeadByDefault) || (getDeathState() != ALIVE && m_IsDeadByDefault))
{ return; }
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Removing corpse of %s ", GetGuidStr().c_str());
@ -236,11 +250,11 @@ void Creature::RemoveCorpse()
uint32 respawnDelay = 0;
if (AI())
AI()->CorpseRemoved(respawnDelay);
{ AI()->CorpseRemoved(respawnDelay); }
// script can set time (in seconds) explicit, override the original
if (respawnDelay)
m_respawnTime = time(NULL) + respawnDelay;
{ m_respawnTime = time(NULL) + respawnDelay; }
float x, y, z, o;
GetRespawnCoord(x, y, z, &o);
@ -254,14 +268,14 @@ void Creature::RemoveCorpse()
UpdateObjectVisibility();
}
/*
/**
* change the entry of creature until respawn
*/
bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/)
{
// use game event entry if any instead default suggested
if (eventData && eventData->entry_id)
Entry = eventData->entry_id;
{ Entry = eventData->entry_id; }
CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if (!normalInfo)
@ -270,6 +284,8 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
return false;
}
// difficulties for dungeons/battleground ordered in normal way
// and if more high version not exist must be used lesser version
CreatureInfo const* cinfo = normalInfo;
for (Difficulty diff = GetMap()->GetDifficulty(); diff > REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, GetMap()->IsRaid()))
{
@ -288,7 +304,7 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
SetEntry(Entry); // normal entry always
m_creatureInfo = cinfo; // map mode related always
SetObjectScale(cinfo->scale);
SetObjectScale(cinfo->Scale);
// equal to player Race field, but creature does not have race
SetByteValue(UNIT_FIELD_BYTES_0, 0, 0);
@ -326,10 +342,10 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
}
else if (!data || data->equipmentId == 0)
{
if (cinfo->equipmentId == 0)
LoadEquipment(normalInfo->equipmentId); // use default from normal template if diff does not have any
if (cinfo->EquipmentTemplateId == 0)
LoadEquipment(normalInfo->EquipmentTemplateId); // use default from normal template if diff does not have any
else
LoadEquipment(cinfo->equipmentId); // else use from diff template
LoadEquipment(cinfo->EquipmentTemplateId); // else use from diff template
}
else if (data && data->equipmentId != -1)
{
@ -366,9 +382,9 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
SelectLevel(GetCreatureInfo(), preserveHPAndPower ? GetHealthPercent() : 100.0f, 100.0f);
if (team == HORDE)
setFaction(GetCreatureInfo()->faction_H);
setFaction(GetCreatureInfo()->FactionHorde);
else
setFaction(GetCreatureInfo()->faction_A);
setFaction(GetCreatureInfo()->FactionAlliance);
SetUInt32Value(UNIT_NPC_FLAGS, GetCreatureInfo()->npcflag);
@ -404,7 +420,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
UpdateAllStats();
// checked and error show at loading templates
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A))
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->FactionAlliance))
{
if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP)
SetPvP(true);
@ -420,7 +436,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = templateSpells->spells[i];
SetVehicleId(GetCreatureInfo()->vehicleId, 0);
SetVehicleId(GetCreatureInfo()->VehicleTemplateId, 0);
// if eventData set then event active and need apply spell_start
if (eventData)
@ -520,7 +536,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
SelectLevel(cinfo);
SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
if (m_isDeadByDefault)
if (m_IsDeadByDefault)
{
SetDeathState(JUST_DIED);
SetHealth(0);
@ -546,7 +562,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
{
Unit::Update(update_diff, diff);
if (m_isDeadByDefault)
if (m_IsDeadByDefault)
break;
if (m_corpseDecayTimer <= update_diff)
@ -568,7 +584,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
}
case ALIVE:
{
if (m_isDeadByDefault)
if (m_IsDeadByDefault)
{
if (m_corpseDecayTimer <= update_diff)
{
@ -764,7 +780,7 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons
if (InstanceData* iData = GetMap()->GetInstanceData())
iData->OnCreatureCreate(this);
switch (GetCreatureInfo()->rank)
switch (GetCreatureInfo()->Rank)
{
case CREATURE_ELITE_RARE:
m_corpseDelay = sWorld.getConfig(CONFIG_UINT32_CORPSE_DECAY_RARE);
@ -1110,7 +1126,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.currentwaypoint = 0;
data.curhealth = GetHealth();
data.curmana = GetPower(POWER_MANA);
data.is_dead = m_isDeadByDefault;
data.is_dead = m_IsDeadByDefault;
// prevent add data integrity problems
data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE
? IDLE_MOTION_TYPE : GetDefaultMovementType();
@ -1148,7 +1164,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth, float percentMana)
{
uint32 rank = IsPet() ? 0 : cinfo->rank;
uint32 rank = IsPet() ? 0 : cinfo->Rank;
// level
uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel);
@ -1304,8 +1320,8 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map)
m_respawnDelay = data->spawntimesecs;
m_corpseDelay = std::min(m_respawnDelay * 9 / 10, m_corpseDelay); // set corpse delay to 90% of the respawn delay
m_isDeadByDefault = data->is_dead;
m_deathState = m_isDeadByDefault ? DEAD : ALIVE;
m_IsDeadByDefault = data->is_dead;
m_deathState = m_IsDeadByDefault ? DEAD : ALIVE;
m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(GetGUIDLow());
@ -1329,7 +1345,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map)
uint32 curhealth = data->curhealth;
if (curhealth)
{
curhealth = uint32(curhealth * _GetHealthMod(GetCreatureInfo()->rank));
curhealth = uint32(curhealth * _GetHealthMod(GetCreatureInfo()->Rank));
if (curhealth < 1)
curhealth = 1;
}
@ -1505,7 +1521,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
void Creature::SetDeathState(DeathState s)
{
if ((s == JUST_DIED && !m_isDeadByDefault) || (s == JUST_ALIVED && m_isDeadByDefault))
if ((s == JUST_DIED && !m_IsDeadByDefault) || (s == JUST_ALIVED && m_IsDeadByDefault))
{
m_corpseDecayTimer = m_corpseDelay * IN_MILLISECONDS; // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called)
m_respawnTime = time(NULL) + m_respawnDelay; // respawn delay (spawntimesecs)
@ -1618,7 +1634,7 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd
return true;
// Taunt immunity special flag check
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NOT_TAUNTABLE)
if (GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_NOT_TAUNTABLE)
{
// Taunt aura apply check
if (spellEffect->Effect == SPELL_EFFECT_APPLY_AURA)
@ -1759,13 +1775,13 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
if (pl->isGameMaster())
return true;
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
if (GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_INVISIBLE)
return false;
// Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0
if (pl->IsAlive() || pl->GetDeathTimer() > 0)
{
return (IsAlive() || m_corpseDecayTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE));
return (IsAlive() || m_corpseDecayTimer > 0 || (m_IsDeadByDefault && m_deathState == CORPSE));
}
// Dead player see live creatures near own corpse
@ -1781,7 +1797,7 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
}
// Dead player can see ghosts
if (GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
if (GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
return true;
// and not see any other
@ -2450,7 +2466,7 @@ void Creature::ClearTemporaryFaction()
return;
// Reset to original faction
setFaction(GetCreatureInfo()->faction_A);
setFaction(GetCreatureInfo()->FactionAlliance);
// Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE or UNIT_FLAG_PASSIVE flags
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NON_ATTACKABLE && GetCreatureInfo()->unit_flags & UNIT_FLAG_NON_ATTACKABLE)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

View file

@ -90,13 +90,13 @@ struct CreatureInfo
uint32 minmana;
uint32 maxmana;
uint32 armor;
uint32 faction_A;
uint32 faction_H;
uint32 FactionAlliance;
uint32 FactionHorde;
uint32 npcflag;
float speed_walk;
float speed_run;
float scale;
uint32 rank;
float Scale;
uint32 Rank;
float mindmg;
float maxdmg;
uint32 dmgschool;
@ -117,7 +117,7 @@ struct CreatureInfo
float maxrangedmg;
uint32 rangedattackpower;
uint32 type; // enum CreatureType values
uint32 type_flags; // enum CreatureTypeFlags mask values
uint32 CreatureTypeFlags; // enum CreatureTypeFlags mask values
uint32 lootid;
uint32 pickpocketLootId;
uint32 SkinLootId;
@ -139,42 +139,42 @@ struct CreatureInfo
uint32 questItems[6];
uint32 movementId;
bool RegenHealth;
uint32 vehicleId;
uint32 equipmentId;
uint32 VehicleTemplateId;
uint32 EquipmentTemplateId;
uint32 trainerId;
uint32 vendorId;
uint32 MechanicImmuneMask;
uint32 flags_extra;
uint32 ExtraFlags;
uint32 ScriptID;
// helpers
HighGuid GetHighGuid() const
{
return vehicleId ? HIGHGUID_VEHICLE : HIGHGUID_UNIT;
return VehicleTemplateId ? HIGHGUID_VEHICLE : HIGHGUID_UNIT;
}
ObjectGuid GetObjectGuid(uint32 lowguid) const { return ObjectGuid(GetHighGuid(), Entry, lowguid); }
SkillType GetRequiredLootSkill() const
{
if (type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
return SKILL_HERBALISM;
else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
return SKILL_MINING;
else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT)
{ return SKILL_HERBALISM; }
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT)
{ return SKILL_MINING; }
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
return SKILL_ENGINEERING;
else
return SKILL_SKINNING; // normal case
{ return SKILL_SKINNING; } // normal case
}
bool IsExotic() const
{
return (type_flags & CREATURE_TYPEFLAGS_EXOTIC);
return (CreatureTypeFlags & CREATURE_TYPEFLAGS_EXOTIC);
}
bool isTameable(bool exotic) const
{
if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
if (type != CREATURE_TYPE_BEAST || family == 0 || (CreatureTypeFlags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
return false;
// if can tame exotic then can tame any temable
@ -376,7 +376,7 @@ struct VendorItemData
void Clear()
{
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
delete(*itr);
{ delete(*itr); }
m_items.clear();
}
};
@ -488,7 +488,7 @@ enum TemporaryFactionFlags // Used at real fact
TEMPFACTION_ALL,
};
class Creature : public Unit
class Creature : public Unit
{
CreatureAI* i_AI;
@ -521,15 +521,15 @@ class Creature : public Unit
bool IsCorpse() const { return getDeathState() == CORPSE; }
bool IsDespawned() const { return getDeathState() == DEAD; }
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
uint32 GetCorpseDelay() const { return m_corpseDelay; }
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
uint32 GetCorpseDelay() const { return m_corpseDelay; }
bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
bool IsCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
bool IsGuard() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
bool IsCivilian() const { return GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_CIVILIAN; }
bool IsGuard() const { return GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_GUARD; }
bool CanWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
virtual bool CanSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
bool CanFly() const { return (GetCreatureInfo()->InhabitType & INHABIT_AIR) || (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_UNK_2) || HasAuraType(SPELL_AURA_FLY); }
bool CanFly() const { return (GetCreatureInfo()->InhabitType & INHABIT_AIR) || (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_FLY_ANIM) || HasAuraType(SPELL_AURA_FLY); }
bool IsTrainerOf(Player* player, bool msg) const;
bool CanInteractWithBattleMaster(Player* player, bool msg) const;
@ -545,18 +545,18 @@ class Creature : public Unit
bool IsElite() const
{
if (IsPet())
return false;
{ return false; }
uint32 rank = GetCreatureInfo()->rank;
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
uint32 Rank = GetCreatureInfo()->Rank;
return Rank != CREATURE_ELITE_NORMAL && Rank != CREATURE_ELITE_RARE;
}
bool IsWorldBoss() const
{
if (IsPet())
return false;
{ return false; }
return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
return GetCreatureInfo()->Rank == CREATURE_ELITE_WORLDBOSS;
}
uint32 GetLevelForTarget(Unit const* target) const override; // overwrite Unit::GetLevelForTarget for boss level support
@ -634,17 +634,50 @@ class Creature : public Unit
virtual void DeleteFromDB(); // overwrited in Pet
static void DeleteFromDB(uint32 lowguid, CreatureData const* data);
/// Represent the loots available on the creature.
Loot loot;
/// Indicates whether the creature has has been pickpocked.
bool lootForPickPocketed;
/// Indicates whether the creature has been checked.
bool lootForBody;
/// Indicates whether the creature has been skinned.
bool lootForSkin;
/**
* Method preparing the creature for the loot state. Based on the previous loot state, the loot ID provided in the database and the creature's type,
* this method updates the state of the creature for loots.
*
* At the end of this method, the creature loot state may be:
* Lootable: UNIT_DYNFLAG_LOOTABLE
* Skinnable: UNIT_FLAG_SKINNABLE
* Not lootable: No flag
*/
void PrepareBodyLootState();
/**
* function returning the GUID of the loot recipient (a player GUID).
*
* \return ObjectGuid Player GUID.
*/
ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; }
uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; }
Player* GetLootRecipient() const; // use group cases as prefered
Group* GetGroupLootRecipient() const;
/**
* function indicating whether the whether the creature has a looter recipient defined (either a group ID, either a player GUID).
*
* \return boolean true if the creature has a recipient defined, false otherwise.
*/
bool HasLootRecipient() const { return m_lootGroupRecipientId || m_lootRecipientGuid; }
/**
* function indicating whether the recipient is a group.
*
* \return boolean true if the creature's recipient is a group, false otherwise.
*/
bool IsGroupLootRecipient() const { return m_lootGroupRecipientId; }
void SetLootRecipient(Unit* unit);
void AllLootRemovedFromCorpse();
@ -680,7 +713,7 @@ class Creature : public Unit
bool IsVisibleInGridForPlayer(Player* pl) const override;
void RemoveCorpse();
bool IsDeadByDefault() const { return m_isDeadByDefault; };
bool IsDeadByDefault() const { return m_IsDeadByDefault; };
void ForcedDespawn(uint32 timeMSToDespawn = 0);
@ -718,9 +751,9 @@ class Creature : public Unit
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
return 0;
{ return 0; }
else
return m_charmInfo->GetCharmSpell(pos)->GetAction();
{ return m_charmInfo->GetCharmSpell(pos)->GetAction(); }
}
void SetCombatStartPosition(float x, float y, float z) { m_combatStartX = x; m_combatStartY = y; m_combatStartZ = z; }
@ -731,7 +764,7 @@ class Creature : public Unit
void GetRespawnCoord(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
void ResetRespawnCoord();
void SetDeadByDefault(bool death_state) { m_isDeadByDefault = death_state; }
void SetDeadByDefault(bool death_state) { m_IsDeadByDefault = death_state; }
void SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags = TEMPFACTION_ALL);
void ClearTemporaryFaction();
@ -739,11 +772,10 @@ class Creature : public Unit
void SendAreaSpiritHealerQueryOpcode(Player* pl);
void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); }
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); }
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
protected:
bool MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const;
@ -785,7 +817,7 @@ class Creature : public Unit
bool m_AlreadySearchedAssistance;
bool m_regenHealth;
bool m_AI_locked;
bool m_isDeadByDefault;
bool m_IsDeadByDefault;
uint32 m_temporaryFactionFlags; // used for real faction changes (not auras etc)
SpellSchoolMask m_meleeDamageSchoolMask;
@ -795,9 +827,9 @@ class Creature : public Unit
float m_combatStartY;
float m_combatStartZ;
Position m_respawnPos;
Position m_respawnPos;
bool DisableReputationGain;
bool DisableReputationGain;
private:
GridReference<Creature> m_gridRef;

View file

@ -30,6 +30,8 @@
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
static_assert(MAXIMAL_AI_EVENT_EVENTAI <= 32, "Maximal 32 AI_EVENTs supported with EventAI");
CreatureAI::~CreatureAI()
{
}
@ -37,7 +39,7 @@ CreatureAI::~CreatureAI()
void CreatureAI::AttackedBy(Unit* attacker)
{
if (!m_creature->getVictim())
AttackStart(attacker);
{ AttackStart(attacker); }
}
CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, bool isTriggered)
@ -47,17 +49,17 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
{
// State does not allow
if (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL))
return CAST_FAIL_STATE;
{ return CAST_FAIL_STATE; }
if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
return CAST_FAIL_STATE;
{ return CAST_FAIL_STATE; }
if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
return CAST_FAIL_STATE;
{ return CAST_FAIL_STATE; }
// Check for power (also done by Spell::CheckCast())
if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature))
return CAST_FAIL_POWER;
{ return CAST_FAIL_POWER; }
}
if (const SpellRangeEntry* pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex))
@ -68,18 +70,18 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
float fDistance = m_creature->GetCombatDistance(pTarget, pSpell->rangeIndex == SPELL_RANGE_IDX_COMBAT);
if (fDistance > (m_creature->IsHostileTo(pTarget) ? pSpellRange->maxRange : pSpellRange->maxRangeFriendly))
return CAST_FAIL_TOO_FAR;
{ return CAST_FAIL_TOO_FAR; }
float fMinRange = m_creature->IsHostileTo(pTarget) ? pSpellRange->minRange : pSpellRange->minRangeFriendly;
if (fMinRange && fDistance < fMinRange)
return CAST_FAIL_TOO_CLOSE;
{ return CAST_FAIL_TOO_CLOSE; }
}
return CAST_OK;
}
else
return CAST_FAIL_OTHER;
{ return CAST_FAIL_OTHER; }
}
CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, ObjectGuid uiOriginalCasterGUID)
@ -87,7 +89,7 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
Unit* pCaster = m_creature;
if (uiCastFlags & CAST_FORCE_TARGET_SELF)
pCaster = pTarget;
{ pCaster = pTarget; }
// Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered
if (!pCaster->IsNonMeleeSpellCasted(false) || (uiCastFlags & (CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS)))
@ -98,21 +100,21 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
if (uiCastFlags & CAST_AURA_NOT_PRESENT)
{
if (pTarget->HasAura(uiSpell))
return CAST_FAIL_TARGET_AURA;
{ return CAST_FAIL_TARGET_AURA; }
}
// Check if cannot cast spell
// Check if can not cast spell
if (!(uiCastFlags & (CAST_FORCE_TARGET_SELF | CAST_FORCE_CAST)))
{
CanCastResult castResult = CanCastSpell(pTarget, pSpell, uiCastFlags & CAST_TRIGGERED);
if (castResult != CAST_OK)
return castResult;
{ return castResult; }
}
// Interrupt any previous spell
if (uiCastFlags & CAST_INTERRUPT_PREVIOUS && pCaster->IsNonMeleeSpellCasted(false))
pCaster->InterruptNonMeleeSpells(false);
{ pCaster->InterruptNonMeleeSpells(false); }
pCaster->CastSpell(pTarget, pSpell, uiCastFlags & CAST_TRIGGERED, NULL, NULL, uiOriginalCasterGUID);
return CAST_OK;
@ -124,7 +126,7 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
}
}
else
return CAST_FAIL_IS_CASTING;
{ return CAST_FAIL_IS_CASTING; }
}
bool CreatureAI::DoMeleeAttackIfReady()
@ -179,7 +181,7 @@ class AiDelayEventAround : public BasicEvent
// Pushing guids because in delay can happen some creature gets despawned => invalid pointer
m_receiverGuids.reserve(receivers.size());
for (std::list<Creature*>::const_iterator itr = receivers.begin(); itr != receivers.end(); ++itr)
m_receiverGuids.push_back((*itr)->GetObjectGuid());
{ m_receiverGuids.push_back((*itr)->GetObjectGuid()); }
}
bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) override
@ -207,12 +209,12 @@ class AiDelayEventAround : public BasicEvent
private:
AiDelayEventAround();
ObjectGuid m_invokerGuid;
GuidVector m_receiverGuids;
Creature& m_owner;
AIEventType m_eventType;
ObjectGuid m_invokerGuid;
Creature& m_owner;
uint32 m_miscValue;
GuidVector m_receiverGuids;
};
void CreatureAI::SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32 uiDelay, float fRadius, uint32 miscValue /*=0*/) const

View file

@ -52,7 +52,8 @@ enum CanCastResult
CAST_FAIL_TOO_CLOSE = 4,
CAST_FAIL_POWER = 5,
CAST_FAIL_STATE = 6,
CAST_FAIL_TARGET_AURA = 7
CAST_FAIL_TARGET_AURA = 7,
CAST_FAIL_NO_LOS = 8
};
enum CastFlags
@ -65,6 +66,14 @@ enum CastFlags
CAST_AURA_NOT_PRESENT = 0x20, // Only casts the spell if the target does not have an aura from the spell
};
enum CombatMovementFlags
{
COMBAT_MOVEMENT_SCRIPT = 0x01, // Combat movement enforced by script
COMBAT_MOVEMENT_LOS = 0x02, // Combat movement triggered by LoS issues
COMBAT_MOVEMENT_OOM = 0x04, // Combat movement triggered by power exhaustion
COMBAT_MOVEMENT_DISTANCE = 0x08 // Combat movement triggered by distance checks
};
enum AIEventType
{
// Usable with Event AI
@ -77,18 +86,18 @@ enum AIEventType
AI_EVENT_CUSTOM_EVENTAI_B = 6, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_GOT_CCED = 7, // Sender = CCed Npc, Invoker = Caster that CCed
MAXIMAL_AI_EVENT_EVENTAI = 8,
// Internal Use
AI_EVENT_CALL_ASSISTANCE = 10, // Sender = Attacked Npc, Invoker = Enemy
// Predefined for SD2
// Predefined for SD3
AI_EVENT_START_ESCORT = 100, // Invoker = Escorting Player
AI_EVENT_START_ESCORT_B = 101, // Invoker = Escorting Player
AI_EVENT_START_EVENT = 102, // Invoker = EventStarter
AI_EVENT_START_EVENT_A = 103, // Invoker = EventStarter
AI_EVENT_START_EVENT_B = 104, // Invoker = EventStarter
// Some IDs for special cases in SD2
// Some IDs for special cases in SD3
AI_EVENT_CUSTOM_A = 1000,
AI_EVENT_CUSTOM_B = 1001,
AI_EVENT_CUSTOM_C = 1002,
@ -97,7 +106,7 @@ enum AIEventType
AI_EVENT_CUSTOM_F = 1005,
};
class CreatureAI
class CreatureAI
{
public:
explicit CreatureAI(Creature* creature) :
@ -111,7 +120,7 @@ class CreatureAI
///== Information about AI ========================
/**
* This funcion is used to display information about the AI.
* This function is used to display information about the AI.
* It is called when the .npc aiinfo command is used.
* Use this for on-the-fly debugging
* @param reader is a ChatHandler to send messages to.
@ -150,7 +159,7 @@ class CreatureAI
* @param pHealer Unit* which deals the heal
* @param uiHealedAmount Amount of healing received
*/
virtual void HealedBy(Unit* /*pHealer*/, uint32& /*uiHealedAmount*/) {}
virtual void HealedBy(Unit * /*pHealer*/, uint32& /*uiHealedAmount*/) {}
/**
* Called at any Damage to any victim (before damage apply)
@ -342,6 +351,8 @@ class CreatureAI
*/
virtual void ReceiveAIEvent(AIEventType /*eventType*/, Creature* /*pSender*/, Unit* /*pInvoker*/, uint32 /*miscValue*/) {}
virtual void Reset() {}
protected:
void HandleMovementOnAttackStart(Unit* victim);

View file

@ -119,7 +119,7 @@ namespace MaNGOS
{
if (u->GetTypeId() == TYPEID_UNIT && (
((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() ||
(((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)))
(((Creature*)u)->GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)))
return 0;
uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId()));

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,7 @@
#include "Object.h"
#include "LootMgr.h"
#include "Database/DatabaseEnv.h"
#include "Utilities/EventProcessor.h"
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
#if defined( __GNUC__ )
@ -294,7 +295,7 @@ struct GameObjectInfo
uint32 maxLevel; // 1
uint32 areaID; // 2
} meetingstone;
// 24 GAMEOBJECT_TYPE_FLAGSTAND
// 24 GAMEOBJECT_CreatureTypeFlagsTAND
struct
{
uint32 lockId; // 0
@ -450,7 +451,7 @@ struct GameObjectInfo
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_CreatureTypeFlagsTAND: return flagstand.lockId;
case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lockId;
case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.lockId;
default: return 0;
@ -465,7 +466,7 @@ struct GameObjectInfo
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_CreatureTypeFlagsTAND: return flagstand.noDamageImmune;
case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.noDamageImmune;
default: return true;
}
@ -691,9 +692,9 @@ class GameObject : public WorldObject
{
time_t now = time(NULL);
if (m_respawnTime > now)
return m_respawnTime;
{ return m_respawnTime; }
else
return now;
{ return now; }
}
void SetRespawnTime(time_t respawn)
@ -799,9 +800,14 @@ class GameObject : public WorldObject
void SetCapturePointSlider(float value);
float GetCapturePointSlider() const { return m_captureSlider; }
uint32 GetScriptId();
GridReference<GameObject>& GetGridRef() { return m_gridRef; }
GameObjectModel* m_model;
// Event Handler
EventProcessor m_Events;
protected:
uint32 m_spellId;

View file

@ -29,6 +29,9 @@
#include "Database/DatabaseEnv.h"
#include "ItemEnchantmentMgr.h"
#include "SQLStorages.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */
void AddItemsSetItem(Player* player, Item* item)
{
@ -44,7 +47,7 @@ void AddItemsSetItem(Player* player, Item* item)
}
if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value)
return;
{ return; }
ItemSetEffect* eff = NULL;
@ -66,12 +69,12 @@ void AddItemsSetItem(Player* player, Item* item)
size_t x = 0;
for (; x < player->ItemSetEff.size(); ++x)
if (!player->ItemSetEff[x])
break;
{ break; }
if (x < player->ItemSetEff.size())
player->ItemSetEff[x] = eff;
{ player->ItemSetEff[x] = eff; }
else
player->ItemSetEff.push_back(eff);
{ player->ItemSetEff.push_back(eff); }
}
++eff->item_count;
@ -79,18 +82,18 @@ void AddItemsSetItem(Player* player, Item* item)
for (uint32 x = 0; x < 8; ++x)
{
if (!set->spells[x])
continue;
{ continue; }
// not enough for spell
if (set->items_to_triggerspell[x] > eff->item_count)
continue;
{ continue; }
uint32 z = 0;
for (; z < 8; ++z)
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
break;
{ break; }
if (z < 8)
continue;
{ continue; }
// new spell
for (uint32 y = 0; y < 8; ++y)
@ -138,18 +141,18 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
// can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough
if (!eff)
return;
{ return; }
--eff->item_count;
for (uint32 x = 0; x < 8; ++x)
{
if (!set->spells[x])
continue;
{ continue; }
// enough for spell
if (set->items_to_triggerspell[x] <= eff->item_count)
continue;
{ continue; }
for (uint32 z = 0; z < 8; ++z)
{
@ -174,7 +177,7 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProto)
{
if (!pProto || !pBagProto)
return false;
{ return false; }
switch (pBagProto->Class)
{
@ -185,15 +188,15 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
return true;
case ITEM_SUBCLASS_SOUL_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_SOUL_SHARDS))
return false;
{ return false; }
return true;
case ITEM_SUBCLASS_HERB_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_HERBS))
return false;
{ return false; }
return true;
case ITEM_SUBCLASS_ENCHANTING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_ENCHANTING_SUPP))
return false;
{ return false; }
return true;
case ITEM_SUBCLASS_MINING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP))
@ -201,7 +204,7 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
return true;
case ITEM_SUBCLASS_ENGINEERING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP))
return false;
{ return false; }
return true;
case ITEM_SUBCLASS_GEM_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_GEMS))
@ -227,11 +230,11 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
{
case ITEM_SUBCLASS_QUIVER:
if (!(pProto->BagFamily & BAG_FAMILY_ARROWS))
return false;
{ return false; }
return true;
case ITEM_SUBCLASS_AMMO_POUCH:
if (!(pProto->BagFamily & BAG_FAMILY_BULLETS))
return false;
{ return false; }
return true;
default:
return false;
@ -383,6 +386,10 @@ Item::Item() :
m_lootState = ITEM_LOOT_NONE;
}
Item::~Item()
{
}
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
{
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
@ -395,14 +402,14 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
if (!itemProto)
return false;
{ return false; }
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
{ SetSpellCharges(i, itemProto->Spells[i].SpellCharges); }
SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration);
@ -419,12 +426,17 @@ bool Item::IsNotEmptyBag() const
void Item::UpdateDuration(Player* owner, uint32 diff)
{
if (!GetUInt32Value(ITEM_FIELD_DURATION))
return;
{ return; }
// DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
{
// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnExpire(owner, GetProto());
#endif /* ENABLE_ELUNA */
if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
owner->ConvertItem(this, newItemId);
else
@ -451,7 +463,7 @@ void Item::SaveToDB()
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
{ ss << GetUInt32Value(i) << " "; }
stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (?, ?, ?, ?)");
stmt.PExecute(guid, GetOwnerGuid().GetCounter(), ss.str().c_str(), m_text.c_str());
@ -465,7 +477,7 @@ void Item::SaveToDB()
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
{ ss << GetUInt32Value(i) << " "; }
stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), m_text.c_str(), guid);
@ -534,11 +546,11 @@ void Item::SaveToDB()
LootItem* item = loot.LootItemInSlot(i, owner, &qitem);
if (!item)
continue;
{ continue; }
// questitems use the blocked field for other purposes
if (!qitem && item->is_blocked)
continue;
{ continue; }
stmt.addUInt32(GetGUIDLow());
stmt.addUInt32(owner->GetGUIDLow());
@ -553,7 +565,7 @@ void Item::SaveToDB()
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
SetLootState(ITEM_LOOT_UNCHANGED);
{ SetLootState(ITEM_LOOT_UNCHANGED); }
SetState(ITEM_UNCHANGED);
}
@ -584,14 +596,14 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
ItemPrototype const* proto = GetProto();
if (!proto)
return false;
{ return false; }
// update max durability (and durability) if need
if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
{
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);
if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);
{ SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability); }
need_save = true;
}
@ -649,7 +661,7 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
{ ss << GetUInt32Value(i) << " "; }
stmt.addString(ss);
stmt.addUInt32(GetOwnerGuid().GetCounter());
@ -756,15 +768,15 @@ uint32 Item::GetSkill()
{
case ITEM_CLASS_WEAPON:
if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
return 0;
{ return 0; }
else
return item_weapon_skills[proto->SubClass];
{ return item_weapon_skills[proto->SubClass]; }
case ITEM_CLASS_ARMOR:
if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
return 0;
{ return 0; }
else
return item_armor_skills[proto->SubClass];
{ return item_armor_skills[proto->SubClass]; }
default:
return 0;
@ -776,7 +788,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
ItemPrototype const* itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id);
if (!itemProto)
return 0;
{ return 0; }
// item must have one from this field values not null if it can have random enchantments
if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
@ -813,7 +825,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
void Item::SetItemRandomProperties(int32 randomPropId)
{
if (!randomPropId)
return;
{ return; }
if (randomPropId > 0)
{
@ -863,7 +875,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
{
// pretend the item never existed
if (forplayer || GetOwnerGuid())
RemoveFromUpdateQueueOf(forplayer);
{ RemoveFromUpdateQueueOf(forplayer); }
delete this;
return;
}
@ -871,10 +883,10 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
if (state != ITEM_UNCHANGED)
{
// new items must stay in new state until saved
if (uState != ITEM_NEW) uState = state;
if (uState != ITEM_NEW) { uState = state; }
if (forplayer || GetOwnerGuid())
AddToUpdateQueueOf(forplayer);
{ AddToUpdateQueueOf(forplayer); }
}
else
{
@ -888,7 +900,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
void Item::AddToUpdateQueueOf(Player* player)
{
if (IsInUpdateQueue())
return;
{ return; }
if (!player)
{
@ -909,7 +921,7 @@ void Item::AddToUpdateQueueOf(Player* player)
}
if (player->m_itemUpdateQueueBlocked)
return;
{ return; }
player->m_itemUpdateQueue.push_back(this);
uQueuePos = player->m_itemUpdateQueue.size() - 1;
@ -918,7 +930,7 @@ void Item::AddToUpdateQueueOf(Player* player)
void Item::RemoveFromUpdateQueueOf(Player* player)
{
if (!IsInUpdateQueue())
return;
{ return; }
if (!player)
{
@ -939,7 +951,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
}
if (player->m_itemUpdateQueueBlocked)
return;
{ return; }
player->m_itemUpdateQueue[uQueuePos] = NULL;
uQueuePos = -1;
@ -958,24 +970,23 @@ bool Item::IsEquipped() const
bool Item::CanBeTraded(bool mail) const
{
if ((!mail || !IsBoundAccountWide()) && IsSoulBound())
return false;
{ return false; }
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
return false;
{ return false; }
if (Player* owner = GetOwner())
{
if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
return false;
{ return false; }
if (owner->GetLootGuid() == GetObjectGuid())
return false;
{ return false; }
}
if (HasGeneratedLoot())
return false;
{ return false; }
if (IsBoundByEnchant())
return false;
{ return false; }
return true;
}
@ -987,7 +998,7 @@ bool Item::IsBoundByEnchant() const
{
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
if (!enchant_id)
continue;
{ continue; }
if (enchant_slot == TRANSMOGRIFY_ENCHANTMENT_SLOT)
return true;
@ -997,10 +1008,10 @@ bool Item::IsBoundByEnchant() const
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!enchantEntry)
continue;
{ continue; }
if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
return true;
{ return true; }
}
return false;
}
@ -1032,12 +1043,12 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
if (equippedItems->EquippedItemClass != -1) // -1 == any item class
{
if (equippedItems->EquippedItemClass != int32(proto->Class))
return false; // wrong item class
{ return false; } // wrong item class
if (equippedItems->EquippedItemSubClassMask != 0) // 0 == any subclass
{
if ((equippedItems->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
return false; // subclass not present in mask
{ return false; } // subclass not present in mask
}
}
@ -1047,7 +1058,7 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
if (equippedItems->EquippedItemInventoryTypeMask != 0 && (spellInfo->GetTargets() & TARGET_FLAG_ITEM)) // 0 == any inventory type
{
if ((equippedItems->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
return false; // inventory type not present in mask
{ return false; } // inventory type not present in mask
}
return true;
@ -1058,24 +1069,23 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
ItemRequiredTargetMapBounds bounds = sObjectMgr.GetItemRequiredTargetMapBounds(GetProto()->ItemId);
if (bounds.first == bounds.second)
return true;
{ return true; }
if (!pUnitTarget)
return false;
{ return false; }
for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
if (itr->second.IsFitToRequirements(pUnitTarget))
return true;
{ return true; }
return false;
}
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid casterGuid /*= ObjectGuid()*/)
{
// Better lost small time at check in comparison lost time at item save to DB.
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
return;
{ return; }
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
{
@ -1096,7 +1106,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
{
if (GetEnchantmentDuration(slot) == duration)
return;
{ return; }
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
SetState(ITEM_CHANGED);
@ -1105,7 +1115,7 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
{
if (GetEnchantmentCharges(slot) == charges)
return;
{ return; }
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
SetState(ITEM_CHANGED);
@ -1114,7 +1124,7 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
void Item::ClearEnchantment(EnchantmentSlot slot)
{
if (!GetEnchantmentId(slot))
return;
{ return; }
for (uint8 x = 0; x < 3; ++x)
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0);
@ -1136,7 +1146,7 @@ bool Item::GemsFitSockets() const
bool fits = true;
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
{
uint8 SocketColor = GetProto()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color;
uint8 SocketColor = GetProto()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color;
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
if (!enchant_id)
@ -1226,7 +1236,7 @@ void Item::SendTimeUpdate(Player* owner)
{
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
if (!duration)
return;
{ return; }
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
data << ObjectGuid(GetObjectGuid());
@ -1237,12 +1247,12 @@ void Item::SendTimeUpdate(Player* owner)
Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 randomPropertyId)
{
if (count < 1)
return NULL; // don't create item at zero count
{ return NULL; } // don't create item at zero count
if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
{
if (count > pProto->GetMaxStackSize())
count = pProto->GetMaxStackSize();
{ count = pProto->GetMaxStackSize(); }
MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
@ -1251,12 +1261,12 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r
{
pItem->SetCount(count);
if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item))
pItem->SetItemRandomProperties(randId);
{ pItem->SetItemRandomProperties(randId); }
return pItem;
}
else
delete pItem;
{ delete pItem; }
}
return NULL;
}
@ -1265,7 +1275,7 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
{
Item* newItem = CreateItem(GetEntry(), count, player, GetItemRandomPropertyId());
if (!newItem)
return NULL;
{ return NULL; }
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
@ -1278,15 +1288,15 @@ bool Item::IsBindedNotWith(Player const* player) const
{
// own item
if (GetOwnerGuid() == player->GetObjectGuid())
return false;
{ return false; }
// has loot with diff owner
if (HasGeneratedLoot())
return true;
{ return true; }
// not binded item
if (!IsSoulBound())
return false;
{ return false; }
// not BOA item case
if (!IsBoundAccountWide())
@ -1307,19 +1317,19 @@ bool Item::IsBindedNotWith(Player const* player) const
void Item::AddToClientUpdateList()
{
if (Player* pl = GetOwner())
pl->GetMap()->AddUpdateObject(this);
{ pl->GetMap()->AddUpdateObject(this); }
}
void Item::RemoveFromClientUpdateList()
{
if (Player* pl = GetOwner())
pl->GetMap()->RemoveUpdateObject(this);
{ pl->GetMap()->RemoveUpdateObject(this); }
}
void Item::BuildUpdateData(UpdateDataMapType& update_players)
{
if (Player* pl = GetOwner())
BuildUpdateDataForPlayer(pl, update_players);
{ BuildUpdateDataForPlayer(pl, update_players); }
ClearUpdateMask(false);
}
@ -1328,15 +1338,15 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
{
// check item type
if (GetEntry() != proto->ItemId)
return EQUIP_ERR_ITEM_CANT_STACK;
{ return EQUIP_ERR_ITEM_CANT_STACK; }
// check free space (full stacks can't be target of merge
if (GetCount() >= proto->GetMaxStackSize())
return EQUIP_ERR_ITEM_CANT_STACK;
{ return EQUIP_ERR_ITEM_CANT_STACK; }
// not allow merge looting currently items
if (HasGeneratedLoot())
return EQUIP_ERR_ALREADY_LOOTED;
{ return EQUIP_ERR_ALREADY_LOOTED; }
return EQUIP_ERR_OK;
}
@ -1344,10 +1354,10 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const
{
if (pUnitTarget->GetTypeId() != TYPEID_UNIT)
return false;
{ return false; }
if (pUnitTarget->GetEntry() != m_uiTargetEntry)
return false;
{ return false; }
switch (m_uiType)
{
@ -1403,15 +1413,15 @@ void Item::SetLootState(ItemLootUpdateState state)
case ITEM_LOOT_CHANGED:
// new loot must stay in new state until saved, temporary must stay until remove
if (m_lootState != ITEM_LOOT_NEW && m_lootState != ITEM_LOOT_TEMPORARY)
m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state;
{ m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state; }
break;
case ITEM_LOOT_UNCHANGED:
// expected that called after DB update or load
if (m_lootState == ITEM_LOOT_REMOVED)
m_lootState = ITEM_LOOT_NONE;
{ m_lootState = ITEM_LOOT_NONE; }
// temporary must stay until remove (ignore any changes)
else if (m_lootState != ITEM_LOOT_TEMPORARY)
m_lootState = ITEM_LOOT_UNCHANGED;
{ m_lootState = ITEM_LOOT_UNCHANGED; }
break;
case ITEM_LOOT_REMOVED:
// if loot not saved then it existence in past can be just ignored
@ -1426,7 +1436,12 @@ void Item::SetLootState(ItemLootUpdateState state)
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_UNCHANGED && m_lootState != ITEM_LOOT_TEMPORARY)
SetState(ITEM_CHANGED);
{ SetState(ITEM_CHANGED); }
}
uint32 Item::GetScriptId() const
{
return sScriptMgr.GetBoundScriptId(SCRIPTED_ITEM, GetEntry());
}
uint32 Item::GetSpecialPrice(ItemPrototype const* proto, uint32 minimumPrice /*= 10000*/)

View file

@ -283,13 +283,14 @@ struct ItemRequiredTarget
bool ItemCanGoIntoBag(ItemPrototype const* proto, ItemPrototype const* pBagProto);
class Item : public Object
class Item : public Object
{
public:
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, uint32 randomPropertyId = 0);
Item* CloneItem(uint32 count, Player const* player = NULL) const;
Item();
~Item();
virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
@ -397,6 +398,7 @@ class Item : public Object
bool HasInvolvedQuest(uint32 /*quest_id*/) const override { return false; }
bool IsPotion() const { return GetProto()->IsPotion(); }
bool IsConjuredConsumable() const { return GetProto()->IsConjuredConsumable(); }
uint32 GetScriptId() const;
void AddToClientUpdateList() override;
void RemoveFromClientUpdateList() override;

View file

@ -49,6 +49,10 @@
#include "TemporarySummon.h"
#include "movement/packet_builder.h"
#include "CreatureLinkingMgr.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#include "ElunaEventMgr.h"
#endif /* ENABLE_ELUNA */
Object::Object()
{
@ -93,7 +97,7 @@ void Object::_InitValues()
void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
{
if (!m_uint32Values)
_InitValues();
{ _InitValues(); }
ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow);
SetGuidValue(OBJECT_FIELD_GUID, guid);
@ -109,7 +113,7 @@ void Object::SetObjectScale(float newScale)
void Object::SendForcedObjectUpdate()
{
if (!m_inWorld || !m_objectUpdated)
return;
{ return; }
UpdateDataMapType update_players;
@ -128,14 +132,14 @@ void Object::SendForcedObjectUpdate()
void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
{
if (!target)
return;
{ return; }
uint8 updatetype = UPDATETYPE_CREATE_OBJECT;
uint16 updateFlags = m_updateFlag;
/** lower flag1 **/
if (target == this) // building packet for yourself
updateFlags |= UPDATEFLAG_SELF;
{ updateFlags |= UPDATEFLAG_SELF; }
switch (GetObjectGuid().GetHigh())
{
@ -168,7 +172,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
{
case GAMEOBJECT_TYPE_TRAP:
case GAMEOBJECT_TYPE_DUEL_ARBITER:
case GAMEOBJECT_TYPE_FLAGSTAND:
case GAMEOBJECT_CreatureTypeFlagsTAND:
case GAMEOBJECT_TYPE_FLAGDROP:
updatetype = UPDATETYPE_CREATE_OBJECT2;
break;
@ -245,7 +249,7 @@ void Object::DestroyForPlayer(Player* target, bool anim) const
target->GetSession()->SendPacket(&data);
}
void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
void Object::BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const
{
ObjectGuid Guid = GetObjectGuid();
@ -542,7 +546,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const
{
if (!target)
return;
{ return; }
uint32 valuesCount = m_valuesCount;
if(GetTypeId() == TYPEID_PLAYER && target != this)
@ -556,7 +560,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
{
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
IsActivateToQuest = true;
{ IsActivateToQuest = true; }
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
}
@ -574,7 +578,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
{
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
IsActivateToQuest = true;
{ IsActivateToQuest = true; }
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
updateMask->SetBit(GAMEOBJECT_BYTES_1); // why do we need this here?
@ -619,7 +623,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (appendValue & UNIT_NPC_FLAG_STABLEMASTER)
{
if (target->getClass() != CLASS_HUNTER)
appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER;
{ appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER; }
}
}
@ -731,7 +735,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
*data << uint32(m_uint32Values[index]);
}
else
*data << m_uint32Values[index]; // other cases
{ *data << m_uint32Values[index]; } // other cases
}
}
}
@ -753,25 +757,25 @@ void Object::ClearUpdateMask(bool remove)
if (m_uint32Values)
{
for (uint16 index = 0; index < m_valuesCount; ++index)
m_changedValues[index] = false;
{ m_changedValues[index] = false; }
}
if (m_objectUpdated)
{
if (remove)
RemoveFromClientUpdateList();
{ RemoveFromClientUpdateList(); }
m_objectUpdated = false;
}
}
bool Object::LoadValues(const char* data)
{
if (!m_uint32Values) _InitValues();
if (!m_uint32Values) { _InitValues(); }
Tokens tokens = StrSplit(data, " ");
if (tokens.size() != m_valuesCount)
return false;
{ return false; }
Tokens::iterator iter;
int index;
@ -783,7 +787,7 @@ bool Object::LoadValues(const char* data)
return true;
}
void Object::_SetUpdateBits(UpdateMask *updateMask, Player* target) const
void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const
{
uint32 valuesCount = m_valuesCount;
if(GetTypeId() == TYPEID_PLAYER && target != this)
@ -791,10 +795,10 @@ void Object::_SetUpdateBits(UpdateMask *updateMask, Player* target) const
for (uint16 index = 0; index < valuesCount; ++index )
if (m_changedValues[index])
updateMask->SetBit(index);
{ updateMask->SetBit(index); }
}
void Object::_SetCreateBits(UpdateMask *updateMask, Player* target) const
void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const
{
uint32 valuesCount = m_valuesCount;
if(GetTypeId() == TYPEID_PLAYER && target != this)
@ -802,7 +806,7 @@ void Object::_SetCreateBits(UpdateMask *updateMask, Player* target) const
for (uint16 index = 0; index < valuesCount; ++index)
if (GetUInt32Value(index) != 0)
updateMask->SetBit(index);
{ updateMask->SetBit(index); }
}
void Object::SetInt32Value(uint16 index, int32 value)
@ -903,7 +907,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
void Object::SetStatFloatValue(uint16 index, float value)
{
if (value < 0)
value = 0.0f;
{ value = 0.0f; }
SetFloatValue(index, value);
}
@ -911,7 +915,7 @@ void Object::SetStatFloatValue(uint16 index, float value)
void Object::SetStatInt32Value(uint16 index, int32 value)
{
if (value < 0)
value = 0;
{ value = 0; }
SetUInt32Value(index, uint32(value));
}
@ -921,7 +925,7 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply)
int32 cur = GetUInt32Value(index);
cur += (apply ? val : -val);
if (cur < 0)
cur = 0;
{ cur = 0; }
SetUInt32Value(index, cur);
}
@ -944,7 +948,7 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
float cur = GetFloatValue(index);
cur += (apply ? val : -val);
if (cur < 0)
cur = 0;
{ cur = 0; }
SetFloatValue(index, cur);
}
@ -1052,7 +1056,6 @@ bool Object::PrintEntryError(char const* descr) const
return false;
}
void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players)
{
UpdateDataMapType::iterator iter = update_players.find(pl);
@ -1098,17 +1101,36 @@ void Object::MarkForClientUpdate()
}
WorldObject::WorldObject() :
m_transportInfo(NULL), m_currMap(NULL),
#ifdef ENABLE_ELUNA
elunaEvents(NULL),
#endif /* ENABLE_ELUNA */
m_transportInfo(NULL),
m_currMap(NULL),
m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_isActiveObject(false)
{
}
WorldObject::~WorldObject()
{
#ifdef ENABLE_ELUNA
delete elunaEvents;
elunaEvents = NULL;
#endif /* ENABLE_ELUNA */
}
void WorldObject::CleanupsBeforeDelete()
{
RemoveFromWorld();
}
void WorldObject::Update(uint32 update_diff, uint32 time_diff)
{
#ifdef ENABLE_ELUNA
elunaEvents->Update(update_diff);
#endif /* ENABLE_ELUNA */
}
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
{
Object::_Create(guidlow, 0, guidhigh);
@ -1123,7 +1145,7 @@ void WorldObject::Relocate(float x, float y, float z, float orientation)
m_position.o = NormalizeOrientation(orientation);
if (isType(TYPEMASK_UNIT))
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation);
{ ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation); }
}
void WorldObject::Relocate(float x, float y, float z)
@ -1133,7 +1155,7 @@ void WorldObject::Relocate(float x, float y, float z)
m_position.z = z;
if (isType(TYPEMASK_UNIT))
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation());
{ ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation()); }
}
void WorldObject::SetOrientation(float orientation)
@ -1141,7 +1163,7 @@ void WorldObject::SetOrientation(float orientation)
m_position.o = NormalizeOrientation(orientation);
if (isType(TYPEMASK_UNIT))
((Unit*)this)->m_movementInfo.ChangeOrientation(orientation);
{ ((Unit*)this)->m_movementInfo.ChangeOrientation(orientation); }
}
uint32 WorldObject::GetZoneId() const
@ -1254,11 +1276,10 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const
{
if (!IsInMap(obj))
return false;
if (!IsInMap(obj)) { return false; }
float ox, oy, oz;
obj->GetPosition(ox, oy, oz);
return IsWithinLOS(ox, oy, oz);
return(IsWithinLOS(ox, oy, oz));
}
bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
@ -1309,7 +1330,7 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
return false;
{ return false; }
}
float maxdist = maxRange + sizefactor;
@ -1329,7 +1350,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange)
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
return false;
{ return false; }
}
float maxdist = maxRange + sizefactor;
@ -1350,7 +1371,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
return false;
{ return false; }
}
float maxdist = maxRange + sizefactor;
@ -1360,7 +1381,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
float WorldObject::GetAngle(const WorldObject* obj) const
{
if (!obj)
return 0.0f;
{ return 0.0f; }
// Rework the assert, when more cases where such a call can happen have been fixed
// MANGOS_ASSERT(obj != this || PrintEntryError("GetAngle (for self)"));
@ -1387,7 +1408,7 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
{
// always have self in arc
if (obj == this)
return true;
{ return true; }
float arc = arcangle;
@ -1400,7 +1421,7 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
if (angle > M_PI_F)
angle -= 2.0f * M_PI_F;
{ angle -= 2.0f * M_PI_F; }
float lborder = -1 * (arc / 2.0f); // in range -pi..0
float rborder = (arc / 2.0f); // in range 0..pi
@ -1454,7 +1475,7 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
{
float new_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
if (new_z > INVALID_HEIGHT)
z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface
{ 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
@ -1475,16 +1496,16 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
z = max_z;
{ z = max_z; }
else if (z < ground_z)
z = ground_z;
{ z = ground_z; }
}
}
else
{
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
if (z < ground_z)
z = ground_z;
{ z = ground_z; }
}
break;
}
@ -1498,9 +1519,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
z = max_z;
{ z = max_z; }
else if (z < ground_z)
z = ground_z;
{ z = ground_z; }
}
}
else
@ -1515,7 +1536,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
{
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
if (ground_z > INVALID_HEIGHT)
z = ground_z;
{ z = ground_z; }
break;
}
}
@ -1551,7 +1572,7 @@ void WorldObject::MonsterTextEmote(const char* text, Unit const* target, bool Is
void WorldObject::MonsterWhisper(const char* text, Unit const* target, bool IsBossWhisper) const
{
if (!target || target->GetTypeId() != TYPEID_PLAYER)
return;
{ return; }
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildMonsterChat(&data, GetObjectGuid(), IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL,
@ -1666,14 +1687,14 @@ void WorldObject::SendMessageToSet(WorldPacket* data, bool /*bToSelf*/) const
{
// if object is in world, map for it already created!
if (IsInWorld())
GetMap()->MessageBroadcast(this, data);
{ GetMap()->MessageBroadcast(this, data); }
}
void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*bToSelf*/) const
{
// if object is in world, map for it already created!
if (IsInWorld())
GetMap()->MessageDistBroadcast(this, data, dist);
{ GetMap()->MessageDistBroadcast(this, data, dist); }
}
void WorldObject::SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver) const
@ -1708,6 +1729,17 @@ void WorldObject::SetMap(Map* map)
// lets save current map's Id/instanceId
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();
#ifdef ENABLE_ELUNA
delete elunaEvents;
// On multithread replace this with a pointer to map's Eluna pointer stored in a map
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
#endif
#ifdef ENABLE_ELUNA
delete elunaEvents;
elunaEvents = NULL;
#endif
}
TerrainInfo const* WorldObject::GetTerrain() const
@ -1734,12 +1766,12 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
Team team = TEAM_NONE;
if (GetTypeId() == TYPEID_PLAYER)
team = ((Player*)this)->GetTeam();
{ team = ((Player*)this)->GetTeam(); }
CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask());
if (x == 0.0f && y == 0.0f && z == 0.0f)
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang);
{ pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); }
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team))
{
@ -1755,11 +1787,16 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
pCreature->Summon(spwtype, despwtime); // Also initializes the AI and MMGen
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
((Creature*)this)->AI()->JustSummoned(pCreature);
{ ((Creature*)this)->AI()->JustSummoned(pCreature); }
#ifdef ENABLE_ELUNA
if (Unit* summoner = ToUnit())
sEluna->OnSummoned(pCreature, summoner);
#endif /* ENABLE_ELUNA */
// Creature Linking, Initial load is handled like respawn
if (pCreature->IsLinkingEventTrigger())
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature);
{ GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); }
// return the creature therewith the summoner has access to it
return pCreature;
@ -1771,7 +1808,7 @@ GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z,
Map *map = GetMap();
if (!map)
if(!map)
return NULL;
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, GetPhaseMask(), x, y, z, angle))
@ -1780,7 +1817,7 @@ GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z,
return NULL;
}
pGameObj->SetRespawnTime(despwtime / IN_MILLISECONDS);
pGameObj->SetRespawnTime(despwtime/IN_MILLISECONDS);
map->Add(pGameObj);
@ -1805,7 +1842,7 @@ namespace MaNGOS
{
// skip self or target
if (c == i_searcher || c == &i_object)
return;
{ return; }
float x, y, z;
@ -1823,7 +1860,7 @@ namespace MaNGOS
{
// skip self or target
if (u == i_searcher || u == &i_object)
return;
{ return; }
float x, y;
@ -1843,21 +1880,21 @@ namespace MaNGOS
// It is ok for the objects to require a bit more space
float delta = u->GetObjectBoundingRadius();
if (i_selector.m_searchPosFor && i_selector.m_searchPosFor != u)
delta += i_selector.m_searchPosFor->GetObjectBoundingRadius();
{ delta += i_selector.m_searchPosFor->GetObjectBoundingRadius(); }
delta *= OCCUPY_POS_DEPTH_FACTOR; // Increase by factor
// u is too near/far away from i_object. Do not consider it to occupy space
if (fabs(i_selector.m_searcherDist - dist2d) > delta)
return;
{ return; }
float angle = i_object.GetAngle(u) - i_absAngle;
// move angle to range -pi ... +pi, range before is -2Pi..2Pi
if (angle > M_PI_F)
angle -= 2.0f * M_PI_F;
{ angle -= 2.0f * M_PI_F; }
else if (angle < -M_PI_F)
angle += 2.0f * M_PI_F;
{ angle += 2.0f * M_PI_F; }
i_selector.AddUsedArea(u, angle, dist2d);
}
@ -1891,7 +1928,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
return;
}
@ -1919,10 +1956,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return;
{ return; }
first_los_conflict = true; // first point have LOS problems
}
@ -1941,10 +1978,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return;
{ return; }
}
// BAD NEWS: not free pos (or used or have LOS problems)
@ -1957,7 +1994,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
return;
}
@ -1973,10 +2010,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return;
{ return; }
}
// BAD BAD NEWS: all found pos (free and used) have LOS problem :(
@ -1986,7 +2023,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
else
UpdateGroundPositionZ(x, y, z);
{ UpdateGroundPositionZ(x, y, z); }
}
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
@ -2004,9 +2041,9 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player const* target /*= NU
data << GetObjectGuid();
data << GetObjectGuid();
if (target)
target->SendDirectMessage(&data);
{ target->SendDirectMessage(&data); }
else
SendMessageToSet(&data, true);
{ SendMessageToSet(&data, true); }
}
void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL*/) const
@ -2020,6 +2057,16 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL
SendMessageToSet(&data, true);
}
void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) const
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(sound_id);
if (target)
{ target->SendDirectMessage(&data); }
else
{ SendMessageToSet(&data, true); }
}
void WorldObject::UpdateVisibilityAndView()
{
GetViewPoint().Call_UpdateVisibilityForOwner();
@ -2054,7 +2101,7 @@ struct WorldObjectChangeAccumulator
// send self fields changes in another way, otherwise
// with new camera system when player's camera too far from player, camera wouldn't receive packets and changes from player
if (i_object.isType(TYPEMASK_PLAYER))
i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas);
{ i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas); }
}
void Visit(CameraMapType& m)
@ -2063,7 +2110,7 @@ struct WorldObjectChangeAccumulator
{
Player* owner = iter->getSource()->GetOwner();
if (owner != &i_object && owner->HaveAtClient(&i_object))
i_object.BuildUpdateDataForPlayer(owner, i_updateDatas);
{ i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); }
}
}
@ -2105,16 +2152,16 @@ bool WorldObject::PrintCoordinatesError(float x, float y, float z, char const* d
void WorldObject::SetActiveObjectState(bool active)
{
if (m_isActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never
return;
{ return; }
if (IsInWorld() && !isType(TYPEMASK_PLAYER))
// player's update implemented in a different from other active worldobject's way
// it's considired to use generic way in future
{
if (isActiveObject() && !active)
GetMap()->RemoveFromActive(this);
{ GetMap()->RemoveFromActive(this); }
else if (!isActiveObject() && active)
GetMap()->AddToActive(this);
{ GetMap()->AddToActive(this); }
}
m_isActiveObject = active;
}

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef _OBJECT_H
#define _OBJECT_H
#ifndef MANGOS_H_OBJECT
#define MANGOS_H_OBJECT
#include "Common.h"
#include "ByteBuffer.h"
@ -39,13 +39,13 @@
#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define MAX_VISIBILITY_DISTANCE 333.0f // max distance for visible object show, limited in 333 yards
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards
#define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards
#define MAX_VISIBILITY_DISTANCE 333.0f // max distance for visible object show, limited in 333 yards
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards
#define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // currently used (correctly?) for any non Unit world objects. This is actually the bounding_radius, like player/creature from creature_model_data
#define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc
#define DEFAULT_OBJECT_SCALE 1.0f // player/item Scale as default, npc/go from database, pets from dbc
#define MAX_STEALTH_DETECT_RANGE 45.0f
@ -73,6 +73,7 @@ class WorldPacket;
class UpdateData;
class WorldSession;
class Creature;
class GameObject;
class Player;
class Unit;
class Group;
@ -84,6 +85,7 @@ class TerrainInfo;
class ElunaEventProcessor;
#endif /* ENABLE_ELUNA */
class TransportInfo;
struct MangosStringLocale;
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
@ -107,6 +109,7 @@ struct WorldLocation
: mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(NormalizeOrientation(loc.orientation)) {}
};
// use this class to measure time between world update ticks
// essential for units updating their spells after cells become active
class WorldUpdateCounter
@ -117,7 +120,7 @@ class WorldUpdateCounter
time_t timeElapsed()
{
if (!m_tmStart)
m_tmStart = WorldTimer::tickPrevTime();
{ m_tmStart = WorldTimer::tickPrevTime(); }
return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime());
}
@ -128,7 +131,7 @@ class WorldUpdateCounter
uint32 m_tmStart;
};
class Object
class Object
{
public:
virtual ~Object();
@ -137,7 +140,7 @@ class Object
virtual void AddToWorld()
{
if (m_inWorld)
return;
{ return; }
m_inWorld = true;
@ -243,8 +246,8 @@ class Object
DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject const*>(this); else return NULL; }
void SetInt32Value(uint16 index, int32 value);
void SetUInt32Value(uint16 index, uint32 value);
void UpdateUInt32Value(uint16 index, uint32 value);
void SetUInt32Value(uint16 index, uint32 value);
void UpdateUInt32Value(uint16 index, uint32 value);
void SetUInt64Value(uint16 index, const uint64& value);
void SetFloatValue(uint16 index, float value);
void SetByteValue(uint16 index, uint8 offset, uint8 value);
@ -272,11 +275,19 @@ class Object
void ToggleFlag(uint16 index, uint32 flag)
{
if (HasFlag(index, flag))
RemoveFlag(index, flag);
{ RemoveFlag(index, flag); }
else
SetFlag(index, flag);
{ SetFlag(index, flag); }
}
/**
* Checks if a certain flag is set.
* @param index The index to check, values may originate from at least \ref EUnitFields
* @param flag Which flag to check, value may originate from a lot of places, see code
* for examples of what
* @return true if the flag is set, false otherwise
* \todo More info on these flags and where they come from, also, which indexes can be used?
*/
bool HasFlag(uint16 index, uint32 flag) const
{
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
@ -286,9 +297,9 @@ class Object
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
{
if (apply)
SetFlag(index, flag);
{ SetFlag(index, flag); }
else
RemoveFlag(index, flag);
{ RemoveFlag(index, flag); }
}
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
@ -297,9 +308,9 @@ class Object
void ToggleByteFlag(uint16 index, uint8 offset, uint8 flag)
{
if (HasByteFlag(index, offset, flag))
RemoveByteFlag(index, offset, flag);
{ RemoveByteFlag(index, offset, flag); }
else
SetByteFlag(index, offset, flag);
{ SetByteFlag(index, offset, flag); }
}
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
@ -312,9 +323,9 @@ class Object
void ApplyModByteFlag(uint16 index, uint8 offset, uint32 flag, bool apply)
{
if (apply)
SetByteFlag(index, offset, flag);
{ SetByteFlag(index, offset, flag); }
else
RemoveByteFlag(index, offset, flag);
{ RemoveByteFlag(index, offset, flag); }
}
void SetShortFlag(uint16 index, bool highpart, uint16 newFlag);
@ -323,9 +334,9 @@ class Object
void ToggleShortFlag(uint16 index, bool highpart, uint8 flag)
{
if (HasShortFlag(index, highpart, flag))
RemoveShortFlag(index, highpart, flag);
{ RemoveShortFlag(index, highpart, flag); }
else
SetShortFlag(index, highpart, flag);
{ SetShortFlag(index, highpart, flag); }
}
bool HasShortFlag(uint16 index, bool highpart, uint8 flag) const
@ -337,9 +348,9 @@ class Object
void ApplyModShortFlag(uint16 index, bool highpart, uint32 flag, bool apply)
{
if (apply)
SetShortFlag(index, highpart, flag);
{ SetShortFlag(index, highpart, flag); }
else
RemoveShortFlag(index, highpart, flag);
{ RemoveShortFlag(index, highpart, flag); }
}
void SetFlag64(uint16 index, uint64 newFlag)
@ -359,9 +370,9 @@ class Object
void ToggleFlag64(uint16 index, uint64 flag)
{
if (HasFlag64(index, flag))
RemoveFlag64(index, flag);
{ RemoveFlag64(index, flag); }
else
SetFlag64(index, flag);
{ SetFlag64(index, flag); }
}
bool HasFlag64(uint16 index, uint64 flag) const
@ -373,9 +384,9 @@ class Object
void ApplyModFlag64(uint16 index, uint64 flag, bool apply)
{
if (apply)
SetFlag64(index, flag);
{ SetFlag64(index, flag); }
else
RemoveFlag64(index, flag);
{ RemoveFlag64(index, flag); }
}
void ClearUpdateMask(bool remove);
@ -435,7 +446,7 @@ class Object
struct WorldObjectChangeAccumulator;
class WorldObject : public Object
class WorldObject : public Object
{
friend struct WorldObjectChangeAccumulator;
@ -443,7 +454,7 @@ class WorldObject : public Object
// class is used to manipulate with WorldUpdateCounter
// it is needed in order to get time diff between two object's Update() calls
class UpdateHelper
class UpdateHelper
{
public:
explicit UpdateHelper(WorldObject* obj) : m_obj(obj) {}
@ -462,9 +473,9 @@ class WorldObject : public Object
WorldObject* const m_obj;
};
virtual ~WorldObject() {}
virtual ~WorldObject();
virtual void Update(uint32 /*update_diff*/, uint32 /*time_diff*/) {}
virtual void Update(uint32 /*update_diff*/, uint32 /*time_diff*/);
void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
@ -485,6 +496,7 @@ class WorldObject : public Object
void GetPosition(WorldLocation& loc) const
{ loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
float GetOrientation() const { return m_position.o; }
/// Gives a 2d-point in distance distance2d in direction absAngle around the current position (point-to-point)
void GetNearPoint2D(float& x, float& y, float distance2d, float absAngle) const;
/** Gives a "free" spot for searcher in distance distance2d in direction absAngle on "good" height
@ -602,6 +614,7 @@ class WorldObject : public Object
void PlayDistanceSound(uint32 sound_id, Player const* target = NULL) const;
void PlayDirectSound(uint32 sound_id, Player const* target = NULL) const;
void PlayMusic(uint32 sound_id, Player const* target = NULL) const;
void SendObjectDeSpawnAnim(ObjectGuid guid);
void SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId = 0);
@ -645,8 +658,7 @@ class WorldObject : public Object
// ASSERT print helper
bool PrintCoordinatesError(float x, float y, float z, char const* descr) const;
virtual void StartGroupLoot(Group* /*group*/, uint32 /*timer*/) {}
virtual void StartGroupLoot(Group* /*group*/, uint32 /*timer*/) { }
#ifdef ENABLE_ELUNA
ElunaEventProcessor* elunaEvents;
#endif /* ENABLE_ELUNA */

View file

@ -585,13 +585,13 @@ void ObjectMgr::LoadCreatureTemplates()
if (!ok)
continue;
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A);
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->FactionAlliance);
if (!factionTemplate)
sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_A template (%u)", cInfo->Entry, cInfo->faction_A);
sLog.outErrorDb("Creature (Entry: %u) has nonexistent factionAlliance template (%u)", cInfo->Entry, cInfo->FactionAlliance);
factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_H);
factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->FactionHorde);
if (!factionTemplate)
sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->faction_H);
sLog.outErrorDb("Creature (Entry: %u) has nonexistent factionHorde template (%u)", cInfo->Entry, cInfo->FactionHorde);
for (int k = 0; k < MAX_KILL_CREDIT; ++k)
{
@ -605,7 +605,7 @@ void ObjectMgr::LoadCreatureTemplates()
}
}
// used later for scale
// used later for Scale
CreatureDisplayInfoEntry const* displayScaleEntry = NULL;
for (int i = 0; i < MAX_CREATURE_MODEL; ++i)
@ -701,18 +701,18 @@ void ObjectMgr::LoadCreatureTemplates()
const_cast<CreatureInfo*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
}
if (cInfo->vehicleId && !sVehicleStore.LookupEntry(cInfo->vehicleId))
if (cInfo->VehicleTemplateId && !sVehicleStore.LookupEntry(cInfo->VehicleTemplateId))
{
sLog.outErrorDb("Creature (Entry: %u) has non-existing vehicle_id (%u), set to 0.", cInfo->Entry, cInfo->vehicleId);
const_cast<CreatureInfo*>(cInfo)->vehicleId = 0;
sLog.outErrorDb("Creature (Entry: %u) has non-existing vehicle_id (%u), set to 0.", cInfo->Entry, cInfo->VehicleTemplateId);
const_cast<CreatureInfo*>(cInfo)->VehicleTemplateId = 0;
}
if (cInfo->equipmentId > 0) // 0 no equipment
if (cInfo->EquipmentTemplateId > 0) // 0 no equipment
{
if (!GetEquipmentInfo(cInfo->equipmentId))
if (!GetEquipmentInfo(cInfo->EquipmentTemplateId))
{
sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId);
const_cast<CreatureInfo*>(cInfo)->equipmentId = 0;
sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->EquipmentTemplateId);
const_cast<CreatureInfo*>(cInfo)->EquipmentTemplateId = 0;
}
}
@ -722,13 +722,13 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with vendor_id %u but not have flag UNIT_NPC_FLAG_VENDOR (%u), vendor items will ignored.", cInfo->Entry, cInfo->vendorId, UNIT_NPC_FLAG_VENDOR);
}
/// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc
if (cInfo->scale <= 0.0f)
/// if not set custom creature Scale then load Scale from CreatureDisplayInfo.dbc
if (cInfo->Scale <= 0.0f)
{
if (displayScaleEntry)
const_cast<CreatureInfo*>(cInfo)->scale = displayScaleEntry->scale;
const_cast<CreatureInfo*>(cInfo)->Scale = displayScaleEntry->Scale;
else
const_cast<CreatureInfo*>(cInfo)->scale = DEFAULT_OBJECT_SCALE;
const_cast<CreatureInfo*>(cInfo)->Scale = DEFAULT_OBJECT_SCALE;
}
}
}
@ -1403,17 +1403,17 @@ void ObjectMgr::LoadCreatures()
data.curhealth = cInfo->minhealth;
}
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
if (cInfo->ExtraFlags & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
{
if (!mapEntry || !mapEntry->IsDungeon())
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND (%u) but creature are not in instance.",
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`ExtraFlags` including CREATURE_FLAG_EXTRA_INSTANCE_BIND (%u) but creature are not in instance.",
guid, data.id, CREATURE_FLAG_EXTRA_INSTANCE_BIND);
}
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE)
if (cInfo->ExtraFlags & CREATURE_FLAG_EXTRA_AGGRO_ZONE)
{
if (!mapEntry || !mapEntry->IsDungeon())
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_AGGRO_ZONE (%u) but creature are not in instance.",
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`ExtraFlags` including CREATURE_FLAG_EXTRA_AGGRO_ZONE (%u) but creature are not in instance.",
guid, data.id, CREATURE_FLAG_EXTRA_AGGRO_ZONE);
}
@ -6273,7 +6273,7 @@ void ObjectMgr::LoadGameobjectInfo()
{
GameObjectInfo const* goInfo = itr.getValue();
if (goInfo->size <= 0.0f) // prevent use too small scales
if (goInfo->size <= 0.0f) // prevent use too small Scales
{
ERROR_DB_STRICT_LOG("Gameobject (Entry: %u GoType: %u) have too small size=%f",
goInfo->id, goInfo->type, goInfo->size);
@ -6449,7 +6449,7 @@ void ObjectMgr::LoadGameobjectInfo()
CheckGOSpellId(goInfo, goInfo->spellcaster.spellId, 0);
break;
}
case GAMEOBJECT_TYPE_FLAGSTAND: // 24
case GAMEOBJECT_CreatureTypeFlagsTAND: // 24
{
if (goInfo->flagstand.lockId)
CheckGOLockId(goInfo, goInfo->flagstand.lockId, 0);

View file

@ -902,15 +902,15 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family);
if (cFamily && cFamily->minScale > 0.0f && getPetType() == HUNTER_PET)
{
float scale;
float Scale;
if (getLevel() >= cFamily->maxScaleLevel)
scale = cFamily->maxScale;
Scale = cFamily->maxScale;
else if (getLevel() <= cFamily->minScaleLevel)
scale = cFamily->minScale;
Scale = cFamily->minScale;
else
scale = cFamily->minScale + float(getLevel() - cFamily->minScaleLevel) / cFamily->maxScaleLevel * (cFamily->maxScale - cFamily->minScale);
Scale = cFamily->minScale + float(getLevel() - cFamily->minScaleLevel) / cFamily->maxScaleLevel * (cFamily->maxScale - cFamily->minScale);
SetObjectScale(scale);
SetObjectScale(Scale);
UpdateModelData();
}
m_bonusdamage = 0;
@ -985,8 +985,8 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
sLog.outErrorDb("Summoned pet (Entry: %u) not have pet stats data in DB", cinfo->Entry);
// remove elite bonuses included in DB values
SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel));
SetCreateMana(uint32(((float(cinfo->maxmana) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel));
SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->Rank)) * petlevel));
SetCreateMana(uint32(((float(cinfo->maxmana) / cinfo->maxlevel) / (1 + 2 * cinfo->Rank)) * petlevel));
SetCreateStat(STAT_STRENGTH, 22);
SetCreateStat(STAT_AGILITY, 22);
@ -1024,7 +1024,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
sLog.outErrorDb("Hunter pet levelstats missing in DB");
// remove elite bonuses included in DB values
SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel));
SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->Rank)) * petlevel));
SetCreateStat(STAT_STRENGTH, 22);
SetCreateStat(STAT_AGILITY, 22);

View file

@ -674,7 +674,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype);
InitDisplayIds(); // model, scale and model data
InitDisplayIds(); // model, Scale and model data
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
@ -7151,13 +7151,13 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply)
DEBUG_LOG("_ApplyItemMods complete.");
}
void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool apply, bool only_level_scale /*= false*/)
void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool apply, bool only_level_Scale /*= false*/)
{
if (slot >= INVENTORY_SLOT_BAG_END || !proto)
return;
ScalingStatDistributionEntry const* ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : NULL;
if (only_level_scale && !ssd)
if (only_level_Scale && !ssd)
return;
// req. check at equip, but allow use for extended range if range limit max level, set proper level
@ -7166,7 +7166,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl
ssd_level = ssd->MaxLevel;
ScalingStatValuesEntry const* ssv = proto->StatScalingFactor ? sScalingStatValuesStore.LookupEntry(ssd_level) : NULL;
if (only_level_scale && !ssv)
if (only_level_Scale && !ssv)
return;
for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
@ -15760,7 +15760,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
_LoadIntoDataField(fields[54].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
_LoadIntoDataField(fields[56].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2);
InitDisplayIds(); // model, scale and model data
InitDisplayIds(); // model, Scale and model data
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
@ -19449,7 +19449,7 @@ void Player::InitDisplayIds()
return;
}
// reset scale before reapply auras
// reset Scale before reapply auras
SetObjectScale(DEFAULT_OBJECT_SCALE);
uint8 gender = getGender();
@ -21484,7 +21484,7 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) const
{
if (((Creature*)pVictim)->IsTotem() ||
((Creature*)pVictim)->IsPet() ||
((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)
((Creature*)pVictim)->GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)
return false;
}
return true;
@ -21921,7 +21921,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
}
// All liquids type - check under water position
if (liquid_status.type_flags & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME))
if (liquid_status.CreatureTypeFlags & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME))
{
if (res & LIQUID_MAP_UNDER_WATER)
m_MirrorTimerFlags |= UNDERWATER_INWATER;
@ -21930,13 +21930,13 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
}
// Allow travel in dark water on taxi or transport
if ((liquid_status.type_flags & MAP_LIQUID_TYPE_DARK_WATER) && !IsTaxiFlying() && !GetTransport())
if ((liquid_status.CreatureTypeFlags & MAP_LIQUID_TYPE_DARK_WATER) && !IsTaxiFlying() && !GetTransport())
m_MirrorTimerFlags |= UNDERWATER_INDARKWATER;
else
m_MirrorTimerFlags &= ~UNDERWATER_INDARKWATER;
// in lava check, anywhere in lava level
if (liquid_status.type_flags & MAP_LIQUID_TYPE_MAGMA)
if (liquid_status.CreatureTypeFlags & MAP_LIQUID_TYPE_MAGMA)
{
if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER | LIQUID_MAP_WATER_WALK))
m_MirrorTimerFlags |= UNDERWATER_INLAVA;
@ -21944,7 +21944,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
m_MirrorTimerFlags &= ~UNDERWATER_INLAVA;
}
// in slime check, anywhere in slime level
if (liquid_status.type_flags & MAP_LIQUID_TYPE_SLIME)
if (liquid_status.CreatureTypeFlags & MAP_LIQUID_TYPE_SLIME)
{
if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER | LIQUID_MAP_WATER_WALK))
m_MirrorTimerFlags |= UNDERWATER_INSLIME;

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef _PLAYER_H
#define _PLAYER_H
#ifndef MANGOS_H_PLAYER
#define MANGOS_H_PLAYER
#include "Common.h"
#include "ItemPrototype.h"
@ -194,8 +194,14 @@ struct ActionButton
ActionButtonUpdateState uState;
// helpers
ActionButtonType GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData)); }
uint32 GetAction() const { return ACTION_BUTTON_ACTION(packedData); }
ActionButtonType GetType() const
{
return ActionButtonType(ACTION_BUTTON_TYPE(packedData));
}
uint32 GetAction() const
{
return ACTION_BUTTON_ACTION(packedData);
}
void SetActionAndType(uint32 action, ActionButtonType type)
{
uint32 newData = action | (uint32(type) << 24);
@ -203,7 +209,7 @@ struct ActionButton
{
packedData = newData;
if (uState != ACTIONBUTTON_NEW)
uState = ACTIONBUTTON_CHANGED;
{ uState = ACTIONBUTTON_CHANGED; }
}
}
};
@ -272,7 +278,10 @@ typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
struct PlayerLevelInfo
{
PlayerLevelInfo() { for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0; }
PlayerLevelInfo()
{
for (int i = 0; i < MAX_STATS; ++i) { stats[i] = 0; }
}
uint8 stats[MAX_STATS];
};
@ -788,21 +797,6 @@ enum EnviromentalDamage
DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
};
/*
* This is defined in Chat.h (just like Zero, One, and Two)
* DELETE THIS IF ALL IS OK
enum PlayerChatTag
{
CHAT_TAG_NONE = 0x00,
CHAT_TAG_AFK = 0x01,
CHAT_TAG_DND = 0x02,
CHAT_TAG_GM = 0x04,
CHAT_TAG_COM = 0x08, // Commentator
CHAT_TAG_DEV = 0x10, // Developer
};
*/
enum PlayedTimeIndex
{
PLAYED_TIME_TOTAL = 0,
@ -886,7 +880,7 @@ enum PlayerRestState
REST_STATE_RAF_LINKED = 0x04 // Exact use unknown
};
class PlayerTaxi
class PlayerTaxi
{
public:
PlayerTaxi();
@ -911,7 +905,7 @@ class PlayerTaxi
return true;
}
else
return false;
{ return false; }
}
void AppendTaximaskTo(ByteBuffer& data, bool all);
@ -919,17 +913,32 @@ class PlayerTaxi
bool LoadTaxiDestinationsFromString(const std::string& values, Team team);
std::string SaveTaxiDestinationsToString();
void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
void ClearTaxiDestinations()
{
m_TaxiDestinations.clear();
}
void AddTaxiDestination(uint32 dest)
{
m_TaxiDestinations.push_back(dest);
}
uint32 GetTaxiSource() const
{
return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front();
}
uint32 GetTaxiDestination() const
{
return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1];
}
uint32 GetCurrentTaxiPath() const;
uint32 NextTaxiDestination()
{
m_TaxiDestinations.pop_front();
return GetTaxiDestination();
}
bool empty() const { return m_TaxiDestinations.empty(); }
bool empty() const
{
return m_TaxiDestinations.empty();
}
friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
private:
@ -975,20 +984,38 @@ class TradeData
public: // access functions
Player* GetTrader() const { return m_trader; }
Player* GetTrader() const
{
return m_trader;
}
TradeData* GetTraderData() const;
Item* GetItem(TradeSlots slot) const;
bool HasItem(ObjectGuid item_guid) const;
uint32 GetSpell() const { return m_spell; }
uint32 GetSpell() const
{
return m_spell;
}
Item* GetSpellCastItem() const;
bool HasSpellCastItem() const { return !m_spellCastItem.IsEmpty(); }
bool HasSpellCastItem() const
{
return !m_spellCastItem.IsEmpty();
}
uint64 GetMoney() const { return m_money; }
uint64 GetMoney() const
{
return m_money;
}
bool IsAccepted() const { return m_accepted; }
bool IsInAcceptProcess() const { return m_acceptProccess; }
bool IsAccepted() const
{
return m_accepted;
}
bool IsInAcceptProcess() const
{
return m_acceptProccess;
}
public: // access functions
void SetItem(TradeSlots slot, Item* item);
@ -998,7 +1025,10 @@ class TradeData
void SetAccepted(bool state, bool crosssend = false);
// must be called only from accept handler helper functions
void SetInAcceptProcess(bool state) { m_acceptProccess = state; }
void SetInAcceptProcess(bool state)
{
m_acceptProccess = state;
}
private: // internal functions
@ -1020,7 +1050,7 @@ class TradeData
ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot
};
class Player : public Unit
class Player : public Unit
{
friend class WorldSession;
friend void Item::AddToUpdateQueueOf(Player* player);
@ -1086,14 +1116,23 @@ class Player : public Unit
void ToggleAFK();
void ToggleDND();
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
bool isAFK() const
{
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
}
bool isDND() const
{
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
}
uint8 GetChatTag() const;
std::string autoReplyMsg;
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint32 newskintone);
PlayerSocial* GetSocial() { return m_social; }
PlayerSocial* GetSocial()
{
return m_social;
}
PlayerTaxi m_taxi;
void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
@ -1102,15 +1141,15 @@ class Player : public Unit
// mount_id can be used in scripting calls
void ContinueTaxiFlight();
bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
void SetAcceptTicket(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
void SetAcceptTicket(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; } else { m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } }
bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
void SetAcceptWhispers(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; } else { m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } }
bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
void SetGameMaster(bool on);
bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
void SetGMChat(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; } else { m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } }
bool IsTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
void SetTaxiCheater(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; } else { m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } }
bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
void SetGMVisible(bool on);
void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
@ -1122,11 +1161,12 @@ class Player : public Unit
m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL);
if (state < 0)
m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY;
{ m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; }
else if (state > 0)
m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL;
{ m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; }
}
void GiveXP(uint32 xp, Unit* victim);
void GiveLevel(uint32 level);
@ -1137,22 +1177,39 @@ class Player : public Unit
time_t m_Last_tick;
uint32 m_Played_time[MAX_PLAYED_TIME_INDEX];
uint32 GetTotalPlayedTime() { return m_Played_time[PLAYED_TIME_TOTAL]; }
uint32 GetLevelPlayedTime() { return m_Played_time[PLAYED_TIME_LEVEL]; }
uint32 GetTotalPlayedTime()
{
return m_Played_time[PLAYED_TIME_TOTAL];
}
uint32 GetLevelPlayedTime()
{
return m_Played_time[PLAYED_TIME_LEVEL];
}
void ResetTimeSync();
void SendTimeSync();
void SetDeathState(DeathState s) override; // overwrite Unit::SetDeathState
float GetRestBonus() const { return m_rest_bonus; }
float GetRestBonus() const
{
return m_rest_bonus;
}
void SetRestBonus(float rest_bonus_new);
RestType GetRestType() const { return rest_type; }
RestType GetRestType() const
{
return rest_type;
}
void SetRestType(RestType n_r_type, uint32 areaTriggerId = 0);
time_t GetTimeInnEnter() const { return time_inn_enter; }
void UpdateInnerTime(time_t time) { time_inn_enter = time; }
time_t GetTimeInnEnter() const
{
return time_inn_enter;
}
void UpdateInnerTime(time_t time)
{
time_inn_enter = time;
}
void RemovePet(PetSaveMode mode);
@ -1181,7 +1238,10 @@ class Player : public Unit
Item* GetItemByPos(uint16 pos) const;
Item* GetItemByPos(uint8 bag, uint8 slot) const;
uint32 GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const;
Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType, false, false); }
Item* GetWeaponForAttack(WeaponAttackType attackType) const
{
return GetWeaponForAttack(attackType, false, false);
}
Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const;
Item* GetShield(bool useable = false) const;
static uint32 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot
@ -1211,7 +1271,7 @@ class Player : public Unit
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const
{
if (!pItem)
return EQUIP_ERR_ITEM_NOT_FOUND;
{ return EQUIP_ERR_ITEM_NOT_FOUND; }
uint32 count = pItem->GetCount();
return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
}
@ -1246,7 +1306,10 @@ class Player : public Unit
void ApplyEquipCooldown(Item* pItem);
void SetAmmo(uint32 item);
void RemoveAmmo();
float GetAmmoDPS() const { return m_ammoDPS; }
float GetAmmoDPS() const
{
return m_ammoDPS;
}
bool CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const;
void QuickEquipItem(uint16 pos, Item* pItem);
void VisualizeItem(uint8 slot, Item* pItem);
@ -1278,10 +1341,22 @@ class Player : public Unit
void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0) const;
void SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param);
void SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param);
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
void AddWeaponProficiency(uint32 newflag)
{
m_WeaponProficiency |= newflag;
}
void AddArmorProficiency(uint32 newflag)
{
m_ArmorProficiency |= newflag;
}
uint32 GetWeaponProficiency() const
{
return m_WeaponProficiency;
}
uint32 GetArmorProficiency() const
{
return m_ArmorProficiency;
}
bool IsTwoHandUsed() const
{
Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
@ -1366,7 +1441,7 @@ class Player : public Unit
void AddQuest(Quest const* pQuest, Object* questGiver);
void CompleteQuest(uint32 quest_id);
void IncompleteQuest(uint32 quest_id);
void RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, bool announce);
void RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, bool announce = true);
void FailQuest(uint32 quest_id);
bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
@ -1509,8 +1584,14 @@ class Player : public Unit
void RegenerateAll(uint32 diff = REGEN_TIME_FULL);
void Regenerate(Powers power, uint32 diff);
void RegenerateHealth(uint32 diff);
void setRegenTimer(uint32 time) {m_regenTimer = time;}
void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
void setRegenTimer(uint32 time)
{
m_regenTimer = time;
}
void setWeaponChangeTimer(uint32 time)
{
m_weaponChangeTimer = time;
}
uint64 GetMoney() const { return GetUInt64Value(PLAYER_FIELD_COINAGE); }
void ModifyMoney(int64 d)
@ -1531,7 +1612,10 @@ class Player : public Unit
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
}
QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
QuestStatusMap& getQuestStatusMap()
{
return mQuestStatus;
};
ObjectGuid const& GetSelectionGuid() const { return m_curSelectionGuid; }
void SetSelectionGuid(ObjectGuid guid) { m_curSelectionGuid = guid; SetTargetGuid(guid); }
@ -1550,12 +1634,24 @@ class Player : public Unit
void RemoveMail(uint32 id);
void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
uint32 GetMailSize() { return m_mail.size(); }
void AddMail(Mail* mail)
{
m_mail.push_front(mail); // for call from WorldSession::SendMailTo
}
uint32 GetMailSize()
{
return m_mail.size();
}
Mail* GetMail(uint32 id);
PlayerMails::iterator GetMailBegin() { return m_mail.begin();}
PlayerMails::iterator GetMailEnd() { return m_mail.end();}
PlayerMails::iterator GetMailBegin()
{
return m_mail.begin();
}
PlayerMails::iterator GetMailEnd()
{
return m_mail.end();
}
/*********************************************************/
/*** MAILED ITEMS SYSTEM ***/
@ -1647,10 +1743,19 @@ class Player : public Unit
void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS, profs); }
void InitPrimaryProfessions();
PlayerSpellMap const& GetSpellMap() const { return m_spells; }
PlayerSpellMap& GetSpellMap() { return m_spells; }
PlayerSpellMap const& GetSpellMap() const
{
return m_spells;
}
PlayerSpellMap& GetSpellMap()
{
return m_spells;
}
SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
SpellCooldowns const& GetSpellCooldownMap() const
{
return m_spellCooldowns;
}
PlayerTalent const* GetKnownTalentById(int32 talentId) const;
SpellEntry const* GetKnownTalentRankById(int32 talentId) const;
@ -1679,8 +1784,10 @@ class Player : public Unit
void RemoveSpellCategoryCooldown(uint32 cat, bool update = false);
void SendClearCooldown(uint32 spell_id, Unit* target);
GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; }
GlobalCooldownMgr& GetGlobalCooldownMgr()
{
return m_GlobalCooldownMgr;
}
void RemoveArenaSpellCooldowns();
void RemoveAllSpellCooldown();
void _LoadSpellCooldowns(QueryResult* result);
@ -1704,8 +1811,14 @@ class Player : public Unit
bool isRessurectRequested() const { return !m_resurrectGuid.IsEmpty(); }
void ResurectUsingRequestData();
uint32 getCinematic() { return m_cinematic; }
void setCinematic(uint32 cine) { m_cinematic = cine; }
uint32 getCinematic()
{
return m_cinematic;
}
void setCinematic(uint32 cine)
{
m_cinematic = cine;
}
static bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player, bool msg = true);
ActionButton* addActionButton(uint8 spec, uint8 button, uint32 action, uint8 type);
@ -1718,7 +1831,10 @@ class Player : public Unit
void UpdatePvP(bool state, bool ovrride = false);
void UpdateZone(uint32 newZone, uint32 newArea);
void UpdateArea(uint32 newArea);
uint32 GetCachedZoneId() const { return m_zoneUpdateId; }
uint32 GetCachedZoneId() const
{
return m_zoneUpdateId;
}
void UpdateZoneDependentAuras();
void UpdateAreaDependentAuras(); // subzones
@ -1727,7 +1843,10 @@ class Player : public Unit
void UpdateAfkReport(time_t currTime);
void UpdatePvPFlag(time_t currTime);
void UpdateContestedPvP(uint32 currTime);
void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
void SetContestedPvPTimer(uint32 newTime)
{
m_contestedPvPTimer = newTime;
}
void ResetContestedPvP()
{
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
@ -1737,7 +1856,10 @@ class Player : public Unit
/** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
DuelInfo* duel;
bool IsInDuelWith(Player const* player) const { return duel && duel->opponent == player && duel->startTime != 0; }
bool IsInDuelWith(Player const* player) const
{
return duel && duel->opponent == player && duel->startTime != 0;
}
void UpdateDuelFlag(time_t currTime);
void CheckDuelDistance(time_t currTime);
void DuelComplete(DuelCompleteType type);
@ -1745,7 +1867,10 @@ class Player : public Unit
bool IsGroupVisibleFor(Player* p) const;
bool IsInSameGroupWith(Player const* p) const;
bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
bool IsInSameRaidWith(Player const* p) const
{
return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup());
}
void UninviteFromGroup();
static void RemoveFromGroup(Group* group, ObjectGuid guid);
void RemoveFromGroup() { RemoveFromGroup(GetGroup(), GetObjectGuid()); }
@ -1858,20 +1983,38 @@ class Player : public Unit
void UpdateArmorSpecializations();
bool FitArmorSpecializationRules(SpellEntry const * spellProto) const;
ObjectGuid const& GetLootGuid() const { return m_lootGuid; }
void SetLootGuid(ObjectGuid const& guid) { m_lootGuid = guid; }
ObjectGuid const& GetLootGuid() const
{
return m_lootGuid;
}
void SetLootGuid(ObjectGuid const& guid)
{
m_lootGuid = guid;
}
void RemovedInsignia(Player* looterPlr);
WorldSession* GetSession() const { return m_session; }
void SetSession(WorldSession* s) { m_session = s; }
WorldSession* GetSession() const
{
return m_session;
}
void SetSession(WorldSession* s)
{
m_session = s;
}
void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override;
void DestroyForPlayer(Player* target, bool anim = false) const override;
void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP);
uint8 LastSwingErrorMsg() const { return m_swingErrorMsg; }
void SwingErrorMsg(uint8 val) { m_swingErrorMsg = val; }
uint8 LastSwingErrorMsg() const
{
return m_swingErrorMsg;
}
void SwingErrorMsg(uint8 val)
{
m_swingErrorMsg = val;
}
// notifiers
void SendAttackSwingCantAttack();
@ -2094,7 +2237,7 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
return true;
{ return true; }
return false;
}
@ -2110,14 +2253,14 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
return i;
{ return i; }
return PLAYER_MAX_BATTLEGROUND_QUEUES;
}
bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
{ return m_bgBattleGroundQueueID[i].invitedToInstance != 0; }
return false;
}
bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
@ -2148,7 +2291,7 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
return true;
{ return true; }
return false;
}
void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
@ -2167,13 +2310,13 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
{ m_bgBattleGroundQueueID[i].invitedToInstance = instanceId; }
}
bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
return true;
{ return true; }
return false;
}
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
@ -2207,7 +2350,7 @@ class Player : public Unit
void SetRestTime(uint32 v) { m_restTime = v; }
/*********************************************************/
/*** ENVIROMENTAL SYSTEM ***/
/*** ENVIRONMENTAL SYSTEM ***/
/*********************************************************/
uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
@ -2612,7 +2755,7 @@ class Player : public Unit
uint32 m_questRewardTalentCount;
// Social
PlayerSocial *m_social;
PlayerSocial* m_social;
// Groups
GroupReference m_group;
@ -2664,7 +2807,7 @@ class Player : public Unit
void ScheduleDelayedOperation(uint32 operation)
{
if (operation < DELAYED_END)
m_DelayedOperations |= operation;
{ m_DelayedOperations |= operation; }
}
void _fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore);

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/**Unit::GetPower
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
@ -27,10 +27,8 @@
* @{
* \file
*/
#ifndef __UNIT_H
#define __UNIT_H
#ifndef MANGOS_H_UNIT
#define MANGOS_H_UNIT
#include "Common.h"
#include "Object.h"
@ -201,7 +199,7 @@ enum UnitStandFlags
enum UnitBytes1_Flags
{
UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01,
UNIT_BYTE1_FLAG_UNK_2 = 0x02, // Creature that can fly and are not on the ground appear to have this flag. If they are on the ground, flag is not present.
UNIT_BYTE1_FLAG_FLY_ANIM = 0x02, // Creature that can fly and are not on the ground appear to have this flag. If they are on the ground, flag is not present.
UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04,
UNIT_BYTE1_FLAG_ALL = 0xFF
};
@ -358,17 +356,20 @@ enum DamageTypeToSchool
DAMAGE_TAKEN
};
/**
* This is what decides how an \ref Aura was removed, the cause of it being removed.
*/
enum AuraRemoveMode
{
AURA_REMOVE_BY_DEFAULT,
AURA_REMOVE_BY_STACK, // at replace by similar aura
AURA_REMOVE_BY_CANCEL,
AURA_REMOVE_BY_DISPEL,
AURA_REMOVE_BY_DEATH,
AURA_REMOVE_BY_DELETE, // use for speedup and prevent unexpected effects at player logout/pet unsummon (must be used _only_ after save), delete.
AURA_REMOVE_BY_SHIELD_BREAK, // when absorb shield is removed by damage, heal absorb debuf
AURA_REMOVE_BY_EXPIRE, // at duration end
AURA_REMOVE_BY_TRACKING, // aura is removed because of a conflicting tracked aura
AURA_REMOVE_BY_STACK, ///< at replace by similar aura
AURA_REMOVE_BY_CANCEL, ///< It was cancelled by the user (needs confirmation)
AURA_REMOVE_BY_DISPEL, ///< It was dispelled by ie Remove Magic
AURA_REMOVE_BY_DEATH, ///< The \ref Unit died and there for it was removed
AURA_REMOVE_BY_DELETE, ///< use for speedup and prevent unexpected effects at player logout/pet unsummon (must be used _only_ after save), delete.
AURA_REMOVE_BY_SHIELD_BREAK, ///< when absorb shield is removed by damage
AURA_REMOVE_BY_EXPIRE, ///< at duration end
AURA_REMOVE_BY_TRACKING ///< aura is removed because of a conflicting tracked aura
};
enum UnitMods
@ -866,10 +867,10 @@ namespace Movement
*/
enum DiminishingLevels
{
DIMINISHING_LEVEL_1 = 0, //< Won't make a difference to stun duration
DIMINISHING_LEVEL_2 = 1, //< Reduces stun time by 50%
DIMINISHING_LEVEL_3 = 2, //< Reduces stun time by 75%
DIMINISHING_LEVEL_IMMUNE = 3 //< The target is immune to the DiminishingGrouop
DIMINISHING_LEVEL_1 = 0, ///<Won't make a difference to stun duration
DIMINISHING_LEVEL_2 = 1, ///<Reduces stun time by 50%
DIMINISHING_LEVEL_3 = 2, ///<Reduces stun time by 75%
DIMINISHING_LEVEL_IMMUNE = 3 ///<The target is immune to the DiminishingGrouop
};
/**
@ -909,14 +910,16 @@ struct DiminishingReturn
uint32 hitCount;
};
// At least some values expected fixed and used in auras field, other custom
/**
* At least some values expected fixed and used in auras field, other custom
*/
enum MeleeHitOutcome
{
MELEE_HIT_EVADE = 0,
MELEE_HIT_MISS = 1,
MELEE_HIT_DODGE = 2, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_BLOCK = 3, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_PARRY = 4, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_DODGE = 2, ///< used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_BLOCK = 3, ///< used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_PARRY = 4, ///< used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_GLANCING = 5,
MELEE_HIT_CRIT = 6,
MELEE_HIT_CRUSHING = 7,
@ -1012,6 +1015,10 @@ struct SpellNonMeleeDamage
uint32 HitInfo;
};
/**
* Used as a convenience struct for the \ref Unit::SendPeriodicAuraLog
* \todo Is it used in more places? Check SpellAuras.cpp for some examples and document it
*/
struct SpellPeriodicAuraLogInfo
{
SpellPeriodicAuraLogInfo(Aura* _aura, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical = false)
@ -1153,6 +1160,11 @@ enum ActionBarIndex
#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
/**
* This structure/class is used when someone is charming (ie: mind control spell and the like)
* someone else, to get the charmed ones action bar, the spells and such. It also takes care
* of pets the charmed one has etc.
*/
struct CharmInfo
{
public:
@ -1680,14 +1692,15 @@ class Unit : public WorldObject
* \see EUnitFields
* \see GetUInt32Value
*/
bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); }
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); }
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); }
bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); }
/**
/**
* Gets the percent of the health. The formula: (GetHealth() * 100) / GetMaxHealth()
* @return the current percent of the health
* \see GetHealth
@ -2185,26 +2198,119 @@ class Unit : public WorldObject
}
bool IsSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); }
/**
* Is this unit flying in taxi?
* @return true if the Unit has the state \ref UNIT_STAT_TAXI_FLIGHT (is flying in taxi), false otherwise
* \see hasUnitState
*/
bool IsTaxiFlying() const { return hasUnitState(UNIT_STAT_TAXI_FLIGHT); }
/**
* Checks to see if a creature, whilst moving along a path, has reached a specific waypoint, or near to
* @param currentPositionX is the creature's current X ordinate in the game world
* @param currentPositionY is the creature's current Y ordinate in the game world
* @param currentPositionZ is the creature's current Z ordinate in the game world
* @param destinationPositionX is the in game ordinate that we wish to check against the creature's current X ordinate (are they the same, or very close?)
* @param destinationPositionY is the in game ordinate that we wish to check against the creature's current Y ordinate (are they the same, or very close?)
* @param destinationPositionZ is the in game ordinate that we wish to check against the creature's current Z ordinate (are they the same, or very close?)
* @param distanceX is the distance from the creature's current X ordinate to the destination X ordinate
* @param distanceY is the distance from the creature's current Y ordinate to the destination Y ordinate
* @param distanceZ is the distance from the creature's current Z ordinate to the destination Z ordinate
*
*/
bool IsNearWaypoint(float currentPositionX, float currentPositionY, float currentPositionZ, float destinationPositionX, float destinationPositionY, float destinationPositionZ, float distanceX, float distanceY, float distanceZ);
/**
* Is this unit in combat?
* @return true if the Unit has the flag \ref UNIT_FLAG_IN_COMBAT (is in combat), false otherwise
* \see EUnitFields
* \see UnitFlags
*/
bool IsInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
/**
* Sets this \ref Unit into combat, if it already was this has no bigger meaning if the
* PvP flag hasn't changed since last time it was applied.
* @param PvP whether this was a PvP combat or not, this is important for how quick the combat flag will wear away and possibly more
* @param enemy Our target that we are attacking, only does something if the attacked one is a creature it seems
* \see ClearInCombat
* \see SetInCombatWith
*/
void SetInCombatState(bool PvP, Unit* enemy = NULL);
/**
* Sets us in combat with the given enemy, this in turn just does a few small checks for if
* it's a duel or PvP and then calls \ref Unit::SetInCombatState with the correct value for
* PvP and enemy
* @param enemy the enemy that we are attacking/engaging
* \see ClearInCombat
* \see SetInCombatState
*/
void SetInCombatWith(Unit* enemy);
/**
* Clears the combat flag for this unit using \ref Object::RemoveFlag and clears
* the Unit state \ref UnitState::UNIT_STAT_ATTACK_PLAYER. This is not where a
* \ref Player s PvP flags are cleared, that is handled in \ref Player::UpdateContestedPvP
* \see EUnitFields
*/
void ClearInCombat();
/**
* Probably returns how long it is until this Unit should get out of PvP combat again,
* although not used in that sense.
* @return the time we have left from our start of PvP combat
* \todo Find out what this actually does/means
*/
uint32 GetCombatTimer() const { return m_CombatTimer; }
/**
* Gets all \ref SpellAuraHolder s that have the same given spell_id
* @param spell_id the spell_id to search for
* @return 2 iterators to the range of \ref SpellAuraHolder s that were found
*/
SpellAuraHolderBounds GetSpellAuraHolderBounds(uint32 spell_id)
{
return m_spellAuraHolders.equal_range(spell_id);
}
/**
* Same as \ref Unit::GetSpellAuraHolderBounds
*/
SpellAuraHolderConstBounds GetSpellAuraHolderBounds(uint32 spell_id) const
{
return m_spellAuraHolders.equal_range(spell_id);
}
/**
* Checks if this \ref Unit has the given AuraType
* @param auraType the type of aura to look for
* @return true if this \ref Unit is affected by the given \ref AuraType, false otherwise
*/
bool HasAuraType(AuraType auraType) const;
/**
* Checks if the given \ref SpellEntry affects the \ref AuraType in some way, this is done
* by calling \ref Aura::isAffectedOnSpell which in turn seems to check if the spellProto
* and the \ref Aura s own \ref SpellEntry have the same \ref SpellEntry::SpellFamilyName.
* (The \ref Aura get's it's \ref SpellEntry by calling \ref Aura::GetSpellProto)
* @param auraType the type of aura we want to check
* @param spellProto the spell we want to check for affecting the aura type
* @return true if the spell affects the given aura type, false otherwise
* \todo Is this actually correct, also, make it more clear what it actually checks
*/
bool HasAffectedAura(AuraType auraType, SpellEntry const* spellProto) const;
/**
* Checks if we have at least one \ref Aura that is associated with the given spell id
* and \ref SpellEffectIndex.
* @param spellId the spell id to look for
* @param effIndex the effect index the \ref Aura should have
* @return true if there was at least one \ref Aura associated with the id that belonged to
* the correct \ref SpellEffectIndex, false otherwise
*/
bool HasAura(uint32 spellId, SpellEffectIndex effIndex) const;
/**
* Checks if we have at least one \ref Aura that is associated with the given spell id via
* the \ref Unit::m_spellAuraHolders multimap. Generalized version of the other
* \ref Unit::HasAura
* @param spellId the spell id to look for
* @return true if there was at least one \ref Aura associated with the id, false otherwise
*/
bool HasAura(uint32 spellId) const
{
return m_spellAuraHolders.find(spellId) != m_spellAuraHolders.end();
@ -3197,7 +3303,7 @@ class Unit : public WorldObject
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
// at any changes to scale and/or displayId
// at any changes to Scale and/or displayId
void UpdateModelData();
DynamicObject* GetDynObject(uint32 spellId, SpellEffectIndex effIndex);