Page 1 of 1

SUGGESTION: Kill aggros, and rest

Posted: Sat May 16, 2009 9:49 am
by aasi888
Coudl you add to the base macro the following: After killing main target check if you are being attacked and clear the aggressive mobs. Then rest (use potions or just wait) to get enough hp to continue. In what file should I put that code?

Re: SUGGESTION: Kill aggros, and rest

Posted: Sat May 16, 2009 5:52 pm
by Administrator
You can put this code in your waypoint script, or within your onLeaveCombat event.

waypoint method:

Code: Select all

  <waypoint x="x" z="z">
    player:clearTarget();
    local lastHP = player.HP
    while(true) do
      player:update();
      if( player.HP == player.MaxHP ) then break; end; -- Full HP, resume

      if( player.HP < lastHP ) then break; end; -- We're taking damage, break
      lastHP = player.HP; -- update our 'lastHP' for checking next repetition

      if( player:haveTarget() ) then break; end; -- We picked up a target, might be getting attacked

      yrest(10);
    end
  </waypoint>
The onLeaveCombat event would work almost exactly the same way, except you place the code inside <onLeaveCombat> and </onLeaveCombat> in your character profile instead.

Re: SUGGESTION: Kill aggros, and rest

Posted: Sat May 16, 2009 8:26 pm
by Bobert

Code: Select all

RoM Bot Version 2.38
Attempt to read playerAddress
playerAddr: 0x2BAC6900
playerTarget: 0x0
...dministrator/Desktop/micromacro/scripts/settings.lua:111: XML Parse Error.
File: ...ator/Desktop/micromacro/scripts/profiles/******.xml
Line: 55
Column: 22
Message: not well-formed (invalid token)

Code: Select all

    <onLeaveCombat>
    player:clearTarget();
    local lastHP = player.HP
    while(true) do
      player:update();
      if( player.HP == player.MaxHP ) then break; end; -- Full HP, resume

      if( player.HP < lastHP ) then break; end; -- We're taking damage, break
      lastHP = player.HP; -- update our 'lastHP' for checking next repetition

      if( player:haveTarget() ) then break; end; -- We picked up a target, might be getting attacked

      yrest(10);
    end
	</onLeaveCombat>

Re: SUGGESTION: Kill aggros, and rest

Posted: Sat May 16, 2009 8:45 pm
by Administrator
I guess that's caused by the '<' character being in the charData section of the XML. It's confusing the less than in the Lua code with an XML tag being opened.

Simple fix would be to reverse it:

Code: Select all

if( lastHP > player.HP )
Instead of:

Code: Select all

if( player.HP < lastHP )

Or, you could make that code a function in functions.lua, and call it from onLeaveCombat.

Or, you can replace the '<' in the code with '<'.

Re: SUGGESTION: Kill aggros, and rest

Posted: Mon May 25, 2009 11:49 am
by aasi888
By adding those lines I got a new problem. MY bot will never loot.

EDIT: solved by editing profile.lua

I put this after looting and not before.

Code: Select all

	if( type(settings.profile.events.onLeaveCombat) == "function" ) then
		local status,err = pcall(settings.profile.events.onLeaveCombat);
		if( status == false ) then
			local msg = sprintf("onLeaveCombat error: %s", err);
			error(msg);
		end
	end
EDIT2: How can i set the health values below i want to rest? I'dd like to define new values for HP_LOW_REST and HP_STAND. How to do this?
I tried to use HP_LOW_POTION value:
if( player.HP < settings.profile.options.HP_LOW_POTION ) then keyboardPress(key.VK_EQUAL); break; end;

But it doesn't allow me to use it like that.

Re: SUGGESTION: Kill aggros, and rest

Posted: Mon May 25, 2009 8:07 pm
by Administrator
aasi888 wrote: EDIT2: How can i set the health values below i want to rest? I'dd like to define new values for HP_LOW_REST and HP_STAND. How to do this?
I tried to use HP_LOW_POTION value:
if( player.HP < settings.profile.options.HP_LOW_POTION ) then keyboardPress(key.VK_EQUAL); break; end;

But it doesn't allow me to use it like that.
Just add them into your profile and they will be created, then you can access them through settings.profile.options.HP_LOW_REST and HP_STAND. I would really suggest not bothering with sitting, though. It has been discussed before; everybody thinks it's useless and adds unnecessary complication. You'll begin to see that sitting to heal outside of combat is just not worth it. You really are better off just buying a lot of health potions.