Ejemplo n.º 1
0
            internal void AddDamageInstance(PSO2DamageInstance instance)
            {
                TotalDamage += instance.Damage;
                TotalHits++;
                if (MinDamage > 0)
                {
                    if (instance.Damage < MinDamage)
                    {
                        MinDamage = instance.Damage;
                    }
                }
                else
                {
                    MinDamage = instance.Damage;
                }
                if (MaxDamage > 0)
                {
                    if (instance.Damage > MaxDamage)
                    {
                        MaxDamage = instance.Damage;
                    }
                }
                else
                {
                    MaxDamage = instance.Damage;
                }

                ja_critHelper.AddDamage(instance);
            }
Ejemplo n.º 2
0
 public void AddDamage(PSO2DamageInstance instance)
 {
     TotalDamage  += instance.Damage;
     UpdateDamage += instance.Damage;
     instanceHistory.Enqueue(instance);
     critJaHelper.AddDamage(instance);
     _damageInstances.Add(instance);
 }
Ejemplo n.º 3
0
 void UpdateMaxHit(PSO2DamageInstance instance)
 {
     if (MaxHit < instance.Damage)
     {
         MaxHit     = instance.Damage;
         MaxHitName = instance.AttackName;
     }
 }
Ejemplo n.º 4
0
 private bool CheckIfSelfInstance(PSO2DamageInstance damageInstance)
 {
     if (damageInstance.SourceName == "YOU")
     {
         selfPlayerId = damageInstance.SourceId;
         Console.WriteLine($"Found self ID {selfPlayerId}");
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
        private void AddAttackInfo(PSO2DamageInstance instance)
        {
            if (!_attackInfoList.ContainsKey(instance.AttackName))
            {
                _attackInfoList.Add(instance.AttackName, new AttackInfo(instance.AttackName, instance.AttackId));
            }
            var container = _attackInfoList[instance.AttackName];

            container.AddDamageInstance(instance);
        }
Ejemplo n.º 6
0
 private void internalReset()
 {
     _players.Clear();
     lastUpdateTime        = TimeSpan.Zero;
     lastDamageInstance    = null;
     hasLogStartTime       = false;
     timeLogStarted        = DateTime.MinValue;
     damageInstancesQueued = 0;
     timeLastUpdateInvoked = DateTime.MinValue;
     ZanversePlayer        = null;
 }
Ejemplo n.º 7
0
 //specifically for Zanverse player, since it has an invalid ID, AddDamageInstance would ignore it
 public void AddZanverseDamageInstance(PSO2DamageInstance instance)
 {
     //instance.ReplaceZanverseName(); //due to adding AnonymizeDamage feature, names might get leaked via zanverse player, so just disable name replacement for now
     ZanverseDamage.AddDamage(instance);
     if (MaxHit < instance.Damage)
     {
         MaxHit     = instance.Damage;
         MaxHitName = instance.AttackName;
     }
     _damageInstances.Add(instance);
 }
Ejemplo n.º 8
0
            public void AddDamageInstance(PSO2DamageInstance instance)
            {
                //this sends the damage instance to the correct split player, or the combined player if this instance isnt split
                //dispatchInstance returns true when damagetype matches split player, once true, wereAnyDispatched will be set to true.
                //we dont deal with ZV separation, since all players are accumulated for that, it is handled in DamageParser class itself
                bool wereAnyDispatched = dispatchInstance(instance.IsAISDamage, PSO2DamageTrackers.AIS, instance, "AIS");

                wereAnyDispatched |= dispatchInstance(instance.IsDarkBlastDamage, PSO2DamageTrackers.DarkBlast, instance, "DB");
                wereAnyDispatched |= dispatchInstance(instance.IsHeroFinishDamage, PSO2DamageTrackers.HTF, instance, "HTF");
                wereAnyDispatched |= dispatchInstance(instance.IsLaconiumDamage, PSO2DamageTrackers.LSW, instance, "LSW");
                wereAnyDispatched |= dispatchInstance(instance.IsPhotonDamage, PSO2DamageTrackers.PWP, instance, "PWP");
                wereAnyDispatched |= dispatchInstance(instance.IsRideroidDamage, PSO2DamageTrackers.Ride, instance, "Ride");
                wereAnyDispatched |= dispatchInstance(instance.IsElementalDamage && !PSO2Player.IsAllyId(instance.TargetId), PSO2DamageTrackers.Elem, instance, "Elem"); //don't split incoming elemental dmg
                if (!wereAnyDispatched)
                {
                    CombinedPlayer.AddDamageInstance(instance);
                }
            }
Ejemplo n.º 9
0
 private void CheckHistory(TimeSpan clockTime)
 {
     for (;;)
     {
         if (instanceHistory.Count == 0)
         {
             return;
         }
         PSO2DamageInstance curInstance = instanceHistory.Peek();
         if (clockTime - curInstance.RelativeTimestamp > historyDuration)
         {
             instanceHistory.Dequeue(); //get rid of this, its too old now
         }
         else
         {
             break;
         }
     }
 }
Ejemplo n.º 10
0
        public void AddDamage(PSO2DamageInstance instance)
        {
            totalHitCount++;
            if (instance.IsCrit)
            {
                critHitCount++;
            }
            if (!PSO2AttackNameHelper.IsIgnoredAttackForJA(instance.AttackId))
            {
                if (instance.IsJustAttack)
                {
                    jaHitCount++;
                }
                totalJAHitCount++;
                JAPercent = (float)jaHitCount * 100f / (float)totalJAHitCount;
            }

            CritPercent = (float)critHitCount * 100f / (float)totalHitCount;
        }
Ejemplo n.º 11
0
 bool dispatchInstance(bool isCorrectType, PSO2DamageTrackers tracker, PSO2DamageInstance instance, string nameSuffix)
 {
     if (!isCorrectType)
     {
         return(false);
     }
     if (parser.trackersToSuppress.HasFlag(tracker) && (tracker == PSO2DamageTrackers.Elem ? !PSO2Player.IsAllyId(instance.TargetId) : true))
     {
         return(true);                                                                                                                                      //swallow this damage instance if it's suppressed. If element is hidden, only hide if its outgoing elemental dmg
     }
     else if (IsSplit(tracker))
     {
         if (!playerTrackerDict.ContainsKey(tracker))
         {
             buildSplitPlayer(tracker, nameSuffix);
         }
         playerTrackerDict[tracker].AddDamageInstance(instance);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 12
0
 private void EnsurePlayerExists(PSO2DamageInstance instance)
 {
     if (PSO2Player.IsAllyId(instance.SourceId))
     {
         if (!_players.ContainsKey(instance.SourceId))
         {
             var controller = new PlayerDamageSeparationController(instance.SourceName, instance.SourceId, updateClock, InstanceUpdateHistoryDuration, this, trackersToSum);
             _players.Add(instance.SourceId, controller);
             Console.WriteLine($"Creating PSO2Player for source id {instance.SourceId}, name {instance.SourceName}");
         }
     }
     if (PSO2Player.IsAllyId(instance.TargetId))
     {
         if (!_players.ContainsKey(instance.TargetId))
         {
             var controller = new PlayerDamageSeparationController(instance.TargetName, instance.TargetId, updateClock, InstanceUpdateHistoryDuration, this, trackersToSum);
             _players.Add(instance.TargetId, controller);
             Console.WriteLine($"Creating PSO2Player for target id {instance.TargetId}, name {instance.TargetName}");
         }
     }
 }
Ejemplo n.º 13
0
 bool dispatchInstance(bool isCorrectType, PSO2DamageTrackers tracker, PSO2DamageInstance instance, string nameSuffix)
 {
     if (!isCorrectType)
     {
         return(false);
     }
     if (parser.trackersToSuppress.HasFlag(tracker))
     {
         return(true);                                            //swallow this damage instance if it's suppressed.
     }
     else if (IsSplit(tracker))
     {
         if (!playerTrackerDict.ContainsKey(tracker))
         {
             buildSplitPlayer(tracker, nameSuffix);
         }
         playerTrackerDict[tracker].AddDamageInstance(instance);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 14
0
        private List <PSO2DamageInstance> getLatestDamageInstances(bool ensurePlayersExist = true)
        {
            List <PSO2DamageInstance> instances = new List <PSO2DamageInstance>();

            string lastReadBuffer = logStream.ReadToEnd();

            foreach (var currentLine in lastReadBuffer.Split('\n').Select(l => l.Trim('\r')))
            {
                if (string.IsNullOrWhiteSpace(currentLine))
                {
                    continue;
                }
                string[] parts = currentLine.Split(',');
                if (parts.Length != 13)
                {
                    continue;
                }

                var damageInstance = new PSO2DamageInstance(parts);
                if (CheckIfSelfInstance(damageInstance))
                {
                    continue;                                      //don't log this.
                }
                if (ensurePlayersExist)
                {
                    EnsurePlayerExists(damageInstance);
                }
                if (damageInstance.InstanceId == -1 || damageInstance.SourceId == 0 || damageInstance.TargetId == 0 || damageInstance.AttackId == 0)
                {
                    continue;                                                                                                                                  //invalid
                }
                if (damageInstance.Damage < 1)
                {
                    continue;                            //not needed, not logging healing, no overheal check so whats the point
                }
                instances.Add(damageInstance);
            }
            return(instances);
        }
Ejemplo n.º 15
0
        private void updateTick(object user)
        {
            lock (updateLock)
            {
                if (resetQueued)
                {
                    resetQueued = false;
                    internalReset();
                }
                if ((DateTime.Now - timeLastLogScanned).TotalSeconds > 10)
                {
                    timeLastLogScanned = DateTime.Now;
                    string latestLogFile = getLatestLogFile();
                    if (latestLogFile != lastOpenedFile)
                    {
                        initializeLogFile(latestLogFile);
                    }
                }
                var damageInstances = getLatestDamageInstances();
                NewDamageInstanceCount = damageInstances.Count;
                if (NewDamageInstanceCount > 0 && resetParserOnNewInstance)
                {
                    resetParserOnNewInstance = false;
                    internalReset();
                    foreach (var instance in damageInstances)
                    {
                        EnsurePlayerExists(instance);                                       //since we clear the _players in internalReset, we must ensure all players exist again.
                    }
                }
                foreach (var instance in damageInstances)
                {
                    if (!hasLogStartTime)
                    {
                        hasLogStartTime = true;
                        timeLogStarted  = instance.Timestamp;
                        NewSessionStarted?.Invoke(this, EventArgs.Empty);
                    }
                    instance.UpdateLogStartTime(timeLogStarted);
                    lastDamageInstance = instance;
                    if (_players.ContainsKey(instance.SourceId))
                    {
                        var sourcePlayer = _players[instance.SourceId];
                        sourcePlayer.AddDamageInstance(instance);
                    }
                    if (_players.ContainsKey(instance.TargetId))
                    {
                        var targetPlayer = _players[instance.TargetId];
                        targetPlayer.AddDamageInstance(instance);
                    }
                    if (instance.IsZanverseDamage && IsZanverseSplit && !trackersToSuppress.HasFlag(PSO2DamageTrackers.Zanverse))
                    {
                        if (ZanversePlayer == null)
                        {
                            ZanversePlayer = new PSO2Player("Zanverse", long.MaxValue, updateClock, InstanceUpdateHistoryDuration, PSO2DamageTrackers.Zanverse, this);
                            ZanversePlayer.SetSpecialPlayer(true, false);
                        }
                        ZanversePlayer.AddZanverseDamageInstance(instance);
                    }
                    damageInstancesQueued++;
                    //should send out an update every time updateClock interval is passed between last update and this.
                    //allows an old log to be pasted at once and still read out dps accurately over time
                    while (lastDamageInstance.RelativeTimestamp - lastUpdateTime > updateClock)
                    {
                        DoUpdateTick();
                    }
                }

                if (timeLastUpdateInvoked != DateTime.MinValue && DateTime.Now - timeLastUpdateInvoked > timeUntilSendManualUpdate && damageInstancesQueued > 0)
                {
                    NewDamageInstanceCount = damageInstancesQueued; //bugfix, NewDamageInstanceCount being set to 0 by above call is incorrect, since there actually are new instances being processed
                    DoUpdateTick();
                }

                if (AutoEndSession && timeLastUpdateInvoked != DateTime.MinValue && DateTime.Now - timeLastUpdateInvoked > AutoEndTimeout && !resetParserOnNewInstance)
                {
                    Console.WriteLine("Notifying to end session");
                    AutoEndSessionEvent?.Invoke(this, EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 16
0
        public void AddDamageInstance(PSO2DamageInstance instance)
        {
            if (instance.TargetId == ID)
            {
                //we took damage from instance.SourceId
                _receivedDamageInstances.Add(instance);
                DamageTaken.AddDamage(instance);

                if (!_attackInfoList.ContainsKey("Damage Taken"))
                {
                    _attackInfoList.Add("Damage Taken", new AttackInfo("Damage Taken", 0));
                }
                _attackInfoList["Damage Taken"].AddDamageInstance(instance);
            }
            else if (instance.SourceId == ID)
            {
                //we dealt damage to instance.TargetId
                if (instance.IsAISDamage)
                {
                    AISDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.AIS))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsDarkBlastDamage)
                {
                    DarkBlastDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.DarkBlast))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsZanverseDamage)
                {
                    ZanverseDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.Zanverse))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsHeroFinishDamage)
                {
                    HeroTimeFinishDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.HTF))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsPhotonDamage)
                {
                    PhotonDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.PWP))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsRideroidDamage)
                {
                    RideroidDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.Ride))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsLaconiumDamage)
                {
                    LaconiumDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.LSW))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else if (instance.IsElementalDamage)
                {
                    ElementDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.Elem))
                    {
                        AddAttackInfo(instance);
                    }
                }
                else
                {
                    BasicDamage.AddDamage(instance);

                    if (trackersToSum.HasFlag(PSO2DamageTrackers.Basic))
                    {
                        AddAttackInfo(instance);
                    }
                }

                _damageInstances.Add(instance);

                if (instance.IsZanverseDamage) //only update ZV max hit if ZV is not separated
                {
                    if (trackersToSum.HasFlag(PSO2DamageTrackers.Zanverse))
                    {
                        UpdateMaxHit(instance);
                    }
                }
                else
                {
                    UpdateMaxHit(instance);
                }
            }
        }