aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp42
-rwxr-xr-xsrc/server/game/Entities/Player/Player.h1
-rwxr-xr-xsrc/server/game/Miscellaneous/SharedDefines.h2
3 files changed, 18 insertions, 27 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index ee4c0302dec..37b3fffe916 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2649,18 +2649,7 @@ void Player::ResetAllPowers()
}
}
-bool Player::CanInteractWithNPCs(bool alive) const
-{
- if (alive && !isAlive())
- return false;
- if (isInFlight())
- return false;
-
- return true;
-}
-
-Creature*
-Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
+Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
{
// unit checks
if (!guid)
@@ -2669,43 +2658,46 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
if (!IsInWorld())
return NULL;
- // exist (we need look pets also for some interaction (quest/etc)
- Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
- if (!unit)
+ if (isInFlight())
return NULL;
- // player check
- if (!CanInteractWithNPCs(!unit->isSpiritService()))
+ // exist (we need look pets also for some interaction (quest/etc)
+ Creature* creature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
+ if (!creature)
return NULL;
- // appropriate npc type
- if (npcflagmask && !unit->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
+ // Deathstate checks
+ if (!isAlive() && !(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_GHOST))
return NULL;
// alive or spirit healer
- if (!unit->isAlive() && (!unit->isSpiritService() || isAlive()))
+ if (!creature->isAlive() && !(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_DEAD_INTERACT))
+ return NULL;
+
+ // appropriate npc type
+ if (npcflagmask && !creature->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
return NULL;
// not allow interaction under control, but allow with own pets
- if (unit->GetCharmerGUID())
+ if (creature->GetCharmerGUID())
return NULL;
// not enemy
- if (unit->IsHostileTo(this))
+ if (creature->IsHostileTo(this))
return NULL;
// not unfriendly
- if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction()))
+ if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(creature->getFaction()))
if (factionTemplate->faction)
if (FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction))
if (faction->reputationListID >= 0 && GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY)
return NULL;
// not too far
- if (!unit->IsWithinDistInMap(this,INTERACTION_DISTANCE))
+ if (!creature->IsWithinDistInMap(this, INTERACTION_DISTANCE))
return NULL;
- return unit;
+ return creature;
}
GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 54fc3814233..1a9debeff3c 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1082,7 +1082,6 @@ class Player : public Unit, public GridObject<Player>
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
- bool CanInteractWithNPCs(bool alive = true) const;
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
bool ToggleAFK();
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index 01b4d41169a..0d6f508ea4f 100755
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -2154,7 +2154,7 @@ enum CreatureTypeFlags
CREATURE_TYPEFLAGS_UNK5 = 0x000010,
CREATURE_TYPEFLAGS_UNK6 = 0x000020,
CREATURE_TYPEFLAGS_UNK7 = 0x000040,
- CREATURE_TYPEFLAGS_UNK8 = 0x000080,
+ CREATURE_TYPEFLAGS_DEAD_INTERACT = 0x000080, // Player can interact with the creature if its dead (not player dead)
CREATURE_TYPEFLAGS_HERBLOOT = 0x000100, // Can be looted by herbalist
CREATURE_TYPEFLAGS_MININGLOOT = 0x000200, // Can be looted by miner
CREATURE_TYPEFLAGS_UNK11 = 0x000400,