SRL Archive - MSI Suggestions

Suggestion: MSI_WalkPath


Cstrike

2010-11-06 18:54:57

I looked through the MSI reflection walking. I'm not exactly sure how the MSI one works since it branches into gathering data from other locations or player input… but for this, if the person inputs a TileArray (or a TPA, it accepts either and works with either– I tested it), it will walk to the location unless there is an error.
It uses the principle behind Drags111's walker, where it will keep walking between points with the failsafes of checking to see whether the character walks or not to look human. Randomess is also specified by players. It does not rely off of WalkToTile (the reflection include, not the MSI one), because the reflection WalkToTile occasionally is buggy and messes up.

In addition, there is space inside of it that you could call a TProcedure argument in the function input to call your own functions inside. This would allow it to check for the pesky " >60 level " interface that crops up for lower level characters.

It is also compatible with MSI_WalktoTile.

{******************************************************************************}
{ function MSI_WalkPath (TileArray : TTileArray; MouseRandomness, TimeoutMS : Integer) : Boolean; }
{ By: Cstrike }
{ Date: 06 November 2010 }
{ Description: Walks a defined path, returns true if target reached. The }
{ randomness is in pixels, not tiles. TimeoutMS is in milliseconds. }
{******************************************************************************}
function MSI_WalkPath (TileArray : TTileArray; MouseRandomness, TimeoutMS : Integer) : Boolean;
var
i, j, t, indexPosStart, failCount : Integer;
TP : TPoint;
begin
//if not LoggedIn then Exit; // Do you guys use this?
Result := False;
if high(TileArray) < 0 then Exit;

// If we are within 4 tiles from our target destination, then 1) true 2) exit
if DistanceFrom (TileArray[high(TileArray)]) < 5 then
begin
Result := True;
Exit;
end;

// Find tile on MM from top of the array to the bottom:
indexPosStart := -1; // Failsafe
for i := high(TileArray) downto low(TileArray) do
begin
if TileOnMM (TileArray[i]) then
begin
indexPosStart := i;
Break;
end;
end;
// If we don't find anything on the minimap, exit [will return false]
if indexPosStart = -1 then Exit;

// Start walking from that tile, and complete the path
failCount := 0;
for j := indexPosStart to high(TileArray) do
begin

// "Click the tile that is on the mainscreen" section
if TileOnMM (TileArray[j]) then
begin
TP := TileToMM (TileArray[j]);
Mouse (TP.x, TP.y, MouseRandomness, MouseRandomness, true);
end;

// "Now that we clicked, make sure we move... if we don't we are stuck" section
MarkTime(t);
repeat
wait (50);
//MSI_FindRandoms;
//Any other procedures here that you want?
until (CharacterMoving) or (TimeFromMark(t) > TimeoutMS)
// If we timed out, increase failcount
if (TimeFromMark(t) > TimeoutMS) then
begin
Inc(failCount);
Writeln ('MSI_WalkPath failed to sense character moving [Failcount = '+IntToStr(failCount)+'/3]');
end;
// If failcount is 3 or more, return false and exit
if failCount > 2 then
begin
Writeln ('MSI_WalkPath failed.');
Exit;
end;

// "Now that we are supposed to be moving, wait until we stop moving" section
MarkTime(t);
repeat
wait (50);
//MSI_FindRandoms;
//Any other procedures here that you want while walking?
if j < high(TileArray) then // So we don't try and find anything higher than the max array index
if (TileOnMM (TileArray[j+1])) then Break; // If tile is on minimap, click it
until (not CharacterMoving) or (TimeFromMark(t) > TimeoutMS)
// If we timed out, increase failcount
if (TimeFromMark(t) > TimeoutMS) then
begin
Inc(failCount);
Writeln ('MSI_WalkPath failed to sense character moving [Failcount = '+IntToStr(failCount)+'/3]');
end;
// If failcount is 3 or more, return false and exit
if failCount > 2 then
begin
Writeln ('MSI_WalkPath failed.');
Exit;
end;

wait (400+random(500)); // Act random

end;

// If we got to the end of the path, result = true
if DistanceFrom (TileArray[high(TileArray)]) < 7 then Result := True;
end;


What do you think? Criticisms always welcome. I won't be offended if it's rejected ;), I just made it to see what you guys would think.
EDIT: Yes I've tested it, no I have not tested it with lag or anything that causes it to fail, it's always worked for me thus far.

nickrules

2010-11-06 21:55:16

Haven't really looked at the code, but it sounds like a good idea.

NCDS

2010-11-07 10:00:58

From: cstrike
This would allow it to check for the pesky " >60 level " interface that crops up for lower level characters.

Pretty sure something has already been added to handle that but I will come back to this a little later when I actually have a minute.

Cstrike

2010-11-07 15:32:44

From: NCDS
Pretty sure something has already been added to handle that but I will come back to this a little later when I actually have a minute.


To clear up my ambiguity on what I said, if that has been done you can easily insert that procedure/function into the MSI_WalkPath :)

Coh3n

2010-11-07 17:15:31

From: NCDS
Pretty sure something has already been added to handle that but I will come back to this a little later when I actually have a minute.

It's in MSI_Flag I'm pretty sure.

Also, cstrick, is this basically just for the user to input a path, then the player will walk there? Just trying to get it straight. :)

E: Also, just curious, I can see why not to use MSI_RelfectionWalk (because it takes locations, not paths), but why not use MSI_WalkToTile?

Cstrike

2010-11-07 19:06:13

From: Coh3n
It's in MSI_Flag I'm pretty sure.

Also, cstrick, is this basically just for the user to input a path, then the player will walk there? Just trying to get it straight. :)

E: Also, just curious, I can see why not to use MSI_RelfectionWalk (because it takes locations, not paths), but why not use MSI_WalkToTile?


It was designed for tile/tile paths (I converted it from Drags' WalkPath to be a more stable function because his gets stuck in infinite loops if it finds the tile but can't move to it, so I fixed that)

MSI_WalkToTile can be implemented :) If it works great with you guys I can convert it I think quite easily.
Maybe the argument for the input can be changed to variant and will walk from location to location? It's another idea :)

Coh3n

2010-11-07 19:10:26

From: cstrike
It was designed for tile/tile paths (I converted it from Drags' WalkPath to be a more stable function because his gets stuck in infinite loops if it finds the tile but can't move to it, so I fixed that)

MSI_WalkToTile can be implemented :) If it works great with you guys I can convert it I think quite easily.
Maybe the argument for the input can be changed to variant and will walk from location to location? It's another idea :)

Well it doesn't need to be a variant, because we already have our function to walk from location to location, and it works perfectly. It would have to be a TPointArray though to avoid compiling issues.

And I was thinking of this for more as a utility script. We can use this function as the basis of an army relocater where the user inputs the paths. That, in combination with your world walker I think would make a very nice army relocater. :)

Cstrike

2010-11-07 19:14:30

From: Coh3n
Well it doesn't need to be a variant, because we already have our function to walk from location to location, and it works perfectly. It would have to be a TPointArray though to avoid compiling issues.

Sounds good

And I was thinking of this for more as a utility script. We can use this function as the basis of an army relocater where the user inputs the paths. That, in combination with your world walker I think would make a very nice army relocater. :)

Sounds like a plan ;)
The biggest pain for making the world walker will be to index all the houses, but hey– once it's done then no account can ever really get lost :D

Coh3n

2010-11-07 19:32:51

What do you mean by 'index' the houses?

Cstrike

2010-11-07 20:05:32

From: Coh3n
What do you mean by 'index' the houses?


This idea was from ILuffsYeww, if the player is having trouble moving, it will check what general location its in, then it will check all the houses (which are defined as TBoxes) and the floor height. It would take some time, but it would be possible with a door/stair handler to make it exit out of any house. That way if people get stuck in the weirdest locations they aren't totally out of luck, or if a random fails and sticks the character in some far away house it won't be active = falsed

i luffs yeww

2010-11-07 20:12:04

It's all lowercase by the way. i luffs yeww. :p

I've been thinking a lot about this (have to think about this stuff for TRiBot, too), and I'm still not sure of how to do it. I know there's a better way. :/

Cstrike

2010-11-07 20:32:25

From: i luffs yeww
It's all lowercase by the way. i luffs yeww. :p

Noted ;)

I've been thinking a lot about this (have to think about this stuff for TRiBot, too), and I'm still not sure of how to do it. I know there's a better way. :/


TBH I think so too, though I'm not sure how I'd go about that. Shuttleu and some random guy in my WorldWalker thread did say that Nexus was able to make a huge web with tons of nodes, though he apparently spent 2 years on it [which isn't feasible for someone like me]
If there was a better way, I would work on it ;)
Plus if there was a way to deconstruct the code of the huge web and see how they did it, I'd just use that.

Coh3n

2010-11-08 00:14:58

From: cstrike
This idea was from ILuffsYeww, if the player is having trouble moving, it will check what general location its in, then it will check all the houses (which are defined as TBoxes) and the floor height. It would take some time, but it would be possible with a door/stair handler to make it exit out of any house. That way if people get stuck in the weirdest locations they aren't totally out of luck, or if a random fails and sticks the character in some far away house it won't be active = falsed

Love it, although that would take a VERY long time! Especially if you eventually wanted to include member areas.

Cstrike

2010-11-08 00:23:32

From: Coh3n
Love it, although that would take a VERY long time! Especially if you eventually wanted to include member areas.


TBH I don't ever see myself doing members, I tried thinking of paths but I can't apply my idea to P2P :( I'd need to do the Nexus web idea

But F2P shall one day be done :D

Coh3n

2010-11-08 00:24:29

From: cstrike
TBH I don't ever see myself doing members, I tried thinking of paths but I can't apply my idea to P2P :( I'd need to do the Nexus web idea

But F2P shall one day be done :D

Good luck! :)