PDA

View Full Version : Finding ID by a certain tile



Joopi
05-16-2015, 06:02 PM
Ok so what I'm trying to do is a simple powerminer.
All it would do is search for an ore, then mine it.
Then it would repeat wait until i find an empty ore in that spot

So what i would basically do is something like:

procedure MineHandler();
var
RObj : TReflectObject;
RTile : TTile;
Point : TPoint;

begin
If GetInvCount = 28 then
exit();
if RObj.Find(ObjGame, 13711, 10) then
begin
Point := RObj.GetMSPoint();
RTile := RObj.GetTile;
...

But then I would have to search for another ID, in that certain tile (RTile).
Is there any function like this? If i have to manually make a function like this, then please guide me.

EDIT: Would also work with search by MSPoints.

AFools
05-17-2015, 01:36 AM
Ok so what I'm trying to do is a simple powerminer.
All it would do is search for an ore, then mine it.
Then it would repeat wait until i find an empty ore in that spot

So what i would basically do is something like:

procedure MineHandler();
var
RObj : TReflectObject;
RTile : TTile;
Point : TPoint;

begin
If GetInvCount = 28 then
exit();
if RObj.Find(ObjGame, 13711, 10) then
begin
Point := RObj.GetMSPoint();
RTile := RObj.GetTile;
...

But then I would have to search for another ID, in that certain tile (RTile).
Is there any function like this? If i have to manually make a function like this, then please guide me.

EDIT: Would also work with search by MSPoints.

Maybe have a look at the recent script i posted for ideas?

https://villavu.com/forum/showthread.php?t=113128

it does rely on custom functions from other member of the forum.

Pakyakkistan
05-17-2015, 07:11 AM
You could also look in the function list under reflection in 'Objects' and you'll find this:


procedure TReflectObject.GetAt(ObjType: TObjectType; _Tile: TTile);
var
ObjectHook, SceneHook: THook;
Multi, BaseX, BaseY, Plane: Integer;
Temp: TReflectObject;
begin
if (HookCache[ckObject][0] <> 0) then
Reflect.Mem.FreeObjects(ckObject, True);
BaseX := Reflect.Misc.BaseX;
BaseY := Reflect.Misc.BaseY;
Plane := Reflect.Tiles.GetPlane;
if HookCache[TCacheKey.ckRegion][0] = 0 then
Reflect.Mem.GetObject(ckNull, ckRegion, Client_Region, 0, 0);
Reflect.Mem.Get3DObject(ckRegion, ckSceneTile, Region_SceneTiles, 0, 0, Plane,
_Tile.X - BaseX, _Tile.Y - BaseY);
Self._ObjType := ObjType;
Self._GetObject(0, _Tile);
Reflect.Mem.FreeObjects(ckSceneTile, False);
end;

Records all the information in a TReflectObject so you can get objects at a specific TTile.
EDIT: I re-read your post. During mining scripts I always did 'While' loops during the mining process. During the loop check for the object at the tile using the above procedure to see if the ID at that tile changes. Might not be the absolute best way to go about it, but from experience it works quite well.
Example:


FindRock;
ClickRock;
BlahBlah;
While IsAnimating do
Begin
TempRock.GetAt(ObjGame, Tile);
If TempRock.GetID <> OreID then
Exit;
end;

Joopi
05-17-2015, 08:52 AM
Yes! Thank you.
That should work 100x better than what I came up with.
I did it stupidly like this:

repeat
RObj2.Find(ObjGame, EMPTYOREID, 5);
RTile2 := RObj2.GetTile;
until (RTile.x = RTile2.x) and (RTile.y = RTile2.y);

This caused the game to crash within 10 seconds or less.
Thank you very much.

Joopi
05-17-2015, 08:56 AM
Maybe have a look at the recent script i posted for ideas?

https://villavu.com/forum/showthread.php?t=113128

it does rely on custom functions from other member of the forum.

Thanks, I'll use it as a guide to myself, since I am trying to learn Reflection atm. :)

AFools
05-17-2015, 09:28 AM
No worries; I thought one of the other guys, would have come past by now and given you an explanation. I mostly self taught myself though i have been bopping around for over 6 years maybe more. always forget my account passwords.

Try find examples. https://villavu.com/forum/showthread.php?t=112434 - Ineedbot script here hold most of the needed functions and procedures.. as the tut island cover most skills.

I only thought of this earlier in the week. so read through it thoroughly.. join IRC if you need specific or try find one of the experienced boys to allow you PM them backwards and forwards.

Im not good with explaining things and probably make things worse, unless i can give examples.