コード例 #1
0
ファイル: PlayerTracker.cs プロジェクト: Roukanken42/Tera
 public PlayerTracker(EntityTracker entityTracker, ServerDatabase serverDatabase = null)
 {
     _serverDatabase              = serverDatabase;
     _entityTracker               = entityTracker;
     IsRaid                       = false;
     entityTracker.EntityUpdated += Update;
 }
コード例 #2
0
        public SkillResult(int amount, bool isCritical, bool isHp, bool isHeal, HotDot hotdot, EntityId source,
                           EntityId target, DateTime time,
                           EntityTracker entityRegistry, PlayerTracker playerTracker)
        {
            Time        = time;
            Amount      = isHp ? Math.Abs(amount) : amount;
            IsCritical  = isCritical;
            IsHp        = isHp;
            IsHeal      = isHeal;
            SkillId     = hotdot.Id;
            Abnormality = true;

            Source = entityRegistry.GetOrPlaceholder(source);
            Target = entityRegistry.GetOrPlaceholder(target);
            var userNpc    = UserEntity.ForEntity(Source);
            var sourceUser = userNpc["root_source"] as UserEntity; // 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

            var pclass = PlayerClass.Common;

            if (sourceUser != null)
            {
                SourcePlayer = playerTracker.Get(sourceUser.ServerId, sourceUser.PlayerId);
                pclass       = SourcePlayer.RaceGenderClass.Class;
            }
            Skill = new UserSkill(hotdot.Id, pclass,
                                  hotdot.Name, "DOT", null, hotdot.IconName);

            if (targetUser != null)
            {
                TargetPlayer = playerTracker.Get(targetUser.ServerId, targetUser.PlayerId);
            }
            HitDirection = HitDirection.Dot;
        }
コード例 #3
0
 public AbnormalityTracker(EntityTracker entityTracker, PlayerTracker playerTracker,
                           HotDotDatabase hotDotDatabase, AbnormalityStorage abnormalityStorage, Action <SkillResult> update = null)
 {
     EntityTracker       = entityTracker;
     PlayerTracker       = playerTracker;
     HotDotDatabase      = hotDotDatabase;
     UpdateDamageTracker = update;
     AbnormalityStorage  = abnormalityStorage;
 }
コード例 #4
0
 public PlayerTracker(EntityTracker entityTracker)
 {
     entityTracker.EntityUpdated += Update;
 }
コード例 #5
0
        public SkillResult(EachSkillResultServerMessage message, EntityTracker entityRegistry,
                           PlayerTracker playerTracker, SkillDatabase skillDatabase, PetSkillDatabase petSkillDatabase = null, AbnormalityTracker abnormalityTracker = null)
        {
            Time        = message.Time;
            Amount      = message.Amount;
            IsCritical  = message.IsCritical;
            IsHp        = message.IsHp;
            IsHeal      = message.IsHeal;
            SkillId     = message.SkillId;
            Abnormality = false;

            Source = entityRegistry.GetOrPlaceholder(message.Source);
            Target = entityRegistry.GetOrPlaceholder(message.Target);
            if (Source is PlaceHolderEntity && (Target as NpcEntity)?.Info.Boss == true)
            {
                Source = playerTracker.GetUnknownPlayer() ?? Source;  //track unknown damage dealt to bosses like in raid-30
            }
            if (abnormalityTracker?.AbnormalityExist(message.Target, 950187) ?? false)
            {
                Amount = 0;                                                                      //fix raid-30 bug with 1kkk damage after shield
            }
            var userNpc    = UserEntity.ForEntity(Source);
            var npc        = (NpcEntity)userNpc["source"];
            var sourceUser = userNpc["root_source"] as UserEntity; // 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);
                if (Skill == null && npc != null)
                {
                    Skill = petSkillDatabase?.GetOrNull(npc.Info, SkillId) ?? new UserSkill(message.SkillId, sourceUser.RaceGenderClass, npc.Info.Name, null,
                                                                                            "", skillDatabase.GetSkillByPetName(npc.Info.Name, sourceUser.RaceGenderClass)?.IconName ?? "", npc.Info);
                }
                SourcePlayer = playerTracker.Get(sourceUser.ServerId, sourceUser.PlayerId);
                if (Skill == null)
                {
                    Skill = new UserSkill(message.SkillId, sourceUser.RaceGenderClass, "Unknown");
                }
            }
            if (targetUser != null)
            {
                TargetPlayer = playerTracker.Get(targetUser.ServerId, targetUser.PlayerId);
            }
            if (Source is PlaceHolderEntity || Target is PlaceHolderEntity)
            {
                return;                                                            //fix error on skills from or dealt to unknown entities
            }
            Source.Position = Source.Position.MoveForvard(Source.Finish, Source.Speed,
                                                          message.Time.Ticks - Source.StartTime);
            if (Source.EndTime > 0 && Source.EndTime <= Source.StartTime)
            {
                Source.Heading = Source.EndAngle;
                Source.EndTime = 0;
            }
            Target.Position = Target.Position.MoveForvard(Target.Finish, Target.Speed,
                                                          message.Time.Ticks - Target.StartTime);
            if (Target.EndTime > 0 && Target.EndTime <= Target.StartTime)
            {
                Target.Heading = Target.EndAngle;
                Target.EndTime = 0;
            }
            if (SourcePlayer != null && npc != null)
            {
                HitDirection = HitDirection.Pet;
            }
            else if (Source is ProjectileEntity || Source.Heading.Gradus == 0)
            {
                if (Skill?.Boom ?? true)
                {
                    HitDirection = Source.Position.GetHeading(Target.Position).HitDirection(Target.Heading);
                }
                else
                {
                    if ((HitDirection = userNpc["root_source"].Heading.HitDirection(Target.Heading)) != Source.Position.GetHeading(Target.Position).HitDirection(Target.Heading))
                    {
                        HitDirection = HitDirection.Front;
                    }
                }
            }
            else if ((HitDirection = Source.Heading.HitDirection(Target.Heading)) != Source.Position.GetHeading(Target.Position).HitDirection(Target.Heading))
            {
                HitDirection = HitDirection.Front;
            }
            if ((SourcePlayer?.Class == PlayerClass.Archer) && (abnormalityTracker?.AbnormalityExist(sourceUser.Id, 601600) ?? false))
            {
                HitDirection = HitDirection.Back;
            }
            //Debug.WriteLine(HitDirection);
            HitDirection = HitDirection & ~(HitDirection.Left | HitDirection.Right);
        }