private static SwitchArgument <RepairState> GetRepairStep(RepairContext context) { var closeAction = new Action(r => { Repair.Close(); context.State = BotManager.Current.Name != "Fate Bot" ? RepairState.MovingBack : RepairState.None; Logger.AgilMessage("Ended repair step, now on: {0}", context.State); }); var close = new Decorator(req => Equipment.GetCondition() >= context.MinimumDurability && Repair.IsOpen, closeAction); var dismount = new Decorator(req => Core.Me.IsMounted, new Action(r => Actionmanager.Dismount())); var selectYes = new Decorator(req => SelectYesno.IsOpen, new Action(r => SelectYesno.ClickYes())); var move = Movement.SprintMove(r => context.Location); var repairAll = new RepairAll(); var selectRepair = new SetIconString(2); var setTarget = new SetTarget(() => context.NpcId); var interact = new Decorator(req => !Repair.IsOpen && !SelectIconString.IsOpen && !SelectYesno.IsOpen, new Interact()); var repairStep = new PrioritySelector(move, dismount, close, selectYes, repairAll, selectRepair, setTarget, interact, new Action(r => RunStatus.Success)); return(new SwitchArgument <RepairState>(repairStep, RepairState.Repairing)); }
/// <summary> /// Repairs current gearset via self-repair. /// </summary> private async Task DoSelfRepair() { Logger.LogInformation(Translations.LOG_REPAIR_SELF); if (!HaveRepairMaterials(InventoryManager.EquippedItems.Where(s => s.IsFilled))) { // TODO: Buy dark matter from NPC, or fail if unable (can't travel, dungeon, low gil, etc) } if (!Repair.IsOpen) { ActionManager.ToggleRepairWindow(); await Coroutine.Sleep(250); } // Only clicks the button, Yes/No is separate Repair.RepairAll(); await Coroutine.Wait(1000, () => SelectYesno.IsOpen); SelectYesno.ClickYes(); await Coroutine.Sleep(2500); Repair.Close(); }
protected Composite Behavior() { return(new PrioritySelector( // can tag execute? new Decorator(ret => !CanRepair(), new Action(r => { _done = true; }) ), new Decorator(ret => CanRepair(), new PrioritySelector( new Decorator(ret => CanRepair() && !Repair.IsOpen, new Action(r => { if (Void == true) { OpenRepair(); } else { ActionManager.ToggleRepairWindow(); } }) ) ) ), // repair new Decorator(ret => Repair.IsOpen, new PrioritySelector( new Decorator(ret => Repaired, new Action(r => { Repair.Close(); _done = true; }) ), new Decorator(ret => Repair.IsOpen && !RepairAllClicked, new Action(r => { RepairAllClicked = true; Repair.RepairAll(); }) ), new Decorator(ret => SelectYesno.IsOpen, new Action(r => { SelectYesno.ClickYes(); Repaired = true; }) ) )) )); }
protected Composite Behavior() { return(new PrioritySelector( // can tag execute? new Decorator(ret => !CanRepair(), new Action(r => { _done = true; }) ), new Decorator(ret => CanRepair(), new PrioritySelector( new Decorator(ret => !Repair.IsOpen, new ActionRunCoroutine(async r => { if (Void == true) { OpenRepair(); } else { ActionManager.ToggleRepairWindow(); await Coroutine.Wait(3000, () => Repair.IsOpen); } }) ), new Decorator(ret => Repair.IsOpen, new ActionRunCoroutine(async r => { Repair.RepairAll(); if (await Coroutine.Wait(4000, () => SelectYesno.IsOpen)) { SelectYesno.ClickYes(); } Repair.Close(); await Coroutine.Wait(3000, () => !Repair.IsOpen); }) ) ) ) )); }
public static async Task RepairAll() { if (InventoryManager.EquippedItems.Any(item => item.Item != null && item.Item.RepairItemId != 0 && item.Condition < 50)) { Log("Repairing items."); await StopBusy(leaveDuty : false, stopFishing : false, dismount : false); if (!Repair.IsOpen) { var repairVTable = Offsets.RepairVTable; var repairVendor = Offsets.RepairVendor; var repairWindow = Offsets.RepairWindowOpen; var repairAgent = AgentModule.FindAgentIdByVtable(repairVTable); var AgentId = repairAgent; Log($"OPEN: AgentId {AgentId} Offset {repairVendor.ToInt64():X} Func {repairWindow.ToInt64():X}"); lock (Core.Memory.Executor.AssemblyLock) { Core.Memory.CallInjected64 <IntPtr>(repairWindow, new object[4] { ff14bot.Managers.AgentModule.GetAgentInterfaceById(AgentId).Pointer, 0, 0, repairVendor }); } await Coroutine.Wait(1500, () => Repair.IsOpen); } Repair.RepairAll(); await Coroutine.Wait(1500, () => SelectYesno.IsOpen); SelectYesno.ClickYes(); Repair.Close(); } else { Log("No items to repair."); } }
protected Composite Behavior() { return(new PrioritySelector( // can tag execute? new Decorator(ret => !CanRepair(), new Action(r => { _done = true; }) ), new Decorator(ret => CraftingLog.IsOpen, new ActionRunCoroutine(ctx => StopCrafting()) ), // stage 1: Find the NPC new Decorator(ret => Poi.Current.Type == PoiType.None, new PrioritySelector( new Decorator(ret => GameObjectManager.GetObjectByNPCId(NpcId) != null, new Action(r => { NPC = GameObjectManager.GetObjectByNPCId(NpcId); Poi.Current = new Poi(NPC, PoiType.Vendor); }) ), new Decorator(ret => XYZ != null && Core.Player.Location.Distance(XYZ) > 20f, CommonBehaviors.MoveAndStop(ret => XYZ, 19f, true, null, RunStatus.Success) ), new Decorator(ret => NPC == null, new Action(r => { _done = true; }) ) ) ), // stage 2: go to NPC and Interact new Decorator(ret => Poi.Current.Type == PoiType.Vendor && !Repair.IsOpen, new PrioritySelector( new Decorator(ret => SelectIconString.IsOpen, new Action(r => { SelectIconString.ClickSlot(DialogOption); }) ), new Decorator(ret => Core.Player.Location.Distance(Poi.Current.Location) > 3f, CommonBehaviors.MoveAndStop(ret => Poi.Current.Location, 2f, true, null, RunStatus.Failure) ), new Decorator(ret => Poi.Current.Type == PoiType.Vendor, new Action(r => { Poi.Current.Unit.Interact(); }) ) )), // stage 3: repair new Decorator(ret => Repair.IsOpen, new PrioritySelector( new Decorator(ret => Repaired, new Action(r => { Repair.Close(); _done = true; }) ), new Decorator(ret => Repair.IsOpen && !RepairAllClicked, new Action(r => { RepairAllClicked = true; Repair.RepairAll(); }) ), new Decorator(ret => SelectYesno.IsOpen, new Action(r => { SelectYesno.ClickYes(); Repaired = true; }) ) )) )); }