SRL Archive - OSR Help

Hows my ATPA + a question


Sk1nyNerd

2013-05-30 02:22:25

So I'm making an AIO script therefore the colors, tolerances and ect and some other things arent present, theyre way up top. im using one function for all the foods :] but any ways thanks to Flight im getting a grasp on ATPA's and im curious as how i could sort it so it searches my inv row by row starting in the 1st slot looking for food rather than from the center out. Most people dont eat food that way :P. comments suggestions concerns?

(this is just a outline, i plan on using percents so it can be easily translated with the hp bar. and this is for 07)
thanks in advance

function FindFood: Boolean;
var
FoodTPA, FoodTempTPA: TPointArray;
FoodATPA: Array of TPointArray;
x, y, i, CTS: Integer;

begin
Result := False;
CurrentHp := GetSkillInfo('hitpoints', True);
RandomHealth := randomrange(-3,3);

repeat

if(not GameTab(tab_Inv)) then
begin
GameTab(tab_Inv);
end;

if(TimeFromMark(FindTime) > 15000) then
begin
writeln('The time to find your food has expired!');
LogOut;
TerminateScript;
end;

CTS := GetToleranceSpeed;
ColorToleranceSpeed(2);

for i:=0 to High(FoodColors) do
begin
SetToleranceSpeed2Modifiers(FoodHueMods[i],FoodSatMods[i]);
FindColorsTolerance(FoodTempTPA, FoodColors[i], MIX1, MIY1, MIX2, MIY2, FoodTolerances[i]);
AppendTPA(FoodTPA,FoodTempTPA);
end;

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2,0.2);

if (High(FoodTPA)> 0) then
begin

FoodATPA := SplitTPA(FoodTPA,10);
SortATPASize(FoodATPA,True);

for i:=0 to High(FoodATPA) do
begin
if High(FoodATPA[i]) < FoodMinPoints then
Break;
end;
if i = 0 then Exit;

SetArrayLength(FoodATPA,i);
SortATPAFromFirstPoint(FoodATPA,Point(MICX, MICY));

for i:=Low(FoodATPA) to Min(High(FoodATPA),3) do
begin
MiddleTPAEX(FoodATPA[i],x,y);
MMouse(RandomRange(x-10,x+10),RandomRange(y-10,y+10),0,0);
if WaitUpTextMulti([FoodUpText], randomrange(200,600)) then
if IsUpTextMultiCustom([FoodUpText]) then
begin
ClickMouse2(mouse_left);
wait(750 + randomrange(250,1000));
CurrentHp := (CurrentHp + HealthHeals + RandomHealth);
end;

begin
Result := True;
Exit;
end;

end;
end else
begin
Result := False;
writeln('We are out of food!');
Logout;
TerminateScript;
end;

until(CurrentHp > HptoEat);

GameTab(tab_Stats);

end;

bud_wis_er_420

2013-05-30 02:38:00

this what you looking for?
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
if FindFood then
InvMouse(i, 1);
end;
end;

Sk1nyNerd

2013-05-30 02:47:39

From: bud_wis_er_420
this what you looking for?
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
if FindFood then
InvMouse(i, 1);
end;
end;


it is! thankyou :) figured there was an inventory function lol

would i sort my atpa from the 1st slot or not at all because im manually checking if the food exists in a spot?

Flight

2013-05-30 02:52:39

In your own code here's the part that sorts your ATPA (food objects I would assume):

SortATPAFromFirstPoint(FoodATPA,Point(MICX, MICY));

That means your ATPA is being sorted from the middle of you inventory (Point(MICX, MICY)), so why not use this instead?

SortATPAFromMidPoint(FoodATPA,Point(MICX, MIY1));

That will sort them from the center top of your inventory.

Sk1nyNerd

2013-05-30 02:57:50

From: Flight
In your own code here's the part that sorts your ATPA (food objects I would assume):

SortATPAFromFirstPoint(FoodATPA,Point(MICX, MICY));

That means your ATPA is being sorted from the middle of you inventory (Point(MICX, MICY)), so why not use this instead?

SortATPAFromMidPoint(FoodATPA,Point(MICX, MIY1));

That will sort them from the center top of your inventory.


cool, you were to quick for my edit :P haha i will try that out