sjesper Posted February 23, 2012 Share Posted February 23, 2012 Hello there. Im in progress on making a RealmOfTheMadGod Autoer (Probaly never going to be finish ) and i have made it walk to a bag and loot the hppotions. But i want it to skip the ones who only have armour or just other things then hp, but after trying many times i thought, why not ask here. This is my code so far: program RealmOfTheMadGod;var Colors: array[1..4] of integer; T: Integer; Status: String; //DTMs HPPotion, ManaPotion, Bag: Integer;const //Settings HPToEat = 35; //HP percent to eat at //Do not touch !-=-=-=// MSX1 = 1; // MSY1 = 1; // MSX2 = 607; // MSY2 = 630; // // MSCX = 307; // MSCY = 337; // // MMX1 = 612; // MMY1 = 34; // MMX2 = 803; // MMY2 = 225; // //-=-=-=-=-=-=-//procedure WaitRR(MinWait, MaxWait: Integer);begin Wait(MinWait + Random(MaxWait - MinWait));end;procedure MMouse(x, y, rx, ry: Integer);begin MoveWindMouse(x, y, rx, ry);end;procedure Mouse(x, y, rx, ry: Integer; Left: Boolean);begin ClickWindMouse(x, y, rx, ry, Left);end;procedure ClickBox(x1, y1, x2, y2: Integer);var x, y: Integer;begin MouseBox(x1, y1, x2, y2); GetMousePos(x, y); Mouse(x, y, 0, 0, True);end;Procedure SetColors;begin Colors[1] := 2608804; //Snake Colors[2] := 5424862; //Scorpion Colors[3] := 13309067; //Red Slime Colors[4] := 54044; //Green slimeend;procedure SetDTMs;begin HPPotion := DTMFromString('78DA636C66626038C3C8800CFEFCF903A661A' + '28CA540356751D5F0F0F030B022AB6900AAB946404D1F91E6EC25' + 'A0A61AA8E604AA9A157272286A005BBA0C62'); ManaPotion := DTMFromString('78DA636C61626038C3C8800CFEFCF903A661A' + '28CA540351750D5F0F2F2A2AAA904AA398EAA86878707554D1B50' + 'CD51026A40EEB98CAAC69A73318A1A00B4910ADB');end;function GetDistance (TPA: TPointArray): Integer;begin Result := Distance(MSCX, MSCY, TPA[1].X, TPA[1].Y);end;function GetHP: Integer;var i: Integer; x: Extended;begin for i := 1 to 100 do begin x := 620 + i * 1.75; if GetColor(Round(x), 301) = 3421408 then result := i; end;end;function GetMana: Integer;var i: Integer; x: Extended;begin for i := 1 to 100 do begin x := 620 + i * 1.75; if GetColor(Round(x), 325) = 14713952 then result := i; end;end;function LoadScreen: Boolean;begin result := GetColor(800, 504) = 0;end;function ItemSlot(Slot: Integer): TBox;begin Case Slot of 1..4: Result := Box(622 + ((Slot - 1) * 44), 438, 661 + ((Slot - 1) * 44), 477); 5..8: Result := Box(622 + ((Slot - 5) * 44), 482, 661 + ((Slot - 5) * 44), 521); end;end;function BagSlot(Slot: Integer): TBox;begin Case Slot of 1..4: Result := Box(622 + ((Slot - 1) * 44), 538, 661 + ((Slot - 1) * 44), 577); 5..8: Result := Box(622 + ((Slot - 5) * 44), 582, 661 + ((Slot - 5) * 44), 621); end;end;procedure GetKey (ATPA: T2DPointArray; Index, Color: Integer; var Key1, Key2: Byte);begin //Down Right if FindColors(ATPA[index], Color, 331, 368, 607, 632) then begin Key1 := GetKeyCode('s'); Key2 := GetKeyCode('d'); exit; end; //Right if FindColors(ATPA[index], Color, 331, 313, 604, 368) then begin Key1 := GetKeyCode('d'); Key2 := 0; exit; end; //Up Right if FindColors(ATPA[index], Color, 331, 29, 604, 313) then begin Key1 := GetKeyCode('w'); Key2 := GetKeyCode('d'); exit; end; //Up if FindColors(ATPA[index], Color, 280, 29, 331, 313) then begin Key1 := GetKeyCode('w'); Key2 := 0; exit; end; //Left up if FindColors(ATPA[index], Color, 8, 28, 280, 319) then begin Key1 := GetKeyCode('w'); Key2 := GetKeyCode('a'); exit; end; //Left if FindColors(ATPA[index], Color, 8, 319, 287, 400) then begin Key1 := GetKeyCode('a'); Key2 := 0; exit; end; //Left Down if FindColors(ATPA[index], Color, 8, 364, 287, 631) then begin Key1 := GetKeyCode('a'); Key2 := GetKeyCode('s'); exit; end; //Down if FindColors(ATPA[index], Color, 287, 364, 331, 634) then begin Key1 := GetKeyCode('s'); Key2 := 0; exit; end; Key1 := 0; Key2 := 0;end;function ItemInSlot (Slot: Integer): boolean;var x, y: Integer; B: TBox;begin B := ItemSlot(Slot); result := FindColor(x, y, 789516, B.X1, B.Y1, B.X2, B.Y2);end;procedure Loot;var x, y, i, ii: Integer; B, BB: TBox;begin //Checking for a potion for i := 1 to 7 do begin if i = 7 then exit; B := BagSlot(i); if FindDTM(HPPotion, x, y, B.X1, B.Y1, B.X2, B.Y2) then begin Break; end; end; //Checking for a slot without an item for ii := 1 to 7 do begin if ii = 7 then exit; BB := ItemSlot(ii); if not ItemInSlot(ii) then begin Break; end; end; Status := 'Looting..' //Dragging MouseBox(B.X1, B.Y1, B.X2, B.Y2) GetMousePos(x, y); HoldMouse(x, y, true); WaitRR(200, 240); //Releasing MouseBox(BB.X1, BB.Y1, BB.X2, BB.Y2) GetMousePos(x, y); ReleaseMouse(x, y, true); WaitRR(200, 240);end;procedure WalkToBag;var x, y, i: Integer; Key1, Key2: Byte; TPA: TPointArray; ATPA: T2DPointArray;begin x := MSCX; y := MSCY; if FindColorsSpiralTolerance(x, y, TPA, 9747941, MSX1, MSY1, MSX2, MSY2, 0) then begin ATPA := SplitTPA(TPA, 48); try for i := 0 to Length(ATPA) do begin while GetDistance(ATPA[i]) > 50 do begin Status := 'Walking to the bag'; GetKey(ATPA, i, 9747941, Key1, Key2); KeyDown(Key1); KeyDown(Key2); WaitRR(275, 300); KeyUp(Key1); KeyUp(Key2); if GetDistance(ATPA[i]) < 50 then begin Loot; ATPA[i] := ATPA[i - 1]; end; end; end; except end; end;end;procedure MMouseToMonster;var i, x, y, x2, y2: Integer;begin for i := 1 to High(Colors) do begin x := MSCX; y := MSCY; if FindcolorSpiral(x, y, Colors[i], MSX1, MSY1, MSX2, MSY2) then begin if not FindColor(x2, y2, 1908060, x - 15, y - 15, x + 15, y + 15) then begin MMouse(x, y, 0, 0); end; end; end;end;procedure Eat;var i, x, y, xe, ye, xs, ys: Integer;begin if GetHP < HPToEat then begin for i := 1 to 8 do begin xe := ItemSlot(i).x1; ye := ItemSlot(i).y1; xs := ItemSlot(i).x2; ys := ItemSlot(i).y2; if FindDTM(HPPotion, x, y, xe, ye, xs, ys) then begin Status := 'Eating'; SendKeys(IntToStr(i)); WaitRR(100, 150); exit; end; end; Status := 'Out of potions. Going to nexus'; ClickBox(780, 235, 795, 248) end;end;procedure WriteDebug;var x, y: Integer;begin ClearDebug; Writeln('HP: ' + IntToStr(GetHP) + '%'); Writeln('Mana: ' + IntToStr(GetMana) + '%'); writeln(''); Writeln('Status: ' + Status); Writeln(''); GetMousePos(x, y); Writeln('Mouse Position: ' + IntToStr(x) + ', ' + IntToStr(y)); T := GetTimeRunning + 500end;procedure ScriptSetup;var i: Integer;begin for i := 1 to 5 do begin ClearDebug; Writeln('The script will start in ' + IntToStr(6 - i) + ' seconds..'); Wait(1000); ClearDebug; end; SetDTMs; SetColors; Writeln('The script has started'); T := GetTimeRunning + 500;end;begin ScriptSetup;repeat While LoadScreen do Wait(200); if T < GetTimeRunning then begin WriteDebug; end; Eat; MMouseToMonster; WalkToBag; Loot;until(false);end.[/Code] Go to WalkToBag for the problem. Quote Link to comment Share on other sites More sharing options...