How to MP/HP potion count for autobuy

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Glopo
Posts: 29
Joined: Tue Aug 11, 2009 9:52 pm

How to MP/HP potion count for autobuy

#1 Post by Glopo » Fri Aug 28, 2009 11:56 am

if you want rebuy potion go here :

http://www.solarstrike.net/phpBB3/viewt ... ties#p5915

Step 1 :

go in you pawn.lua and open it (..\micromacro\scripts\rom\classes\pawn.lua)

and choose a

Code: Select all

self.free_counter1 = 0;
this is the counter for your hp potion. (you can add free_counter for that copy/past the code ligne and change the free counter number exp:

Code: Select all

 self.free_counter5 = 0;
my pawn.lua:

Code: Select all

  self.free_counter1 = 0;				-- free counter for user use
		self.free_counter2 = 0;				-- free counter for user use
		self.free_counter3 = 0;				-- free counter for user use
		self.free_counter4 = 0;				-- HP POTION counter
		self.free_counter5 = 0;				-- MP POTION counter



do same for MP potion

quit and save

Step 2 :

open player.lua (same folder)

go to near Ligne:323 and after

Code: Select all

keyboardPress(settings.profile.hotkeys.HP_POTION.key);
add

Code: Select all

self.free_counter4 = self.free_counter4 + 1;

(don't forget to change the number of the free_counter)

now go to near ligne: 340 and after

Code: Select all

keyboardPress(settings.profile.hotkeys.MP_POTION.key);
add

Code: Select all

self.free_counter5 = self.free_counter5 + 1;
quit and save.

Step 3

open your porfile.xml

and add this on the leavecombat state

Code: Select all

<onLeaveCombat>
printf( "|-----------------> HP potion use: %d\n", player.free_counter4);
printf( "|-----------------> MP potion use: %d\n", player.free_counter5);
</onLeaveCombat>
Quit and save

Step 4

open your waypoint file and edit your waypoint.

for change your path :

Code: Select all

player.free_counter1 = player.free_counter1 + 1;
      if(player.free_counter1 == 10) then
load_paths("buypotion.xml");
	end;
you can change thefree_counter number (player.free_counter1 = player.free_counter1)
and the counter value : (player.free_counter1 == 10)
the name of the path to load : load_paths("buypotion.xml");
or the action : load_paths("buypotion.xml");

exp :

Code: Select all

  player.free_counter1 = player.free_counter1 + 1;
      if(player.free_counter1 == 10) then
         player:sleep();
end;
for sleep the bot

Code: Select all

  player.free_counter1 = player.free_counter1 + 1;
      if(player.free_counter1 == 10) then
         player:logout();
end;
for logout

Code: Select all

  player.free_counter1 = player.free_counter1 + 1;
      if(player.free_counter1 == 10) then
settings.loadProfile("playerName");
end;
for load a porfile

you can download my file.

sry for the english :)
Attachments
player.lua
(54.62 KiB) Downloaded 83 times
pawn.lua
(9.39 KiB) Downloaded 101 times
Last edited by Glopo on Fri Aug 28, 2009 11:00 pm, edited 5 times in total.

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: show free counter in bot log

#2 Post by d003232 » Fri Aug 28, 2009 12:21 pm

Glopo wrote:this is a correct code ?

1)

Code: Select all

<!-- # 2 --><waypoint x="-14169" z="8399">
      if(player.free_counter1 == 198) then
	Player:logout();
	end;


</waypoint>

2)

Code: Select all

if( arg1.Name == "MP_LOW_POTION" ) then
    player.free_counter1 = player.free_counter1 + 1;
  end
</onSkillCast>

how can i see the free counter in the log bot window ?
I think that look rather good. Except:

Code: Select all

	Player:logout();
should be

Code: Select all

	player:logout();
You can do a printf:

Code: Select all

printf("Thats the counter %d\n", player.free_counter1);
The RoM Bot Online Wiki needs your help!

Glopo
Posts: 29
Joined: Tue Aug 11, 2009 9:52 pm

Re: show free counter in bot log

#3 Post by Glopo » Fri Aug 28, 2009 3:35 pm

hum thx and sorry but where should i put

Code: Select all

printf("Mp potion use %d\n", player.free_counter1);

Code: Select all

<onSkillCast>-- Additional Lua code to execute when casting a skill
-- Note: arg1 contains the skill being used.
-- i.e. arg1.Name will be the name of the skill being cast.

 if( arg1.Name == "ROGUE_THROW" ) then
    player:rest(5);
  end

 if( arg1.Name == "ROGUE_VANISH" ) then
    player:rest(20);
  end

if( arg1.Name == "MP_LOW_POTION" ) then
    player.free_counter1 = player.free_counter1 + 1;
printf("Mp potion use %d\n", player.free_counter1);
  end


