Example #1
0
        protected override async Task Run()
        {
            const int baseButton = 2;

            while (!Ct.IsCancellationRequested)
            {
                if (_lastHealTime.AddSeconds(NoOperationDelay) < DateTime.UtcNow)
                {
                    await DoHeal(baseButton.ToString());
                }


                var model = MacroModel.GetClientModel(_targetWnd);

                var hpStr = string.Join(" ", model.Party.Select(m => $"hp:{m.Hp:0}"));
                var cd    = (DateTime.UtcNow - _lastHealTime).TotalSeconds;
                Status = $"t: {cd:0} " + hpStr;

                for (int pIndex = 0; pIndex < model.Party.Count; pIndex++)
                {
                    var m = model.Party[pIndex];
                    if (m.Hp.HasValue && m.Hp < PercentToHeal)
                    {
                        await DoHeal((baseButton + pIndex).ToString());

                        break;
                    }
                }

                await Task.Delay(200, Ct).ConfigureAwait(false);
            }
        }
Example #2
0
        protected override async Task Run()
        {
            var canSwitch = false;

            while (!Ct.IsCancellationRequested)
            {
                await Task.Delay(200, Ct).ConfigureAwait(false);

                var watch = MacroModel.GetClientModel(_watchWnd);
                var hp    = watch.TargetHp;

                Status = $"tHP:{hp}% last:{_lastHp}%";

                if (!watch.TargetHp.HasValue)
                {
                    continue;
                }

                if (_lastHp.HasValue && hp > _lastHp)
                {
                    canSwitch = true;
                }

                if (canSwitch && hp < HpToStartDd)
                {
                    canSwitch = false;
                    SetWarn(true);
                    using (new InjectContext())
                    {
                        AutoItX.WinActivate(_actWnd);
                        AutoItX.Send("{NUMPAD0}");
                    }
                    SetWarn(false);
                    await Task.Delay(1500, Ct).ConfigureAwait(false);
                }

                _lastHp = hp;
            }
        }