SimbaGod
2014-02-22 11:46:26
I literally tried to figure out for hours how to get the bot search for the monk again when it didnt find it. I thought that the if (not(…)) would be ok but omg i need help.
Im using this script (well trying) but if it wants to heal or attack a monk and theres no monk at the time on the screen, it will just freeze there (even when a monk comes back and we can see it in the camera)…
So yea, thanks for helping in advance! I hope you can find a way to get it work as i tried for hours and am not good with this…
like in heal; in this line : if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 3)) then
what if it doesnt find it? I want the bot to continue searching :/
Im using this script (well trying) but if it wants to heal or attack a monk and theres no monk at the time on the screen, it will just freeze there (even when a monk comes back and we can see it in the camera)…
So yea, thanks for helping in advance! I hope you can find a way to get it work as i tried for hours and am not good with this…
program LeDonsMonks;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/misc/SmartGraphics.Simba}
// Thanks to
// Turpinator, Euphemism, Bolshak25, Officer Barbrady, asdfjkl & others on IRC who helped with this.
// Credits to Saikek for the InCombat function
//--------------------------AUTHOR NOTES-------------------------
// Need failsafe for InCombat
// Perhaps a DTM for healthbar detection?
//--------------------------INSTRUCTIONS------------------------
//Find a world where Monks is empty
//Fill in the PLAYER CREDENTIALS, SCRIPTCONFIGURATION & PLAYER INFORMATION fields
//Go
//Babysit, not flawless - randoms not yet supported. See bellow for supported
//features.
//------------------------CURRENT FEATURES-----------------------
//FINDS MONKS AND ATTACKS THEM
//BASIC PROGGY
//ANTI-BAN
//HEALS
//-----------------------------PLANNED---------------------------
//LOOTING
//BURYING BONES
//BETTER PROGGY
//------------------------------SETUP----------------------------
const
VER = 0.21;
//PLAYER CREDENTIALS
PLAYER_USERNAME = '';
PLAYER_PASSWORD = '';
PLAYER_NICK = '';
//SCRIPT CONFIGURATION
HEALAT = 27; //When should we heal?
ENABLELOOT = 0; //Loot items? 1 for yes 0 for no. Should only be used for arrows etc as monks drop nothing.
ENABLEBURYB = 0; //Bury bones? 1 for yes 0 for no
SPEEDMOUSE = 7; //How fast SMART will move the mouse
LOOTITEM1 = 'woe'; //Put here parts of the names of items you want to loot,
LOOTITEM2 = ''; //IE: 'rrow', 'row', for arrow.
LOOTITEM3 = ''; //1 for each LOOTITEM#.
LOOTITEM4 = '';
LOOTITEM5 = '';
LOOTCOLOR = 43432;
TRAININGSKILL = 'strength'; //enter the skill you're training here for Random checking
//COLOR INFORMATION
HPCOLOUR = 65280;
IRONARROWCOLOR = 537173; //COLOR TOLERANCE 0!
BONECOLOR = 11842750; //best with color tolerance 5
MONKCOLOR1 = 3301261;
MONKCOLOR2 = 3301261;
MONKCOLOR3 = 1386813;
var //GLOBAL VARIABLES
MonksKilled:integer;
procedure Proggy(ScriptStatus:String);
var MonksKilledStr: string;
begin
// Cleardebug;
SMART_ClearCanvas;
MonksKilledStr:= 'Monks Killed: ' + IntToStr(MonksKilled);
Smart_DrawBoxEx (false, true, IntToBox (6, 343, 512, 474), 10206672);
SMART_DrawText (340, 342, LoginChars, MonksKilledStr, clTeal);
SMART_DrawText (6, 455, LoginChars, 'Status: ' + ScriptStatus, clTeal);
end;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := PLAYER_USERNAME;
Players[0].Pass := PLAYER_PASSWORD;
Players[0].Nick := PLAYER_NICK;
Players[0].Active := True;
end;
procedure SetupCamera;
begin
Proggy('Setting up Camera and enabling Auto Retaliate');
KeyDown(VK_UP);
wait(randomrange(1500, 2500));
KeyUp(VK_UP);
Retaliate(true);
wait(randomrange(300, 500));
MakeCompass('N');
if IsRunOn(false) then
begin
Writeln('Run is on.');
end
else
begin
wait(randomrange(500,700));
mousebox (622, 412, 661, 452, 1);
wait(randomrange(500,700));
mousebox (567, 176, 590, 198, 1);
end;
end;
{---------------------------------FUNCTIONS------------------------------------}
function InCombat: Boolean; //credits to Saikek
var
x, y: Integer;
begin
if (FindColor(x, y, HPCOLOUR, 200, 100, 300, 200)) then
Result := true
else
Result := false
end;
procedure HumanMove; //NOTE TO SELF: IMPLEMENT THIS.
var
x, y: integer;
begin
case random(200) of
0..160: MMouse(RandomRange(X - 5, X + 5), RandomRange(y - 5, y + 5), 0, 0);
161..190: MMouse(RandomRange(X - 7, X + 7), RandomRange(y - 7, y + 7), 0, 0);
191..200: MMouse(RandomRange(X - 10, X + 10), RandomRange(y - 10, y + 10), 0, 0);
end;
end;
//procedure BoredCirlce; //Moves the mouse Around In a Circle
//var
//x, y: integer;
//begin
//
//end;
{---------------------------DO NOT GET BANNED----------------------------------}
procedure AntiBan; //NOOB LOOKING AT MY SCRIPT?
//var //ANTIBAN 101: http://villavu.com/forum/showthread.php?t=74999
//x, y: integer;
begin
Case Random(100) Of
1: begin Proggy('AntiBan: BoredHuman'); Boredhuman; end;
2: begin Proggy('AntiBan: BoredHuman'); PickUpMouse; end;
3: begin Proggy('AntiBan: RandomMovement'); RandomMovement; end;
4: begin Proggy('AntiBan: RandomRClick'); RandomRClick; end;
end;
end;
procedure MiniAntiBan; //WE CALL THIS SPECIFICALLY WHILST WAITING FOR MONKS TO DIE
var //---!!MAKE MORE COMPLEX!!---
x, y: integer;
begin
Case Random(200) of //We mean waiting for our healthbar to disapear
1: begin Proggy('MiniAntiBan - Waiting for monk to die - BoredHuman'); BoredHuman; end;
2: begin Proggy('MiniAntiBan - Waiting for monk to die - RandomRClick'); RandomRClick; end;
3: begin Proggy('MiniAntiBan - Waiting for monk to die - RandomMovement'); RandomMovement; end;
4: begin Proggy('MiniAntiBan - Waiting for monk to die - SmallRandomMouse'); SmallRandomMouse; end;
// 5: begin Proggy('MiniAntiBan - Waiting for monk to die - HoverSkill'); HoverSkill(hitpoint, false); end;
5: begin Proggy('MiniAntiBan - Waiting for monk to die - HoverSkill'); HoverSkill(TRAININGSKILL, false); end;
6: begin Proggy('MiniAntiBan - Waiting for monk to die - Waiting'); wait(randomrange(1000,2000)); end;
7: begin end;
end;
end;
procedure MiniBreak;
begin
Case Random (160) of
1: begin Proggy('MiniBreak - Breaking - 40 to 60 seconds'); MMouseOffClient('rand'); Wait(randomrange(40000,60000)); end;
2: begin Proggy('MiniBreak - Breaking - 30 to 35 seconds'); MMouseOffClient('rand'); Wait(randomrange(30000,35000)); end;
3: begin Proggy('MiniBreak - Breaking - 20 to 29 seconds'); MMouseOffClient('rand'); Wait(randomrange(20000,29000)); end;
4: begin Proggy('MiniBreak - Breaking - 15 to 20 seconds'); MMouseOffClient('rand'); Wait(randomRange(15000,20000)); end;
end;
end;
procedure Heal;
var
hitpoints: integer;
x, y, monkchatbox: integer;
begin
Proggy('Checking Hitpoints');
if (GetSkillInfo(hitpoints, true) < HEALAT) then
begin
Proggy('Healing');
begin
PlaySound('C:/Simba/sound2.wav');
if (not InCombat) then
begin
if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 3)) then
ClickMouse2(mouse_right);
ChooseOption('alk');
monkchatbox := BitmapFromString(38, 11, 'meJx9VEEOwjAM29N5A6gSgmcg7T' + 'DGjQNoHPok3Hl1TTohRVOapHaSJkvTkqblNL6H4QC53D8QKGnO5Vt' + 'daQ0LApf04+3ZXHOGyzF59Iu0QxejLJRwZOROGpUrXFQwdVIERrl0' + 'UV5XQqVgDBaHgpzHl+Mrjb6NgVGwoaK+4Q7l+V8fmUcqCsNF2mVRz' + '3ctbhe4RAk7vhBAXVq0dkmzFHL2woPdwft6PVufVTGG4JDqLqPPJN' + '7OB96DS13dO/bBHIC+1c6IZWFp3lK+EbvH+K2ThKrVNeQ5hzH7UyP' + 'XU3vHABw5qyBiGqxRCfST4NsqOtwSgk9L+v2xeIZMvm30nDfqylL6' + 's74pw0jRXrlO14ZgkbSE9fkC7/HkKQ==');
repeat
begin
wait(randomrange(100, 300));
end;
until (FindBitmapToleranceIn(monkchatbox, x, y, 282, 362, 333, 383, 10));
mousebox(232, 443, 359, 459, 1);
wait(randomrange(300, 700));
mousebox(156, 387, 361, 400, 1);
wait(randomrange(300, 700));
mousebox(232, 443, 359, 459, 1);
wait(randomrange(300, 700));
mousebox(232, 443, 359, 459, 1);
end
else
begin
Writeln('We need to heal but we are in combat! waiting..');
repeat
wait(randomrange(1000, 3000));
until(not InCombat)
begin
if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 10)) then
ClickMouse2(mouse_right);
ChooseOption('alk');
monkchatbox := BitmapFromString(38, 11, 'meJx9VEEOwjAM29N5A6gSgmcg7T' + 'DGjQNoHPok3Hl1TTohRVOapHaSJkvTkqblNL6H4QC53D8QKGnO5Vt' + 'daQ0LApf04+3ZXHOGyzF59Iu0QxejLJRwZOROGpUrXFQwdVIERrl0' + 'UV5XQqVgDBaHgpzHl+Mrjb6NgVGwoaK+4Q7l+V8fmUcqCsNF2mVRz' + '3ctbhe4RAk7vhBAXVq0dkmzFHL2woPdwft6PVufVTGG4JDqLqPPJN' + '7OB96DS13dO/bBHIC+1c6IZWFp3lK+EbvH+K2ThKrVNeQ5hzH7UyP' + 'XU3vHABw5qyBiGqxRCfST4NsqOtwSgk9L+v2xeIZMvm30nDfqylL6' + 's74pw0jRXrlO14ZgkbSE9fkC7/HkKQ==');
repeat
begin
wait(randomrange(100, 300));
end;
until (FindBitmapToleranceIn(monkchatbox, x, y, 282, 362, 333, 383, 10));
mousebox(232, 443, 359, 459, 1);
wait(randomrange(300, 700));
mousebox(156, 387, 361, 400, 1);
wait(randomrange(300, 700));
mousebox(232, 443, 359, 459, 1);
wait(randomrange(300, 700));
mousebox(232, 443, 359, 459, 1);
end;
end;
end;
end
else
begin
Writeln('Hp is fine');
end;
end;
procedure Loot; //basic
var //NEEDS TPA
x, y, BonesDTM: integer;
LootItemsStr: string;
begin
Proggy('Looting');
if (ENABLEBURYB = 1) then //BONES
begin
BonesDTM := DTMFromString('m6wAAAHicjcw7CoBADEXRiKBiRp0PIkzj/jc0jYvRC5PCMoHziuQRFZGCjA0zdty2j7jsVqEYrbdaN+DAiQkJC57WyMHlJb18H7vffMzdDuA=');
Writeln('Burying bones is enabled');
begin
if (FindObjCustom(x, y, ['Take', 'ake', 'bones', 'ones'], [BONECOLOR], 5)) then
begin
MMouse(x, y, 3, 3);
ClickMouse2(mouse_right);
wait(randomrange(300,400));
ChooseOptionMulti(['ones', 'one']);
wait(randomrange(400,600));
MouseBox(628, 173, 655, 197, 1);
if FindDTM(BonesDTM, x, y, 552, 208, 735, 466) then
repeat
begin
MMouse(x, y, 3, 3);
ClickMouse2(mouse_left);
end;
until (not FindDTM(BonesDTM, x, y, 552, 208, 735, 466))
end
end;
end
else
begin
Writeln('Burying bones is not enabled');
end;
if (ENABLELOOT = 1) then //OTHER STUFF
begin
if (ENABLEBURYB = 1) then
begin
Writeln('Burying bones is enabled. We should already have looted them.');
Writeln('Our loot should be bellow us.');
while (IsMoving) do wait(500);
repeat
MouseBox(241, 180, 258, 194, Mouse_Move);
SMART_DrawBox(intToBox( 241, 180, 258, 194));
if IsUpTextMultiCustom(['ake', 'ke', 'Take']) then
begin
ClickMouse2(Mouse_Right);
ChooseOptionMulti([LOOTITEM1, LOOTITEM2, LOOTITEM3, LOOTITEM4, LOOTITEM5]);
end
else
begin
Writeln('Cannot find loot bellow us, we bugggd or your loot is enabled when it should not be.');
end;
until not IsUpTextMultiCustom(['ake', 'ke', 'Take', LOOTITEM1, LOOTITEM2, LOOTITEM3, LOOTITEM4, LOOTITEM5]);
end;
LootItemsStr:= 'Looting is enabled! Looting: ' + (LOOTITEM1) + (LOOTITEM2) + (LOOTITEM3) + (LOOTITEM4) + (LOOTITEM5);
Writeln(LootItemsStr);
if (FindObjCustom(x, y, ['Take', 'ake', 'bones', 'ones'], [BONECOLOR, LOOTCOLOR], 5)) then
begin
repeat
MMouse(x, y, 3, 3);
Clickmouse2(mouse_right);
wait(randomrange(200,300));
ChooseOptionMulti([LOOTITEM1, LOOTITEM2, LOOTITEM3, LOOTITEM4, LOOTITEM5]);
until not IsUpTextMultiCustom([LOOTITEM1, LOOTITEM2, LOOTITEM3, LOOTITEM4, LOOTITEM5]);
end;
end
else
begin
WriteLn('Looting not enabled!');
end;
end;
procedure AttackMonk;
var
starttime, x, y: integer;
begin
starttime := getsystemtime;
if (not InCombat) then
Writeln('Attacking Monk!');
repeat
Proggy('Attacking Monk');
wait(randomrange(1000,1400));
if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 3)) then
begin
Writeln('Found monk. Clicking.');
MMouse(x, y, 3, 3);
ClickMouse2(mouse_left);
if DidYellowClick then
begin
repeat
Writeln('Misclicked monk - Trying again!');
if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 10)) then
begin
Writeln('Found monk. Clicking.');
MMouse(x, y, 3, 3);
ClickMouse2(mouse_left);
end;
until(not DidYellowClick);
end;
end
else
begin
Writeln('Did not find monk. Random chance of moving Camera.');
case random(20) of
1: begin KeyDown(VK_LEFT); wait(randomrange(1000,1500)); KeyUp(VK_LEFT); end;
2: begin KeyDown(VK_RIGHT); wait(randomrange(1000,1500)); KeyUp(VK_RIGHT); end;
end;
end;
until (InCombat) or (getsystemtime - starttime > (randomrange(20000, 25000)));
while (InCombat) do begin Wait(1000); MiniAntiBan; end; //CALLS MiniAntiBan whilst InCombat is true
MonksKilled := MonksKilled +1
Writeln('We probably killed a monk.');
end;
begin
MouseSpeed := SPEEDMOUSE;
DeclarePlayers;
SetupSRL;
ActivateClient;
Wait(2000);
LoginPlayer;
SetupCamera;
repeat
if (not loggedin) then
begin
loginplayer;
setupcamera;
end;
if loggedin then
begin
AttackMonk;
Loot;
AntiBan;
MiniBreak;
Heal;
end;
until(false)
end.like in heal; in this line : if (FindObjCustom(x, y, ['Attack', 'ttack', 'onk'], [MONKCOLOR1, MONKCOLOR2, MONKCOLOR3], 3)) then
what if it doesnt find it? I want the bot to continue searching :/