PDA

View Full Version : TReflectGroundItemArray appears to not work as intended



terd
05-06-2017, 06:32 AM
Using this code:


procedure myProcedure;
var
TheItems: TReflectGroundItemArray;
I: Integer;
Point: TPoint;
begin


TheItems.GetAll(3);



for i:= 0 to High(TheItems) do
begin
writeln(TheItems[i].GetName );

if IsArrInStr(['Potato'], TheItems[i].GetName) then
begin
wait(500+random(500));
Point:= TheItems[i].GetMSPoint;

Insert whatever item you want to pick up/manipulate with the TPoint into potato. This code is supposed to iterate through every item on the ground in X tiles near the player, but it never finds anything. Upon further inspection, when TheItems[i].GetName is printed, they are all called either "Toolkit" or "Instruction manual". I assume this is a bug.

Aspect
05-06-2017, 06:43 AM
Are you using it in a potato field, or to actually pickup potatoes that have been dropped?

terd
05-06-2017, 06:54 AM
Are you using it in a potato field, or to actually pickup potatoes that have been dropped?

I'm using it in a chicken pen with feather as the item in the array, but it holds with any item that has been dropped by any npc as far as I can tell.

Aspect
05-06-2017, 07:11 AM
Alright, and also the code you posted doesn't have any code to move the mouse, or do anything. Only to obtain information.
var
Grounds: TReflectGroundItemArray;
I: Integer;


begin
Grounds.GetAll(20);

for I := 0 to High(Grounds) do
begin
begin
Reflect.Mouse.Move(Grounds[I].GetMSPoint, 0, 0);
Reflect.Mouse.Click(Mouse_Right);
Reflect.Text.ChooseOption(Grounds[I].GetName);
end;
end;
end.

terd
05-06-2017, 07:24 AM
Alright, and also the code you posted doesn't have any code to move the mouse, or do anything. Only to obtain information.
var
Grounds: TReflectGroundItemArray;
I: Integer;


begin
Grounds.GetAll(20);

for I := 0 to High(Grounds) do
begin
begin
Reflect.Mouse.Move(Grounds[I].GetMSPoint, 0, 0);
Reflect.Mouse.Click(Mouse_Right);
Reflect.Text.ChooseOption(Grounds[I].GetName);
end;
end;
end.

It prints the name of every item in the array, which will be wrong on testing. But yeah, also the code you provided will also not work, assuming you don't want to pick up every single thing near you.

Aspect
05-06-2017, 07:51 AM
Could be a hook problem then.

AFools
05-06-2017, 11:36 AM
Goto you Hooks file change



{Item: as}
Item_StackSizes: THook = ['c', 1707626481];
Item_ID: THook = ['d', -933263931];


As for the code




function loot(D: Integer): boolean;
var
e,i, j: integer;
_gItems: TReflectGroundItemArray;
s : string;
InInv: TReflectInvItem;
gItems : tstringarray;
begin
gItems := [ 'bones','big bones','bronze bar'];

_gItems.GetAll(D);

if length(_gItems) = 0 then Exit;
for i := 0 to high(_gItems) do begin
for j := 0 to high(gItems) do begin

if (pos(gItems[j], lowercase(_gItems[i].getName)) > 0) then begin

If InteractTileOnce(_gItems[I].GetTile, 'Take ', 'Take ' + _gItems[I].GetName, Mouse_Right,0,0,0)then
writeln('Picked up: '+ _gItems[I].GetName);
end;
end;
end;
end;



procedure loot;
var
i, j, me_indice: integer;
_gItems: TReflectGroundItemArray;
gItems: tstringarray;
s : string;
begin
_gItems.GetAll;
for i := 0 to high(_gItems) do
begin
for j := 0 to high(gItems) do
begin
if (pos(gItems[j], lowercase(_gItems[i].getName)) > 0) then
begin
s:=_gItems[i].GetName;
begin
Mouse.Move(_gItems[i].GetMSPoint, 2, 2);
Wait(50);
Mouse.Click(Mouse_Right);
Wait(50);
Reflect.Text.ChooseOption('Take '+s);
end
waitMove(3000);
end;
end;
end;
end;

Can use the above if you don't have your own custom interactonce or similar function..



But there is still one more problem... It will search through the piles.. but it returns to the last pile and false clicks.- where as it should release the final TPoint

Something i need to discuss && resolve

I have written the looting function 4 different ways; they all result with the same bug.

terd
05-06-2017, 09:11 PM
Cool man, let me know if I can do anything to test or help. I'd love to learn how to update this stuff on my own.

It appears to work with those changes, but only can see the items on the bottom of a stack.

AFools
05-08-2017, 05:08 AM
Cool man, let me know if I can do anything to test or help. I'd love to learn how to update this stuff on my own.

It appears to work with those changes, but only can see the items on the bottom of a stack.

When i get home; i will debug ground items again.. when i quickly tested it before the post it seemed fine.


writeln('Ground item'+ _gItems[I].GetName); - If you move this line above


(pos(gItems[j], lowercase(_gItems[i].getName)) > 0) it will output all items it finds.




In regards to hook updates; you need to learn how to use the updater Kyle posted.(providing the update didn't break it)

terd
05-08-2017, 06:07 AM
This fix worked for me: https://villavu.com/forum/showthread.php?t=117153

I've read through the Brandon guide on how to make sense of the hook updater, but I still don't really understand. I'm not sure exactly what is being analyzed, or how it's being done.

AFools
05-08-2017, 06:28 AM
https://github.com/KyleHunter/Java-Class-Updater

Try find the forum post by Kyle.

A few hooks are broken.. A couple senior members directed me to other forums to get their hook log; then edit in the broken hooks.

I will try the fix you found.. As i am slowly building my own slayer script..

Being able to loot ground objects is a must.

I just moved onto the other essential parts and was going to come back to the looting part at the end.

terd
05-08-2017, 07:12 AM
https://github.com/KyleHunter/Java-Class-Updater

Try find the forum post by Kyle.

A few hooks are broken.. A couple senior members directed me to other forums to get their hook log; then edit in the broken hooks.

I will try the fix you found.. As i am slowly building my own slayer script..

Being able to loot ground objects is a must.

I just moved onto the other essential parts and was going to come back to the looting part at the end.

ok, hit me up on the discord if you want to collaborate or test.

Sable
06-09-2017, 02:49 PM
Edited: problem with grounditems was a wrong hook.
Client_GroundItems: THook = ['client.ji', 1];