SRL Archive - OSR Help

Any suggestions/tweaks for this function?


J J

2012-05-08 11:41:07

Hi

I've finally worked out an idea that will provide the most accurate walking for the script I'm working on (GOP). I need to walk to orbs, and once orbs are found the script must walk back to the altar, while attracting the altar.

The first thing I did was making loads of Tboxes to store Tpoints in and check where the player would be roughly located. After that I made loads of BlindWalk Random Tpoints to walk back to the altar.. However I just thought of making my own SPS function to achieve the same thing.

Quite a lot of time wasted by the original idea, but yeah, that's how you learn how to script :P

So I made this function.
// Walks from the current position to the altar taking steps of roughly 5 tiles each time \\
function SPS_RcWalk(P: TPoint): Boolean;
var
i: Integer;
M, MyPoint: TPoint;
PointsToAltar: TPointArray;

begin
M := SPS_GetMyPos;
PointsToAltar := TPABetweenPoints(Point(M.X, M.Y), Point(P.X, P.Y), 5, 2);
if Length(PointsToAltar) < 6 then
begin
WriteLn('Array length is '+IntToStr(Length(PointsToAltar))+'');
WriteLn('We are very close to our desired point, result is true');
Result:=True;
end else
begin
WriteLn('Array length is '+IntToStr(Length(PointsToAltar))+'');
i := RandomRange(3, 6);
MyPoint := PointsToAltar[i];
SPS_BlindWalk(MyPoint);
end;
end;
Calculates the distance between the current location and the desired location. The desired location is a Box around the Mind Altar. I've also made a custom map for this to get the best results. I've been testing it and it works pretty well, it does what I wanted.

I could pretty much loop that until the result = true, which means that the player is near the box around the altar. After each time it should attract an orb again.

I'm looking for some suggestions though, is there any way I can make this even more accurate or better?

Mezzanine

2012-06-27 22:19:16

I didn't really like how inaccurate SPS can sometimes be so I decided to try out walking by objectDTM's, and they work pretty great. It walks faster and more accurately than SPS in my own opinion.

wantonman

2012-06-28 01:17:56

ive read that another good way to find your position on the mm is to use walls for angles and stuff but read on…

putonajonny

2012-06-28 20:42:49

I don't think this part is quite right:
    WriteLn('Array length is '+IntToStr(Length(PointsToAltar))+'');
i := RandomRange(3, 6);
MyPoint := PointsToAltar[i];
SPS_BlindWalk(MyPoint);

If you are not very close to the alter at all it won't click very close to the alter, infact it probably won't click at all, I'll show you why:
Say our current position was (60, 60) and we wanted to walk to (10, 10), a path that it could generate is:
[(60, 60), (54, 56), (52, 52), (48, 49), (45, 44), (43, 43), (37, 39), (36, 36), (30, 30), (28, 26), (23, 24), (20, 19), (16, 18), (12, 12), (12, 11), (10, 10)]
It would then say:
Array length is 16
So it would do the else part of that if statement…
Say "i" was assigned the value of 4, it would then put MyPoint as (45, 44) which is no where near the (10, 10) that we wanted to walk to. I think you want to do something like:
    WriteLn('Array length is '+IntToStr(Length(PointsToAltar))+'');
i := RandomRange(high(PointsToAltar) - 3, high(PointsToAltar));
MyPoint := PointsToAltar[i];
SPS_BlindWalk(MyPoint);
That way the furthest away point it could generate is (16, 18) which is 10 pixels away (2 RS Squares)

J J

2012-06-29 04:46:45

Thanks Jonny, but this got gravedigged yesterday (originally posted at 05-08-2012 which is 1,5 months ago). Your post explained some helpful things though but I believe I took a different approach.

Question has been answered.

Gu3st...

2012-06-29 04:59:13

Closed on request :)