fix(Core/SAI): Exclude GMs for player target/event (#22345)

This commit is contained in:
Kitzunu
2025-06-23 02:47:32 +02:00
committed by GitHub
parent 94f941731e
commit 8200f3729e

View File

@@ -3707,10 +3707,12 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
if (!units.empty() && baseObject) if (!units.empty() && baseObject)
for (WorldObject* unit : units) for (WorldObject* unit : units)
if (IsPlayer(unit) && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist))) if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
targets.push_back(unit); targets.push_back(unit);
if (e.target.playerRange.maxCount) if (e.target.playerRange.maxCount)
Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount); Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
break; break;
} }
case SMART_TARGET_PLAYER_DISTANCE: case SMART_TARGET_PLAYER_DISTANCE:
@@ -4664,12 +4666,11 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!targets.empty()) if (!targets.empty())
{ {
for (WorldObject* target : targets) for (WorldObject* target : targets)
{ if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
if (IsPlayer(target))
playerCount++; playerCount++;
}
if (playerCount >= e.event.nearPlayer.minCount) if (playerCount >= e.event.nearPlayer.minCount)
ProcessAction(e, unit); ProcessAction(e, unit);
} }
RecalcTimer(e, e.event.nearPlayer.repeatMin, e.event.nearPlayer.repeatMax); RecalcTimer(e, e.event.nearPlayer.repeatMin, e.event.nearPlayer.repeatMax);
break; break;
@@ -4683,10 +4684,8 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!targets.empty()) if (!targets.empty())
{ {
for (WorldObject* target : targets) for (WorldObject* target : targets)
{ if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
if (IsPlayer(target))
playerCount++; playerCount++;
}
if (playerCount < e.event.nearPlayerNegation.maxCount) if (playerCount < e.event.nearPlayerNegation.maxCount)
ProcessAction(e, unit); ProcessAction(e, unit);