public LineHistory(Line line)
        {
            TimeStamp           = DateTime.Now;
            Line                = line;
            SourceStatusEntries = new List <StatusEntry>();
            TargetStatusEntries = new List <StatusEntry>();
            uint PlayerID = 0;

            try
            {
                var monsterEntries = MonsterWorkerDelegate.GetNPCEntities();
                var pcEntries      = PCWorkerDelegate.GetNPCEntities();
                // process you => monster
                foreach (var actorEntity in pcEntries)
                {
                    if (!String.Equals(actorEntity.Name, line.Source, Constants.InvariantComparer))
                    {
                        continue;
                    }
                    PlayerID = actorEntity.ID;
                    foreach (var statusEntry in actorEntity.StatusEntries)
                    {
                        SourceStatusEntries.Add(statusEntry);
                    }
                }
                foreach (var actorEntity in monsterEntries)
                {
                    if (!String.Equals(actorEntity.Name, line.Target, Constants.InvariantComparer))
                    {
                        return;
                    }
                    foreach (var statusEntry in actorEntity.StatusEntries)
                    {
                        if (statusEntry.CasterID == PlayerID)
                        {
                            TargetStatusEntries.Add(statusEntry);
                        }
                    }
                }
                // process monster => you
                foreach (var actorEntity in pcEntries)
                {
                    if (!String.Equals(actorEntity.Name, line.Target, Constants.InvariantComparer))
                    {
                        continue;
                    }
                    PlayerID = actorEntity.ID;
                    foreach (var statusEntry in actorEntity.StatusEntries)
                    {
                        TargetStatusEntries.Add(statusEntry);
                    }
                }
                foreach (var actorEntity in monsterEntries)
                {
                    if (!String.Equals(actorEntity.Name, line.Source, Constants.InvariantComparer))
                    {
                        return;
                    }
                    foreach (var statusEntry in actorEntity.StatusEntries)
                    {
                        if (statusEntry.CasterID == PlayerID)
                        {
                            SourceStatusEntries.Add(statusEntry);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 2
0
        private void StatusUpdateTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (StatusUpdateTimerProcessing)
            {
                return;
            }
            StatusUpdateTimerProcessing = true;
            var monsterEntries = MonsterWorkerDelegate.GetNPCEntities();
            var pcEntries      = PCWorkerDelegate.GetNPCEntities();

            StatusEntriesSelf.Clear();
            StatusEntriesPlayers.Clear();
            StatusEntriesMonsters.Clear();
            if (pcEntries.Any())
            {
                try
                {
                    var cleanedName = Regex.Replace(Name, @"\[[\w]+\]", "")
                                      .Trim();
                    var isYou = Regex.IsMatch(cleanedName, @"^(([Dd](ich|ie|u))|You|Vous)$") || String.Equals(cleanedName, Constants.CharacterName, Constants.InvariantComparer);
                    var isPet = false;
                    try
                    {
                        NPCEntry = isYou ? PCWorkerDelegate.CurrentUser : null;
                        if (!isYou)
                        {
                            try
                            {
                                NPCEntry = pcEntries.First(p => String.Equals(p.Name, cleanedName, Constants.InvariantComparer));
                            }
                            catch (Exception ex)
                            {
                                isPet = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (NPCEntry != null)
                    {
                        ID = NPCEntry.ID;
                        if (ID > 0)
                        {
                            StatusEntriesSelf = NPCEntry.StatusEntries;
                            try
                            {
                                foreach (var statusEntry in
                                         monsterEntries.ToList()
                                         .Where(p => p.HPCurrent > 0)
                                         .SelectMany(monster => monster.StatusEntries)
                                         .Where(statusEntry => statusEntry.CasterID == ID))
                                {
                                    StatusEntriesMonsters.Add(statusEntry);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                foreach (var statusEntry in
                                         pcEntries.ToList()
                                         .Where(p => p.HPCurrent > 0)
                                         .SelectMany(pc => pc.StatusEntries)
                                         .Where(statusEntry => statusEntry.CasterID == ID))
                                {
                                    StatusEntriesPlayers.Add(statusEntry);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            if (!StatusEntriesMonsters.Any() && !StatusEntriesPlayers.Any())
            {
                StatusUpdateTimerProcessing = false;
                return;
            }
            if (StatusEntriesMonsters.Any())
            {
                ProcessDamageOverTime(StatusEntriesMonsters);
            }
            if (StatusEntriesPlayers.Any())
            {
                ProcessHealingOverTime(StatusEntriesPlayers);
                ProcessBuffs(StatusEntriesPlayers);
            }
            StatusUpdateTimerProcessing = false;
        }
Esempio n. 3
0
        private static void UpdateActions(Match actions, Line line, Expressions exp, FilterType type)
        {
            _type = type;
            _lastActionYouIsAttack         = false;
            _lastActionPetIsAttack         = false;
            _lastActionPartyIsAttack       = false;
            _lastActionPetPartyIsAttack    = false;
            _lastActionAllianceIsAttack    = false;
            _lastActionPetAllianceIsAttack = false;
            try
            {
                if (String.IsNullOrWhiteSpace(line.Source))
                {
                    line.Source = Convert.ToString(actions.Groups["source"].Value);
                }
                var isHealingSkill = false;
                var player         = ParseControl.Instance.Timeline.GetSetPlayer(line.Source);
                var action         = StringHelper.TitleCase(Convert.ToString(actions.Groups["action"].Value));
                foreach (var healingAction in ParseHelper.HealingActions.Where(healingAction => String.Equals(healingAction, action, Constants.InvariantComparer)))
                {
                    isHealingSkill = true;
                }
                switch (type)
                {
                case FilterType.You:
                    _lastActionYou = action;
                    break;

                case FilterType.Pet:
                    _lastActionPet = action;
                    _lastNamePet   = line.Source;
                    break;

                case FilterType.Party:
                    if (isHealingSkill)
                    {
                        _lastActionPartyHealingFrom = action;
                        _lastNamePartyHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPartyFrom = action;
                        _lastNamePartyFrom   = line.Source;
                    }
                    break;

                case FilterType.PetParty:
                    if (isHealingSkill)
                    {
                        _lastActionPetPartyHealingFrom = action;
                        _lastNamePetPartyHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetPartyFrom = action;
                        _lastNamePetPartyFrom   = line.Source;
                    }
                    break;

                case FilterType.Alliance:
                    if (isHealingSkill)
                    {
                        _lastActionAllianceHealingFrom = action;
                        _lastNameAllianceHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionAllianceFrom = action;
                        _lastNameAllianceFrom   = line.Source;
                    }
                    break;

                case FilterType.PetAlliance:
                    if (isHealingSkill)
                    {
                        _lastActionPetAllianceHealingFrom = action;
                        _lastNamePetAllianceHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetAllianceFrom = action;
                        _lastNamePetAllianceFrom   = line.Source;
                    }
                    break;

                case FilterType.Other:
                    if (isHealingSkill)
                    {
                        _lastActionOtherHealingFrom = action;
                        _lastNameOtherHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionOtherFrom = action;
                        _lastNameOtherFrom   = line.Source;
                    }
                    break;

                case FilterType.PetOther:
                    if (isHealingSkill)
                    {
                        _lastActionPetOtherHealingFrom = action;
                        _lastNamePetOtherHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetOtherFrom = action;
                        _lastNamePetOtherFrom   = line.Source;
                    }
                    break;
                }
                player.LastActionTime = DateTime.Now;
                try
                {
                    var players = PCWorkerDelegate.GetNPCEntities();
                    if (!players.Any())
                    {
                        return;
                    }
                    foreach (var actorEntity in players)
                    {
                        var playerName = actorEntity.Name;
                        ParseControl.Instance.Timeline.TrySetPlayerCurable(playerName, actorEntity.HPMax - actorEntity.HPCurrent);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            catch (Exception ex)
            {
                ParsingLogHelper.Error(Logger, "Action", exp.Event, ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// </summary>
        /// <param name="statusEntriesPlayers"></param>
        private void ProcessHealingOverTime(IEnumerable <StatusEntry> statusEntriesPlayers)
        {
            foreach (var statusEntry in statusEntriesPlayers)
            {
                try
                {
                    var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                    var statusKey  = statusInfo.Name.English;
                    switch (Constants.GameLanguage)
                    {
                    case "French":
                        statusKey = statusInfo.Name.French;
                        break;

                    case "Japanese":
                        statusKey = statusInfo.Name.Japanese;
                        break;

                    case "German":
                        statusKey = statusInfo.Name.German;
                        break;

                    case "Chinese":
                        statusKey = statusInfo.Name.Chinese;
                        break;
                    }
                    if (String.IsNullOrWhiteSpace(statusKey))
                    {
                        continue;
                    }
                    var             amount     = NPCEntry.Level / ((60 - NPCEntry.Level) * .025m);
                    var             key        = statusKey;
                    XOverTimeAction actionData = null;
                    foreach (var healingOverTimeAction in HealingOverTimeHelper.PlayerActions.ToList()
                             .Where(d => String.Equals(d.Key, key, Constants.InvariantComparer)))
                    {
                        actionData = healingOverTimeAction.Value;
                    }
                    if (actionData == null)
                    {
                        continue;
                    }
                    var zeroFoundInList    = false;
                    var regen              = Regex.IsMatch(key, @"(リジェネ|récup|regen|再生|whispering|murmure|erhebendes|光の囁き|日光的低语)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
                    var healingHistoryList = ParseHelper.LastAmountByAction.GetPlayer(Name)
                                             .ToList();
                    var resolvedPotency = 350;
                    foreach (var healingAction in healingHistoryList)
                    {
                        if (regen)
                        {
                            var found         = false;
                            var cureActions   = HealingOverTimeHelper.CureActions;
                            var medicaActions = HealingOverTimeHelper.MedicaActions;
                            var action        = healingAction;
                            if (cureActions["III"].Any(cureAction => String.Equals(action.Key, cureAction, Constants.InvariantComparer)))
                            {
                                found           = zeroFoundInList = true;
                                resolvedPotency = 550;
                            }
                            if (cureActions["II"].Any(cureAction => String.Equals(action.Key, cureAction, Constants.InvariantComparer)))
                            {
                                found           = zeroFoundInList = true;
                                resolvedPotency = 650;
                            }
                            if (cureActions["I"].Any(cureAction => String.Equals(action.Key, cureAction, Constants.InvariantComparer)))
                            {
                                found           = zeroFoundInList = true;
                                resolvedPotency = 400;
                            }
                            if (medicaActions["II"].Any(medicaAction => String.Equals(action.Key, medicaAction, Constants.InvariantComparer)))
                            {
                                found           = zeroFoundInList = true;
                                resolvedPotency = 200;
                            }
                            if (medicaActions["I"].Any(medicaAction => String.Equals(action.Key, medicaAction, Constants.InvariantComparer)))
                            {
                                found           = zeroFoundInList = true;
                                resolvedPotency = 300;
                            }
                            if (found)
                            {
                                if (action.Value > 0)
                                {
                                    amount = action.Value;
                                }
                                break;
                            }
                        }
                        if (String.Equals(healingAction.Key, key, Constants.InvariantComparer))
                        {
                            amount = healingAction.Value;
                            break;
                        }
                    }
                    statusKey = String.Format("{0} [•]", statusKey);
                    if (amount == 0)
                    {
                        amount = 75;
                    }
                    resolvedPotency = zeroFoundInList ? resolvedPotency : regen ? resolvedPotency : actionData.ActionPotency;
                    var tickHealing = Math.Ceiling(((amount / resolvedPotency) * actionData.ActionOverTimePotency) / 3);
                    if (actionData.HasNoInitialResult && !zeroFoundInList)
                    {
                        var nonZeroActions = healingHistoryList.Where(d => !d.Key.Contains("•"));
                        var keyValuePairs  = nonZeroActions as IList <KeyValuePair <string, decimal> > ?? nonZeroActions.ToList();
                        var healing        = 0m;
                        switch (regen)
                        {
                        case true:
                            healing = Math.Ceiling(((amount / resolvedPotency) * actionData.ActionOverTimePotency) / 3);
                            break;

                        case false:
                            if (keyValuePairs.Any())
                            {
                                amount = keyValuePairs.Sum(action => action.Value);
                                amount = amount / keyValuePairs.Count();
                            }
                            healing = Math.Ceiling(((amount / resolvedPotency) * actionData.ActionOverTimePotency) / 3);
                            break;
                        }
                        tickHealing = healing > 0 ? healing : tickHealing;
                    }
                    var line = new Line
                    {
                        Action         = statusKey,
                        Amount         = tickHealing,
                        EventDirection = EventDirection.Unknown,
                        EventType      = EventType.Cure,
                        EventSubject   = EventSubject.Unknown,
                        Source         = Name
                    };
                    try
                    {
                        var players = Controller.Timeline.Party.ToList();
                        var entry   = statusEntry;
                        foreach (var player in players.Where(player => player.Name.Contains(entry.TargetName)))
                        {
                            line.Target = player.Name;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (String.IsNullOrWhiteSpace(line.Target))
                    {
                        line.Target = String.Format("[???] {0}", statusEntry.TargetName);
                    }
                    Controller.Timeline.FightingRightNow = true;
                    Controller.Timeline.FightingTimer.Stop();
                    switch (Settings.Default.StoreHistoryEvent)
                    {
                    case "Any":
                        Controller.Timeline.StoreHistoryTimer.Stop();
                        break;
                    }
                    DispatcherHelper.Invoke(delegate
                    {
                        line.Hit = true;
                        // resolve player hp each tick to ensure they are not at max
                        try
                        {
                            var players = PCWorkerDelegate.GetNPCEntities();
                            if (!players.Any())
                            {
                                return;
                            }
                            foreach (var actorEntity in players)
                            {
                                var playerName = actorEntity.Name;
                                Controller.Timeline.TrySetPlayerCurable(playerName, actorEntity.HPMax - actorEntity.HPCurrent);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        var currentCritPercent = (double)Stats.GetStatValue("HealingCritPercent");
                        if (new Random().NextDouble() * 3 < currentCritPercent)
                        {
                            line.Crit   = true;
                            line.Amount = line.Amount * 1.5m;
                        }
                        Controller.Timeline.GetSetPlayer(line.Source)
                        .SetHealingOverTime(line);
                    });
                }
                catch (Exception ex)
                {
                }
            }
            Controller.Timeline.FightingTimer.Start();
            switch (Settings.Default.StoreHistoryEvent)
            {
            case "Any":
                Controller.Timeline.StoreHistoryTimer.Start();
                break;
            }
        }