bfir3 Posted August 9, 2014 Share Posted August 9, 2014 (edited) Hey all, I have another issue lately. I can't seem to successfully unregister to RunAwayFromCombat hook. Here is a piece of code I have with traces for now: this.getBot().getRandomExecutor().unregisterHook(RandomEvent.RUN_AWAY_FROM_COMBAT); if (this.getBot().getRandomExecutor().hasHook(RandomEvent.RUN_AWAY_FROM_COMBAT)) { log("RunAwayFromCombat random handler has hook"); } else { log("RunAwayFromCombat random handler does not have hook"); } this.getBot().getRandomExecutor().registerRandoms(); if (this.getBot().getRandomExecutor().hasHook(RandomEvent.RUN_AWAY_FROM_COMBAT)) { log("RunAwayFromCombat random handler has hook"); } else { log("RunAwayFromCombat random handler does not have hook"); } That is in my onStart() method. And I see that the "RunAwayFromCombat random handler does not have hook" twice in the log when starting -- indicating that it would not run, I imagine. Yet, when I am attacked by a swarm or other I still get the random RunAwayFromCombat overlay and OSBot handles it normally. Any ideas? EDIT: Pretty sure I tried this without calling this.getBot().getRandomExecutor().registerRandoms() after unregistering the hook and it still didn't work. Edited August 9, 2014 by bfir3 Link to comment Share on other sites More sharing options...
Botre Posted August 9, 2014 Share Posted August 9, 2014 The RandomEvent enum does not refer to a solver: You can override the event in question like this: this.getBot().getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.RUN_AWAY_FROM_COMBAT) { //STUFF }; Link to comment Share on other sites More sharing options...
bfir3 Posted August 9, 2014 Author Share Posted August 9, 2014 I don't need to provide additional functionality, I just want to disable it. Surely the "unregisterHook" method which takes a RandomEvent argument is intended for this? Link to comment Share on other sites More sharing options...
Botre Posted August 9, 2014 Share Posted August 9, 2014 I don't need to provide additional functionality, I just want to disable it. Surely the "unregisterHook" method which takes a RandomEvent argument is intended for this? You can override it to remove functionality / disable it entirely. Hook != Solver, RandomSolver != RandomBehaviorHook. Clearing hooks doesn't mean disabling the solver per se. script.getBot().getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.RUN_AWAY_FROM_COMBAT) { @Override public boolean shouldActivate() { return false; } }); Link to comment Share on other sites More sharing options...