SRL Archive - Reflection Help

How to turn a reflection TNPCArray to x and y???


Troll

2010-10-17 07:09:35

well title says it all ive found a cow im looking for

If (NPCs[i].Name = 'Cow') then
i want to get it so i can use it like

Mouse(x,y,3,3,True);
any help would be great

thanks

Edit: still not sure here is what i've got


Function HelloCow:Boolean;

Var NPCs : TNPCArray;
I,x,y : Integer;
CowTile : TPoint;
Begin
If Not LoggedIn Then Exit;
NPCs := GetNPCsBy('Cow');
If high(NPCs) > 0 Then
Begin
For i:= 0 To high(NPCs) Do
Begin
If (NPCs[i].Name = 'Cow') then
Begin
writeln ('Found cow');
CowTile := TileToMS(NPCs[i],0)
MMouse(CowTile.x,CowTile.y,3,3);
If R_IsUpText('Cow') Then
GetMousePos(x,y);
If Not Random(15) = 5 Then
Mouse(x,y,0,0,true);
Else Begin
Mouse(x,y,0,0,False);
R_ChooseOption('ttac');
End;
Result := True
End;
End;
End;
End;

JuKKa

2010-10-17 07:38:09

NPCs.MS.X
NPCs.MS.Y

think its that

Troll

2010-10-17 07:39:14

Ok thanks ill try it out

JPHamlett

2010-10-17 07:59:19

IIRC you have to determine which tile it's on, which can be done by npcs.tile (or something like that).

Then you have to do TileToMs(Tile, 0);

Granted this is very early in the morning and I'm tired so that information might be a little bit off.

Troll

2010-10-17 08:16:23

Umm not really sure what you mean :(
ive edited my first post with my code

Cstrike

2010-10-17 10:12:48

Check here: http://villavu.com/forum/showthread.php?t=59400

Now to explain it better:

Now after you've done NPC's name = 'cow', you need to make sure that the tile the cow is on, is on the mainscreen– so use this failsafe (just add another if begin end in there)

if TileOnMS(NPCs[i].Tile, 0) then // 0 is height, play around with it if it doesnt work. If it finds cow it returns true (on MainScreen)

then after the 'if', returning true means its on the MS (mainscreen) so then you invoke the function to return a TPoint:
You have the code correct, but a TPoint is technically not a tile… I suggest checking the guide section so you know how useful a TPoint is :) Plus if you mix up a procedure with tiles and TP's in the future you're screwed.

EDIT: I found out why it wasn't working
For inputting a tile, you use
"CowTile := TileToMS(NPCs,0)"
But the NPCs should be
NPCs.Tile ;)

Here is a full working version that will help:
NOTE I haven't compiled it, but it has some nice writeln debugs for you
Function AttackCow :Boolean;

Var NPCs : TNPCArray;
I,x,y : Integer;
CowTile : TPoint;
Begin
If Not LoggedIn Then Exit;
result := false;
NPCs := GetNPCsBy('Cow');
If high(NPCs) > -1 Then // Should be -1, because a high of 0 means that one NPC was found, -1 means nothing was found
Begin
For i:= 0 To high(NPCs) Do
Begin
If (NPCs[i].Name = 'Cow') then
Begin
writeln ('Found cow');
if TileOnMS (NPCs[i].Tile, 0) then
begin
CowTile := TileToMS(NPCs[i].Tile,0);
MMouse(CowTile.x,CowTile.y,3,3);
If R_IsUpText('Cow') Then
Begin
GetMousePos(x,y);
If Not Random(15) = 5 Then // This means you have a 1 in 16 chance of clicking true
Begin
Mouse(x,y,0,0,true);
End Else
Begin
Mouse(x,y,0,0,False);
R_ChooseOption('ttac');
End;
Result := True;
End else writeln ('Did not find cow uptext!');
end else writeln ('Cow #'+inttostr(i)+' not on mainscreen [dont worry too much about this msg]');
End;
End;
End writeln ('Warning, array has nothing in it');
End;

Troll

2010-10-17 11:12:56

Thanks so much, its working now :)