SRL Archive - Reflection Help

Reflection finding cows but not clicking?


Troll

2010-10-21 15:10:47

Hi
well im trying to click and attack cows but every time the mouse does not go near the cows just next to them.

Function AttackCow(calf:Boolean) :Boolean;

Var NPCs : TNPCArray;
I,x,y : Integer;
CowTile : TPoint;
Begin
If Not LoggedIn Then Exit;
result := false;
If calf Then
NPCs := GetNPCsBy('Cow')
else
NPCs := GetNPCsBy('Cow calf');
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
If Not NPCs[I].Fighting Then
Begin
CowTile := TileToMS(NPCs[i].Tile,5);
MMouse(CowTile.x,CowTile.y,3,3);
If R_IsUpText('Cow') Then
Begin
GetMousePos(x,y);
If 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 Begin
writeln ('Did not find cow uptext!');
Wait(750);
End;
End Else writeln('cow in fight');
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;
Any idea's?
Thanks

i luffs yeww

2010-10-21 18:24:43

I'd click on the actual NPC point, not the tile. Sorry can't help more than that right now. Check Players.simba or NPCs.simba or something in the reflection include. I think the function is like GetNPCs or something. Good luck.

MylesMadness

2010-10-21 19:25:09

Change the hight of tiletoms?

Cstrike

2010-10-21 19:51:49

Maybe try [based off of MylesMadness' post]

CowTile := TileToMS(NPCs[i].Tile, 0); // Height of 0 
and see if that does anything.

Also, maybe the cow moves when the tile spot is read? Just a thought that may happen

mormonman

2010-10-21 21:03:34

From: cstrike
Maybe try [based off of MylesMadness' post]

CowTile := TileToMS(NPCs[i].Tile, 0); // Height of 0 
and see if that does anything.

Also, maybe the cow moves when the tile spot is read? Just a thought that may happen


The cow is a multi-tiled NPC, so the best you could do is tiletoms(npcs.tile, npcs.height/2) but that will still be way off.

Cstrike

2010-10-21 23:25:46

From: mormonman
The cow is a multi-tiled NPC, so the best you could do is tiletoms(npcs.tile, npcs.height/2) but that will still be way off.


BTW what does the tile height work as? Is it pixels or some other measurement? I can't find out what it is :(
Ex: What location does tile height / 2 take you to? The height of the NPC in half?

mormonman

2010-10-22 01:40:11

From: cstrike
BTW what does the tile height work as? Is it pixels or some other measurement? I can't find out what it is :(
Ex: What location does tile height / 2 take you to? The height of the NPC in half?


Ya the approximate middle of the npc. I'm pretty sure it is pixels. That was part of a graphics update not too long ago.

Troll

2010-10-22 04:12:07

So is there a way of geting a Tpoint or something insted of getting a tile?

i luffs yeww

2010-10-22 04:27:51

From: Troll Man
So is there a way of geting a Tpoint or something insted of getting a tile?


From: i luffs yeww
I'd click on the actual NPC point, not the tile. Sorry can't help more than that right now. Check Players.simba or NPCs.simba or something in the reflection include. I think the function is like GetNPCs or something. Good luck.


From the Reflection include,


Result[c].Index := Index;
Result[c].ID := SmartGetFieldInt(TheNPCDef, hook_npcdef_GetID);
Result[c].Name := GetJavaString(TheBytes, 255);
Result[c].Actions := _GetNPCActionArray(TheNPCDef);
Result[c].Tile.X := (SmartGetFieldInt(0, hook_static_BaseX) + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].Tile.Y := (SmartGetFieldInt(0, hook_static_BaseY) + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));
Result[c].Pixel.X := SmartGetFieldInt(TheNPC, hook_animable_PixelX) mod 512;
Result[c].Pixel.Y := SmartGetFieldInt(TheNPC, hook_animable_PixelY) mod 512;
Result[c].Moving := (SmartGetFieldInt(TheNPC, hook_character_Motion)>0);
Result[c].Animation := SmartGetFieldInt(TheNPC, hook_character_Animation);
Result[c].Height := iabs(SmartGetFieldInt(TheNPC, hook_character_GetHeight));
Result[c].HPRatio := SmartGetFieldInt(TheNPC, hook_character_HPRatio) * 100 / $FF;
Result[c].Fighting := (SmartGetFieldInt(TheNPC, hook_character_LoopCycleStatus) >
SmartGetFieldInt(0, hook_static_LoopCycle));
Result[c].Orientation := Round(FixD(180 + (SmartGetFieldInt(TheNPC, hook_character_Orientation)* 45) / 2048));
Result[c].Level := SmartGetFieldInt(TheNPCDef, hook_npcdef_GetLevel);
Result[c].Interacting := SmartGetFieldInt(TheNPC, hook_character_GetInteracting);

Try using Pixel.x, Pixel.y.

(Above is from GetNPCs in Characters.simba)


{*******************************************************************************
function GetNPCs: TNPCArray;
By: Drags111
Description: Stores all the loaded NPCs into an array of TNPC;
*******************************************************************************}

Troll

2010-10-22 10:12:36

From: i luffs yeww
From the Reflection include,


Result[c].Index := Index;
Result[c].ID := SmartGetFieldInt(TheNPCDef, hook_npcdef_GetID);
Result[c].Name := GetJavaString(TheBytes, 255);
Result[c].Actions := _GetNPCActionArray(TheNPCDef);
Result[c].Tile.X := (SmartGetFieldInt(0, hook_static_BaseX) + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].Tile.Y := (SmartGetFieldInt(0, hook_static_BaseY) + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));
Result[c].Pixel.X := SmartGetFieldInt(TheNPC, hook_animable_PixelX) mod 512;
Result[c].Pixel.Y := SmartGetFieldInt(TheNPC, hook_animable_PixelY) mod 512;
Result[c].Moving := (SmartGetFieldInt(TheNPC, hook_character_Motion)>0);
Result[c].Animation := SmartGetFieldInt(TheNPC, hook_character_Animation);
Result[c].Height := iabs(SmartGetFieldInt(TheNPC, hook_character_GetHeight));
Result[c].HPRatio := SmartGetFieldInt(TheNPC, hook_character_HPRatio) * 100 / $FF;
Result[c].Fighting := (SmartGetFieldInt(TheNPC, hook_character_LoopCycleStatus) >
SmartGetFieldInt(0, hook_static_LoopCycle));
Result[c].Orientation := Round(FixD(180 + (SmartGetFieldInt(TheNPC, hook_character_Orientation)* 45) / 2048));
Result[c].Level := SmartGetFieldInt(TheNPCDef, hook_npcdef_GetLevel);
Result[c].Interacting := SmartGetFieldInt(TheNPC, hook_character_GetInteracting);

