void SendNonChatPacket(WorldObject source, ServerPacket data, ChatMsg msgType, WorldObject whisperTarget, CreatureTextRange range, Team team, bool gmOnly) { float dist = GetRangeForChatType(msgType); switch (msgType) { case ChatMsg.MonsterParty: if (!whisperTarget) { return; } Player whisperPlayer = whisperTarget.ToPlayer(); if (whisperPlayer) { Group group = whisperPlayer.GetGroup(); if (group) { group.BroadcastWorker(player => player.SendPacket(data)); } } return; case ChatMsg.MonsterWhisper: case ChatMsg.RaidBossWhisper: { if (range == CreatureTextRange.Normal) //ignores team and gmOnly { if (!whisperTarget || !whisperTarget.IsTypeId(TypeId.Player)) { return; } whisperTarget.ToPlayer().SendPacket(data); return; } break; } default: break; } switch (range) { case CreatureTextRange.Area: { uint areaId = source.GetAreaId(); var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if (pl.GetAreaId() == areaId && (team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { pl.SendPacket(data); } } return; } case CreatureTextRange.Zone: { uint zoneId = source.GetZoneId(); var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if (pl.GetZoneId() == zoneId && (team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { pl.SendPacket(data); } } return; } case CreatureTextRange.Map: { var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if ((team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { pl.SendPacket(data); } } return; } case CreatureTextRange.World: { var smap = Global.WorldMgr.GetAllSessions(); foreach (var session in smap) { Player player = session.GetPlayer(); if (player != null) { if ((team == 0 || player.GetTeam() == team) && (!gmOnly || player.IsGameMaster())) { player.SendPacket(data); } } } return; } case CreatureTextRange.Normal: default: break; } source.SendMessageToSetInRange(data, dist, true); }
public void SendChatPacket(WorldObject source, MessageBuilder builder, ChatMsg msgType, WorldObject whisperTarget = null, CreatureTextRange range = CreatureTextRange.Normal, Team team = Team.Other, bool gmOnly = false) { if (source == null) { return; } var localizer = new CreatureTextLocalizer(builder, msgType); switch (msgType) { case ChatMsg.MonsterWhisper: case ChatMsg.RaidBossWhisper: { if (range == CreatureTextRange.Normal) //ignores team and gmOnly { if (!whisperTarget || !whisperTarget.IsTypeId(TypeId.Player)) { return; } localizer.Invoke(whisperTarget.ToPlayer()); return; } break; } default: break; } switch (range) { case CreatureTextRange.Area: { uint areaId = source.GetAreaId(); var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if (pl.GetAreaId() == areaId && (team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { localizer.Invoke(pl); } } return; } case CreatureTextRange.Zone: { uint zoneId = source.GetZoneId(); var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if (pl.GetZoneId() == zoneId && (team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { localizer.Invoke(pl); } } return; } case CreatureTextRange.Map: { var players = source.GetMap().GetPlayers(); foreach (var pl in players) { if ((team == 0 || pl.GetTeam() == team) && (!gmOnly || pl.IsGameMaster())) { localizer.Invoke(pl); } } return; } case CreatureTextRange.World: { var smap = Global.WorldMgr.GetAllSessions(); foreach (var session in smap) { Player player = session.GetPlayer(); if (player != null) { if ((team == 0 || player.GetTeam() == team) && (!gmOnly || player.IsGameMaster())) { localizer.Invoke(player); } } } return; } case CreatureTextRange.Normal: default: break; } float dist = GetRangeForChatType(msgType); var worker = new PlayerDistWorker(source, dist, localizer); Cell.VisitWorldObjects(source, worker, dist); }
public static void OnAreaChange(WorldObject obj) { PhaseShift phaseShift = obj.GetPhaseShift(); PhaseShift suppressedPhaseShift = obj.GetSuppressedPhaseShift(); var oldPhases = phaseShift.GetPhases(); // for comparison ConditionSourceInfo srcInfo = new ConditionSourceInfo(obj); obj.GetPhaseShift().ClearPhases(); obj.GetSuppressedPhaseShift().ClearPhases(); uint areaId = obj.GetAreaId(); AreaTableRecord areaEntry = CliDB.AreaTableStorage.LookupByKey(areaId); while (areaEntry != null) { var newAreaPhases = Global.ObjectMgr.GetPhasesForArea(areaEntry.Id); if (!newAreaPhases.Empty()) { foreach (PhaseAreaInfo phaseArea in newAreaPhases) { if (phaseArea.SubAreaExclusions.Contains(areaId)) { continue; } uint phaseId = phaseArea.PhaseInfo.Id; if (Global.ConditionMgr.IsObjectMeetToConditions(srcInfo, phaseArea.Conditions)) { phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), phaseArea.Conditions); } else { suppressedPhaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), phaseArea.Conditions); } } } areaEntry = CliDB.AreaTableStorage.LookupByKey(areaEntry.ParentAreaID); } bool changed = phaseShift.GetPhases() != oldPhases; Unit unit = obj.ToUnit(); if (unit) { foreach (AuraEffect aurEff in unit.GetAuraEffectsByType(AuraType.Phase)) { uint phaseId = (uint)aurEff.GetMiscValueB(); changed = phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), null) || changed; } foreach (AuraEffect aurEff in unit.GetAuraEffectsByType(AuraType.PhaseGroup)) { var phasesInGroup = Global.DB2Mgr.GetPhasesForGroup((uint)aurEff.GetMiscValueB()); foreach (uint phaseId in phasesInGroup) { changed = phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), null) || changed; } } if (changed) { unit.OnPhaseChange(); } ForAllControlled(unit, controlled => { InheritPhaseShift(controlled, unit); }); if (changed) { unit.RemoveNotOwnSingleTargetAuras(true); } } UpdateVisibilityIfNeeded(obj, true, changed); }