Page 1 of 1

[Suggestion] Additional Method Hook

Posted: Sun Jul 21, 2013 7:29 pm
by evilband7
First, my English skill is poor. please try to understand what i mean. T^T

I just wanna suggest what i did to the scripts. ;D

Is it a good idea to add method hook for some action ? such as beforeBotFight and afterBotFight.

this is example for CPlayer:fight()

Code: Select all

function CPlayer:fight()
   if( not self:haveTarget() ) then
      return false;
  end
  pcall(beforeBotFight);  -- i add beforeFight method hook here.
  ....
  ....
  ....
  ...
  pcall(afterBotFight);   -- and add afterFight method hook here.
end -- end of CPlayer:fight()

if i wanna use this method hook just add the function to userfunction, <onload> in waypoint.xml or <onload> in profile.xml

Code: Select all

<onload>
function afterBotFight()
   cprintf(cli.yellow, "[INFO] this is afterBotFight() method.");
end
</onload>
and the reason I added afterBotFight method because <onLeaveCombat> was hooked before looting. ;(

Re: [Suggestion] Additional Method Hook

Posted: Mon Jul 22, 2013 12:29 am
by rock5
For yourself, that is ok. The nice thing about SVN is when you do an update it normally wont affect your edits so they remain in affect until you remove them.

Or are you asking if they should be added to the bot for everyone?

Re: [Suggestion] Additional Method Hook

Posted: Mon Jul 22, 2013 3:17 am
by lisa
There was discussion about making the event "preCodeOnElite" to be for all mobs and not just elite and then if people wanted they could just do a HP check if they wanted to. So that would be the code before starting combat.


As for code before looting and after combat, just set loot to false and put the code in onleavecombat and then add in the player:loot() at the end of the onleavecombat. This can be done without altering the bot at all and just altering your profile.