Try using Pixel.x, Pixel.y.

(Above is from GetNPCs in Characters.simba)


{*******************************************************************************
function GetNPCs: TNPCArray;
By: Drags111
Description: Stores all the loaded NPCs into an array of TNPC;
*******************************************************************************}


Umm its proberly me being stupid by how would i do it as this gives me compileing errors


MMouse(NPCs.pixel.x,NPCs.pixel.y,3,3);

Thanks

i luffs yeww

2010-10-23 01:51:19

From: Troll Man
Umm its proberly me being stupid by how would i do it as this gives me compileing errors


MMouse(NPCs.pixel.x,NPCs.pixel.y,3,3);

Thanks


I COULD PROBERLY HELP BUT ITS PROBERLY ME BEING STUPID BY HOW WOULD I HELP AS THIS GIVES ME COMPILEING WORKS.


{$Define SMART}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

var
AllNPCs: TNPCArray;

begin
SMART_Server := 64;
SMART_Signed := True;
SMART_Members := True;
SMART_SuperDetail := False;
SetupSRL;
SetupReflectionEx(True);
AllNPCs := GetNPCs;
Writeln(ToStr(AllNPCs));
end.

Run that, let smart open, stop the script, login to rs through smart, then when you're around NPCs, enable smart and run the script. Read the debug box.

herp derp if you need more help.. look through the reflection include KTHX?BAI.

Narcle

2010-10-24 15:00:06

Pixel is the pixel coords the npc is on the tile, not the screen. Its used to find the offset of the NPC.


with NPCs[i] do
CowTile := TileToMSEx(Tile, Pixel.x / 512.0, Pixel.y / 512.0, Height/2);