SRL Archive - Development

Colored movement by tiles


Feroc1ty

2010-11-17 15:41:37

Hey, I was creating a color script for a script with much larger picture involved a few weeks ago, but since I figured multi-threading is completely impossible in simba I kind of gave up on it.

Here is a little mini-script I was working on which would move the character by tiles on the minimap… very similarly to reflection, except it is completely color based.

All it needs is some configuration, such as how many pixels and tiles are from the middle of minimap to the outer edge of the map; sorry for the comments but it's just my train of thought as I was creating the function.

The way it works is it assumes tile position (0,0) to be your characters location, the tile (0,10) would be 10 tiles north of your character, and so fourth…

program test;

var
// The part where there is a white dot on the minimap representing your character
minimaploc:TPoint;

const
// How many tiles there are from the character to any outer lining of the minimap
MINIMAP_TILE_SIZE = 20;
// How many pixels there are from the character to any outer lining of minimap
MINIMAP_GRID_SIZE = 75;

procedure MoveByMinimap(x,y:integer);
var fx,fy:integer;
length,angle:extended;
begin
{
here is how the function started and what it came out to be with the train of thought
included

(minimapbox.x2 - minimapbox.x1) ((MINIMAP_SIZE/2 + x)/MINIMAP_SIZE)
(minimapbox.y2 - minimapbox.y1) ((MINIMAP_SIZE/2 + y)/MINIMAP_SIZE)

right now both of them are just measurements of how much the variable
will be added onto the very top left of the minimap
}

{added a new constant and renamed old one, now they're _TILE_SIZE and _GRID_SIZE

found a function out of my old code i could use here it is:

function pangle(pointa,pointb:TPoint):extended;
begin
result := ArcTan2(pointb.y-pointa.y,pointb.x-pointa.x)
end;

*((MINIMAP_TILE_SIZE/2 + x)/MINIMAP_TILE_SIZE)
*((MINIMAP_TILE_SIZE/2 + y)/MINIMAP_TILE_SIZE)

WriteLn(floattostr(ArcTan2(x,y)));


ArcTan2(x,y) * ((MINIMAP_TILE_SIZE/2 + x)/MINIMAP_TILE_SIZE)

dunno wat i was thinking here but i think im getting a better idea... and ill get
help from another one of my old functions, this time its distance:

function pdistance(pointa,pointb:TPoint):integer;
begin
result := Round(Sqrt( Pow(pointa.x-pointb.x,2) + Pow(pointa.y-pointb.y,2) ))
end;

new approach, ill create an offset from middle of minimap towards the angle calculating the
distance from tile distance rather than pixels }


{ WARNING!!! this part of the code needs to be updated ASAP! }
angle := ArcTan2(x,y); {+ (get runescape angle)
if angle > 360 then angle := angle - 360;}
writeln(floattostr(angle));

length := MINIMAP_GRID_SIZE * (Sqrt(Pow(0-x,2) + Pow(0-y,2))/MINIMAP_TILE_SIZE);

if length > MINIMAP_GRID_SIZE then
begin
length := MINIMAP_GRID_SIZE;
writeln('MoveByMinimap function attempted to click out of the bounds of the minimap.');
end;

writeln(floattostr(length));

fx := minimaploc.x + Round(length * Cos ( angle ));
fy := minimaploc.y + Round(length * Sin ( angle ));

// Click mouse at fx,fy

{the function appears to be finished, just need to add the runescape angle function
here are some of the test runs:

movebyminimap(10,5)
Compiled succesfully in 15 ms.
1.10714871779409
111.803398874989
Successfully executed.
;

movebyminimap(15,5)
Compiled succesfully in 15 ms.
1.24904577239825
158.113883008418
Successfully executed.
;

movebyminimap(-5,5)
Compiled succesfully in 32 ms.
-0.78539816339744
70.7106781186547
Successfully executed.
;

}
end;

begin
end.