private static void InsertOutOfGameHooks() { const string hookName = "TreeStart"; if (_goldInactiveComposite == null) { _goldInactiveComposite = GoldInactivity.CreateGoldInactiveLeaveGame(); } if (_xpInactiveComposite == null) { _xpInactiveComposite = XpInactivity.CreateXpInactiveLeaveGame(); } Logger.Log("Inserting GoldInactivity into " + hookName); TreeHooks.Instance.InsertHook(hookName, 0, _goldInactiveComposite); Logger.Log("Inserting XPInactivity into " + hookName); TreeHooks.Instance.InsertHook(hookName, 0, _xpInactiveComposite); }
/// <summary> /// This will replace the main BehaviorTree hooks for Combat, Vendoring, and Looting. /// </summary> internal static void ReplaceTreeHooks() { if (Trinity.IsPluginEnabled) { // This is the do-all-be-all god-head all encompasing piece of trinity StoreAndReplaceHook("Combat", new Decorator(Trinity.TargetCheck, Trinity.HandleTargetAction())); // We still want the main VendorRun logic, we're just going to take control of *when* this logic kicks in var vendorDecorator = TreeHooks.Instance.Hooks["VendorRun"][0] as Decorator; if (vendorDecorator != null) { StoreAndReplaceHook("VendorRun", new Decorator(TownRun.TownRunCanRun, TownRun.TownRunWrapper(vendorDecorator.Children[0]))); } // Loot tree is now empty and never runs (Loot is handled through combat) // This is for special out of combat handling like Horadric Cache Composite lootComposite = TreeHooks.Instance.Hooks["Loot"][0]; StoreAndReplaceHook("Loot", Composites.CreateLootBehavior(lootComposite)); if (_goldInactiveComposite == null) { _goldInactiveComposite = GoldInactivity.CreateGoldInactiveLeaveGame(); } Logger.Log("Inserting GoldInactivity into BotBehavior"); TreeHooks.Instance.InsertHook("BotBehavior", 0, _goldInactiveComposite); } else { ReplaceHookWithOriginal("Combat"); ReplaceHookWithOriginal("VendorRun"); ReplaceHookWithOriginal("Loot"); Logger.Log("Removing GoldInactivity from BotBehavior"); TreeHooks.Instance.RemoveHook("BotBehavior", _goldInactiveComposite); } }