- stopping and rest before a new fight if mana or hp is under a certain limit
- skip loot if near mobs are around the death one
- skip loot if getting aggro befor looting
I think that points make the bot a little smarter and look more human. Here my code:
1. Stop and rest before a new fight:
I suggest to use potions. You get them from the merchant, they are cheap and speed up your botting. I use potions at 30%. But if you fall under a certain limit with your mana or hp, it is not usefull to start a new fight. The hard coded default is 15%. You can set that in your profile. If you fall under that limit, the bot will wait and rest. He will still fight if he get aggro and use buffs and potions. The resting time is random between 30-99 seconds.
You need two new options in your profile *charname*.xml
Code: Select all
<option name="HP_REST" value="15" />
<option name="MP_REST" value="15" />
Code: Select all
[36] = "resting %s sec for full mana and full HP\n",
[37] = "get aggro at sec %s\n",
[38] = "full at sec %s\n",
Code: Select all
[36] = "warte %s sek bis Mana und HP voll sindP\n",
[37] = "Aggro bei Sekunde %s\n",
[38] = "voll bei Sekunde %s\n",
then add in the player.lua at line 107 after function CPlayer:fight()
Code: Select all
function CPlayer:fight()
-- wait if mana or hp is lower than x%
if( self.Battling == false ) then -- only if no aggro
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 or
player.HP < hf_hp_rest ) then
self:clearTarget(); -- get rid of mob, so we dont cast while resting
hf_count = 30 + math.random( 69 ); -- set rest counter, up to 99 sec pause
cprintf(cli.green, language[36], hf_count); -- resting x sec for Mana and HP
while hf_count > 0 do
-- printf("%s Mana: %s MaxMana: %s HP: %s MaxHP %s\n", hf_count, player.Mana, player.MaxMana, player.HP, player.MaxHP); -- debug info
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(language[37], hf_count ); -- get aggro at sec x
hf_count = 0; -- stop countdown
end;
-- printf("ManaPZ %s HPPZ: %s\n", (player.Mana/player.MaxMana*100), (player.HP/player.MaxHP*100) ); -- debug
if( player.Mana == player.MaxMana and -- some chars have MaxMana = 0
player.HP == player.MaxHP ) then -- Mana and HP are full
printf(language[38], 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; -- end of MP/HP < xx
end; -- end of self.battling
If you fight a mob in a mobgroup, it is not usefull und not human after the fight to run into that group for looting. It is better to skip the looting and fight the other mobs first.
Enter the following code in player.lua nearby line 300
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
-- Modifikation Stephen: skip loot if nearby mobs
hf_skip_loot = false;
keyboardPress(settings.hotkeys.TARGET.key); -- more mobs there?
if( self:haveTarget() ) then
hf_skip_loot = true;
cprintf(cli.green, language[50]); -- skip loot, more mobs around\n
end;
-- End of modifikation
3. Skip loot if getting aggro before looting
It is not usefull and not common human behaivor to go and loot the death mob, if you still have aggro from another mob. The following code will skip looting and first fight the aggroing mob.
Enter the following code in player.lua nearby line 300 before 'if( settings.profile.options.LOOT == true ) then'
Code: Select all
-- Modifikation Stephen, skip loot if getting aggro
yrest(800); -- wait a little for battling flag update in client STEPHEN
-- Monster is dead (0 HP) but still targeted.
-- Loot and clear target.
self:update();
if( self.Battling ) then -- skip looting if aggro STEPHEN
cprintf(cli.green, language[39]); -- aggro, skip looting
self:clearTarget(); -- get rid of the death mob
hf_skip_loot = true;
end;
if( hf_skip_loot == false and self.TargetPtr ~= 0 ) then
-- if( self.TargetPtr ~= 0 ) then -- old code, replaced by line before
-- End of modifikation
if( settings.profile.options.LOOT == true ) then
Code: Select all
[39] = "aggro, skip looting\n",
[50] = "skip loot, nearby mobs around\n",
Code: Select all
[39] = "\129berspringe Looten, Aggro\n",
[50] = "skip loot, nearby mobs around\n",
I would be happy, if some of the code findes his way into the standard bot. I tested it with different chars, but surly not with all possibe combinations.