Misc optimizations and changes.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
DROP PROCEDURE IF EXISTS add_migration;
|
||||
delimiter ??
|
||||
CREATE PROCEDURE `add_migration`()
|
||||
BEGIN
|
||||
DECLARE v INT DEFAULT 1;
|
||||
SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20200223110513');
|
||||
IF v=0 THEN
|
||||
INSERT INTO `migrations` VALUES ('20200223110513');
|
||||
-- Add your query below.
|
||||
|
||||
|
||||
-- These mobs shouldn't have a forced display id.
|
||||
UPDATE `creature` SET `display_id`=0 WHERE `id2`!=0 && `display_id`!=0;
|
||||
|
||||
|
||||
-- End of migration.
|
||||
END IF;
|
||||
END??
|
||||
delimiter ;
|
||||
CALL add_migration();
|
||||
DROP PROCEDURE IF EXISTS add_migration;
|
||||
@@ -145,7 +145,7 @@ bool PetEventAI::FindTargetForAttack()
|
||||
}
|
||||
}
|
||||
|
||||
Unit* pOwner = m_creature->GetCharmerOrOwner();
|
||||
Unit const* pOwner = m_creature->GetCharmerOrOwner();
|
||||
|
||||
if (!pOwner)
|
||||
return false;
|
||||
@@ -178,14 +178,13 @@ bool PetEventAI::FindTargetForAttack()
|
||||
|
||||
void PetEventAI::UpdateAI(uint32 const uiDiff)
|
||||
{
|
||||
bool bHasVictim = m_creature->GetVictim();
|
||||
|
||||
//Must return if creature isn't alive. Normally select hostile target and get victim prevent this
|
||||
if (!m_creature->IsAlive())
|
||||
return;
|
||||
|
||||
Unit* pOwner = m_creature->GetCharmerOrOwner();
|
||||
bool hasAliveOwner = pOwner && pOwner->IsAlive() && m_creature->GetCharmInfo();
|
||||
Unit const* pOwner = m_creature->GetCharmerOrOwner();
|
||||
bool const hasAliveOwner = pOwner && pOwner->IsAlive() && m_creature->GetCharmInfo();
|
||||
bool bHasVictim = m_creature->GetVictim();
|
||||
|
||||
if (!bHasVictim && (m_creature->IsInCombat() || (hasAliveOwner && pOwner->IsInCombat())))
|
||||
{
|
||||
|
||||
@@ -340,7 +340,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/)
|
||||
return;
|
||||
}
|
||||
|
||||
//instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
|
||||
// instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
|
||||
if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->IsTaxiFlying() ||
|
||||
GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_INSTANT_LOGOUT))
|
||||
{
|
||||
@@ -603,17 +603,17 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recv_data)
|
||||
|
||||
DEBUG_LOG("WORLD: Received CMSG_ADD_IGNORE");
|
||||
|
||||
std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
|
||||
std::string ignoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
|
||||
|
||||
recv_data >> IgnoreName;
|
||||
recv_data >> ignoreName;
|
||||
|
||||
if (!normalizePlayerName(IgnoreName))
|
||||
if (!normalizePlayerName(ignoreName))
|
||||
return;
|
||||
|
||||
DEBUG_LOG("WORLD: %s asked to Ignore: '%s'",
|
||||
GetMasterPlayer()->GetName(), IgnoreName.c_str());
|
||||
GetMasterPlayer()->GetName(), ignoreName.c_str());
|
||||
|
||||
PlayerCacheData *pData = sObjectMgr.GetPlayerDataByName(IgnoreName);
|
||||
PlayerCacheData *pData = sObjectMgr.GetPlayerDataByName(ignoreName);
|
||||
if (!pData)
|
||||
return;
|
||||
|
||||
@@ -971,18 +971,18 @@ void WorldSession::HandleNextCinematicCamera(WorldPacket& /*recv_data*/)
|
||||
|
||||
void WorldSession::HandleSetActionBarTogglesOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
uint8 ActionBar;
|
||||
uint8 actionBar;
|
||||
|
||||
recv_data >> ActionBar;
|
||||
recv_data >> actionBar;
|
||||
|
||||
if (!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
|
||||
{
|
||||
if (ActionBar != 0)
|
||||
sLog.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(ActionBar));
|
||||
if (actionBar != 0)
|
||||
sLog.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(actionBar));
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar);
|
||||
GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, actionBar);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePlayedTime(WorldPacket& /*recv_data*/)
|
||||
@@ -1010,7 +1010,8 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) {
|
||||
void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
recv_data >> guid;
|
||||
// DEBUG_LOG("Party Stats guid is " I64FMTD,guid);
|
||||
@@ -1076,18 +1077,18 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data)
|
||||
// Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593
|
||||
|
||||
uint32 time;
|
||||
uint32 mapid;
|
||||
float PositionX;
|
||||
float PositionY;
|
||||
float PositionZ;
|
||||
float Orientation;
|
||||
uint32 mapId;
|
||||
float positionX;
|
||||
float positionY;
|
||||
float positionZ;
|
||||
float orientation;
|
||||
|
||||
recv_data >> time; // time in m.sec.
|
||||
recv_data >> mapid;
|
||||
recv_data >> PositionX;
|
||||
recv_data >> PositionY;
|
||||
recv_data >> PositionZ;
|
||||
recv_data >> Orientation; // o (3.141593 = 180 degrees)
|
||||
recv_data >> mapId;
|
||||
recv_data >> positionX;
|
||||
recv_data >> positionY;
|
||||
recv_data >> positionZ;
|
||||
recv_data >> orientation; // o (3.141593 = 180 degrees)
|
||||
|
||||
//DEBUG_LOG("Received opcode CMSG_WORLD_TELEPORT");
|
||||
|
||||
@@ -1097,10 +1098,10 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time / 1000, mapid, PositionX, PositionY, PositionZ, Orientation);
|
||||
DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time / 1000, mapId, positionX, positionY, positionZ, orientation);
|
||||
|
||||
if (GetSecurity() >= SEC_ADMINISTRATOR)
|
||||
GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation);
|
||||
GetPlayer()->TeleportTo(mapId, positionX, positionY, positionZ, orientation);
|
||||
else
|
||||
SendNotification(LANG_YOU_NOT_HAVE_PERMISSION);
|
||||
DEBUG_LOG("Received worldport command from player %s", GetPlayer()->GetName());
|
||||
@@ -1187,7 +1188,6 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
||||
void WorldSession::HandleFarSightOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
DEBUG_LOG("WORLD: CMSG_FAR_SIGHT");
|
||||
//recv_data.hexlike();
|
||||
|
||||
uint8 op;
|
||||
recv_data >> op;
|
||||
|
||||
@@ -168,18 +168,17 @@ bool CreatureCreatePos::Relocate(Creature* cr) const
|
||||
Creature::Creature(CreatureSubtype subtype) :
|
||||
Unit(), i_AI(nullptr),
|
||||
loot(this), lootForPickPocketed(false), lootForBody(false), lootForSkin(false), skinningForOthersTimer(5000), m_TargetNotReachableTimer(0),
|
||||
_pacifiedTimer(0), m_manaRegen(0),
|
||||
m_pacifiedTimer(0), m_manaRegen(0),
|
||||
m_groupLootTimer(0), m_groupLootId(0), m_lootMoney(0), m_lootGroupRecipientId(0), m_corpseDecayTimer(0),
|
||||
m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60),
|
||||
m_wanderDistance(5.0f), m_combatStartTime(0), m_combatState(false), m_combatResetCount(0), m_subtype(subtype),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), m_AlreadyCallAssistance(false),
|
||||
m_AlreadySearchedAssistance(false),
|
||||
m_bRegenHealth(true), m_bRegenMana(true), m_AI_locked(false), m_temporaryFactionFlags(TEMPFACTION_NONE),
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), _creatureGroup(nullptr),
|
||||
m_wanderDistance(5.0f), m_combatStartTime(0), m_combatResetCount(0), m_subtype(subtype),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), m_creatureStateFlags(0),
|
||||
m_AI_locked(false), m_temporaryFactionFlags(TEMPFACTION_NONE),
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_creatureGroup(nullptr),
|
||||
m_combatStartX(0.0f), m_combatStartY(0.0f), m_combatStartZ(0.0f), m_reactState(REACT_PASSIVE),
|
||||
_lastDamageTakenForEvade(0), _playerDamageTaken(0), _nonPlayerDamageTaken(0), m_creatureInfo(nullptr),
|
||||
m_AI_InitializeOnRespawn(false), m_detectionDistance(20.0f), m_callForHelpDist(5.0f), m_leashDistance(0.0f), m_combatWithZoneState(false), m_mountId(0),
|
||||
_isEscortable(false), m_reputationId(-1), m_castingTargetGuid(0)
|
||||
m_lastDamageTakenForEvade(0), m_playerDamageTaken(0), m_nonPlayerDamageTaken(0), m_creatureInfo(nullptr),
|
||||
m_detectionDistance(20.0f), m_callForHelpDist(5.0f), m_leashDistance(0.0f), m_mountId(0),
|
||||
m_reputationId(-1), m_castingTargetGuid(0)
|
||||
{
|
||||
m_regenTimer = 200;
|
||||
m_valuesCount = UNIT_END;
|
||||
@@ -206,8 +205,8 @@ void Creature::AddToWorld()
|
||||
if (!IsInWorld() && GetObjectGuid().GetHigh() == HIGHGUID_UNIT)
|
||||
GetMap()->InsertObject<Creature>(GetObjectGuid(), this);
|
||||
|
||||
sCreatureGroupsManager->LoadCreatureGroup(this, _creatureGroup);
|
||||
if (_creatureGroup && _creatureGroup->IsFormation())
|
||||
sCreatureGroupsManager->LoadCreatureGroup(this, m_creatureGroup);
|
||||
if (m_creatureGroup && m_creatureGroup->IsFormation())
|
||||
SetActiveObjectState(true);
|
||||
Unit::AddToWorld();
|
||||
|
||||
@@ -468,8 +467,15 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, CreatureData const* data /*=
|
||||
LoadCreatureAddon(true);
|
||||
}
|
||||
|
||||
m_bRegenHealth = GetCreatureInfo()->regeneration & REGEN_FLAG_HEALTH;
|
||||
m_bRegenMana = GetCreatureInfo()->regeneration & REGEN_FLAG_POWER;
|
||||
if (GetCreatureInfo()->regeneration & REGEN_FLAG_HEALTH)
|
||||
AddCreatureState(CSTATE_REGEN_HEALTH);
|
||||
else
|
||||
ClearCreatureState(CSTATE_REGEN_HEALTH);
|
||||
|
||||
if (GetCreatureInfo()->regeneration & REGEN_FLAG_POWER)
|
||||
AddCreatureState(CSTATE_REGEN_MANA);
|
||||
else
|
||||
ClearCreatureState(CSTATE_REGEN_MANA);
|
||||
|
||||
// creatures always have melee weapon ready if any
|
||||
SetSheath(SHEATH_STATE_MELEE);
|
||||
@@ -661,7 +667,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
||||
|
||||
// If the creature AI needs to be re-initialized after respawn, do it now
|
||||
// Useful for swapping AIs on mobs that change entry on respawn
|
||||
if (m_AI_InitializeOnRespawn)
|
||||
if (HasCreatureState(CSTATE_INIT_AI_ON_RESPAWN))
|
||||
AIM_Initialize();
|
||||
}
|
||||
|
||||
@@ -750,12 +756,12 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
||||
m_corpseDecayTimer -= update_diff;
|
||||
}
|
||||
|
||||
if (_pacifiedTimer <= update_diff)
|
||||
_pacifiedTimer = 0;
|
||||
if (m_pacifiedTimer <= update_diff)
|
||||
m_pacifiedTimer = 0;
|
||||
else
|
||||
_pacifiedTimer -= update_diff;
|
||||
m_pacifiedTimer -= update_diff;
|
||||
|
||||
_lastDamageTakenForEvade += update_diff;
|
||||
m_lastDamageTakenForEvade += update_diff;
|
||||
Unit::Update(update_diff, diff);
|
||||
|
||||
if (GetVictim())
|
||||
@@ -800,7 +806,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
||||
m_TargetNotReachableTimer = 0;
|
||||
|
||||
bool leash = false;
|
||||
if (m_combatState)
|
||||
if (HasCreatureState(CSTATE_COMBAT))
|
||||
{
|
||||
if (GetCombatTime(false) > sWorld.getConfig(CONFIG_UINT32_LONGCOMBAT))
|
||||
{
|
||||
@@ -814,7 +820,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
||||
if (m_leashDistance && !IsWithinDist3d(m_combatStartX, m_combatStartY, m_combatStartZ, m_leashDistance))
|
||||
leash = true;
|
||||
// Raid bosses do a periodic combat pulse
|
||||
else if (m_combatWithZoneState)
|
||||
else if (HasCreatureState(CSTATE_COMBAT_WITH_ZONE))
|
||||
SetInCombatWithZone(false);
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1033,7 @@ bool Creature::AIM_Initialize()
|
||||
}
|
||||
|
||||
// Clear flag. Escort AI will set it if this creature is escortable
|
||||
_isEscortable = false;
|
||||
SetEscortable(false);
|
||||
|
||||
i_motionMaster.Initialize();
|
||||
|
||||
@@ -1688,7 +1694,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map)
|
||||
|
||||
// We need to assign new AI on respawn if spawn has multiple creature ids
|
||||
if (data->GetCreatureIdCount() > 1)
|
||||
m_AI_InitializeOnRespawn = true;
|
||||
AddCreatureState(CSTATE_INIT_AI_ON_RESPAWN);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2114,7 +2120,7 @@ void Creature::SendAIReaction(AiReaction reactionType)
|
||||
|
||||
void Creature::CallAssistance()
|
||||
{
|
||||
if (!m_AlreadyCallAssistance && GetVictim() && !IsPet() && !IsCharmed())
|
||||
if (!HasCreatureState(CSTATE_ALREADY_CALL_ASSIST) && GetVictim() && !IsPet() && !IsCharmed())
|
||||
{
|
||||
SetNoCallAssistance(true);
|
||||
|
||||
@@ -2347,7 +2353,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const
|
||||
//Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick.
|
||||
float threatAreaDistance = ThreatRadius > AttackDist ? ThreatRadius : AttackDist;
|
||||
bool inThreatArea = pVictim->IsWithinDist3d(m_combatStartX, m_combatStartY, m_combatStartZ, threatAreaDistance);
|
||||
if (!inThreatArea && _lastDamageTakenForEvade > 12000)
|
||||
if (!inThreatArea && m_lastDamageTakenForEvade > 12000)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2469,7 +2475,7 @@ void Creature::SetInCombatWithZone(bool initialPulse)
|
||||
if (PlList.isEmpty())
|
||||
return;
|
||||
|
||||
if (!m_combatWithZoneState)
|
||||
if (!HasCreatureState(CSTATE_COMBAT_WITH_ZONE))
|
||||
UpdateCombatWithZoneState(true);
|
||||
|
||||
for (const auto& i : PlList)
|
||||
@@ -3143,8 +3149,8 @@ void Creature::OnLeaveCombat()
|
||||
UpdateCombatState(false);
|
||||
UpdateCombatWithZoneState(false);
|
||||
|
||||
if (_creatureGroup)
|
||||
_creatureGroup->OnLeaveCombat(this);
|
||||
if (m_creatureGroup)
|
||||
m_creatureGroup->OnLeaveCombat(this);
|
||||
|
||||
if (i_AI)
|
||||
i_AI->EnterEvadeMode();
|
||||
@@ -3161,8 +3167,8 @@ void Creature::OnEnterCombat(Unit* pWho, bool notInCombat)
|
||||
if (i_AI && !HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING))
|
||||
i_AI->AttackedBy(pWho);
|
||||
|
||||
if (_creatureGroup)
|
||||
_creatureGroup->OnMemberAttackStart(this, pWho);
|
||||
if (m_creatureGroup)
|
||||
m_creatureGroup->OnMemberAttackStart(this, pWho);
|
||||
|
||||
if (notInCombat)
|
||||
{
|
||||
@@ -3170,7 +3176,7 @@ void Creature::OnEnterCombat(Unit* pWho, bool notInCombat)
|
||||
UpdateCombatState(true);
|
||||
|
||||
SetStandState(UNIT_STAND_STATE_STAND);
|
||||
_pacifiedTimer = 0;
|
||||
m_pacifiedTimer = 0;
|
||||
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnCreatureEnterCombat(this);
|
||||
|
||||
+84
-40
@@ -327,6 +327,19 @@ enum RegenStatsFlags
|
||||
REGEN_FLAG_POWER = 0x002,
|
||||
};
|
||||
|
||||
// Change to uint16 if adding more flags!
|
||||
enum CreatureStateFlag : uint8
|
||||
{
|
||||
CSTATE_ALREADY_CALL_ASSIST = 0x01,
|
||||
CSTATE_ALREADY_SEARCH_ASSIST = 0x02,
|
||||
CSTATE_REGEN_HEALTH = 0x04,
|
||||
CSTATE_REGEN_MANA = 0x08,
|
||||
CSTATE_INIT_AI_ON_RESPAWN = 0x10,
|
||||
CSTATE_COMBAT = 0x20,
|
||||
CSTATE_COMBAT_WITH_ZONE = 0x40,
|
||||
CSTATE_ESCORTABLE = 0x80,
|
||||
};
|
||||
|
||||
// Vendors
|
||||
struct VendorItem
|
||||
{
|
||||
@@ -503,8 +516,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
void UnloadCreatureAddon(CreatureDataAddon const* data);
|
||||
|
||||
// CreatureGroups
|
||||
CreatureGroup* GetCreatureGroup() const { return _creatureGroup; }
|
||||
void SetCreatureGroup(CreatureGroup* group) { _creatureGroup = group; }
|
||||
CreatureGroup* GetCreatureGroup() const { return m_creatureGroup; }
|
||||
void SetCreatureGroup(CreatureGroup* group) { m_creatureGroup = group; }
|
||||
void JoinCreatureGroup(Creature* leader, float dist, float angle, uint32 options);
|
||||
void LeaveCreatureGroup();
|
||||
uint32 GetSpawnFlags() const;
|
||||
@@ -537,6 +550,10 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
float GetHomePositionO() const { return m_homePosition.o; }
|
||||
void ResetHomePosition();
|
||||
|
||||
void AddCreatureState(CreatureStateFlag f) { m_creatureStateFlags |= f; }
|
||||
bool HasCreatureState(CreatureStateFlag f) const { return m_creatureStateFlags & f; }
|
||||
void ClearCreatureState(CreatureStateFlag f) { m_creatureStateFlags &= ~f; }
|
||||
|
||||
CreatureSubtype GetSubtype() const { return m_subtype; }
|
||||
bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
|
||||
bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
|
||||
@@ -611,7 +628,13 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
|
||||
CreatureAI* AI() { return i_AI; }
|
||||
CreatureAI const* AI() const { return i_AI; }
|
||||
void SetAInitializeOnRespawn(bool initialize) { m_AI_InitializeOnRespawn = initialize; }
|
||||
void SetAInitializeOnRespawn(bool initialize)
|
||||
{
|
||||
if (initialize)
|
||||
AddCreatureState(CSTATE_INIT_AI_ON_RESPAWN);
|
||||
else
|
||||
ClearCreatureState(CSTATE_INIT_AI_ON_RESPAWN);
|
||||
}
|
||||
|
||||
uint32 GetShieldBlockValue() const override
|
||||
{
|
||||
@@ -704,9 +727,21 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
void MoveAwayFromTarget(Unit* pTarget, float distance);
|
||||
void CallForHelp(float fRadius);
|
||||
void CallAssistance();
|
||||
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
|
||||
void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
|
||||
bool HasSearchedAssistance() const { return m_AlreadySearchedAssistance; }
|
||||
void SetNoCallAssistance(bool val)
|
||||
{
|
||||
if (val)
|
||||
AddCreatureState(CSTATE_ALREADY_CALL_ASSIST);
|
||||
else
|
||||
ClearCreatureState(CSTATE_ALREADY_CALL_ASSIST);
|
||||
}
|
||||
void SetNoSearchAssistance(bool val)
|
||||
{
|
||||
if (val)
|
||||
AddCreatureState(CSTATE_ALREADY_SEARCH_ASSIST);
|
||||
else
|
||||
ClearCreatureState(CSTATE_ALREADY_SEARCH_ASSIST);
|
||||
}
|
||||
bool HasSearchedAssistance() const { return HasCreatureState(CSTATE_ALREADY_SEARCH_ASSIST); }
|
||||
bool CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction = true) const;
|
||||
bool CanInitiateAttack();
|
||||
bool CanHaveTarget() const { return !(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_TARGET); }
|
||||
@@ -761,8 +796,21 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
// Smartlog
|
||||
time_t GetCombatTime(bool total) const;
|
||||
void ResetCombatTime(bool combat = false);
|
||||
void UpdateCombatState(bool combat) { m_combatState = combat; }
|
||||
void UpdateCombatWithZoneState(bool combat) { m_combatWithZoneState = combat; }
|
||||
void UpdateCombatState(bool combat)
|
||||
{
|
||||
if (combat)
|
||||
AddCreatureState(CSTATE_COMBAT);
|
||||
else
|
||||
ClearCreatureState(CSTATE_COMBAT);
|
||||
}
|
||||
// For raid bosses that set the entire raid in combat
|
||||
void UpdateCombatWithZoneState(bool combat)
|
||||
{
|
||||
if (combat)
|
||||
AddCreatureState(CSTATE_COMBAT_WITH_ZONE);
|
||||
else
|
||||
ClearCreatureState(CSTATE_COMBAT_WITH_ZONE);
|
||||
}
|
||||
void LogDeath(Unit* pKiller) const;
|
||||
void LogLongCombat() const;
|
||||
void LogScriptInfo(std::ostringstream &data) const;
|
||||
@@ -828,8 +876,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
uint32 GetDefaultGossipMenuId() const override { return GetCreatureInfo()->gossip_menu_id; }
|
||||
|
||||
GridReference<Creature>& GetGridRef() { return m_gridRef; }
|
||||
bool IsRegeneratingHealth() const { return m_bRegenHealth; }
|
||||
bool IsRegeneratingMana() const { return m_bRegenMana; }
|
||||
bool IsRegeneratingHealth() const { return HasCreatureState(CSTATE_REGEN_HEALTH); }
|
||||
bool IsRegeneratingMana() const { return HasCreatureState(CSTATE_REGEN_MANA); }
|
||||
virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
||||
{
|
||||
@@ -859,15 +907,14 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
// Auto evade timer (if target not reachable)
|
||||
// Tested on retail 5.4.0: Creatures evade after 3 seconds (but does not return to home position)
|
||||
bool IsEvadeBecauseTargetNotReachable() const { return m_TargetNotReachableTimer > 3000; }
|
||||
uint32 GetLastDamageTakenTime() const { return _lastDamageTakenForEvade; }
|
||||
void ResetLastDamageTakenTime() { _lastDamageTakenForEvade = 0; }
|
||||
uint32 GetLastDamageTakenTime() const { return m_lastDamageTakenForEvade; }
|
||||
void ResetLastDamageTakenTime() { m_lastDamageTakenForEvade = 0; }
|
||||
uint32 m_TargetNotReachableTimer;
|
||||
|
||||
bool IsTempPacified() const { return _pacifiedTimer > 0; }
|
||||
void SetTempPacified(uint32 timer) { if (_pacifiedTimer < timer) _pacifiedTimer = timer; }
|
||||
uint32 GetTempPacifiedTimer() const { return _pacifiedTimer; }
|
||||
uint32 _pacifiedTimer;
|
||||
void AllowManaRegen(bool v) { m_bRegenMana = v; }
|
||||
bool IsTempPacified() const { return m_pacifiedTimer > 0; }
|
||||
void SetTempPacified(uint32 timer) { if (m_pacifiedTimer < timer) m_pacifiedTimer = timer; }
|
||||
uint32 GetTempPacifiedTimer() const { return m_pacifiedTimer; }
|
||||
uint32 m_pacifiedTimer;
|
||||
uint32 m_manaRegen;
|
||||
|
||||
void RegenerateHealth();
|
||||
@@ -877,21 +924,21 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
|
||||
void ResetDamageTakenOrigin()
|
||||
{
|
||||
_playerDamageTaken = 0;
|
||||
_nonPlayerDamageTaken = 0;
|
||||
m_playerDamageTaken = 0;
|
||||
m_nonPlayerDamageTaken = 0;
|
||||
}
|
||||
|
||||
void CountDamageTaken(uint32 damage, bool fromPlayerOrSelf)
|
||||
{
|
||||
if (fromPlayerOrSelf)
|
||||
_playerDamageTaken += damage;
|
||||
m_playerDamageTaken += damage;
|
||||
else
|
||||
_nonPlayerDamageTaken += damage;
|
||||
m_nonPlayerDamageTaken += damage;
|
||||
}
|
||||
|
||||
bool IsLootAllowedDueToDamageOrigin() const
|
||||
{
|
||||
return 65*_playerDamageTaken > 35*_nonPlayerDamageTaken;
|
||||
return 65 * m_playerDamageTaken > 35 * m_nonPlayerDamageTaken;
|
||||
}
|
||||
|
||||
float GetXPModifierDueToDamageOrigin() const
|
||||
@@ -899,7 +946,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
// If players dealt less than 35% of the damage, no XP and no loot - or both=0
|
||||
if (!IsLootAllowedDueToDamageOrigin())
|
||||
return 0.0f;
|
||||
return float(_playerDamageTaken) / (_playerDamageTaken + _nonPlayerDamageTaken);
|
||||
return float(m_playerDamageTaken) / (m_playerDamageTaken + m_nonPlayerDamageTaken);
|
||||
}
|
||||
|
||||
bool HasWeapon() const;
|
||||
@@ -922,8 +969,14 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
// (msecs)timer used for group loot
|
||||
uint32 GetGroupLootTimer() { return m_groupLootTimer; }
|
||||
|
||||
void SetEscortable(bool escortable) { _isEscortable = escortable; }
|
||||
bool IsEscortable() const { return _isEscortable; }
|
||||
void SetEscortable(bool escortable)
|
||||
{
|
||||
if (escortable)
|
||||
AddCreatureState(CSTATE_ESCORTABLE);
|
||||
else
|
||||
ClearCreatureState(CSTATE_ESCORTABLE);
|
||||
}
|
||||
bool IsEscortable() const { return HasCreatureState(CSTATE_ESCORTABLE); }
|
||||
bool CanAssistPlayers() { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CAN_ASSIST; }
|
||||
|
||||
bool CanSummonGuards() { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_SUMMON_GUARD; }
|
||||
@@ -954,9 +1007,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
float m_wanderDistance;
|
||||
|
||||
time_t m_combatStartTime;
|
||||
bool m_combatState;
|
||||
uint32 m_combatResetCount;
|
||||
bool m_combatWithZoneState; // for raid bosses that set the entire raid in combat
|
||||
|
||||
CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use
|
||||
MovementGeneratorType m_defaultMovementType;
|
||||
@@ -964,20 +1015,15 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
uint32 m_equipmentId;
|
||||
uint32 m_mountId; // display Id to mount
|
||||
|
||||
// below fields has potential for optimization
|
||||
bool m_AlreadyCallAssistance;
|
||||
bool m_AlreadySearchedAssistance;
|
||||
bool m_bRegenHealth;
|
||||
bool m_bRegenMana;
|
||||
bool m_AI_locked;
|
||||
bool m_AI_InitializeOnRespawn;
|
||||
uint8 m_creatureStateFlags; // change this to uint16 if adding more state flags
|
||||
uint32 m_temporaryFactionFlags; // used for real faction changes (not auras etc)
|
||||
int32 m_reputationId; // Id of the creature's faction in the client reputations list.
|
||||
int32 m_reputationId; // Id of the creature's faction in the client reputations list.
|
||||
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
uint32 m_originalEntry;
|
||||
|
||||
CreatureGroup* _creatureGroup;
|
||||
CreatureGroup* m_creatureGroup;
|
||||
|
||||
float m_combatStartX;
|
||||
float m_combatStartY;
|
||||
@@ -989,17 +1035,15 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||
|
||||
Position m_summonPos;
|
||||
|
||||
uint32 _lastDamageTakenForEvade;
|
||||
uint32 m_lastDamageTakenForEvade;
|
||||
// Used to compute XP.
|
||||
uint32 _playerDamageTaken;
|
||||
uint32 _nonPlayerDamageTaken;
|
||||
uint32 m_playerDamageTaken;
|
||||
uint32 m_nonPlayerDamageTaken;
|
||||
|
||||
float m_callForHelpDist;
|
||||
float m_leashDistance;
|
||||
float m_detectionDistance;
|
||||
|
||||
bool _isEscortable;
|
||||
|
||||
private:
|
||||
GridReference<Creature> m_gridRef;
|
||||
CreatureInfo const* m_creatureInfo;
|
||||
|
||||
+19
-19
@@ -7722,8 +7722,8 @@ CharmInfo* Unit::InitCharmInfo(Unit* charm)
|
||||
|
||||
CharmInfo::CharmInfo(Unit* unit)
|
||||
: m_unit(unit), m_originalFactionTemplate(nullptr), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0),
|
||||
_isCommandAttack(false), _isCommandFollow(false), _isAtStay(false), _isFollowing(false), _isReturning(false),
|
||||
_stayX(0.0f), _stayY(0.0f), _stayZ(0.0f)
|
||||
m_isCommandAttack(false), m_isCommandFollow(false), m_isAtStay(false), m_isFollowing(false), m_isReturning(false),
|
||||
m_stayX(0.0f), m_stayY(0.0f), m_stayZ(0.0f)
|
||||
{
|
||||
for (auto& itr : m_charmspells)
|
||||
itr.SetActionAndType(0, ACT_DISABLED);
|
||||
@@ -7951,73 +7951,73 @@ void CharmInfo::SetSpellAutocast(uint32 spell_id, bool state)
|
||||
|
||||
void CharmInfo::SetIsCommandAttack(bool val)
|
||||
{
|
||||
_isCommandAttack = val;
|
||||
m_isCommandAttack = val;
|
||||
}
|
||||
|
||||
bool CharmInfo::IsCommandAttack()
|
||||
{
|
||||
return _isCommandAttack;
|
||||
return m_isCommandAttack;
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsCommandFollow(bool val)
|
||||
{
|
||||
_isCommandFollow = val;
|
||||
m_isCommandFollow = val;
|
||||
}
|
||||
|
||||
bool CharmInfo::IsCommandFollow()
|
||||
{
|
||||
return _isCommandFollow;
|
||||
return m_isCommandFollow;
|
||||
}
|
||||
|
||||
void CharmInfo::SaveStayPosition()
|
||||
{
|
||||
// No Unit::StopMoving while possessed
|
||||
if (m_unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
|
||||
m_unit->GetPosition(_stayX, _stayY, _stayZ);
|
||||
m_unit->GetPosition(m_stayX, m_stayY, m_stayZ);
|
||||
else //! At this point a new spline destination is enabled because of Unit::StopMoving()
|
||||
{
|
||||
G3D::Vector3 stayPos = m_unit->movespline->FinalDestination();
|
||||
_stayX = stayPos.x;
|
||||
_stayY = stayPos.y;
|
||||
_stayZ = stayPos.z;
|
||||
m_stayX = stayPos.x;
|
||||
m_stayY = stayPos.y;
|
||||
m_stayZ = stayPos.z;
|
||||
}
|
||||
}
|
||||
|
||||
void CharmInfo::GetStayPosition(float &x, float &y, float &z)
|
||||
{
|
||||
x = _stayX;
|
||||
y = _stayY;
|
||||
z = _stayZ;
|
||||
x = m_stayX;
|
||||
y = m_stayY;
|
||||
z = m_stayZ;
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsAtStay(bool val)
|
||||
{
|
||||
_isAtStay = val;
|
||||
m_isAtStay = val;
|
||||
}
|
||||
|
||||
bool CharmInfo::IsAtStay()
|
||||
{
|
||||
return _isAtStay;
|
||||
return m_isAtStay;
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsFollowing(bool val)
|
||||
{
|
||||
_isFollowing = val;
|
||||
m_isFollowing = val;
|
||||
}
|
||||
|
||||
bool CharmInfo::IsFollowing()
|
||||
{
|
||||
return _isFollowing;
|
||||
return m_isFollowing;
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsReturning(bool val)
|
||||
{
|
||||
_isReturning = val;
|
||||
m_isReturning = val;
|
||||
}
|
||||
|
||||
bool CharmInfo::IsReturning()
|
||||
{
|
||||
return _isReturning;
|
||||
return m_isReturning;
|
||||
}
|
||||
|
||||
uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition)
|
||||
|
||||
@@ -183,7 +183,7 @@ extern pAuraProcHandler AuraProcHandler[TOTAL_AURAS];
|
||||
|
||||
struct GlobalCooldown
|
||||
{
|
||||
explicit GlobalCooldown(uint32 _dur = 0, uint32 _time = 0) : duration(_dur), cast_time(_time) {}
|
||||
explicit GlobalCooldown(uint32 dur = 0, uint32 time = 0) : duration(dur), cast_time(time) {}
|
||||
|
||||
uint32 duration;
|
||||
uint32 cast_time;
|
||||
@@ -321,14 +321,14 @@ private:
|
||||
ReactStates m_reactState;
|
||||
uint32 m_petnumber;
|
||||
|
||||
bool _isCommandAttack;
|
||||
bool _isCommandFollow;
|
||||
bool _isAtStay;
|
||||
bool _isFollowing;
|
||||
bool _isReturning;
|
||||
float _stayX;
|
||||
float _stayY;
|
||||
float _stayZ;
|
||||
bool m_isCommandAttack;
|
||||
bool m_isCommandFollow;
|
||||
bool m_isAtStay;
|
||||
bool m_isFollowing;
|
||||
bool m_isReturning;
|
||||
float m_stayX;
|
||||
float m_stayY;
|
||||
float m_stayZ;
|
||||
};
|
||||
|
||||
typedef std::set<ObjectGuid> GuardianPetList;
|
||||
|
||||
@@ -1297,7 +1297,7 @@ struct npc_Emissary_RomankhanAI : public ScriptedAI
|
||||
m_uiSanityTimer = 1;
|
||||
m_uiCheckPlayerTimer = 1000;
|
||||
m_bNeedCheck = false;
|
||||
m_creature->AllowManaRegen(false);
|
||||
m_creature->ClearCreatureState(CSTATE_REGEN_MANA);
|
||||
m_creature->SetPower(POWER_MANA, 0);
|
||||
|
||||
for (uint64 & guid : PlayerGuids)
|
||||
@@ -1318,7 +1318,7 @@ struct npc_Emissary_RomankhanAI : public ScriptedAI
|
||||
|
||||
void Aggro(Unit* pWho) override
|
||||
{
|
||||
m_creature->AllowManaRegen(true);
|
||||
m_creature->AddCreatureState(CSTATE_REGEN_MANA);
|
||||
}
|
||||
|
||||
inline float GetManaPercent()
|
||||
|
||||
Reference in New Issue
Block a user