diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 4e1394679..b74a2e24b 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -8100,6 +8100,37 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co } case CONDITION_GENDER: return player->getGender() == m_value1; + case CONDITION_DEAD_OR_AWAY: + switch (m_value1) + { + case 0: // Player dead or out of range + return !player || !player->isAlive() || (m_value2 && source && !source->IsWithinDistInMap(player, m_value2)); + case 1: // All players in Group dead or out of range + if (!player) + return true; + if (Group const* grp = player->GetGroup()) + { + for (GroupReference const* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player const* pl = itr->getSource(); + if (pl && pl->isAlive() && !pl->isGameMaster() && (!m_value2 || !source || source->IsWithinDistInMap(pl, m_value2))) + return false; + } + return true; + } + else + return !player->isAlive() || (m_value2 && source && !source->IsWithinDistInMap(player, m_value2)); + case 2: // All players in instance dead or out of range + for (Map::PlayerList::const_iterator itr = map->GetPlayers().begin(); itr != map->GetPlayers().end(); ++itr) + { + Player const* plr = itr->getSource(); + if (plr && plr->isAlive() && !plr->isGameMaster() && (!m_value2 || !source || source->IsWithinDistInMap(plr, m_value2))) + return false; + } + return true; + case 3: // Creature source is dead + return !source || source->GetTypeId() != TYPEID_UNIT || !((Unit*)source)->isAlive(); + } default: return false; } @@ -8147,6 +8178,31 @@ bool PlayerCondition::CheckParamRequirements(Player const* pPlayer, Map const* m return false; } break; + case CONDITION_DEAD_OR_AWAY: + switch (m_value1) + { + case 0: // Player dead or out of range + case 1: // All players in Group dead or out of range + case 2: // All players in instance dead or out of range + if (m_value2 && !source) + { + sLog.outErrorDb("CONDITION_DEAD_OR_AWAY %u - called from %s without source, but source expected for range check", m_entry, conditionSourceToStr[conditionSourceType]); + return false; + } + if (m_value1 != 2) + return true; + // Case 2 (Instance map only) + if (!map && (pPlayer || source)) + map = source ? source->GetMap() : pPlayer->GetMap(); + if (!map || !map->Instanceable()) + { + sLog.outErrorDb("CONDITION_DEAD_OR_AWAY %u (Player in instance case) - called from %s without map param or from non-instanceable map %i", m_entry, conditionSourceToStr[conditionSourceType], map ? map->GetId() : -1); + return false; + } + case 3: // Creature source is dead + return true; + } + break; default: if (!pPlayer) { @@ -8521,6 +8577,15 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu } break; } + case CONDITION_DEAD_OR_AWAY: + { + if (value1 >= 4) + { + sLog.outErrorDb("Dead condition (entry %u, type %u) has an invalid value in value1. (Has %u, must be smaller than 4), skipping.", entry, condition, value1); + return false; + } + break; + } case CONDITION_NONE: break; default: diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index ed5588215..b0e862509 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -406,6 +406,8 @@ enum ConditionType CONDITION_LAST_WAYPOINT = 33, // waypointId 0 = exact, 1: wp <= waypointId, 2: wp > waypointId Use to check what waypoint was last reached CONDITION_XP_USER = 34, // 0, 1 (0: XP off, 1: XP on) for player 0 CONDITION_GENDER = 35, // 0=male, 1=female, 2=none (see enum Gender) + CONDITION_DEAD_OR_AWAY = 36, // value1: 0=player dead, 1=player is dead (with group dead), 2=player in instance are dead, 3=creature is dead + // value2: if != 0 only consider players in range of this value }; enum ConditionSource // From where was the condition called? diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 70cb88952..f5d00b7ca 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12605" + #define REVISION_NR "12606" #endif // __REVISION_NR_H__