</onSkillCast>
no work :(

Code: Select all

 <onLeaveCombat>

printf("Mp potion use %d\n", player.free_counter1);

</onLeaveCombat>
no work too :(

Code: Select all

[27] = "Fight finished. Target dead/lost (fight #%d / runtime %d minutes / Mp potion use %d\n", player.free_counter1)\n",
no work :(




:idea:

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: show free counter in bot log

#4 Post by Administrator » Fri Aug 28, 2009 3:51 pm

MP potions are not skills. Therefor, MP_LOW_POTION would not trigger onSkillCast.

Code: Select all

[27] = "Fight finished. Target dead/lost (fight #%d / runtime %d minutes / Mp potion use %d\n", player.free_counter1)\n",
Don't do that. You broke it.

Code: Select all

<onLeaveCombat>

printf("Mp potion use %d\n", player.free_counter1);

</onLeaveCombat>
This works. Make sure you have the latest version available that fixed some of the problems with events.

Glopo
Posts: 29
Joined: Tue Aug 11, 2009 9:52 pm

Re: show free counter in bot log

#5 Post by Glopo » Fri Aug 28, 2009 3:58 pm

so impossible to count it ?

and is that for nothing happens when i put

Code: Select all

printf("Mp potion use %d\n", player.free_counter1);
in leavecombat section ?

no definitively nothing write on bot log with the code on leavecombat section (i try with trow skill for count)

thx again :)


ps: v2.46 r184

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: show free counter in bot log

#6 Post by Administrator » Fri Aug 28, 2009 4:08 pm

Glopo wrote:so impossible to count it ?
No. You can modify CPlayer:checkPotions() in player.lua to increment the variable.

and is that for nothing happens when i put

Code: Select all

printf("Mp potion use %d\n", player.free_counter1);
in leavecombat section ?

no definitively nothing write on bot log with the code on leavecombat section (i try with trow skill for count)

thx again :)

ps: v2.46 r184
Well, it definitely prints text to the MicroMacro window. If you were expecting it to show up in the log.txt, then use this instead:

Code: Select all

logMessage(sprintf("Mp potion use %d", player.free_counter1));

Glopo
Posts: 29
Joined: Tue Aug 11, 2009 9:52 pm

Re: show free counter in bot log

#7 Post by Glopo » Fri Aug 28, 2009 4:28 pm

thx

but

ok this

Code: Select all

logMessage(sprintf("Mp potion use %d", player.free_counter1));
work perfectly in log.txt

but this

Code: Select all

printf("Mp potion use %d\n", player.free_counter1);
not



thx for help

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: How to MP/HP potion count for autobuy

#8 Post by d003232 » Sat Aug 29, 2009 4:37 am

Glopo wrote:i
my pawn.lua:

Code: Select all

self.free_counter4 = 0;				-- HP POTION counter
		self.free_counter5 = 0;				-- MP POTION counter
do same for MP potion
thx for your suggestion. I put that counters within the standard. It is available in SVN 187.

The name of the fields are now:

Code: Select all

self.MP_counter = 0;		-- counts use of mana potions
self.HP_counter = 0;		-- counts use of HP potions
That fields will be counted if the bot uses a potion.
The RoM Bot Online Wiki needs your help!

Glopo
Posts: 29
Joined: Tue Aug 11, 2009 9:52 pm

Re: How to MP/HP potion count for autobuy

#9 Post by Glopo » Sat Aug 29, 2009 8:04 am

thx for you upgrade :)

j_schlott
Posts: 119
Joined: Tue Aug 18, 2009 11:42 pm

Re: How to MP/HP potion count for autobuy

#10 Post by j_schlott » Sun Aug 30, 2009 10:17 am

Code: Select all

<!--#1--><waypoint x="000" y="000" >
    player:target_NPC("merchant"); <!-- target merchant-->
    player:rest(2);   
    if( self.HP_counter =< 99 ) then <!-- if bot has used 99 or less -->
    printchat("/script StoreBuyItem(1, (self.HP_counter))"); <!--print code to chat to buy how many hp pots used-->
    elseif( self.HP_counter > 99 ) then <!-- if bot used more then 99  need 2 commands to buy-->
    printchat("/script StoreBuyItem(1, 99)"); <!--buys 1 stack-->
    player:rest(.1);
    printchat("/script StoreBuyItem(1, (self.HP_counter-99))") <!-- subtracts 99 from the HP_counter and buys remainder of potions-->
    end;
</waypoint>
ok so im no coder, and i know this doesnt work as-is, but i think it could work, buying exactly how many potions the bot used from a merchant

using the potion counter,
when at a merchant we check to see if potions consumed are under 99, if we are under 99 we paste /script StoreBuyItem(1, (self.HP_counter)) to chat window, that will buy how ever many pots consumed from merchant window slot1
or if HP counter is over 99, we buy 1 stack (99) then buy HP_counter-99

it will only work up to 198 potions but that should be plenty

could someone that knows the commands for what this is suppose to do, clean it up?

ah and one other thing, does the counter get reset when you load waypoints?
if you loaded a waypoint from botspot to run to merchant, would the HP_counter be reset when you got to him?
it wouldnt work very well if it did,
and if it doesnt reset itself then we would need to add a reset for HP_counter in the waypoints after you leave merchant

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: How to MP/HP potion count for autobuy

#11 Post by d003232 » Mon Aug 31, 2009 1:44 am

j_schlott wrote:ah and one other thing, does the counter get reset when you load waypoints?
if you loaded a waypoint from botspot to run to merchant, would the HP_counter be reset when you got to him?
it wouldnt work very well if it did,
and if it doesnt reset itself then we would need to add a reset for HP_counter in the waypoints after you leave merchant
No. It is not reseted.
The RoM Bot Online Wiki needs your help!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests