Skip to content

Commit

Permalink
StaticFlags: Implement CreatureTypeFlags from StaticFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Aug 9, 2024
1 parent b0d09a1 commit c8461e1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 14 deletions.
71 changes: 71 additions & 0 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,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 @@ -1038,6 +1040,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 |= CREATURE_TYPEFLAGS_TAMEABLE;
if (staticFlags1 & uint32(CreatureStaticFlags::BOSS_MOB))
typeFlags |= CREATURE_TYPEFLAGS_BOSS_MOB;
if (staticFlags1 & uint32(CreatureStaticFlags::VISIBLE_TO_GHOSTS))
typeFlags |= CREATURE_TYPEFLAGS_GHOST_VISIBLE;
if (staticFlags1 & uint32(CreatureStaticFlags::NO_FACTION_TOOLTIP))
typeFlags |= CREATURE_TYPEFLAGS_NO_FACTION_TOOLTIP;
if (staticFlags1 & uint32(CreatureStaticFlags::DO_NOT_PLAY_WOUND_ANIM))
typeFlags |= CREATURE_TYPEFLAGS_NO_WOUND_ANIM;
if (staticFlags1 & uint32(CreatureStaticFlags::MORE_AUDIBLE))
typeFlags |= CREATURE_TYPEFLAGS_MORE_AUDIBLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::SPELL_ATTACKABLE))
typeFlags |= CREATURE_TYPEFLAGS_SPELL_ATTACKABLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::INTERACT_WHILE_DEAD))
typeFlags |= CREATURE_TYPEFLAGS_INTERACT_DEAD;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_HERBALISM))
typeFlags |= CREATURE_TYPEFLAGS_HERBLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_MINING))
typeFlags |= CREATURE_TYPEFLAGS_MININGLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::ALLOW_MOUNTED_COMBAT))
typeFlags |= CREATURE_TYPEFLAGS_MOUNTED_COMBAT;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_DEATH_MESSAGE))
typeFlags |= CREATURE_TYPEFLAGS_NO_DEATH_MSG; // Not proven
if (staticFlags2 & uint32(CreatureStaticFlags2::CAN_ASSIST))
typeFlags |= CREATURE_TYPEFLAGS_CAN_ASSIST;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_PET_BAR))
typeFlags |= CREATURE_TYPEFLAGS_NO_PET_BAR;
if (staticFlags3 & uint32(CreatureStaticFlags3::MASK_UID))
typeFlags |= CREATURE_TYPEFLAGS_NO_UID;
if (staticFlags3 & uint32(CreatureStaticFlags3::SKIN_WITH_ENGINEERING))
typeFlags |= CREATURE_TYPEFLAGS_ENGINEERLOOT;
if (staticFlags3 & uint32(CreatureStaticFlags3::TAMEABLE_EXOTIC))
typeFlags |= CREATURE_TYPEFLAGS_EXOTIC;
if (staticFlags3 & uint32(CreatureStaticFlags3::NO_NAME_PLATE))
typeFlags |= CREATURE_TYPEFLAGS_NO_NAMEPLATE; // Not proven
if (staticFlags3 & uint32(CreatureStaticFlags3::USE_MODEL_COLLISION_SIZE))
typeFlags |= CREATURE_TYPEFLAGS_MODEL_COLLISION_SIZE; // Not proven
if (staticFlags3 & uint32(CreatureStaticFlags3::ALLOW_INTERACTION_WHILE_IN_COMBAT))
typeFlags |= CREATURE_TYPEFLAGS_SIEGE_WEAPON; // Not proven
if (staticFlags3 & uint32(CreatureStaticFlags3::COLLIDE_WITH_MISSILES))
typeFlags |= CREATURE_TYPEFLAGS_COLLIDE_WITH_MISSILES; // Not proven
if (staticFlags3 & uint32(CreatureStaticFlags3::DO_NOT_PLAY_MOUNTED_ANIMATIONS))
typeFlags |= CREATURE_TYPEFLAGS_NO_MOUNTED_ANIM; // Not proven
if (staticFlags3 & uint32(CreatureStaticFlags3::LINK_ALL))
typeFlags |= CREATURE_TYPEFLAGS_UNK23; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::INTERACT_ONLY_WITH_CREATOR))
typeFlags |= CREATURE_TYPEFLAGS_SQUIRE; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_PLAY_UNIT_EVENT_SOUNDS))
typeFlags |= CREATURE_TYPEFLAGS_NO_DEATH_SOUND; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::HAS_NO_SHADOW_BLOB))
typeFlags |= CREATURE_TYPEFLAGS_NO_SHADOW_BLOB; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS))
typeFlags |= CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID;
if (staticFlags4 & uint32(CreatureStaticFlags4::FORCE_GOSSIP))
typeFlags |= CREATURE_TYPEFLAGS_FORCE_GOSSIP;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_SHEATHE))
typeFlags |= CREATURE_TYPEFLAGS_UNK29; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_TARGET_ON_INTERACTION))
typeFlags |= CREATURE_TYPEFLAGS_UNK30; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_RENDER_OBJECT_NAME))
typeFlags |= CREATURE_TYPEFLAGS_UNK31; // Not proven
if (staticFlags4 & uint32(CreatureStaticFlags4::QUEST_BOSS))
typeFlags |= CREATURE_TYPEFLAGS_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 @@ -1300,6 +1300,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
28 changes: 14 additions & 14 deletions src/game/Globals/SharedDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -1320,30 +1320,30 @@ enum CreatureTypeFlags
{
CREATURE_TYPEFLAGS_TAMEABLE = 0x00000001, // Tameable by any hunter
CREATURE_TYPEFLAGS_GHOST_VISIBLE = 0x00000002, // Creatures which can _also_ be seen when player is a ghost, used in CanInteract function by client, can't be attacked
CREATURE_TYPEFLAGS_UNK3 = 0x00000004, // "BOSS" flag for tooltips
CREATURE_TYPEFLAGS_UNK4 = 0x00000008,
CREATURE_TYPEFLAGS_UNK5 = 0x00000010, // controls something in client tooltip related to creature faction
CREATURE_TYPEFLAGS_UNK6 = 0x00000020, // may be sound related
CREATURE_TYPEFLAGS_UNK7 = 0x00000040, // may be related to attackable / not attackable creatures with spells, used together with lua_IsHelpfulSpell/lua_IsHarmfulSpell
CREATURE_TYPEFLAGS_BOSS_MOB = 0x00000004, // "BOSS" flag for tooltips
CREATURE_TYPEFLAGS_NO_WOUND_ANIM = 0x00000008,
CREATURE_TYPEFLAGS_NO_FACTION_TOOLTIP=0x00000010, // controls something in client tooltip related to creature faction
CREATURE_TYPEFLAGS_MORE_AUDIBLE = 0x00000020, // may be sound related
CREATURE_TYPEFLAGS_SPELL_ATTACKABLE = 0x00000040, // may be related to attackable / not attackable creatures with spells, used together with lua_IsHelpfulSpell/lua_IsHarmfulSpell
CREATURE_TYPEFLAGS_INTERACT_DEAD = 0x00000080, // Creature can be interacted with even if it's dead
CREATURE_TYPEFLAGS_HERBLOOT = 0x00000100, // Can be looted by herbalist
CREATURE_TYPEFLAGS_MININGLOOT = 0x00000200, // Can be looted by miner
CREATURE_TYPEFLAGS_UNK11 = 0x00000400, // no idea, but it used by client
CREATURE_TYPEFLAGS_NO_DEATH_MSG = 0x00000400, // no idea, but it used by client
CREATURE_TYPEFLAGS_MOUNTED_COMBAT = 0x00000800, // possibility to attack and cast spells while mounted
CREATURE_TYPEFLAGS_CAN_ASSIST = 0x00001000, // Can aid any player (and group) in combat. Typically seen for escorting NPC's
CREATURE_TYPEFLAGS_UNK14 = 0x00002000, // checked from calls in Lua_PetHasActionBar
CREATURE_TYPEFLAGS_UNK15 = 0x00004000, // Lua_UnitGUID, client does guid_low &= 0xFF000000 if this flag is set
CREATURE_TYPEFLAGS_NO_PET_BAR = 0x00002000, // checked from calls in Lua_PetHasActionBar
CREATURE_TYPEFLAGS_NO_UID = 0x00004000, // Lua_UnitGUID, client does guid_low &= 0xFF000000 if this flag is set
CREATURE_TYPEFLAGS_ENGINEERLOOT = 0x00008000, // Can be looted by engineer
CREATURE_TYPEFLAGS_EXOTIC = 0x00010000, // Can be tamed by hunter as exotic pet
CREATURE_TYPEFLAGS_UNK18 = 0x00020000, // related to CreatureDisplayInfo and scaling in some way
CREATURE_TYPEFLAGS_MODEL_COLLISION_SIZE=0x00020000, // related to CreatureDisplayInfo and scaling in some way
CREATURE_TYPEFLAGS_SIEGE_WEAPON = 0x00040000, // Related to vehicle/siege weapons
CREATURE_TYPEFLAGS_UNK20 = 0x00080000, // may be has something to do with missiles
CREATURE_TYPEFLAGS_UNK21 = 0x00100000, // no idea, but it used by client, may be related to rendering
CREATURE_TYPEFLAGS_UNK22 = 0x00200000, // may be has something to do with animation (disable animation?)
CREATURE_TYPEFLAGS_COLLIDE_WITH_MISSILES=0x00080000, // may be has something to do with missiles
CREATURE_TYPEFLAGS_NO_NAMEPLATE = 0x00100000, // no idea, but it used by client, may be related to rendering
CREATURE_TYPEFLAGS_NO_MOUNTED_ANIM = 0x00200000, // may be has something to do with animation (disable animation?)
CREATURE_TYPEFLAGS_UNK23 = 0x00400000, // this one probably controls some creature visual
CREATURE_TYPEFLAGS_SQUIRE = 0x00800000, // First seen in 3.2.2. Related to banner/backpack of creature/companion, used in CanInteract function by client
CREATURE_TYPEFLAGS_UNK25 = 0x01000000, // pet sounds related?
CREATURE_TYPEFLAGS_UNK26 = 0x02000000, // this one probably controls some creature visual
CREATURE_TYPEFLAGS_NO_DEATH_SOUND = 0x01000000, // pet sounds related?
CREATURE_TYPEFLAGS_NO_SHADOW_BLOB = 0x02000000, // this one probably controls some creature visual
CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID = 0x04000000, // creature has no type, or forces creature to be considered as in party, may be related to creature assistance
CREATURE_TYPEFLAGS_FORCE_GOSSIP = 0x08000000, // used in Lua_ForceGossip
CREATURE_TYPEFLAGS_UNK29 = 0x10000000, // no idea, but it used by client
Expand Down
1 change: 1 addition & 0 deletions src/modules/PlayerBots

0 comments on commit c8461e1

Please sign in to comment.