protected override Composite CreateBehavior() { return(new PrioritySelector( new Decorator(r => Request.IsOpen, new Action(r => { var items = InventoryManager.FilledInventoryAndArmory.ToArray(); for (int i = 0; i < ItemIds.Length; i++) { BagSlot item; item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && !usedSlots.Contains(z)); if (item == null) { LogError($"We don't have any items with an id of {ItemIds[i]}."); } else { item.Handover(); usedSlots.Add(item); } } usedSlots.Clear(); Request.HandOver(); }) ), new Decorator(r => Core.Player.HasTarget && UseItem && !doneUseItem, new Action(r => { var targetNpc = GameObjectManager.GetObjectByNPCId(InteractNpcId); foreach (BagSlot slot in InventoryManager.FilledSlots) { if (slot.RawItemId == ItemIds.FirstOrDefault()) { Log($"Using {slot.EnglishName} on {targetNpc.EnglishName}."); slot.UseItem(targetNpc); } } if (Core.Player.IsCasting) { doneUseItem = true; } if (SelectYesno.IsOpen) { doneUseItem = true; } }) ), base.CreateBehavior() )); }
protected override Composite CreateBehavior() { return(new PrioritySelector( CommonBehaviors.HandleLoading, new Decorator(ret => QuestLogManager.InCutscene, new ActionAlwaysSucceed() ), new Decorator(r => Request.IsOpen, new Action(r => { var items = InventoryManager.FilledInventoryAndArmory.ToArray(); for (int i = 0; i < ItemIds.Length; i++) { BagSlot item; item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && !usedSlots.Contains(z)); if (item == null) { LogError($"We don't have any items with an id of {ItemIds[i]}."); } else { item.Handover(); usedSlots.Add(item); } } usedSlots.Clear(); Request.HandOver(); }) ), new Decorator(r => Core.Player.HasTarget && UseItem && !doneUseItem, new Action(r => { var targetNpc = GameObjectManager.GetObjectByNPCId(InteractNpcId); foreach (BagSlot slot in InventoryManager.FilledSlots) { if (slot.RawItemId == ItemIds.FirstOrDefault()) { Log($"Using {slot.EnglishName} on {targetNpc.EnglishName}."); slot.UseItem(targetNpc); } } if (Core.Player.IsCasting) { doneUseItem = true; } if (SelectYesno.IsOpen) { doneUseItem = true; } }) ), new Decorator(ret => HasInteractObjects && DutyManager.InInstance && !Core.Player.InCombat && InteractableTarget != null, new PrioritySelector( new Decorator(ret => Core.Player.Location.Distance(InteractableTarget.Location) <= 5, new Action(r => { InteractableTarget.Interact(); }) ), new Decorator(ret => Core.Player.Location.Distance(InteractableTarget.Location) > 5, CommonBehaviors.MoveAndStop(ret => InteractableTarget.Location, 3) ), new ActionAlwaysSucceed() ) ), new Decorator(ret => HasCheckpoints && DutyManager.InInstance, new PrioritySelector( new Decorator(ret => Core.Player.Location.Distance(CurrentCheckpoint) < 5, new Action(r => { Checkpoints.Remove(Checkpoints.First()); }) ), new Decorator(ret => Core.Player.Location.Distance(CurrentCheckpoint) > 5, CommonBehaviors.MoveAndStop(ret => CurrentCheckpoint, 3) ) ) ), base.CreateBehavior() )); }