Beispiel #1
0
 internal void HostilityTarget()
 {
     if (IsHostile && Target == -1)
     {
         Character character = ServerManager.Instance.Sessions.FirstOrDefault(s => s?.Character != null && s.Character.Hp > 0 && !s.Character.InvisibleGm && !s.Character.Invisible && s.Character.MapInstance == MapInstance && Map.GetDistance(new MapCell {
             X = MapX, Y = MapY
         }, new MapCell {
             X = s.Character.PositionX, Y = s.Character.PositionY
         }) < (NoticeRange == 0 ? Monster.NoticeRange : NoticeRange))?.Character;
         if (character != null)
         {
             if (!OnNoticeEvents.Any() && MoveEvent == null)
             {
                 Target = character.CharacterId;
                 if (!Monster.NoAggresiveIcon && LastEffect.AddSeconds(5) < DateTime.Now)
                 {
                     character.Session.SendPacket(GenerateEff(5000));
                 }
             }
             OnNoticeEvents.ForEach(e =>
             {
                 EventHelper.Instance.RunEvent(e, monster: this);
             });
             OnNoticeEvents.RemoveAll(s => s != null);
         }
     }
 }
Beispiel #2
0
 internal void HostilityTarget()
 {
     if (IsHostile && Target == -1)
     {
         Character character = ServerManager.Instance.Sessions.Where(s => s?.Character != null && (ServerManager.Instance.ChannelId != 51 || MonsterVNum - (byte)s.Character.Faction != 678) && s.Character.Hp > 0 && !s.Character.InvisibleGm && !s.Character.Invisible && s.Character.MapInstance == MapInstance && Map.GetDistance(new MapCell {
             X = MapX, Y = MapY
         }, new MapCell {
             X = s.Character.PositionX, Y = s.Character.PositionY
         }) < Monster.NoticeRange).OrderBy(s => ServerManager.Instance.RandomNumber(0, int.MaxValue)).FirstOrDefault()?.Character;
         if (character != null)
         {
             if (OnNoticeEvents.Count == 0 && MoveEvent == null)
             {
                 Target = character.CharacterId;
                 if (!NoAggresiveIcon)
                 {
                     character.Session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Monster, MapMonsterId, 5000));
                 }
             }
             OnNoticeEvents.ForEach(e => EventHelper.Instance.RunEvent(e, monster: this));
             OnNoticeEvents.RemoveAll(s => s != null);
         }
     }
 }