SRL Archive - Reflection Help

GetMe.Infight error?


Nindustries

2009-02-24 18:45:22

It doesn't seems to work ..
I use this code but still it keeps clicking the chickens!

Function SearchAndDestroy : Boolean ;
var
NPC: TNPC;
P: TPoint;
begin
Result := False ;
IF NOT(LoggedIn) THEN Exit;
IF (Myself.InFight = True) THEN Exit;
Repeat
ClickNPC('Chicken','Attack',False)
Until (MySelf.InFight = True) OR ( GetChatBoxLine(8) ='I can''t reach that!');
End

mormonman

2009-02-24 19:42:03


Function SearchAndDestroy : Boolean ;
var
NPC: TNPC;
P: TPoint;
begin
Result := False ;
IF NOT(LoggedIn) THEN Exit;
IF (GetMe.InFight) THEN Exit;// = True is not necessary
Repeat
ClickNPC('Chicken','Attack',False)
Until (GetMe.InFight) OR ( GetChatBoxLine(8) ='I can''t reach that!');
End

try that…

Narcle

2009-02-24 20:56:39

You can't call GetMe like that, you have to declare it to a variable first. I would do something like this:

function BarInFight: boolean;
Var
Me: TMe;
begin
Me := GetMe;
result := Me.InFight;
end;

Function SearchAndDestroy : Boolean;
var
NPC: TNPC;
P: TPoint;
begin
//Result := False; -Not needed
IF BarInFight THEN Exit;
Repeat
if not LoggedIn then Exit;//move fail safe to loop
ClickNPC('Chicken','Attack',False);
wait(400+random(300));//try a wait - might need to be longer
Until BarInFight OR ( GetChatBoxLine(8) ='I can''t reach that!');
End;

mormonman

2009-02-24 20:58:17

with the wait thing, you should use a FFlag(0) or Flag and then use the wait…

Nindustries

2009-02-25 12:16:08

From: mormonman
with the wait thing, you should use a FFlag(0) or Flag and then use the wait…

Isn't Flag the function that gives the result TRUE when there is a flag on the minimap?
And OMG, stupid error of me ..

Bobarkinator

2009-03-01 14:59:31

From: Narcle
You can't call GetMe like that, you have to declare it to a variable first. I would do something like this:

function BarInFight: boolean;
Var
Me: TMe;
begin
Me := GetMe;
result := Me.InFight;
end;

Function SearchAndDestroy : Boolean;
var
NPC: TNPC;
P: TPoint;
begin
//Result := False; -Not needed
IF BarInFight THEN Exit;
Repeat
if not LoggedIn then Exit;//move fail safe to loop
ClickNPC('Chicken','Attack',False);
wait(400+random(300));//try a wait - might need to be longer
Until BarInFight OR ( GetChatBoxLine(8) ='I can''t reach that!');
End;



…You can use GetMe like that. I do it all the time.

Narcle

2009-03-01 20:59:30

From: Bobarkinator
…You can use GetMe like that. I do it all the time.


Really? It gave me errors when we first started reflection so I had to make a separate var just to use it.

Capricorn

2009-03-01 21:02:54

I thought you had to put it to a variable too myself.

Bobarkinator

2009-03-01 21:08:49

WriteLn(BoolToStr(GetMe.InFight));

You can also do it with any function. For instance in the Object functions. You can access the ObjectType directly by doing GetObjectAt(TileX, TileY).objType;

Edit: Hmm, it seems that it only works sometimes, other times you get an out of global vars range error