private void RegisterAggro(SNpcStatus aggro)
        {
            var time   = aggro.Time.Ticks;
            var entity = EntityTracker.GetOrNull(aggro.Npc) as NpcEntity;

            if (entity == null)
            {
                return;                 //not sure why, but sometimes it fails
            }
            var user = EntityTracker.GetOrNull(aggro.Target) as UserEntity;

            if (user != null)
            {
                var player = PlayerTracker.GetOrUpdate(user);
                if (AbnormalityStorage.Last(entity) != player)
                {
                    if (AbnormalityStorage.Last(entity) != null)
                    {
                        AbnormalityStorage.AggroEnd(AbnormalityStorage.Last(entity), entity, time);
                    }
                    AbnormalityStorage.AggroStart(player, entity, time);
                    AbnormalityStorage.LastAggro[entity] = player;
                }
            }
            else
            {
                if (AbnormalityStorage.Last(entity) != null)
                {
                    AbnormalityStorage.AggroEnd(AbnormalityStorage.Last(entity), entity, time);
                    AbnormalityStorage.LastAggro[entity] = null;
                }
            }
        }
Example #2
0
        private void RegisterAggro(SNpcStatus aggro)
        {
            var time   = aggro.Time.Ticks;
            var entity = EntityTracker.GetOrNull(aggro.Npc) as NpcEntity;

            if (entity == null)
            {
                return;                 //not sure why, but sometimes it fails
            }
            var user = EntityTracker.GetOrNull(aggro.Target) as UserEntity;

            if (user != null)
            {
                var player = PlayerTracker.GetOrUpdate(user);
                if (AbnormalityStorage.Last(entity) != player)
                {
                    if (AbnormalityStorage.Last(entity) != null)
                    {
                        AbnormalityStorage.AggroEnd(AbnormalityStorage.Last(entity), entity, time);
                    }
                    else
                    {
                        if (!AggroRegistered.Contains(aggro.Npc))
                        {
                            // Add a arbitrary dummy damage to auto start fight timer on aggro
                            AggroRegistered.Add(aggro.Npc);
                            UpdateDamageTracker(new SkillResult(0, false, true, false, HotDotDatabase.Enraged, aggro.Target, aggro.Npc, aggro.Time, EntityTracker, PlayerTracker));
                        }
                    }

                    AbnormalityStorage.AggroStart(player, entity, time);
                    AbnormalityStorage.LastAggro[entity] = player;
                }
            }
            else
            {
                if (AbnormalityStorage.Last(entity) != null)
                {
                    AbnormalityStorage.AggroEnd(AbnormalityStorage.Last(entity), entity, time);
                    AbnormalityStorage.LastAggro[entity] = null;
                }
            }
        }