Example #1
0
        public SkillResult(EachSkillResultServerMessage message, EntityTracker entityRegistry, PlayerTracker playerTracker, SkillDatabase skillDatabase)
        {
            Time = message.Time;
            Amount = message.Amount;
            IsCritical = message.IsCritical;
            IsHeal = message.IsHeal;
            SkillId = message.SkillId;

            Debug.Assert(!message.IsUseless);

            Source = entityRegistry.GetOrPlaceholder(message.Source);
            Target = entityRegistry.GetOrPlaceholder(message.Target);
            var sourceUser = UserEntity.ForEntity(Source); // Attribute damage dealt by owned entities to the owner
            var targetUser = Target as UserEntity; // But don't attribute damage received by owned entities to the owner

            if (sourceUser != null)
            {
                Skill = skillDatabase.Get(sourceUser, message);
                SourcePlayer = playerTracker.Get(sourceUser.PlayerId);
            }

            if (targetUser != null)
            {
                TargetPlayer = playerTracker.Get(targetUser.PlayerId);
            }
        }
Example #2
0
        internal void UpdateMeterBoss(Tera.Game.Messages.EachSkillResultServerMessage message)
        {
            var source = NetworkController.Instance.EntityTracker.GetOrNull(message.Source) as UserEntity;

            if (NetworkController.Instance.EntityTracker.MeterUser != source)
            {
                return;
            }
            var target = NetworkController.Instance.EntityTracker.GetOrNull(message.Target) as NpcEntity;

            if (target == null)
            {
                return;
            }
            if (target.Info.Boss)
            {
                _lastBossMeterUser = target.Id;
            }
        }
Example #3
0
        // skillIds are reused across races and class, so we need a RaceGenderClass to disambiguate them
        public Skill Get(UserEntity user, EachSkillResultServerMessage message)
        {
            var skillId = message.SkillId;

            //check if we have an override first

            var overrideCollection = message.IsHeal ? _healSkillIdOverrides : _damageSkillIdOverrides;
            if (overrideCollection.ContainsKey(user.RaceGenderClass.Class))
            {   //check class specific overrides
                var skill = overrideCollection[user.RaceGenderClass.Class].FirstOrDefault(s => s.Id == skillId);
                //check common overrides
                if (skill == null && overrideCollection.ContainsKey(PlayerClass.Common))
                {
                    skill = overrideCollection[PlayerClass.Common].FirstOrDefault(s => s.Id == skillId);
                }

                if (skill != null)
                    return skill;
            }

            var raceGenderClass = user.RaceGenderClass;
            var comparer = new Helpers.ProjectingEqualityComparer<Skill, int>(x => x.Id);
            foreach (var rgc2 in raceGenderClass.Fallbacks())
            {
                if (!_userSkilldata.ContainsKey(rgc2))
                    continue;

                var searchSkill = new UserSkill(skillId, raceGenderClass, null);

                var index = _userSkilldata[rgc2].BinarySearch(searchSkill, comparer);
                if (index < 0)
                    index = ~index - 1;
                if (index < 0)
                    continue;

                var item = _userSkilldata[rgc2][index];
                return item;
            }
            return null;
        }