diff options
author | Shauren <shauren.trinity@gmail.com> | 2011-04-18 12:17:45 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2011-04-18 12:17:45 +0200 |
commit | 542bc3008d36397f9f41ef0d5dffa2f7716049ab (patch) | |
tree | c30420e388b5469f6daead083bca6aa2e156cad1 /src | |
parent | 0d477ab13293c9cf8f6b081a0a00f75a19a3a21c (diff) |
Core/Player: Fixed interaction rules with dead creatures
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 42 | ||||
-rwxr-xr-x | src/server/game/Entities/Player/Player.h | 1 | ||||
-rwxr-xr-x | src/server/game/Miscellaneous/SharedDefines.h | 2 |
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, |