Creature type flags (#2195)
fix(Core/Creature): refactoring creature type flags and adding CREATURE_TYPE_FLAG_CAN_COLLIDE_WITH_MISSILES - closes #1984
This commit is contained in:
parent
5815808faa
commit
7954a2a07e
9 changed files with 61 additions and 53 deletions
|
|
@ -65,7 +65,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* who)
|
|||
return false;
|
||||
|
||||
//experimental (unknown) flag not present
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST))
|
||||
return false;
|
||||
|
||||
//not a player
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* who)
|
|||
return false;
|
||||
|
||||
//experimental (unknown) flag not present
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST))
|
||||
return false;
|
||||
|
||||
//not a player
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@ bool SmartAI::AssistPlayerInCombat(Unit* who)
|
|||
return false;
|
||||
|
||||
//experimental (unknown) flag not present
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
|
||||
if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST))
|
||||
return false;
|
||||
|
||||
// Xinef: victim of unit has to be a player controlled unit
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
|
|||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
|
||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
|
||||
}
|
||||
else if (cinfo->type_flags & CREATURE_TYPEFLAGS_GHOST) // Xinef: Add ghost visibility for ghost units
|
||||
else if (cinfo->type_flags & CREATURE_TYPE_FLAG_GHOST_VISIBLE) // Xinef: Add ghost visibility for ghost units
|
||||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
||||
|
||||
if (Entry == VISUAL_WAYPOINT)
|
||||
|
|
|
|||
|
|
@ -139,11 +139,11 @@ struct CreatureTemplate
|
|||
// helpers
|
||||
SkillType GetRequiredLootSkill() const
|
||||
{
|
||||
if (type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
|
||||
if (type_flags & CREATURE_TYPE_FLAG_HERB_SKINNING_SKILL)
|
||||
return SKILL_HERBALISM;
|
||||
else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
|
||||
else if (type_flags & CREATURE_TYPE_FLAG_MINING_SKINNING_SKILL)
|
||||
return SKILL_MINING;
|
||||
else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
|
||||
else if (type_flags & CREATURE_TYPE_FLAG_ENGINEERING_SKINNING_SKILL)
|
||||
return SKILL_ENGINEERING;
|
||||
else
|
||||
return SKILL_SKINNING; // normal case
|
||||
|
|
@ -151,11 +151,11 @@ struct CreatureTemplate
|
|||
|
||||
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 || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
|
||||
return false;
|
||||
|
||||
// if can tame exotic then can tame any temable
|
||||
return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC) == 0;
|
||||
// if can tame exotic then can tame any tameable
|
||||
return exotic || (type_flags & CREATURE_TYPE_FLAG_EXOTIC_PET) == 0;
|
||||
}
|
||||
|
||||
void InitializeQueryData();
|
||||
|
|
@ -483,7 +483,7 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje
|
|||
if (IsPet())
|
||||
return false;
|
||||
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB;
|
||||
}
|
||||
|
||||
bool IsDungeonBoss() const;
|
||||
|
|
|
|||
|
|
@ -2881,11 +2881,11 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
|||
return NULL;
|
||||
|
||||
// Deathstate checks
|
||||
if (!IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_GHOST))
|
||||
if (!IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_GHOST_VISIBLE))
|
||||
return NULL;
|
||||
|
||||
// alive or spirit healer
|
||||
if (!creature->IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_DEAD_INTERACT))
|
||||
if (!creature->IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_INTERACT_WHILE_DEAD))
|
||||
return NULL;
|
||||
|
||||
// appropriate npc type
|
||||
|
|
|
|||
|
|
@ -12548,7 +12548,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
|
|||
UpdateSpeed(MOVE_FLIGHT, true);
|
||||
}
|
||||
|
||||
if (!(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
|
||||
if (!(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_MOUNTED_COMBAT_ALLOWED))
|
||||
Dismount();
|
||||
if (!IsStandState()) // pussywizard: already done in CombatStart(target, initialAggro) for the target, but when aggro'ing from MoveInLOS CombatStart is not called!
|
||||
SetStandState(UNIT_STAND_STATE_STAND);
|
||||
|
|
@ -12718,7 +12718,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
|||
}
|
||||
|
||||
Creature const* creatureAttacker = ToCreature();
|
||||
if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER)
|
||||
if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)
|
||||
return false;
|
||||
|
||||
Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : NULL;
|
||||
|
|
@ -12806,7 +12806,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
|||
// can't assist non-friendly targets
|
||||
if (GetReactionTo(target) < REP_NEUTRAL
|
||||
&& target->GetReactionTo(this) < REP_NEUTRAL
|
||||
&& (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER)))
|
||||
&& (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)))
|
||||
return false;
|
||||
|
||||
// PvP case
|
||||
|
|
@ -12840,7 +12840,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
|||
&& !target->IsPvP())
|
||||
{
|
||||
if (Creature const* creatureTarget = target->ToCreature())
|
||||
return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS;
|
||||
return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -17373,8 +17373,8 @@ bool Unit::IsInPartyWith(Unit const* unit) const
|
|||
else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer())
|
||||
return u1->getFaction() == u2->getFaction();
|
||||
// Xinef: creature type_flag should work for party check only if player group is not a raid
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup()))
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup()))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
@ -17395,8 +17395,8 @@ bool Unit::IsInRaidWith(Unit const* unit) const
|
|||
// Xinef: we assume that npcs with the same faction are in party
|
||||
else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer())
|
||||
return u1->getFaction() == u2->getFaction();
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PARTY_MEMBER))
|
||||
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) ||
|
||||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2567,38 +2567,38 @@ enum CreatureFamily
|
|||
|
||||
enum CreatureTypeFlags
|
||||
{
|
||||
CREATURE_TYPEFLAGS_TAMEABLE = 0x00000001, // Tameable by any hunter
|
||||
CREATURE_TYPEFLAGS_GHOST = 0x00000002, // Creature are also visible for not alive player. Allow gossip interaction if npcflag allow?
|
||||
CREATURE_TYPEFLAGS_BOSS = 0x00000004,
|
||||
CREATURE_TYPEFLAGS_UNK3 = 0x00000008,
|
||||
CREATURE_TYPEFLAGS_UNK4 = 0x00000010,
|
||||
CREATURE_TYPEFLAGS_UNK5 = 0x00000020,
|
||||
CREATURE_TYPEFLAGS_UNK6 = 0x00000040,
|
||||
CREATURE_TYPEFLAGS_DEAD_INTERACT = 0x00000080, // Player can interact with the creature if its dead (not player dead)
|
||||
CREATURE_TYPEFLAGS_HERBLOOT = 0x00000100, // Can be looted by herbalist
|
||||
CREATURE_TYPEFLAGS_MININGLOOT = 0x00000200, // Can be looted by miner
|
||||
CREATURE_TYPEFLAGS_DONT_LOG_DEATH = 0x00000400, // Death event will not show up in combat log
|
||||
CREATURE_TYPEFLAGS_MOUNTED_COMBAT = 0x00000800, // Creature can remain mounted when entering combat
|
||||
CREATURE_TYPEFLAGS_AID_PLAYERS = 0x00001000, // ? Can aid any player in combat if in range?
|
||||
CREATURE_TYPEFLAGS_UNK13 = 0x00002000,
|
||||
CREATURE_TYPEFLAGS_UNK14 = 0x00004000, // ? Possibly not in use
|
||||
CREATURE_TYPEFLAGS_ENGINEERLOOT = 0x00008000, // Can be looted by engineer
|
||||
CREATURE_TYPEFLAGS_EXOTIC = 0x00010000, // Can be tamed by hunter as exotic pet
|
||||
CREATURE_TYPEFLAGS_UNK17 = 0x00020000, // ? Related to vehicles/pvp?
|
||||
CREATURE_TYPEFLAGS_UNK18 = 0x00040000, // ? Related to vehicle/siege weapons?
|
||||
CREATURE_TYPEFLAGS_PROJECTILE_COLLISION = 0x00080000, // Projectiles can collide with this creature - interacts with TARGET_DEST_TRAJ
|
||||
CREATURE_TYPEFLAGS_UNK20 = 0x00100000,
|
||||
CREATURE_TYPEFLAGS_UNK21 = 0x00200000,
|
||||
CREATURE_TYPEFLAGS_UNK22 = 0x00400000,
|
||||
CREATURE_TYPEFLAGS_UNK23 = 0x00800000, // ? First seen in 3.2.2. Related to banner/backpack of creature/companion?
|
||||
CREATURE_TYPEFLAGS_UNK24 = 0x01000000,
|
||||
CREATURE_TYPEFLAGS_UNK25 = 0x02000000,
|
||||
CREATURE_TYPEFLAGS_PARTY_MEMBER = 0x04000000, //! Creature can be targeted by spells that require target to be in caster's party/raid
|
||||
CREATURE_TYPEFLAGS_UNK27 = 0x08000000,
|
||||
CREATURE_TYPEFLAGS_UNK28 = 0x10000000,
|
||||
CREATURE_TYPEFLAGS_UNK29 = 0x20000000,
|
||||
CREATURE_TYPEFLAGS_UNK30 = 0x40000000,
|
||||
CREATURE_TYPEFLAGS_UNK31 = 0x80000000,
|
||||
CREATURE_TYPE_FLAG_TAMEABLE_PET = 0x00000001, // Makes the mob tameable (must also be a beast and have family set)
|
||||
CREATURE_TYPE_FLAG_GHOST_VISIBLE = 0x00000002, // Creature are also visible for not alive player. Allow gossip interaction if npcflag allow?
|
||||
CREATURE_TYPE_FLAG_BOSS_MOB = 0x00000004, // Changes creature's visible level to "??" in the creature's portrait - Immune Knockback.
|
||||
CREATURE_TYPE_FLAG_DO_NOT_PLAY_WOUND_PARRY_ANIMATION = 0x00000008,
|
||||
CREATURE_TYPE_FLAG_HIDE_FACTION_TOOLTIP = 0x00000010,
|
||||
CREATURE_TYPE_FLAG_UNK5 = 0x00000020, // Sound related
|
||||
CREATURE_TYPE_FLAG_SPELL_ATTACKABLE = 0x00000040,
|
||||
CREATURE_TYPE_FLAG_CAN_INTERACT_WHILE_DEAD = 0x00000080, // Player can interact with the creature if its dead (not player dead)
|
||||
CREATURE_TYPE_FLAG_HERB_SKINNING_SKILL = 0x00000100, // Can be looted by herbalist
|
||||
CREATURE_TYPE_FLAG_MINING_SKINNING_SKILL = 0x00000200, // Can be looted by miner
|
||||
CREATURE_TYPE_FLAG_DO_NOT_LOG_DEATH = 0x00000400, // Death event will not show up in combat log
|
||||
CREATURE_TYPE_FLAG_MOUNTED_COMBAT_ALLOWED = 0x00000800, // Creature can remain mounted when entering combat
|
||||
CREATURE_TYPE_FLAG_CAN_ASSIST = 0x00001000, // ? Can aid any player in combat if in range?
|
||||
CREATURE_TYPE_FLAG_IS_PET_BAR_USED = 0x00002000,
|
||||
CREATURE_TYPE_FLAG_MASK_UID = 0x00004000,
|
||||
CREATURE_TYPE_FLAG_ENGINEERING_SKINNING_SKILL = 0x00008000, // Can be looted by engineer
|
||||
CREATURE_TYPE_FLAG_EXOTIC_PET = 0x00010000, // Can be tamed by hunter as exotic pet
|
||||
CREATURE_TYPE_FLAG_USE_DEFAULT_COLLISION_BOX = 0x00020000, // Collision related. (always using default collision box?)
|
||||
CREATURE_TYPE_FLAG_IS_SIEGE_WEAPON = 0x00040000,
|
||||
CREATURE_TYPE_FLAG_CAN_COLLIDE_WITH_MISSILES = 0x00080000, // Projectiles can collide with this creature - interacts with TARGET_DEST_TRAJ
|
||||
CREATURE_TYPE_FLAG_HIDE_NAME_PLATE = 0x00100000,
|
||||
CREATURE_TYPE_FLAG_DO_NOT_PLAY_MOUNTED_ANIMATIONS = 0x00200000,
|
||||
CREATURE_TYPE_FLAG_IS_LINK_ALL = 0x00400000,
|
||||
CREATURE_TYPE_FLAG_INTERACT_ONLY_WITH_CREATOR = 0x00800000,
|
||||
CREATURE_TYPE_FLAG_DO_NOT_PLAY_UNIT_EVENT_SOUNDS = 0x01000000,
|
||||
CREATURE_TYPE_FLAG_HAS_NO_SHADOW_BLOB = 0x02000000,
|
||||
CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT = 0x04000000, // ! Creature can be targeted by spells that require target to be in caster's party/raid
|
||||
CREATURE_TYPE_FLAG_FORCE_GOSSIP = 0x08000000, // Allows the creature to display a single gossip option.
|
||||
CREATURE_TYPE_FLAG_DO_NOT_SHEATHE = 0x10000000,
|
||||
CREATURE_TYPE_FLAG_DO_NOT_TARGET_ON_INTERACTION = 0x20000000,
|
||||
CREATURE_TYPE_FLAG_DO_NOT_RENDER_OBJECT_NAME = 0x40000000,
|
||||
CREATURE_TYPE_FLAG_UNIT_IS_QUEST_BOSS = 0x80000000 // Not verified
|
||||
};
|
||||
|
||||
enum CreatureEliteType
|
||||
|
|
|
|||
|
|
@ -1844,9 +1844,17 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
|||
for (; itr != targets.end(); ++itr)
|
||||
{
|
||||
if (Unit* unitTarget = (*itr)->ToUnit())
|
||||
{
|
||||
if (m_caster == *itr || m_caster->IsOnVehicle(unitTarget) || (unitTarget)->GetVehicle())//(*itr)->IsOnVehicle(m_caster))
|
||||
continue;
|
||||
|
||||
if (Creature * creatureTarget = unitTarget->ToCreature())
|
||||
{
|
||||
if (!(creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_COLLIDE_WITH_MISSILES))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3)
|
||||
// TODO: all calculation should be based on src instead of m_caster
|
||||
const float objDist2d = fabs(m_targets.GetSrcPos()->GetExactDist2d(*itr) * cos(m_targets.GetSrcPos()->GetRelativeAngle(*itr)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue