Modification: rest function

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Modification: rest function

#1 Post by d003232 » Sat Jul 11, 2009 6:11 pm

Here a function to rest before next fight if your hp or mana is below a given level. I tried to make the modification so easy as possible, thus I put it into a separate file:

1.: Put two new options into your profile:

Code: Select all

<option name="HP_REST" value="15" />
<option name="MP_REST" value="15" /> 
If your hp points or mana in percent is below that level, your char will rest before starting a new fight.

2.: Download the attached file 'modif_rest_function.lua' and save it in your classes folder. That file includes the following function

Code: Select all

function CPlayer:rest()
-- rest to restore mana and healthpoint if under a certain level

	if( self.Battling == true) then return; end;		-- if aggro, go back

	if( settings.profile.options.MP_REST == nil ) then  settings.profile.options.MP_REST = 15; end;
	if( settings.profile.options.HP_REST == nil ) then  settings.profile.options.HP_REST = 15; end;

	-- some classes dont have mana, in that cases Player.mana = 0
	hf_mana_rest = (player.MaxMana * settings.profile.options.MP_REST / 100);	-- rest if mana is lower then
	hf_hp_rest   = (player.MaxHP   * settings.profile.options.HP_REST / 100);	-- rest if HP is lower then

	if( player.Mana >= hf_mana_rest  and player.HP >= hf_hp_rest   ) then	-- nothing to do
		return;								-- go back
	end;
	
	self:clearTarget();		-- get rid of mob, so we dont cast while resting
	hf_count = 30 + math.random( 69 );			-- set rest time, up to 99 sec pause
	cprintf(cli.green, "resting %s sec for full mana and full HP\n", hf_count);		-- resting x sec for Mana and HP
	while hf_count > 0 do
		yrest(1000);
		hf_count = hf_count - 1;	
		self:update();

		if( self.Battling ) then          -- we get aggro,
			self:clearTarget();       -- get rid of mob to be able to target attackers
			printf("get aggro at sec %s\n", hf_count );   -- get aggro at sec x
			hf_count = 0;		-- stop countdown
		end;
		if( player.Mana == player.MaxMana  and		-- some chars have MaxMana = 0
 	 	    player.HP   == player.MaxHP ) then		-- Mana and HP are full
			printf("full at sec %s\n", hf_count );   -- full at sec x
			hf_count = 0;				-- stop countdown
		end;

		self:checkPotions();   
		self:checkSkills(); 		-- check if we need to cast buffs/heals.

	end;			-- end of while

end


3.: Add the following line at the end of your player.lua file

Code: Select all

include("modif_rest_function.lua");
4.: Add three new lines in bot.lua before line 225

Code: Select all

	if( player:haveTarget() ) then	          -- <<< NEW LINE
		player:rest();			                 --  rest befor next fight <<< NEW LINE
	end;	                                    -- <<< NEW LINE
	if( player:haveTarget() ) then		
Attachments
modif_rest_function.lua
(1.7 KiB) Downloaded 135 times
The RoM Bot Online Wiki needs your help!

aasi888
Posts: 64
Joined: Fri May 15, 2009 5:13 am

Re: Modification: rest function

#2 Post by aasi888 » Sun Jul 12, 2009 5:24 am

Thx alot. I changed it a bit to rest right where mob is killed. If I go near mob and rest after targeting the mob could wander too close and atk.

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

Re: Modification: rest function

#3 Post by d003232 » Sun Jul 12, 2009 5:48 am

aasi888 wrote:Thx alot. I changed it a bit to rest right where mob is killed. If I go near mob and rest after targeting the mob could wander too close and atk.
I think it looks more natural if you rest before a fight instead of directly after killing a mob. If you get attackted while resting, the bot will fight back.

It is also better to buy a lot of mana potions at the NPC to avoid resting. Thats much faster then resting.
The RoM Bot Online Wiki needs your help!

aasi888
Posts: 64
Joined: Fri May 15, 2009 5:13 am

Re: Modification: rest function

#4 Post by aasi888 » Sun Jul 12, 2009 11:53 am

d003232 wrote:
aasi888 wrote:Thx alot. I changed it a bit to rest right where mob is killed. If I go near mob and rest after targeting the mob could wander too close and atk.
I think it looks more natural if you rest before a fight instead of directly after killing a mob. If you get attackted while resting, the bot will fight back.

It is also better to buy a lot of mana potions at the NPC to avoid resting. Thats much faster then resting.
Your prolly right. I'll go get the pots ;). But incase pots run out this is a good mod.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 8 guests