Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticFlags: Implement CreatureTypeFlags from StaticFlags #546

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/game/AI/BaseAI/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CreatureAI::CreatureAI(Creature* creature, uint32 combatActions) :
m_creature(creature),
m_deathPrevented(false), m_followAngle(0.f), m_followDist(0.f)
{
m_dismountOnAggro = !(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT);
m_dismountOnAggro = !(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::MOUNTED_COMBAT);
SetMeleeEnabled(!(m_creature->GetSettings().HasFlag(CreatureStaticFlags::NO_MELEE_FLEE)
|| m_creature->GetSettings().HasFlag(CreatureStaticFlags4::NO_MELEE_APPROACH)));
if (m_creature->GetSettings().HasFlag(CreatureStaticFlags::SESSILE))
Expand Down
2 changes: 1 addition & 1 deletion src/game/AI/ScriptDevAI/base/escort_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* who)
return false;

// experimental (unknown) flag not present
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_CAN_ASSIST))
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::CAN_ASSIST))
return false;

// unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here)
Expand Down
2 changes: 1 addition & 1 deletion src/game/AI/ScriptDevAI/base/follower_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* who)
return false;

// experimental (unknown) flag not present
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_CAN_ASSIST))
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::CAN_ASSIST))
return false;

// unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
}

// Dead player can see ghosts
if (GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
if (GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE)
return true;

// and not see any other
Expand Down
12 changes: 6 additions & 6 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,24 @@ struct CreatureInfo

SkillType GetRequiredLootSkill() const
{
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::HERBLOOT)
return SKILL_HERBALISM;
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::MININGLOOT)
return SKILL_MINING;
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::ENGINEERLOOT)
return SKILL_ENGINEERING;
return SKILL_SKINNING;
// normal case
}

bool IsExotic() const
{
return (CreatureTypeFlags & CREATURE_TYPEFLAGS_EXOTIC) != 0;
return (CreatureTypeFlags & CreatureTypeFlags::EXOTIC) != 0;
}

bool isTameable(bool exotic) const
{
if (CreatureType != CREATURE_TYPE_BEAST || Family == 0 || (CreatureTypeFlags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
if (CreatureType != CREATURE_TYPE_BEAST || Family == 0 || (CreatureTypeFlags & CreatureTypeFlags::TAMEABLE) == 0)
return false;

// if can tame exotic then can tame any tameable
Expand Down Expand Up @@ -783,7 +783,7 @@ class Creature : public Unit
uint32 GetInteractionPauseTimer() const { return m_interactionPauseTimer; }

GridReference<Creature>& GetGridRef() { return m_gridRef; }
bool IsRegeneratingHealth() const { return (GetCreatureInfo()->RegenerateStats & REGEN_FLAG_HEALTH) != 0 && !(GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SIEGE_WEAPON); }
bool IsRegeneratingHealth() const { return (GetCreatureInfo()->RegenerateStats & REGEN_FLAG_HEALTH) != 0 && !(GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SIEGE_WEAPON); }
bool IsRegeneratingPower() const;
virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
Expand Down
22 changes: 11 additions & 11 deletions src/game/Entities/Relations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ bool Unit::IsFriend(const Unit* unit) const
// WotLK+: Special flag overrides reaction
if (GetTypeId() == TYPEID_UNIT)
{
if (static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID)
if (static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::TREAT_AS_IN_RAID)
return true;
}
return (GetReactionTo(unit) > REP_NEUTRAL);
Expand Down Expand Up @@ -367,7 +367,7 @@ bool Unit::CanAttack(const Unit* unit) const
// Creatures cannot attack player ghosts, unless it is a specially flagged ghost creature
if (GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(unit)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

Expand Down Expand Up @@ -478,7 +478,7 @@ bool Unit::CanAttackNow(const Unit* unit) const
if (IsMounted())
{
// ... unless we are a creature with a special flag
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::MOUNTED_COMBAT))
return false;
}

Expand Down Expand Up @@ -524,7 +524,7 @@ bool Unit::CanAssist(const Unit* unit, bool ignoreFlags) const
if (GetReactionTo(unit) < REP_FRIENDLY)
{
// ... unless we are a creature with a special flag
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::TREAT_AS_IN_RAID))
return false;
}

Expand Down Expand Up @@ -568,10 +568,10 @@ bool Unit::CanAssist(const Unit* unit, bool ignoreFlags) const
{
if (const uint32 flags = static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags)
{
if (flags & CREATURE_TYPEFLAGS_CAN_ASSIST)
if (flags & CreatureTypeFlags::CAN_ASSIST)
return true;

if (flags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID)
if (flags & CreatureTypeFlags::TREAT_AS_IN_RAID)
return true;
}
}
Expand Down Expand Up @@ -668,14 +668,14 @@ bool Unit::CanInteract(const Unit* unit) const
// We can't interact with anyone as a ghost except specially flagged NPCs
if (GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(this)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (unit->GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (unit->GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

// WotLK+: personal squire support
if (GetTypeId() == TYPEID_PLAYER && unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && unit->GetTypeId() == TYPEID_UNIT)
{
if ((static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SQUIRE) && unit->GetOwnerGuid() != GetObjectGuid())
if ((static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SQUIRE) && unit->GetOwnerGuid() != GetObjectGuid())
return false;
}

Expand Down Expand Up @@ -724,7 +724,7 @@ bool Unit::CanInteractNow(const Unit* unit) const
// We can't interact with dead units, unless it's a creature with special flag
if (!unit->IsAlive())
{
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_INTERACT_DEAD))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::INTERACT_DEAD))
return false;
}

Expand All @@ -739,7 +739,7 @@ bool Unit::CanInteractNow(const Unit* unit) const
bool interactable = false;

// We can interact with siege weapons in fight
if (!interactable && unit->GetTypeId() == TYPEID_UNIT && (static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SIEGE_WEAPON))
if (!interactable && unit->GetTypeId() == TYPEID_UNIT && (static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SIEGE_WEAPON))
interactable = true;

// We can interact with UNIT_FLAG2_INTERACT_ANY_REACTION flagged units even in fight
Expand Down Expand Up @@ -1368,7 +1368,7 @@ bool Unit::CanAttackServerside(const Unit* unit, bool ignoreFlagsSource, bool ig
// Creatures cannot attack player ghosts, unless it is a specially flagged ghost creature
if (GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(unit)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

Expand Down
71 changes: 71 additions & 0 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outErrorDb("Table creature_template entry %u StringID2 %u does not exist. Setting to 0.", cInfo->Entry, cInfo->StringID2);
const_cast<CreatureInfo*>(cInfo)->StringID2 = 0;
}
if (cInfo->StaticFlags || cInfo->StaticFlags2 || cInfo->StaticFlags3 || cInfo->StaticFlags4)
const_cast<CreatureInfo*>(cInfo)->CreatureTypeFlags = GetTypeFlagsFromStaticFlags(cInfo->CreatureTypeFlags, cInfo->StaticFlags, cInfo->StaticFlags2, cInfo->StaticFlags3, cInfo->StaticFlags4);
}

sLog.outString(">> Loaded %u creature definitions", sCreatureStorage.GetRecordCount());
Expand Down Expand Up @@ -1035,6 +1037,75 @@ VehicleSeatParameters const* ObjectMgr::GetVehicleSeatParameters(uint32 seatEntr
return &itr->second;
}

uint32 ObjectMgr::GetTypeFlagsFromStaticFlags(uint32 typeFlags, uint32 staticFlags1, uint32 staticFlags2, uint32 staticFlags3, uint32 staticFlags4) const
{
if (staticFlags1 & uint32(CreatureStaticFlags::TAMEABLE))
typeFlags |= CreatureTypeFlags::TAMEABLE;
if (staticFlags1 & uint32(CreatureStaticFlags::BOSS_MOB))
typeFlags |= CreatureTypeFlags::BOSS_MOB;
if (staticFlags1 & uint32(CreatureStaticFlags::VISIBLE_TO_GHOSTS))
typeFlags |= CreatureTypeFlags::GHOST_VISIBLE;
if (staticFlags1 & uint32(CreatureStaticFlags::NO_FACTION_TOOLTIP))
typeFlags |= CreatureTypeFlags::NO_FACTION_TOOLTIP;
if (staticFlags1 & uint32(CreatureStaticFlags::DO_NOT_PLAY_WOUND_ANIM))
typeFlags |= CreatureTypeFlags::NO_WOUND_ANIM;
if (staticFlags1 & uint32(CreatureStaticFlags::MORE_AUDIBLE))
typeFlags |= CreatureTypeFlags::MORE_AUDIBLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::SPELL_ATTACKABLE))
typeFlags |= CreatureTypeFlags::SPELL_ATTACKABLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::INTERACT_WHILE_DEAD))
typeFlags |= CreatureTypeFlags::INTERACT_DEAD;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_HERBALISM))
typeFlags |= CreatureTypeFlags::HERBLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_MINING))
typeFlags |= CreatureTypeFlags::MININGLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::ALLOW_MOUNTED_COMBAT))
typeFlags |= CreatureTypeFlags::MOUNTED_COMBAT;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_DEATH_MESSAGE))
typeFlags |= CreatureTypeFlags::NO_DEATH_MSG;
if (staticFlags2 & uint32(CreatureStaticFlags2::CAN_ASSIST))
typeFlags |= CreatureTypeFlags::CAN_ASSIST;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_PET_BAR))
typeFlags |= CreatureTypeFlags::NO_PET_BAR;
if (staticFlags3 & uint32(CreatureStaticFlags3::MASK_UID))
typeFlags |= CreatureTypeFlags::MASK_UID;
if (staticFlags3 & uint32(CreatureStaticFlags3::SKIN_WITH_ENGINEERING))
typeFlags |= CreatureTypeFlags::ENGINEERLOOT;
if (staticFlags3 & uint32(CreatureStaticFlags3::TAMEABLE_EXOTIC))
typeFlags |= CreatureTypeFlags::EXOTIC;
if (staticFlags3 & uint32(CreatureStaticFlags3::NO_NAME_PLATE))
typeFlags |= CreatureTypeFlags::NO_NAMEPLATE;
if (staticFlags3 & uint32(CreatureStaticFlags3::USE_MODEL_COLLISION_SIZE))
typeFlags |= CreatureTypeFlags::MODEL_COLLISION_SIZE;
if (staticFlags3 & uint32(CreatureStaticFlags3::ALLOW_INTERACTION_WHILE_IN_COMBAT))
typeFlags |= CreatureTypeFlags::SIEGE_WEAPON;
if (staticFlags3 & uint32(CreatureStaticFlags3::COLLIDE_WITH_MISSILES))
typeFlags |= CreatureTypeFlags::COLLIDE_WITH_MISSILES;
if (staticFlags3 & uint32(CreatureStaticFlags3::DO_NOT_PLAY_MOUNTED_ANIMATIONS))
typeFlags |= CreatureTypeFlags::NO_MOUNTED_ANIM;
if (staticFlags3 & uint32(CreatureStaticFlags3::LINK_ALL))
typeFlags |= CreatureTypeFlags::LINK_ALL;
if (staticFlags4 & uint32(CreatureStaticFlags4::INTERACT_ONLY_WITH_CREATOR))
typeFlags |= CreatureTypeFlags::SQUIRE;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_PLAY_UNIT_EVENT_SOUNDS))
typeFlags |= CreatureTypeFlags::NO_DEATH_SOUND;
if (staticFlags4 & uint32(CreatureStaticFlags4::HAS_NO_SHADOW_BLOB))
typeFlags |= CreatureTypeFlags::NO_SHADOW_BLOB;
if (staticFlags4 & uint32(CreatureStaticFlags4::TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS))
typeFlags |= CreatureTypeFlags::TREAT_AS_IN_RAID;
if (staticFlags4 & uint32(CreatureStaticFlags4::FORCE_GOSSIP))
typeFlags |= CreatureTypeFlags::FORCE_GOSSIP;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_SHEATHE))
typeFlags |= CreatureTypeFlags::DO_NOT_SHEATHE;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_TARGET_ON_INTERACTION))
typeFlags |= CreatureTypeFlags::NO_INTERACT_TARGET;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_RENDER_OBJECT_NAME))
typeFlags |= CreatureTypeFlags::DO_NOT_RENDER_NAME;
if (staticFlags4 & uint32(CreatureStaticFlags4::QUEST_BOSS))
typeFlags |= CreatureTypeFlags::QUEST_BOSS;
return typeFlags;
}

CreatureImmunityVector const* ObjectMgr::GetCreatureImmunitySet(uint32 entry, uint32 setId) const
{
auto itr = m_creatureImmunities.find(entry);
Expand Down
2 changes: 2 additions & 0 deletions src/game/Globals/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ class ObjectMgr

// Vehicles
VehicleSeatParameters const* GetVehicleSeatParameters(uint32 seatEntry) const;

uint32 GetTypeFlagsFromStaticFlags(uint32 typeFlags, uint32 staticFlags1, uint32 staticFlags2, uint32 staticFlags3, uint32 staticFlags4) const;
protected:

// current locale settings
Expand Down
Loading