SRL Archive - Test corner

Paths!


WT-Fakawi

2007-05-24 18:29:59

Paths!



Working on a new method of walking using Dynamic DTM's (Tossing DDTM: Dynamic DTM's). I made a small script that will walk you from LumbridgeSquare to the ChickenPen above the sheep. It is entirely made of Paths: DDTM's made of RoadColor. These Paths are made on-the-spot. We can now walk anywhere.

The DDTM's are RoadColor-Paths, made of max 4 SubPoints and one MainPoint pointing to the direction we are heading. Since these DTM's are dynamic, by simply inserting the RoadColor in a FindDTMRotated, they function as a kind of path…. a Path that is always found!

Try the script.

Place your Player at LumbrudgeCastle, face north. Run the script. See if it walks you to the chickenpen near the sheep.

The Point I am making is: I made these Paths on-the-fly, in twenty seconds. We can now make paths! We can walk across generic pointing DTM's until we find a landmark. We can generate difficult sequences using on-the-spot DDTM-Making. My code isnt any good and not even nearly begun to work but I need some input, thoughts from the community. This could well be a breakthrough in walking!

The Idea is Simple: For Walking I have collected an Array of Records consisting of One MainPoint with upto 4 SubPoints. I parse that data through a DDTM making function (SetDTM). I scan that DTM using FindDTMRotated.

For Making: I Right-Click SubPoints (upto 4 allowed) beginging with the one closest to me) on the Minimap, I hold my Mouse over the MainPoint and press 'q'. DTM[index] is printed in the debug. (MakePath, stupid but works)

So, I put my crummy code here, and hope you can provide me with some valuable input, or maybe even a PathMaker Program, that allows you to generate/modify/display DTM's on the-fly <jk>

program Paths;
{.include SRL/SRL.scar}
var
CurrentPath, SubPointCounter: Integer;

type
TDTMPoints = record
MainPoint : TPoint;
SubPoints : array[0..5] of Tpoint;
end;
var
Path: array[0..50] of TDTMPoints;

procedure LoadPaths;
begin
Path[0].Mainpoint.x:=700;
Path[0].Mainpoint.y:=81;
Path[0].Subpoints[0].x:=611;
Path[0].Subpoints[0].y:=43;
Path[0].Subpoints[1].x:=608;
Path[0].Subpoints[1].y:=117;
Path[0].Subpoints[2].x:=646;
Path[0].Subpoints[2].y:=96;
Path[0].Subpoints[3].x:=646;
Path[0].Subpoints[3].y:=66;
Path[1].Mainpoint.x:=616;
Path[1].Mainpoint.y:=25;
Path[1].Subpoints[0].x:=652;
Path[1].Subpoints[0].y:=83;
Path[1].Subpoints[1].x:=649;
Path[1].Subpoints[1].y:=57;
Path[1].Subpoints[2].x:=630;
Path[1].Subpoints[2].y:=41;
Path[2].Mainpoint.x:=609;
Path[2].Mainpoint.y:=38;
Path[2].Subpoints[0].x:=643;
Path[2].Subpoints[0].y:=82;
Path[2].Subpoints[1].x:=624;
Path[2].Subpoints[1].y:=65;
Path[2].Subpoints[2].x:=615;
Path[2].Subpoints[2].y:=47;
Path[3].Mainpoint.x:=651;
Path[3].Mainpoint.y:=24;
Path[3].Subpoints[0].x:=650;
Path[3].Subpoints[0].y:=82;
Path[3].Subpoints[1].x:=648;
Path[3].Subpoints[1].y:=58;
Path[3].Subpoints[2].x:=650;
Path[3].Subpoints[2].y:=39;
Path[4].Mainpoint.x:=629;
Path[4].Mainpoint.y:=37;
Path[4].Subpoints[0].x:=644;
Path[4].Subpoints[0].y:=75;
Path[4].Subpoints[1].x:=646;
Path[4].Subpoints[1].y:=49;
Path[5].Mainpoint.x:=592;
Path[5].Mainpoint.y:=53;
Path[5].Subpoints[0].x:=642;
Path[5].Subpoints[0].y:=79;
Path[5].Subpoints[1].x:=626;
Path[5].Subpoints[1].y:=72;
Path[5].Subpoints[2].x:=602;
Path[5].Subpoints[2].y:=65;
Path[6].Mainpoint.x:=598;
Path[6].Mainpoint.y:=88;
Path[6].Subpoints[0].x:=636;
Path[6].Subpoints[0].y:=82;
Path[6].Subpoints[1].x:=617;
Path[6].Subpoints[1].y:=85;
Path[7].Mainpoint.x:=630;
Path[7].Mainpoint.y:=70;
Path[7].Subpoints[0].x:=628;
Path[7].Subpoints[0].y:=51;
Path[7].Subpoints[1].x:=602;
Path[7].Subpoints[1].y:=68;
Path[7].Subpoints[2].x:=653;
Path[7].Subpoints[2].y:=84;
end;

Function SetDTM(Number:Integer):Integer;

var
DTMSubPoints: array of TDTMPointDef;
DTMMainPoint: TDTMPointDef;
TempTDTM: TDTM;
NrofSubPoints, i:integer;
TheDTM :integer;

begin

for i := 0 to 4 do
if Path[Number].SubPoints[i].x = 0 then
begin
NrofSubPoints := i;
writeln(IntToStr(NrofSubPoints));
break;
end;

SetArrayLength(DTMSubPoints, NrofSubPoints);

DTMMainPoint.x:=Path[Number].Mainpoint.x;
DTMMainPoint.y:=Path[Number].Mainpoint.y;
DTMMainPoint.areasize:=1;
DTMMainPoint.areashape:=0;
DTMMainPoint.color:=RoadColor;
DTMMainPoint.tolerance:=0;

for i := 0 to NrofSubPoints - 1 do
begin
DTMSubPoints[i].x:=Path[Number].SubPoints[i].x;
DTMSubPoints[i].y:=Path[Number].SubPoints[i].y;
DTMSubPoints[i].areasize:=1;
DTMSubPoints[i].areashape:=0;
DTMSubPoints[i].color:=RoadColor;
DTMSubPoints[i].tolerance:=0;
end;

TempTDTM.MainPoint := DTMMainPoint;
TempTDTM.SubPoints := DTMSubPoints;
TheDTM := AddDTM(TempTDTM);
Result := TheDTM;
end;

procedure WritePath;
var i:Integer;
begin
writeln('Path['+IntToStr(CurrentPath)+'].Mainpoint.x:='+IntToStr(Path[CurrentPath].MainPoint.x)+';');
writeln('Path['+IntToStr(CurrentPath)+'].Mainpoint.y:='+IntToStr(Path[CurrentPath].MainPoint.y)+';');

for i := 0 to SubPointCounter -1 do
begin
writeln('Path['+IntToStr(CurrentPath)+'].Subpoints['+IntToStr(i)+'].x:='+IntToStr(Path[CurrentPath].Subpoints[i].x)+';');
writeln('Path['+IntToStr(CurrentPath)+'].Subpoints['+IntToStr(i)+'].y:='+IntToStr(Path[CurrentPath].Subpoints[i].y)+';');
end
end;

procedure WalkPath(TheDTM:Integer);
var WhichAngle: Extended;
begin
if FindDtmRotated(TheDTM, x, y, MMX1, MMY1, MMX2, MMY2, Radians(-20), Radians(20), 0.005,
WhichAngle) then
begin
Mouse(x, y, 0, 0, True);
Wait(6000);
countflag(5);
writeln('DTMRotated Found');
end
else
Begin
writeln('not found');
end;
end;

Function FindPath(TheDTM:Integer; Click: Boolean):Boolean;
var WhichAngle: Extended;
begin
if FindDtmRotated(TheDTM, x, y, MMX1, MMY1, MMX2, MMY2, Radians(-20), Radians(20), 0.005,
WhichAngle) then
begin
Result:= True;
if Click then
begin
Mouse(x, y, 0, 0, True);
Wait(7000);
countflag(5);
end
end
else
Begin
Result := False;
writeln('not found');
end;
end;

procedure MakePaths;
begin
repeat
if IsMouseButtonDown(False) then
begin
GetMousePos(x, y);
Path[CurrentPath].SubPoints[SubPointCounter].x :=x;
Path[CurrentPath].SubPoints[SubPointCounter].y :=y;
repeat
until not IsMouseButtonDown(False);
SubPointCounter := SubPointCounter + 1;
end

if IsKeyDown('q') then
begin
GetMousePos(x, y);
Path[CurrentPath].MainPoint.x :=x;
Path[CurrentPath].MainPoint.y :=y;
repeat
until not IsKeyDown('q');
WritePath;
SubPointCounter := 0;
CurrentPath := CurrentPath + 1;
end
until False;
end;

Procedure FindLumbridgeRoadColor;
var FX, FY, d, CastleFloor: Integer;
begin
CastleFloor := BitmapFromString(8, 8, 'z78DA333334753475341B2507' +
'880400B5B154C1');
if ( not ( LoggedIn )) then Exit;
while (D < 85) do
begin
D := D + 5;
If FindBitMapToleranceIn(CastleFloor, FX, FY, 580, 50, 600, 80, D) then
begin
RoadColor:=GetColor(FX, FY);
FreeBitmap(CastleFloor);
Exit;
end
end
FreeBitmap(CastleFloor);
end;

begin
SetupSRL;
// CurrentPath:=0;
// MakePaths;
FindLumbridgeRoadColor;
LoadPaths;
// Stand at Lumbridge square and see if this brings you to the chickenpen
WalkPath(SetDTM(0));
WalkPath(SetDTM(1));
WalkPath(SetDTM(2));
WalkPath(SetDTM(3));
WalkPath(SetDTM(4));
WalkPath(SetDTM(5));
WalkPath(SetDTM(6));
WalkPath(SetDTM(7));
end.

Smartzkid

2007-05-24 18:35:32

Very, very cool example, Fawki

Sounds like this will become extremely powerful once it's more developed

:) I think Boreas will be very interested in this for the webwalker


Going to test it right now

First Try:

Okay, here's what happened (only the first try, will do some more testing, maybe even try to make a 'path maker')

It walked fine until it got to the tutors. The only reason it messed up is because I decided that, since it uses rotated dtms, it should work from any compass angle :p

I'll try it again only facing north.

For this to work really well, I think we'll need to make a new dtm finding procedure (somewhat like radialwalk, search from the outside in)

Second Try:

Worked perfectly. I kept the compass facing north, and all went well.

I am going to try to extend it to draynor, so I can better understand how you did it and get a better feel for these dynamic dtms

–
Surprised that there's no other posts yet… (maybe because of the upcoming holiday?)

shaunthasheep

2007-05-24 20:43:22

im gonna try now.. sounds awesome.. love your posting style btw.. you make everything sound enjoyable :P
ill edit once i test.

edit: very very buggy.
first try i had to do if not findmmcolor then findroad color because it got lost because it didnt have the right road color =[
and second try it got me to the intersection where the windmill hits the main road. like 2 other trys it got messed up somehow not finding the first dtm… but i think that was my fault.

i think its a good idea.. but i would base all of my walking on this =p

Infantry001

2007-05-24 20:45:03

O I already got the file. Im just testing another one of my scripts before I tele to lumby :)

EDIT: So i really liked the walking. It made it pretty much perfectly to the chicken pen. But… instead of stopping @ chicken pen, it wnet on to the flour mill. Is that supposed to happen?

Boreas

2007-05-24 21:17:47

If you just loaded a new world, make sure you log out and in before running this.

This pwns! It over shot it every (5) time, but it went to the same spot each time, so the concept works.

What are you imagining for a path maker?

Looks like making paths for WebWalker is covered :) (don't ask me when the framework will be finished)

Killerdou

2007-05-25 01:07:39

it doesnt work with the mm turned because it only scans from -20 to 20, but what you could do is have it scan from -20 - x to 20 - x where x =: FindCompassAngle, i always do that with RRW…

ruler

2007-05-25 02:29:19

sounds like your going in the direction i was before i quit color walking.

Here is where i got and the results i got.

A Path is merly a sequence of Tiles.

3 color tiles:
Tile
RoadTile
SymbolTile

All threee have a x pixle location and a y pixle location.

They must all be relational to each other.

With the Compass pointing NORTH as in the compass's North direction points to the Top of your Computers Monitor.* The X axis is defined and the Y axis is defined.

Walking doesn't modify the compass* it uses the compass to determine the current location.

Path functions:
walkToStartTile()
walkToEndTile()
walkFromStartToEnd()
walkFromEndToStart()

We prefer that each path uses map symbols for start and ends.
walkToStartTile(),walkToEndTile() are ment for example, i am in the mine and i want to click on my last tile which is most likly a map symbol.

Example usage:

toMine.add(new SymbolTile(0, 0, MiniMap.SYMBOL_BANK));
toMine.add(new RoadTile(-38, -13));
toMine.add(new RoadTile(-38 - 10, -13 - 279));
toMine.add(new RoadTile(-38 - 10 - 108, -13 - 279 - 44));
toMine.add(new RoadTile(-38 - 10 - 108 - 11, -13 - 279 - 44 - 51));
toMine.add(new Tile(-38 - 10 - 108 - 11 + 4, -13 - 279 - 44 - 51 - 41));
toMine.add(new SymbolTile(-38 - 10 - 108 - 11 + 4 + 10, -13 - 279 - 44 - 51 - 41 - 47, MiniMap.SYMBOL_MINING_SPOT));

simplified:

toMine = new Path(this);
toMine.add(new SymbolTile(0, 0, MiniMap.SYMBOL_BANK));
toMine.add(new RoadTile(-38, -13));
toMine.add(new RoadTile(-48, -292));
toMine.add(new RoadTile(-156, -336));
toMine.add(new RoadTile(-167, -387));
toMine.add(new Tile(-163, -479));
toMine.add(new SymbolTile(-153, -526, MiniMap.SYMBOL_MINING_SPOT));

I got these numbers using the line utility in ms paint that tells me the x, y change when drawing a line.


RoadTile can only be used for roads.

If you dont use road tiles odds are the walking will not be accurate.


The problems we ran into:

The Path must be started at exact locations.
The most fail-safe path are rarely the shortest path.
Most fail safe path success rate was only 95% from rimmington to bank.

http://www.rscheata.net/images/mapwalking.JPG

Yakman

2007-05-25 03:19:42

that looks really good fawki, i cant test it right now because im out, but when i get back ill try it.
if you want to make it scan from outside-in, you could look at this function called FindDtmIn, which finds a dtm in the square, but the subpoints are allowed to be outside the box,
use it with the radial walk formula

Bobarkinator

2007-05-25 04:23:15

I'm definitely gonna test, this could be an addition to WebWalker.

WT-Fakawi

2007-05-25 06:06:33

Follow- up on Paths.


This is what I did. I sampled the coords and placed them inside an array of Tpoints. I feed the Array one-by-one into a DDTM making functon.
I think you instantly understand the power of this method of walking. Remember, This only needs to be done once.








Ideas

  • Pathfiles. SCAR datafiles containing paths from one place to another.
  • Multiple Color DDTM's. Suppose you need to walk alongside the Water and the Road or you need to scan for a particular color.
  • Patterns. Repetitive Patterns like cabbagefields or checkerboard could be placed in DDTM's
  • DDTM Maker DeLuxe. A Form oriented DDTM maker, with graphic UI, runtime-magnifier, print-to-file option, step back etc. Basically a revamped DTM-Editor.
  • DDTM combined with Symbols. A new Type of highlevel pathwalker that has built-in Symbol detection. WalkPath('Up',Bank');
  • LandMarks. DDTM Landmarks you can "hook" onto and follow a Path from a certain hook[index]

I honestly believe that with this method we can finally walk 100%. I am sure that there is a lot more power to reveal with DDTM's.

I am looking for a skilled formguy willing to assist me in implementing a DDTM Maker and a skilled coder willing to help me implementing the code. Anyone?

GoF

2007-05-25 07:47:03

Wow, this seems nice and could be very useful too.. But i dont understand TPoints well so im not 100% sure how this thing works.. Ill test soon.

shaunthasheep

2007-05-25 08:44:17

From: WT-Fakawi

I am looking for a skilled formguy willing to assist me in implementing a DDTM Maker and a skilled coder willing to help me implementing the code. Anyone?


i may be able to do the form.. ill edit in a few mins with some code

EDIT:

a featureless, unfinished example of a dtm editor. I hope you like it. RIGHT CLICK TO PRINT OUT THE DTM IN DEBUG BOX.



program TEST;
var
frmDesign : TForm;
Image1 : TImage;
Capture : TCanvas;
bmpCapture : integer;
bmpMyCanvas : integer;
CreatingMainDot : boolean;
DotNumber : integer;

const TheColor = 255;

var
TheDTM : TDTM;

procedure MyCapture;
begin
//looked at radialwalkingaid.

try
FreeBitmap(bmpCapture);
except
Writeln('nobitmaptofree');
end

bmpCapture:=BitmapFromString(Image1.Width,Image1.Height,'');
Capture:=GetBitmapCanvas(bmpCapture);

try
SafeCopyCanvas(GetClientCanvas,Capture,0,0,Image1.Width,Image1.Height,0,0,Image1.Width,Image1.Height);
SafeCopyCanvas(Capture,Image1.canvas,0,0,Image1.Width,Image1.Height,0,0,Image1.Width,Image1.Height);
bmpMyCanvas := bmpCapture;
except
Writeln('error!');
end


end;

procedure CreateDot(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
i : integer;
begin
//i didn't make it print out areasize, tolerance, etc yet because this example
//doesn't support it!!!
if (Button = mbRight) then
begin
Writeln('TheDTM.MainPoint.x := ' + inttostr(TheDTM.MainPoint.x) + ';');
Writeln('TheDTM.MainPoint.y := ' + inttostr(TheDTM.MainPoint.y) + ';');
Writeln('TheDtm.MainPoint.color := ' + inttostr(TheDtm.MainPoint.color) + ';');
for i := 0 to GetArrayLength(TheDTM.SubPoints) - 1 do
begin
Writeln('TheDTM.SubPoints[' + inttostr(i) + '].x := ' + inttostr(TheDTM.SubPoints[i].x) + ';');
Writeln('TheDTM.SubPoints[' + inttostr(i) + '].y := ' + inttostr(TheDTM.SubPoints[i].x) + ';');
Writeln('TheDTM.SubPoints[' + inttostr(i) + '].color := ' + inttostr(TheDtm.SubPoints[i].Color) + ';');
end;
Exit;
end;

Writeln('Creating Dot! Right Click To Print Out Dtm ');
//if moving a dot then
//begin
//redraw captured image
//redraw the dots after moved
//end
if CreatingMainDot then
begin
TheDTM.MainPoint.x := x;
TheDTM.MainPoint.y := y;
TheDTM.MainPoint.areasize:=1;
TheDTM.MainPoint.areashape:=0;
TheDTM.MainPoint.color:= Image1.Canvas.Pixels[x, y];
TheDTM.MainPoint.tolerance:=0;
Image1.Canvas.Pixels[x, y] := 255;
CreatingMainDot := False;
end else
begin
SetArrayLength(TheDTM.SubPoints, DotNumber + 1);
TheDTM.SubPoints[DotNumber].x := x;
TheDTM.SubPoints[DotNumber].y := y;
TheDTM.SubPoints[DotNumber].areasize:=1;
TheDTM.SubPoints[DotNumber].areashape:=0;
TheDTM.SubPoints[DotNumber].color:= Image1.Canvas.Pixels[x, y];
TheDTM.SubPoints[DotNumber].tolerance:=0;
Image1.Canvas.Pixels[x, y] := 255;
Image1.Canvas.Pen.Color := 255;
Image1.Canvas.MoveTo(x, y);
Image1.Canvas.LineTo(TheDTM.MainPoint.x, TheDTM.MainPoint.y);
DotNumber := DotNumber + 1;
end;
end;

procedure InitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 341;
frmDesign.Height := 293;
frmDesign.Caption := 'DTM TEST';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Image1 := TImage.Create(frmDesign);
Image1.Parent := frmDesign;
Image1.Left := 5;
Image1.Top := 10;
Image1.Width := 321;
Image1.Height := 245;
Image1.OnMouseUp := @CreateDot;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

function ShowFormModal: Boolean;
begin
Result:= False;
if(frmDesign.ShowModal = mrOk)then
Result:= True;
end;

function SafeShowFormModal: Boolean;
var
v: TVariantArray;
begin
setarraylength(V, 0);
result:= ThreadSafeCall('ShowFormModal', v);
end;

begin
CreatingMainDot := True;
SafeInitForm;
MyCapture;
SafeShowFormModal;
DotNumber := 0;
end.

Markus

2007-05-25 08:48:33

I can help on the pathfiles. I'm currently working on a tdtmfromstring function, you will give it a string and it will return a TDTM. It reads the road and watercolor from the vars roadcolor and watercolor.

Yakman

2007-05-25 10:53:01

i might be able to help with that form,
however i do have exams, i think the best i can do is give advice or something

however, here is a form utility which used a lot of features that might be needed in that Dtm editor. http://www.villavu.com/forum/showthread.php?t=4083

shaunthasheep

2007-05-25 14:41:01

im starting on the "Path Creator Deluxe" =p
heres a short example (IN THE MENU Path -> Add Tab Works to test out);

tell me what more features i should add/take out
i might add a combox box at the bottom of each tab that says
"Keep walking Path until it finds Next Path (Path[0])"
and
"Walk This Path Once" or
"Walk This Path Multiple Times" then a textbox will appear and ask how many.

and it will save the paths in a certain way.. allowing another a script to run these paths.


program PathMakerDeluxe;
var
frmPathMaker: TForm;
mnuPathMaker: TMainMenu;
mnuFile, mnuEdit, mnuPaths, mnuHelp : TMenuItem;
{File - I don't want to use arrays}
mnuNew, mnuOpen, mnuSave, mnuSep1, mnuCreatePath, mnuSep2, mnuClose : TMenuItem;
{Edit}
mnuUndo, mnuRedo : TMenuItem;
{Paths}
mnuAddPath, mnuDelPath : TMenuItem;
{Help}
mnuHowToUse, mnuSep3, mnuAbout : TMenuItem;
tbsContainer : TPageControl;
tbsPath : Array Of TTabSheet;

{For tbsPaths Array}
var
imgMap, imgMagnified : Array Of TImage;
lblX, lblY, lblColor, lblTolerance : Array Of TLabel;
listPoints : Array Of TListBox;
btnAdd, btnDelete : Array Of TButton;
txtX, txtY : Array Of TEdit;
choiceRoad, choiceWater, choiceCustom : Array Of TRadioButton;
scrllTolerance : Array Of TScrollBar;

procedure AddATab;
begin
SetArrayLength(tbsPath, GetArrayLength(tbsPath) + 1);
tbsPath[GetArrayLength(tbsPath) - 1] := TTabSheet.Create(frmPathMaker);
TabSheetCaption(tbsPath[GetArrayLength(tbsPath) - 1], 'Path [ ' + inttostr(GetArrayLength(tbsPath) - 1) + ' ]');
tbsPath[GetArrayLength(tbsPath) - 1].PageControl := tbsContainer;
end;

procedure LoadTabObjs(Index : integer);
begin
SetArrayLength(imgMap, Index + 1);
imgMap[Index] := TImage.Create(tbsPath[Index]);
imgMap[Index].Parent := tbsPath[Index];
imgMap[Index].SetBounds(1, 1, 156, 150);

SetArrayLength(imgMagnified, Index + 1);
imgMagnified[Index] := TImage.Create(tbsPath[Index]);
imgMagnified[Index].Parent := tbsPath[Index];
imgMagnified[Index].SetBounds(1, 153, 156, 156);

SetArrayLength(lblX, Index + 1);
lblX[Index] := TLabel.Create(tbsPath[Index]);
lblX[Index].Parent := tbsPath[Index];
lblX[Index].SetBounds(160, 160, 10, 13);
lblX[Index].Caption := 'X:';

SetArrayLength(lblY, Index + 1);
lblY[Index] := TLabel.Create(tbsPath[Index]);
lblY[Index].Parent := tbsPath[Index];
lblY[Index].SetBounds(160, 184, 10, 13);
lblY[Index].Caption := 'Y:';

SetArrayLength(lblColor, Index + 1);
lblColor[Index] := TLabel.Create(tbsPath[Index]);
lblColor[Index].Parent := tbsPath[Index];
lblColor[Index].SetBounds(160, 254, 27, 13);
lblColor[Index].Caption := 'Color:';

SetArrayLength(lblTolerance, Index + 1);
lblTolerance[Index] := TLabel.Create(tbsPath[Index]);
lblTolerance[Index].Parent := tbsPath[Index];
lblTolerance[Index].SetBounds(160, 207, 63, 13);
lblTolerance[Index].Caption := 'Tolerance: 0 ';

SetArrayLength(listPoints, Index + 1);
listPoints[Index] := TListBox.Create(tbsPath[Index]);
listPoints[Index].Parent := tbsPath[Index];
listPoints[Index].SetBounds(160, 2, 121, 122);
listPoints[Index].ItemHeight := 13;

SetArrayLength(btnAdd, Index + 1);
btnAdd[Index] := TButton.Create(tbsPath[Index]);
btnAdd[Index].Parent := tbsPath[Index];
btnAdd[Index].SetBounds(160, 127, 61, 25);
btnAdd[Index].Caption := 'Add';

SetArrayLength(btnDelete, Index + 1);
btnDelete[Index] := TButton.Create(tbsPath[Index]);
btnDelete[Index].Parent := tbsPath[Index];
btnDelete[Index].SetBounds(221, 127, 61, 25);
btnDelete[Index].Caption := 'Delete';

SetArrayLength(txtX, Index + 1);
txtX[Index] := TEdit.Create(tbsPath[Index]);
txtX[Index].Parent := tbsPath[Index];
txtX[Index].SetBounds(176, 157, 54, 21);
txtX[Index].Text := 'txtX';

SetArrayLength(txtY, Index + 1);
txtY[Index] := TEdit.Create(tbsPath[Index]);
txtY[Index].Parent := tbsPath[Index];
txtY[Index].SetBounds(176, 181, 54, 21);
txtY[Index].Text := 'txtY';

SetArrayLength(choiceRoad, Index + 1);
choiceRoad[Index] := TRadioButton.Create(tbsPath[Index]);
choiceRoad[Index].Parent := tbsPath[Index];
choiceRoad[Index].SetBounds(193, 253, 88, 16);
choiceRoad[Index].Caption := 'Road';

SetArrayLength(choiceWater, Index + 1);
choiceWater[Index] := TRadioButton.Create(tbsPath[Index]);
choiceWater[Index].Parent := tbsPath[Index];
choiceWater[Index].SetBounds(193, 269, 88, 17);
choiceWater[Index].Caption := 'Water';


SetArrayLength(choiceCustom, Index + 1);
choiceCustom[Index] := TRadioButton.Create(tbsPath[Index]);
choiceCustom[Index].Parent := tbsPath[Index];
choiceCustom[Index].SetBounds(193, 286, 88, 17);
choiceCustom[Index].Caption := '0';

SetArrayLength(scrllTolerance, Index + 1);
scrllTolerance[Index] := TScrollBar.Create(tbsPath[Index]);
scrllTolerance[Index].Parent := tbsPath[Index];
scrllTolerance[Index].SetBounds(161, 227, 121, 16);
scrllTolerance[Index].Min := 0;
scrllTolerance[Index].Max := 200;

//just example here
imgMap[Index].Canvas.Pen.Color := clBlack;
imgMap[Index].Canvas.Rectangle(0, 0, 156, 150);
imgMap[Index].Canvas.TextOut(1, 1, 'Map will be here');
imgMagnified[Index].Canvas.Pen.Color := clBlack;
imgMagnified[Index].Canvas.Rectangle(0, 0, 156, 156);
imgMagnified[Index].Canvas.TextOut(1, 1, 'Magnifier here');
end;

procedure SetNewTab(Sender : TObject);
begin
AddATab;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
end;

procedure InitializeForm;
begin
frmPathMaker := CreateForm;
frmPathMaker.Left := 259;
frmPathMaker.Top := 132;
frmPathMaker.Width := 300;
frmPathMaker.Height := 384;
frmPathMaker.Caption := 'Path Maker Deluxe';
frmPathMaker.Color := clBtnFace;
frmPathMaker.Font.Color := clWindowText;
frmPathMaker.Font.Height := -11;
frmPathMaker.Font.Name := 'MS Sans Serif';
frmPathMaker.Font.Style := [];
frmPathMaker.Visible := False;
frmPathMaker.PixelsPerInch := 96;

mnuPathMaker := TMainMenu.Create(frmPathMaker);
mnuFile := TMenuItem.Create(frmPathMaker);
mnuFile.Caption := 'File';
mnuPathMaker.Items.Add(mnuFile);
mnuNew := TMenuItem.Create(frmPathMaker);
mnuNew.Caption := 'New';
mnuPathMaker.Items.Items[0].Add(mnuNew);
mnuOpen := TMenuItem.Create(frmPathMaker);
mnuOpen.Caption := 'Open';
mnuPathMaker.Items.Items[0].Add(mnuOpen);
mnuSave := TMenuItem.Create(frmPathMaker);
mnuSave.Caption := 'Save';
mnuPathMaker.Items.Items[0].Add(mnuSave);
mnuSep1 := TMenuItem.Create(frmPathMaker);
mnuSep1.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep1);
mnuCreatePath := TMenuItem.Create(frmPathMaker);
mnuCreatePath.Caption := 'Create Test.scar';
mnuPathMaker.Items.Items[0].Add(mnuCreatePath);
mnuSep2 := TMenuItem.Create(frmPathMaker);
mnuSep2.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep2);
mnuClose := TMenuItem.Create(frmPathMaker);
mnuClose.Caption := 'Exit';
mnuPathMaker.Items.Items[0].Add(mnuClose);
mnuEdit := TMenuItem.Create(frmPathMaker);
mnuEdit.Caption := 'Edit';
mnuPathMaker.Items.Add(mnuEdit);
mnuUndo := TMenuItem.Create(frmPathMaker);
mnuUndo.Caption := 'Undo';
mnuPathMaker.Items.Items[1].Add(mnuUndo);
mnuRedo := TMenuItem.Create(frmPathMaker);
mnuRedo.Caption := 'Redo';
mnuPathMaker.Items.Items[1].Add(mnuRedo);
mnuPaths := TMenuItem.Create(frmPathMaker);
mnuPaths.Caption := 'Path';
mnuPathMaker.Items.Add(mnuPaths);
mnuAddPath := TMenuItem.Create(frmPathMaker);
mnuAddPath.Caption := 'Add new path (new tab)';
mnuAddPath.OnClick := @SetNewTab;
mnuPathMaker.Items.Items[2].Add(mnuAddPath);
mnuDelPath := TMenuItem.Create(frmPathMaker);
mnuDelPath.Caption := 'Delete path (current tab)';
mnuPathMaker.Items.Items[2].Add(mnuDelPath);
mnuHelp := TMenuItem.Create(frmPathMaker);
mnuHelp.Caption := 'Help';
mnuPathMaker.Items.Add(mnuHelp);
mnuHowToUse := TMenuItem.Create(frmPathMaker);
mnuHowToUse.Caption := 'How to use...';
mnuPathMaker.Items.Items[3].Add(mnuHowToUse);
mnuSep3 := TMenuItem.Create(frmPathMaker);
mnuSep3.Caption := '-';
mnuPathMaker.Items.Items[3].Add(mnuSep3);
mnuAbout := TMenuItem.Create(frmPathMaker);
mnuAbout.Caption := 'About';
mnuPathMaker.Items.Items[3].Add(mnuAbout);

tbsContainer := TPageControl.Create(frmPathMaker);
tbsContainer.Parent := frmPathMaker;
tbsContainer.Align := alClient;

AddATab;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
end;

procedure SafeInitializeForm;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('InitializeForm', v);
end;

procedure ShowFormModal;
begin
frmPathMaker.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitializeForm;
SafeShowFormModal;
FreeForm(frmPathMaker);
end.

tell me if this is what you want the form to look like
ill do the coding for it too. (The form.. not the actually script that walks the path)

Markus

2007-05-25 15:39:04

I'm working on the load path from file thingy.
This thing here loads a dynamic dtm from a string, much like LoadDTMFromString.
A DDTM is divided in points, each point is described in 9 characters.
1, 2, 3 : x coord
4, 5, 6 : y coord
7 : areasize
8 : areashape
9 : color, 0 is black, 1 is global var roadcolor, 2 is global var watercolor. If anyone has ideas of more colors please post.


function TdtmPointFromString(dtm : string) : TDTMpointDef;
begin
if (length(dtm) <> 9) then exit; //Exit if the point is not ok
try
result.x := strtoint(copy(dtm, 1, 3));
result.y := strtoint(copy(dtm, 4, 3));
result.areasize := strtoint(copy(dtm, 7, 1));
result.areashape := strtoint(copy(dtm, 8, 1));
except
writeln('ERROR: could not load TDTMPoint!');
exit;
end;
case dtm[9] of
'1' : result.color := roadcolor;
'2' : result.color := WaterColor;
end;
end;

function TDTMFromString(dtm : string) : TDTM;
var I : integer;
pnts : array of string;
begin
if length(dtm) mod 9 <> 0 then exit;
try
i := strtoint(dtm);
except
writeln('ERROR: DTM isn''t fully numerical!');
exit;
end;
SetArrayLength(pnts, length(dtm) / 9);
SetArrayLength(result.subpoints, getarraylength(pnts) - 1);
try
for i := 0 to length(dtm) / 9 - 1 do
pnts[i] := Copy(dtm, (i+1) * 9 - 8, 9); //Create an array with points
for i := 1 to GetArrayLength(pnts) - 1 do
result.subpoints[i] := TDtmPointFromString(pnts[i]);
result.mainpoint := TDTMFromString(pnts[0]);
except
writeln('ERROR LOADING TDTM!!!');
exit;
end;
end;

shaunthasheep

2007-05-25 15:43:10

From: markus
I'm working on the load path from file thingy.
This thing here loads a dynamic dtm from a string, much like LoadDTMFromString.
A DDTM is divided in points, each point is described in 9 characters.
1, 2, 3 : x coord
4, 5, 6 : y coord
7 : areasize
8 : areashape
9 : color, 0 is black, 1 is global var roadcolor, 2 is global var watercolor. If anyone has ideas of more colors please post.


for your colors, like u said, but like i did, i put Roadcolor, WaterColor, and 0.. 0 is so when they select a point it will take that color and replace the 0

u should remove black.. and allow.. road color, watercolor, and a custom color.
so allow the color to be like 9 characters or how ever long the max characters it can be

Janilabo

2007-05-25 15:46:26

From: The_Rs_Monkey
im starting on the "Path Creator Deluxe" =p
heres a short example (IN THE MENU Path -> Add Tab Works to test out);

tell me what more features i should add/take out
i might add a combox box at the bottom of each tab that says
"Keep walking Path until it finds Next Path (Path[0])"
and
"Walk This Path Once" or
"Walk This Path Multiple Times" then a textbox will appear and ask how many.

and it will save the paths in a certain way.. allowing another a script to run these paths.


program PathMakerDeluxe;
var
frmPathMaker: TForm;
mnuPathMaker: TMainMenu;
mnuFile, mnuEdit, mnuPaths, mnuHelp : TMenuItem;
{File - I don't want to use arrays}
mnuNew, mnuOpen, mnuSave, mnuSep1, mnuCreatePath, mnuSep2, mnuClose : TMenuItem;
{Edit}
mnuUndo, mnuRedo : TMenuItem;
{Paths}
mnuAddPath, mnuDelPath : TMenuItem;
{Help}
mnuHowToUse, mnuSep3, mnuAbout : TMenuItem;
tbsContainer : TPageControl;
tbsPath : Array Of TTabSheet;

{For tbsPaths Array}
var
imgMap, imgMagnified : Array Of TImage;
lblX, lblY, lblColor, lblTolerance : Array Of TLabel;
listPoints : Array Of TListBox;
btnAdd, btnDelete : Array Of TButton;
txtX, txtY : Array Of TEdit;
choiceRoad, choiceWater, choiceCustom : Array Of TRadioButton;
scrllTolerance : Array Of TScrollBar;

procedure AddATab;
begin
SetArrayLength(tbsPath, GetArrayLength(tbsPath) + 1);
tbsPath[GetArrayLength(tbsPath) - 1] := TTabSheet.Create(frmPathMaker);
TabSheetCaption(tbsPath[GetArrayLength(tbsPath) - 1], 'Path [ ' + inttostr(GetArrayLength(tbsPath) - 1) + ' ]');
tbsPath[GetArrayLength(tbsPath) - 1].PageControl := tbsContainer;
end;

procedure LoadTabObjs(Index : integer);
begin
SetArrayLength(imgMap, Index + 1);
imgMap[Index] := TImage.Create(tbsPath[Index]);
imgMap[Index].Parent := tbsPath[Index];
imgMap[Index].SetBounds(1, 1, 156, 150);

SetArrayLength(imgMagnified, Index + 1);
imgMagnified[Index] := TImage.Create(tbsPath[Index]);
imgMagnified[Index].Parent := tbsPath[Index];
imgMagnified[Index].SetBounds(1, 153, 156, 156);

SetArrayLength(lblX, Index + 1);
lblX[Index] := TLabel.Create(tbsPath[Index]);
lblX[Index].Parent := tbsPath[Index];
lblX[Index].SetBounds(160, 160, 10, 13);
lblX[Index].Caption := 'X:';

SetArrayLength(lblY, Index + 1);
lblY[Index] := TLabel.Create(tbsPath[Index]);
lblY[Index].Parent := tbsPath[Index];
lblY[Index].SetBounds(160, 184, 10, 13);
lblY[Index].Caption := 'Y:';

SetArrayLength(lblColor, Index + 1);
lblColor[Index] := TLabel.Create(tbsPath[Index]);
lblColor[Index].Parent := tbsPath[Index];
lblColor[Index].SetBounds(160, 254, 27, 13);
lblColor[Index].Caption := 'Color:';

SetArrayLength(lblTolerance, Index + 1);
lblTolerance[Index] := TLabel.Create(tbsPath[Index]);
lblTolerance[Index].Parent := tbsPath[Index];
lblTolerance[Index].SetBounds(160, 207, 63, 13);
lblTolerance[Index].Caption := 'Tolerance: 0 ';

SetArrayLength(listPoints, Index + 1);
listPoints[Index] := TListBox.Create(tbsPath[Index]);
listPoints[Index].Parent := tbsPath[Index];
listPoints[Index].SetBounds(160, 2, 121, 122);
listPoints[Index].ItemHeight := 13;

SetArrayLength(btnAdd, Index + 1);
btnAdd[Index] := TButton.Create(tbsPath[Index]);
btnAdd[Index].Parent := tbsPath[Index];
btnAdd[Index].SetBounds(160, 127, 61, 25);
btnAdd[Index].Caption := 'Add';

SetArrayLength(btnDelete, Index + 1);
btnDelete[Index] := TButton.Create(tbsPath[Index]);
btnDelete[Index].Parent := tbsPath[Index];
btnDelete[Index].SetBounds(221, 127, 61, 25);
btnDelete[Index].Caption := 'Delete';

SetArrayLength(txtX, Index + 1);
txtX[Index] := TEdit.Create(tbsPath[Index]);
txtX[Index].Parent := tbsPath[Index];
txtX[Index].SetBounds(176, 157, 54, 21);
txtX[Index].Text := 'txtX';

SetArrayLength(txtY, Index + 1);
txtY[Index] := TEdit.Create(tbsPath[Index]);
txtY[Index].Parent := tbsPath[Index];
txtY[Index].SetBounds(176, 181, 54, 21);
txtY[Index].Text := 'txtY';

SetArrayLength(choiceRoad, Index + 1);
choiceRoad[Index] := TRadioButton.Create(tbsPath[Index]);
choiceRoad[Index].Parent := tbsPath[Index];
choiceRoad[Index].SetBounds(193, 253, 88, 16);
choiceRoad[Index].Caption := 'Road';

SetArrayLength(choiceWater, Index + 1);
choiceWater[Index] := TRadioButton.Create(tbsPath[Index]);
choiceWater[Index].Parent := tbsPath[Index];
choiceWater[Index].SetBounds(193, 269, 88, 17);
choiceWater[Index].Caption := 'Water';


SetArrayLength(choiceCustom, Index + 1);
choiceCustom[Index] := TRadioButton.Create(tbsPath[Index]);
choiceCustom[Index].Parent := tbsPath[Index];
choiceCustom[Index].SetBounds(193, 286, 88, 17);
choiceCustom[Index].Caption := '0';

SetArrayLength(scrllTolerance, Index + 1);
scrllTolerance[Index] := TScrollBar.Create(tbsPath[Index]);
scrllTolerance[Index].Parent := tbsPath[Index];
scrllTolerance[Index].SetBounds(161, 227, 121, 16);
scrllTolerance[Index].Min := 0;
scrllTolerance[Index].Max := 200;

//just example here
imgMap[Index].Canvas.Pen.Color := clBlack;
imgMap[Index].Canvas.Rectangle(0, 0, 156, 150);
imgMap[Index].Canvas.TextOut(1, 1, 'Map will be here');
imgMagnified[Index].Canvas.Pen.Color := clBlack;
imgMagnified[Index].Canvas.Rectangle(0, 0, 156, 156);
imgMagnified[Index].Canvas.TextOut(1, 1, 'Magnifier here');
end;

procedure SetNewTab(Sender : TObject);
begin
AddATab;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
end;

procedure InitializeForm;
begin
frmPathMaker := CreateForm;
frmPathMaker.Left := 259;
frmPathMaker.Top := 132;
frmPathMaker.Width := 300;
frmPathMaker.Height := 384;
frmPathMaker.Caption := 'Path Maker Deluxe';
frmPathMaker.Color := clBtnFace;
frmPathMaker.Font.Color := clWindowText;
frmPathMaker.Font.Height := -11;
frmPathMaker.Font.Name := 'MS Sans Serif';
frmPathMaker.Font.Style := [];
frmPathMaker.Visible := False;
frmPathMaker.PixelsPerInch := 96;

mnuPathMaker := TMainMenu.Create(frmPathMaker);
mnuFile := TMenuItem.Create(frmPathMaker);
mnuFile.Caption := 'File';
mnuPathMaker.Items.Add(mnuFile);
mnuNew := TMenuItem.Create(frmPathMaker);
mnuNew.Caption := 'New';
mnuPathMaker.Items.Items[0].Add(mnuNew);
mnuOpen := TMenuItem.Create(frmPathMaker);
mnuOpen.Caption := 'Open';
mnuPathMaker.Items.Items[0].Add(mnuOpen);
mnuSave := TMenuItem.Create(frmPathMaker);
mnuSave.Caption := 'Save';
mnuPathMaker.Items.Items[0].Add(mnuSave);
mnuSep1 := TMenuItem.Create(frmPathMaker);
mnuSep1.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep1);
mnuCreatePath := TMenuItem.Create(frmPathMaker);
mnuCreatePath.Caption := 'Create Test.scar';
mnuPathMaker.Items.Items[0].Add(mnuCreatePath);
mnuSep2 := TMenuItem.Create(frmPathMaker);
mnuSep2.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep2);
mnuClose := TMenuItem.Create(frmPathMaker);
mnuClose.Caption := 'Exit';
mnuPathMaker.Items.Items[0].Add(mnuClose);
mnuEdit := TMenuItem.Create(frmPathMaker);
mnuEdit.Caption := 'Edit';
mnuPathMaker.Items.Add(mnuEdit);
mnuUndo := TMenuItem.Create(frmPathMaker);
mnuUndo.Caption := 'Undo';
mnuPathMaker.Items.Items[1].Add(mnuUndo);
mnuRedo := TMenuItem.Create(frmPathMaker);
mnuRedo.Caption := 'Redo';
mnuPathMaker.Items.Items[1].Add(mnuRedo);
mnuPaths := TMenuItem.Create(frmPathMaker);
mnuPaths.Caption := 'Path';
mnuPathMaker.Items.Add(mnuPaths);
mnuAddPath := TMenuItem.Create(frmPathMaker);
mnuAddPath.Caption := 'Add new path (new tab)';
mnuAddPath.OnClick := @SetNewTab;
mnuPathMaker.Items.Items[2].Add(mnuAddPath);
mnuDelPath := TMenuItem.Create(frmPathMaker);
mnuDelPath.Caption := 'Delete path (current tab)';
mnuPathMaker.Items.Items[2].Add(mnuDelPath);
mnuHelp := TMenuItem.Create(frmPathMaker);
mnuHelp.Caption := 'Help';
mnuPathMaker.Items.Add(mnuHelp);
mnuHowToUse := TMenuItem.Create(frmPathMaker);
mnuHowToUse.Caption := 'How to use...';
mnuPathMaker.Items.Items[3].Add(mnuHowToUse);
mnuSep3 := TMenuItem.Create(frmPathMaker);
mnuSep3.Caption := '-';
mnuPathMaker.Items.Items[3].Add(mnuSep3);
mnuAbout := TMenuItem.Create(frmPathMaker);
mnuAbout.Caption := 'About';
mnuPathMaker.Items.Items[3].Add(mnuAbout);

tbsContainer := TPageControl.Create(frmPathMaker);
tbsContainer.Parent := frmPathMaker;
tbsContainer.Align := alClient;

AddATab;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
end;

procedure SafeInitializeForm;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('InitializeForm', v);
end;

procedure ShowFormModal;
begin
frmPathMaker.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitializeForm;
SafeShowFormModal;
FreeForm(frmPathMaker);
end.

tell me if this is what you want the form to look like
ill do the coding for it too. (The form.. not the actually script that walks the path)
That form looks very cool TRsM (h)

Nice job :p

Markus

2007-05-27 14:21:11

New version of TDTMFromString!
Every point is now 15 chars, to contain custom colors.
Character explanation:
1, 2, 3 : x coord
4, 5, 6 : y coord
7 : areasize
8 : areashape
9 - 15 : color, 0000001 for global var water color, 0000002 for global var watercolor. All other color or possible too, as long as the color is 7 characters long, you can add zeros before the actual color. So if you want 65536 as a color, you need to enter 0065536

The Code:

function NumericalString(s : string) : boolean;
var i, j : integer;
st : string;
begin
for i := 1 to length(s) do
try
st := s[i];
j := strtoint(st);
except
exit;
end;
result := true;
end;

function TdtmPointFromString(dtm : string) : TDTMpointDef;
var color : string;
begin
if (length(dtm) <> 15) then exit; //Exit if the point is not ok
try
result.x := strtoint(copy(dtm, 1, 3));
result.y := strtoint(copy(dtm, 4, 3));
result.areasize := strtoint(copy(dtm, 7, 1));
result.areashape := strtoint(copy(dtm, 8, 1));
except
writeln('ERROR: could not load TDTMPoint!');
exit;
end;
color := copy(dtm, 9, 7)
if color = '0000001' then result.color := roadcolor else
if color = '0000002' then result.color := WaterColor else
result.color := strtoint(color);
end;

function TDTMFromString(dtm : string) : TDTM;
var I, J : integer;
pnts : array of string;
begin
if length(dtm) mod 15 <> 0 then exit;
if not NumericalString(dtm) then exit;
SetArrayLength(pnts, length(dtm) / 15);
SetArrayLength(result.subpoints, length(dtm) / 15 - 1);
try
for i := 0 to GetArrayLength(pnts) - 1 do
begin
pnts[i] := Copy(dtm, (i+1) * 15 - 14, 15); //Create an array with points
writeln(pnts[i]);
end;
result.MainPoint := TDTMPointFromString(pnts[0]);
writeln(inttostr(GetArrayLength(pnts)));
for i := 1 to GetArrayLength(pnts) - 1 do
result.subpoints[i-1] := TDtmPointFromString(pnts[i]);
except
writeln('ERROR LOADING TDTM!!!');
exit;
end;
end;

function WalkTDTM(StringDTM : string) : boolean;
var
mmDTM : integer;
angle : extended;
begin
try
mmdtm := AddDTM(TDTMFromString(stringdtm));
except
writeln('Screwed it, sorry :-(');
exit;
end;
if FindDTMRotated(mmdtm, x, y, mmx1, mmy1, mmx2, mmy2, -1.0, 2.0, 0.1, angle) then
begin
MouseFindFlag(x, y, 1, 1);
result := true;
FFlag(2);
end;
end;

function WalkTDTMPath(path : array of string) : boolean;
var i : integer;
begin
for i := 0 to getarraylength(path)-1 do
if not WalkTDTM(path[i]) then exit;
result := true;
end;
Notice that there's now a WalkTDTM and a WalkTDTMPath. WalkTDTM loads the DTM, tries to find it and then clicks on it, WalkTDTMPath is the same thing, except that you give it multiple DTMs in an array of string, and then tries to walk them all.
WalkTDTMPath is the base of a yet to create WalkPathFromFile. The only thing you need to add to that function is the actual file loading and an explode function to split the file in seperate DTMs.

All functions are tested, except WalkTDTMPath.

WhiteShadow

2007-05-27 15:45:15

Wow. Nice new method Fawki!

I don't want to test, but it seems successful!

This is rly nice, you could make a web walker sort of thing with this, and organize the TPoints into array of arrays… :] That would be sexyy. ;D I never thought of this.. wow. <3 Fred and new SCAR Divi capabilities…

shaunthasheep

2007-05-27 16:20:43


program PathMakerDeluxe;
{
/------------------------------------------------------------------------------\
' Path Maker Deluxe verion 0.0.1 '
' Design Dynamic DTM Walking Paths the easy way. Use Path Maker Deluxe! '
|------------------------------------------------------------------------------|
' About '
|------------------------------------------------------------------------------|
' This is a DDTM (Dynamic DTM) Creator. Dynamic DTM's are the newest path '
' walking routine. With this program, you can make paths like you never '
' would been able to do before.... And in just minutes! Dynamic Dtm's have '
' a HUGE advantage over regular Dtm's. They can be constructed during '
' RUN-TIME! I no this doesn't sound cool, but it is! Allowing us to create '
' DTM's inside the running script, we can make DTM's of intersections and '
' roads whilist changing the road color as it changes in the Rs Applet! '
' But thats not all! With FindDtmRotated, we can find the road at any angle! '
|------------------------------------------------------------------------------|
' Unnofficial Moto: "Explore More" '
|------------------------------------------------------------------------------|
' This Creator was made by The_Rs_Monkey. All code belongs to him and may not '
' be used without his permission and/or posting credits. The code that executes'
' these paths created from this program are property of WT_Fawaki and the peop-'
' le who helped create the code. It is up to them if you may redistribute it. '
\------------------------------------------------------------------------------/ }
{
/------------------------------------------\
' My Check List '
|------------------------------------------|
' 1. Finish Undo/Redo '
' 2. Files Saving And Opening / New... '
' 3. Allow Add/Delete Points '
' 4. Export To Test Script. '
' 5. Delete Path '
' 6. Add Help '
' 7. Add Loop to NextPath '
' 8. Main Point Box '
' 9. Add More Colors. Door, TreePixel, User'
' Set Pixel, Ladder Color, Rock Color '
\------------------------------------------/

}
var
frmPathMaker: TForm;
mnuPathMaker: TMainMenu;
mnuFile, mnuEdit, mnuPaths, mnuHelp, mnuMouseClick : TMenuItem;
{File - I don't want to use arrays}
mnuNew, mnuOpen, mnuSave, mnuSep1, mnuCreatePath, mnuSep2, mnuClose : TMenuItem;
{Edit}
mnuUndo, mnuRedo, mnuSep4, mnuRedoCapture, mnuRedoCaptureAll : TMenuItem;
{Mouse Does...}
mnuMovePoint, mnuCreatePoint : TMenuItem;
{Paths}
mnuAddPath, mnuDelPath : TMenuItem;
{Help}
mnuHowToUse, mnuSep3, mnuAbout : TMenuItem;
tbsContainer : TPageControl;
tbsPath : Array Of TTabSheet;
FoundRsYet : boolean;

{For tbsPaths Array}
var
imgMap, imgMagnified : Array Of TImage;
lblX, lblY, lblColor, lblTolerance : Array Of TLabel;
listPoints : Array Of TListBox;
btnAdd, btnDelete : Array Of TButton;
txtX, txtY : Array Of TEdit;
choiceRoad, choiceWater, choiceCustom : Array Of TRadioButton;
scrllTolerance : Array Of TScrollBar;
ThePathDtm : Array Of TDTM;


{For Script}
var
bmpCapturedMap : Array Of integer;
Capture : TCanvas;
Captured : Boolean;
AreWeCreatingMainDot : Array Of Boolean;
MouseDoesWhat : Boolean; //True = Creates Dot, Fasle = Moves Dot
ii : integer;
ProgramChanging : boolean;
OriginalColor : Array Of Array Of Integer;

const
X1 = 573;
Y1 = 5;
W = 156;
H = 150;

//Undo And Redo types... i no.. alot lol, Try to stay organized.. LOL
type TAction = (actNewPoint, actDeletedPoint, actChangePoint, actMovePoint, actDeletePath, actAddedPath);
type TColorType = (coltypeRoad, coltypeWater, coltypeCustom);
type TWhichVar = (varX, varY, varTolerance, varColor);
type TEvent = Record
//all the needed variables for any of these changes.
Kind : TAction;
WhichVar : TWhichVar;
X, Y, Tolerance : integer;
X2, Y2, Tolerance2 : integer;
Color : TColorType;
Color2 : TColorType;
CustomColor : integer;
PathIndex : integer;
OldPath : TDTM;
end;

var
History : Array Of TEvent;
//Variable to store Undo and Redo History.

function FindRsClient : boolean;
begin
Result := FindWindowBySize(766,504);
if((not FoundRsYet) and (Result)) then
begin
Writeln('Rs Handle Is := ' + inttostr(GetClientWindowHandle) + ';');
FoundRsYet := True;
end;
//so we only writeln the handle once.
end;

function CaptureMap(Index : integer) : Boolean;
begin
//Credits := Yakman, Thank you!
if FindRsClient then
begin
//Note... i had to skip bmpCapturedMap[0] due to a weird error. Thats y ull see all these + 1's after [Index] or [i] when next to bmpMapCaptured
SetArrayLength(bmpCapturedMap, GetArrayLength(tbsPath) + 1);

try //frees an older bitmap if it exists
FreeBitmap(bmpCapturedMap[Index + 1]);
except
//there was no older bitmap to free
end

bmpCapturedMap[Index + 1] := BitmapFromString(W, H, '');
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);

try
SafeCopyCanvas(GetClientCanvas, Capture, X1, Y1, X1 + W, Y1 + H, 0, 0, W, H);
Captured := True;
except
Writeln('Couldn''t Capture Map! Srry!!!');
end;
Result := True;
end;
end;

procedure DrawDTM(Index : integer); Forward;
function SetMap(Index : integer) : Boolean;
begin
if Captured then
begin
try
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);
SafeCopyCanvas(Capture, ImgMap[Index].Canvas, 0, 0, W, H, 0, 0, W, H);
Result := True;
except
Writeln('Error!');
end;
end;
end;

procedure Magnify(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
i, a, b : integer;
begin
for i := 0 to GetArrayLength(ImgMap) - 1 do
begin
if Sender = ImgMap[i] then
begin
if Captured then
begin
try
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
SafeCopyCanvas(Capture, ImgMagnified[i].Canvas, X - 2, Y - 2, X + 3, Y + 3, 0, 0, 156, 156);
except
Writeln('Error drawing map for ImgMap[' + inttostr(i) + ']; Told ya!');
end;
a := (156 / 5) * 2 //middle pixel left and top
b := (156 / 5) * 3 //middle pixel left + width and top + height
ImgMagnified[i].Canvas.Pen.Color := 255;
ImgMagnified[i].Canvas.MoveTo(a, a);
ImgMagnified[i].Canvas.LineTo(a, b);
ImgMagnified[i].Canvas.LineTo(b, b);
ImgMagnified[i].Canvas.LineTo(b, a);
ImgMagnified[i].Canvas.LineTo(a, a);
end;
end;
end;
end;

procedure AskQuit(Sender: TObject; var CanClose: Boolean);
begin
Writeln('are u sure u want to quit');
end;

function GetColorType(Index : integer) : integer;
begin
if choiceRoad[Index].Checked then
begin
Result := 1;
end else
if choiceWater[Index].Checked then
begin
Result := 2;
end else
if choiceCustom[Index].Checked then
begin
try
Result := strtoint(choiceCustom[Index].Caption);
except
Writeln('Cannot pick custom color for some reason! Srry! Picking Road Color Instead!');
ProgramChanging := True;
choiceRoad[Index].Checked := True;
ProgramChanging := False;
Result := 1;
end;
end else
begin //If none are checked.
ProgramChanging := True;
choiceRoad[Index].Checked := True;
ProgramChanging := False;
Result := 1;
end;
end;

function CustomColor(Index : integer) : boolean;
begin
Result := ((GetColorType(Index) < 1) or (GetColorType(Index) > 2));
end;

procedure SetVariables(Index, xvalue, yvalue, tolerance, CustomColor : integer);
begin
ProgramChanging := True;
txtX[Index].Text := inttostr(xvalue);
txtY[Index].Text := inttostr(yvalue);
lblTolerance[Index].Caption := 'Tolerance: ' + inttostr(tolerance);
choiceCustom[Index].Caption := inttostr(CustomColor);
ProgramChanging := False;
end;

procedure DrawDtm(Index : integer);
var
i : integer;
begin
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);
SafeCopyCanvas(Capture, ImgMap[Index].Canvas, 0, 0, W, H, 0, 0, W, H);
ImgMap[Index].Canvas.Pen.Color := 255;
ImgMap[Index].Canvas.Pixels[ThePathDTM[Index].MainPoint.x, ThePathDTM[Index].MainPoint.y] := 255;
for i := 0 to GetArrayLength(ThePathDTM[Index].SubPoints) - 1 do
begin
ImgMap[Index].Canvas.MoveTo(ThePathDTM[Index].MainPoint.x, ThePathDTM[Index].MainPoint.y);
ImgMap[Index].Canvas.LineTo(ThePathDTM[Index].SubPoints[i].x, ThePathDTM[Index].SubPoints[i].y);
end;
end;
//add point to listbox that is
procedure AddPoint(Index, IndexSub : integer; MainPoint : boolean);
var
ColorStr : string;
begin
if MainPoint then
begin
listPoints[Index].Items.Clear;
ColorStr := inttostr(ThePathDTM[Index].MainPoint.Color);
case ThePathDTM[Index].MainPoint.Color of
1 : ColorStr := 'Road';
2 : ColorStr := 'Water';
end;
listPoints[Index].Items.Add('(' + inttostr(ThePathDTM[Index].MainPoint.x) +
', ' + inttostr(ThePathDTM[Index].MainPoint.y) +
' : ' + ColorStr + ')');
end else
begin
ColorStr := inttostr(ThePathDTM[Index].SubPoints[IndexSub].Color);
case ThePathDTM[Index].SubPoints[IndexSub].Color of
1 : ColorStr := 'Road';
2 : ColorStr := 'Water';
end;
listPoints[Index].Items.Add('(' + inttostr(ThePathDTM[Index].SubPoints[IndexSub].x) +
', ' + inttostr(ThePathDTM[Index].SubPoints[IndexSub].y) +
' : ' + ColorStr + ')');
end;
end;

procedure SetListBox(Index : integer; MoveToLastIndex : boolean);
var
i, a : integer;
begin
if not MoveToLastIndex then
a := listPoints[Index].ItemIndex;

//addpoint adds to list box fyi.
listPoints[Index].Items.Clear;
AddPoint(Index, 0, True);

for i := 0 to GetArrayLength(ThePathDTM[Index].SubPoints) - 1 do
AddPoint(Index, i, False);

if MoveToLastIndex then
a := listPoints[Index].Items.Count - 1;

listPoints[Index].ItemIndex := a;
end;

procedure CreateDot(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
i, a : integer;
begin
for i := 0 to GetArrayLength(ImgMap) - 1 do
begin
if Sender = ImgMap[i] then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
if AreWeCreatingMainDot[i] then
begin
SetArrayLength(OriginalColor[i], 1);
SetVariables(i, x, y, 0, Capture.Pixels[x, y]);
ThePathDTM[i].MainPoint.x := x;
ThePathDTM[i].MainPoint.y := y;
ThePathDTM[i].MainPoint.areasize:=1;
ThePathDTM[i].MainPoint.areashape:=0;
ThePathDTM[i].MainPoint.color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].MainPoint.tolerance:=0;
OriginalColor[i][0] := Capture.Pixels[x, y];
AreWeCreatingMainDot[i] := False;
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
if MouseDoesWhat then //We need to create dot
begin
SetArrayLength(ThePathDTM[i].SubPoints, GetArrayLength(ThePathDTM[i].SubPoints) + 1);
SetArrayLength(OriginalColor[i], GetArrayLength(ThePathDTM[i].SubPoints) + 2);
a := GetArrayLength(ThePathDTM[i].SubPoints) - 1
SetVariables(i, x, y, 0, Capture.Pixels[x, y]);
ThePathDTM[i].SubPoints[a].x := x;
ThePathDTM[i].SubPoints[a].y := y;
ThePathDTM[i].SubPoints[a].areasize:=1;
ThePathDTM[i].SubPoints[a].areashape:=0;
ThePathDTM[i].SubPoints[a].color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].SubPoints[a].tolerance:=0;
OriginalColor[i][a + 1] := Capture.Pixels[x, y];
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
if not MouseDoesWhat then
begin
if listPoints[i].ItemIndex <= -1 then
begin
//i need to remember to put in MessageBox
Writeln('No point selected to move. From menu "Mouse Click" ->');
Writeln('"Creates Point" to create point. Currently Moving Points!');
Exit;
end;
if listPoints[i].ItemIndex = 0 then //if we moving main point
begin
ProgramChanging := True;
txtX[i].Text := inttostr(x);
txtY[i].Text := inttostr(Y);
ProgramChanging := False;
ThePathDTM[i].MainPoint.x := x;
ThePathDTM[i].MainPoint.y := y;
OriginalColor[i][0] := Capture.Pixels[x, y];
ProgramChanging := True;
choiceCustom[i].Caption := inttostr(Capture.Pixels[x, y]);
ProgramChanging := False;
if CustomColor(i) then
begin
ThePathDTM[i].MainPoint.Color := Capture.Pixels[x, y];
end;
end;
if listPoints[i].ItemIndex > 0 then //if we moving sub points
begin
ProgramChanging := True;
txtX[i].Text := inttostr(x);
txtY[i].Text := inttostr(Y);
ProgramChanging := False;
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].x := x;
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].y := y;
OriginalColor[i][listPoints[i].ItemIndex] := Capture.Pixels[x, y];
ProgramChanging := True;
choiceCustom[i].Caption := inttostr(Capture.Pixels[x, y]);
ProgramChanging := False;
if CustomColor(i) then
begin
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].Color := Capture.Pixels[x, y];
end;
end;
DrawDtm(i);
SetListBox(i, False);
Exit;
end;
//DeleteHardWork('All'); lol
end;
end;
end;

procedure SetStuff(sender : TObject);
var
i, a : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if Sender = listPoints[i] then
begin
a := listPoints[i].ItemIndex;
if a = 0 then
begin
ProgramChanging := True;
txtX[i].Text := inttostr(ThePathDTM[i].MainPoint.x)
txtY[i].Text := inttostr(ThePathDTM[i].MainPoint.y)
if ThePathDTM[i].MainPoint.Color = 1 then
choiceRoad[i].Checked := True;
if ThePathDTM[i].MainPoint.Color = 2 then
choiceWater[i].Checked := True;
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
if ((ThePathDTM[i].MainPoint.Color < 1) or (ThePathDTM[i].MainPoint.Color > 2)) then
begin
choiceCustom[i].Checked := True;
end;
scrllTolerance[i].Position := ThePathDTM[i].MainPoint.Tolerance;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(ThePathDTM[i].MainPoint.Tolerance);
ProgramChanging := False;
end;

if a > 0 then
begin
ProgramChanging := True;
txtX[i].Text := inttostr(ThePathDTM[i].SubPoints[a - 1].x)
txtY[i].Text := inttostr(ThePathDTM[i].SubPoints[a - 1].y)
if ThePathDTM[i].SubPoints[a - 1].Color = 1 then
choiceRoad[i].Checked := True;
if ThePathDTM[i].SubPoints[a - 1].Color = 2 then
choiceWater[i].Checked := True;
choiceCustom[i].Caption := inttostr(OriginalColor[i][a]);
if ((ThePathDTM[i].SubPoints[a - 1].Color < 1) or (ThePathDTM[i].SubPoints[a - 1].Color > 2)) then
begin
choiceCustom[i].Checked := True;
end;
scrllTolerance[i].Position := ThePathDTM[i].SubPoints[a - 1].Tolerance;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(ThePathDTM[i].SubPoints[a - 1].Tolerance);
ProgramChanging := False;
end;
end;
end;
end;

function TEditToInt(var myedit : TEdit) : integer;
begin
ProgramChanging := True;
myedit.Text := GetNumbers(myedit.Text);
if myedit.Text = '' then myedit.Text := '0';
try
Result := strtoint(myedit.text);
except
//Somehow we got an error. We shouldn't tho
end;
ProgramChanging := False;
end;

procedure HandleChange(sender : TObject);
var
i, a : integer;
begin
if ProgramChanging then Exit;

for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if not AreWeCreatingMainDot[i] then
begin
a := listPoints[i].ItemIndex;
if a < 0 then Exit;
if a = 0 then
begin
case Sender of
txtX[i]: ThePathDtm[i].MainPoint.x := TEditToInt(txtX[i]);
txtY[i]: ThePathDtm[i].MainPoint.y := TEditToInt(txtY[i]);
scrllTolerance[i]: begin
ThePathDtm[i].MainPoint.Tolerance := scrllTolerance[i].Position;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(scrllTolerance[i].Position);
end;
choiceRoad[i]: ThePathDtm[i].MainPoint.Color := 1;
choiceWater[i]: ThePathDtm[i].MainPoint.Color := 2;
choiceCustom[i]: ThePathDtm[i].MainPoint.Color := OriginalColor[i][0];
end;
if ((Sender = txtX[i]) or (Sender = txtY[i])) then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
OriginalColor[i][0] := Capture.Pixels[strtoint(txtX[i].text), strtoint(txtY[i].text)];
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
if choiceCustom[i].Checked then
ThePathDtm[i].MainPoint.Color := OriginalColor[i][0];
end;
end;
if a > 0 then
begin
case Sender of
txtX[i]: ThePathDtm[i].SubPoints[a - 1].x := TEditToInt(txtX[i]);
txtY[i]: ThePathDtm[i].SubPoints[a - 1].y := TEditToInt(txtY[i]);
scrllTolerance[i]: begin
ThePathDtm[i].SubPoints[a - 1].Tolerance := scrllTolerance[i].Position;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(scrllTolerance[i].Position);
end;
choiceRoad[i]: ThePathDtm[i].SubPoints[a - 1].Color := 1;
choiceWater[i]: ThePathDtm[i].SubPoints[a - 1].Color := 2;
choiceCustom[i]: ThePathDtm[i].SubPoints[a - 1].Color := OriginalColor[i][0];
end;
if ((Sender = txtX[i]) or (Sender = txtY[i])) then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
OriginalColor[i][a - 1] := Capture.Pixels[strtoint(txtX[i].text), strtoint(txtY[i].text)];
choiceCustom[i].Caption := inttostr(OriginalColor[i][a - 1]);
if choiceCustom[i].Checked then
ThePathDtm[i].SubPoints[a - 1].Color := OriginalColor[i][a - 1];
end;
end;
SetListBox(i, False);
DrawDTM(i);
end;
end;
end;

procedure LoadTabObjs(Index : integer);
begin
SetArrayLength(imgMap, Index + 1);
imgMap[Index] := TImage.Create(tbsPath[Index]);
imgMap[Index].Parent := tbsPath[Index];
imgMap[Index].OnMouseMove := @Magnify;
imgMap[Index].OnMouseUp := @CreateDot;
imgMap[Index].SetBounds(1, 1, 156, 150);

SetArrayLength(imgMagnified, Index + 1);
imgMagnified[Index] := TImage.Create(tbsPath[Index]);
imgMagnified[Index].Parent := tbsPath[Index];
imgMagnified[Index].SetBounds(1, 153, 156, 156);

SetArrayLength(lblX, Index + 1);
lblX[Index] := TLabel.Create(tbsPath[Index]);
lblX[Index].Parent := tbsPath[Index];
lblX[Index].SetBounds(160, 160, 10, 13);
lblX[Index].Caption := 'X:';

SetArrayLength(lblY, Index + 1);
lblY[Index] := TLabel.Create(tbsPath[Index]);
lblY[Index].Parent := tbsPath[Index];
lblY[Index].SetBounds(160, 184, 10, 13);
lblY[Index].Caption := 'Y:';

SetArrayLength(lblColor, Index + 1);
lblColor[Index] := TLabel.Create(tbsPath[Index]);
lblColor[Index].Parent := tbsPath[Index];
lblColor[Index].SetBounds(160, 254, 27, 13);
lblColor[Index].Caption := 'Color:';

SetArrayLength(lblTolerance, Index + 1);
lblTolerance[Index] := TLabel.Create(tbsPath[Index]);
lblTolerance[Index].Parent := tbsPath[Index];
lblTolerance[Index].SetBounds(160, 207, 63, 13);
lblTolerance[Index].Caption := 'Tolerance: 0 ';

SetArrayLength(listPoints, Index + 1);
listPoints[Index] := TListBox.Create(tbsPath[Index]);
listPoints[Index].Parent := tbsPath[Index];
listPoints[Index].SetBounds(160, 2, 121, 122);
listPoints[Index].ItemHeight := 13;
listPoints[Index].OnClick := @SetStuff;

SetArrayLength(btnAdd, Index + 1);
btnAdd[Index] := TButton.Create(tbsPath[Index]);
btnAdd[Index].Parent := tbsPath[Index];
btnAdd[Index].SetBounds(160, 127, 61, 25);
btnAdd[Index].Caption := 'Add';

SetArrayLength(btnDelete, Index + 1);
btnDelete[Index] := TButton.Create(tbsPath[Index]);
btnDelete[Index].Parent := tbsPath[Index];
btnDelete[Index].SetBounds(221, 127, 61, 25);
btnDelete[Index].Caption := 'Delete';

SetArrayLength(txtX, Index + 1);
txtX[Index] := TEdit.Create(tbsPath[Index]);
txtX[Index].Parent := tbsPath[Index];
txtX[Index].SetBounds(176, 157, 54, 21);
txtX[Index].Text := 'txtX';
txtX[Index].OnChange := @HandleChange;

SetArrayLength(txtY, Index + 1);
txtY[Index] := TEdit.Create(tbsPath[Index]);
txtY[Index].Parent := tbsPath[Index];
txtY[Index].SetBounds(176, 181, 54, 21);
txtY[Index].Text := 'txtY';
txtY[Index].OnChange := @HandleChange;

SetArrayLength(choiceRoad, Index + 1);
choiceRoad[Index] := TRadioButton.Create(tbsPath[Index]);
choiceRoad[Index].Parent := tbsPath[Index];
choiceRoad[Index].SetBounds(193, 253, 88, 16);
choiceRoad[Index].Caption := 'Road';
choiceRoad[Index].OnClick := @HandleChange;

SetArrayLength(choiceWater, Index + 1);
choiceWater[Index] := TRadioButton.Create(tbsPath[Index]);
choiceWater[Index].Parent := tbsPath[Index];
choiceWater[Index].SetBounds(193, 269, 88, 17);
choiceWater[Index].Caption := 'Water';
choiceWater[Index].OnClick := @HandleChange;

SetArrayLength(choiceCustom, Index + 1);
choiceCustom[Index] := TRadioButton.Create(tbsPath[Index]);
choiceCustom[Index].Parent := tbsPath[Index];
choiceCustom[Index].SetBounds(193, 286, 88, 17);
choiceCustom[Index].Caption := '0';
choiceCustom[Index].OnClick := @HandleChange;

SetArrayLength(scrllTolerance, Index + 1);
scrllTolerance[Index] := TScrollBar.Create(tbsPath[Index]);
scrllTolerance[Index].Parent := tbsPath[Index];
scrllTolerance[Index].SetBounds(161, 227, 121, 16);
scrllTolerance[Index].Min := 0;
scrllTolerance[Index].Max := 200;
scrllTolerance[Index].OnChange := @HandleChange;
end;


procedure AddATab;
begin
SetArrayLength(tbsPath, GetArrayLength(tbsPath) + 1);
tbsPath[GetArrayLength(tbsPath) - 1] := TTabSheet.Create(frmPathMaker);
TabSheetCaption(tbsPath[GetArrayLength(tbsPath) - 1], 'Path [ ' + inttostr(GetArrayLength(tbsPath) - 1) + ' ]');
tbsPath[GetArrayLength(tbsPath) - 1].PageControl := tbsContainer;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
if CaptureMap(GetArrayLength(tbsPath) - 1) then
SetMap(GetArrayLength(tbsPath) - 1);
SetArrayLength(AreWeCreatingMainDot, GetArrayLength(tbsPath));
AreWeCreatingMainDot[GetArrayLength(tbsPath) - 1] := True;
SetArrayLength(ThePathDTM, GetArrayLength(tbsPath));
SetArrayLength(OriginalColor, GetArrayLength(tbsPath));
end;


procedure SetNewTab(Sender : TObject);
begin
AddATab;
end;

procedure ReDoCapture(sender : TObject);
var
i : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if tbsContainer.ActivePage = tbsPath[i] then
begin
if CaptureMap(i) then
begin
SetMap(i);
if not AreWeCreatingMainDot[i] then DrawDtm(i);
end;
end;
end;
end;

procedure ReDoCaptureAll(sender : TObject);
var
i : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if CaptureMap(i) then
begin
SetMap(i);
if not AreWeCreatingMainDot[i] then DrawDtm(i);
end;
end;
end;

procedure ChangeMouseClicks(Sender : TObject);
begin
case Sender of
mnuMovePoint : MouseDoesWhat := False;
mnuCreatePoint : MouseDoesWhat := True;
end;
mnuMovePoint.Checked := not(MouseDoesWhat);
mnuCreatePoint.Checked := (MouseDoesWhat);
end;

procedure InitializeForm;
begin
if not FindRsClient then
begin
Writeln('Must have Rs open first. Terminating!');
TerminateScript;
end;
frmPathMaker := CreateForm;
frmPathMaker.Left := 259;
frmPathMaker.Top := 132;
frmPathMaker.Width := 300;
frmPathMaker.Height := 384;
frmPathMaker.Caption := 'Path Maker Deluxe';
frmPathMaker.Color := clBtnFace;
frmPathMaker.Font.Color := clWindowText;
frmPathMaker.Font.Height := -11;
frmPathMaker.Font.Name := 'MS Sans Serif';
frmPathMaker.Font.Style := [];
frmPathMaker.Visible := False;
frmPathMaker.PixelsPerInch := 96;
frmPathMaker.Onclosequery := @AskQuit;

mnuPathMaker := TMainMenu.Create(frmPathMaker);
mnuFile := TMenuItem.Create(frmPathMaker);
mnuFile.Caption := 'File';
mnuPathMaker.Items.Add(mnuFile);
mnuNew := TMenuItem.Create(frmPathMaker);
mnuNew.Caption := 'New';
mnuPathMaker.Items.Items[0].Add(mnuNew);
mnuOpen := TMenuItem.Create(frmPathMaker);
mnuOpen.Caption := 'Open';
mnuPathMaker.Items.Items[0].Add(mnuOpen);
mnuSave := TMenuItem.Create(frmPathMaker);
mnuSave.Caption := 'Save';
mnuPathMaker.Items.Items[0].Add(mnuSave);
mnuSep1 := TMenuItem.Create(frmPathMaker);
mnuSep1.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep1);
mnuCreatePath := TMenuItem.Create(frmPathMaker);
mnuCreatePath.Caption := 'Create Test.scar';
mnuPathMaker.Items.Items[0].Add(mnuCreatePath);
mnuSep2 := TMenuItem.Create(frmPathMaker);
mnuSep2.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep2);
mnuClose := TMenuItem.Create(frmPathMaker);
mnuClose.Caption := 'Exit';
mnuPathMaker.Items.Items[0].Add(mnuClose);
mnuEdit := TMenuItem.Create(frmPathMaker);
mnuEdit.Caption := 'Edit';
mnuPathMaker.Items.Add(mnuEdit);
mnuUndo := TMenuItem.Create(frmPathMaker);
mnuUndo.Caption := 'Undo';
mnuPathMaker.Items.Items[1].Add(mnuUndo);
mnuRedo := TMenuItem.Create(frmPathMaker);
mnuRedo.Caption := 'Redo';
mnuPathMaker.Items.Items[1].Add(mnuRedo);
mnuSep4 := TMenuItem.Create(frmPathMaker);
mnuSep4.Caption := '-';
mnuPathMaker.Items.Items[1].Add(mnuSep4);
mnuRedoCapture := TMenuItem.Create(frmPathMaker);
mnuRedoCapture.Caption := 'Do/Redo Capture This Path';
mnuRedoCapture.OnClick := @RedoCapture;
mnuPathMaker.Items.Items[1].Add(mnuRedoCapture);
mnuRedoCaptureAll := TMenuItem.Create(frmPathMaker);
mnuRedoCaptureAll.Caption := 'Do/Redo Capture All Paths';
mnuRedoCaptureAll.OnClick := @RedoCaptureAll;
mnuPathMaker.Items.Items[1].Add(mnuRedoCaptureAll);
mnuMouseClick := TMenuItem.Create(frmPathMaker);
mnuMouseClick.Caption := 'Mouse Click';
mnuPathMaker.Items.Add(mnuMouseClick);
mnuMovePoint := TMenuItem.Create(frmPathMaker);
mnuMovePoint.Caption := 'Moves Selected Point';
mnuMovePoint.OnClick := @ChangeMouseClicks;
mnuPathMaker.Items.Items[2].Add(mnuMovePoint);
mnuCreatePoint := TMenuItem.Create(frmPathMaker);
mnuCreatePoint.Caption := 'Creates New Point';
mnuCreatePoint.OnClick := @ChangeMouseClicks;
mnuCreatePoint.Checked := True;
mnuPathMaker.Items.Items[2].Add(mnuCreatePoint);
mnuPaths := TMenuItem.Create(frmPathMaker);
mnuPaths.Caption := 'Path';
mnuPathMaker.Items.Add(mnuPaths);
mnuAddPath := TMenuItem.Create(frmPathMaker);
mnuAddPath.Caption := 'Add new path (new tab)';
mnuAddPath.OnClick := @SetNewTab;
mnuPathMaker.Items.Items[3].Add(mnuAddPath);
mnuDelPath := TMenuItem.Create(frmPathMaker);
mnuDelPath.Caption := 'Delete path (current tab)';
mnuPathMaker.Items.Items[3].Add(mnuDelPath);
mnuHelp := TMenuItem.Create(frmPathMaker);
mnuHelp.Caption := 'Help';
mnuPathMaker.Items.Add(mnuHelp);
mnuHowToUse := TMenuItem.Create(frmPathMaker);
mnuHowToUse.Caption := 'How to use...';
mnuPathMaker.Items.Items[4].Add(mnuHowToUse);
mnuSep3 := TMenuItem.Create(frmPathMaker);
mnuSep3.Caption := '-';
mnuPathMaker.Items.Items[4].Add(mnuSep3);
mnuAbout := TMenuItem.Create(frmPathMaker);
mnuAbout.Caption := 'About';
mnuPathMaker.Items.Items[4].Add(mnuAbout);

tbsContainer := TPageControl.Create(frmPathMaker);
tbsContainer.Parent := frmPathMaker;
tbsContainer.Align := alClient;
CaptureMap(-1); //Its like initiallizing the bmpMapCaptured Array!

AddATab;

end;

procedure SafeInitializeForm;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('InitializeForm', v);
end;

procedure ShowFormModal;
begin
frmPathMaker.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;


begin
MouseDoesWhat := True;
SafeInitializeForm;
SafeShowFormModal;
FreeForm(frmPathMaker);
for ii := 0 to GetArrayLength(imgMap) - 1 do
begin
try
FreeBitmap(bmpCapturedMap[ii]);
except
end;
end;
end.

ive gotten really far on the form. id say 60 - 75% done.

but we still need a guy to make a script that can read the Form paths this creator will spit out.

im thinking a ini to save the paths. eg


[SRLRoute]
RouteName=LumbridgeToDraynor
NumOfPaths=5
[Path0]
NumOfSubPoints=1
MainPoint.x=1
mainpoint.y=1
mainpoint.tolerance=1 //only if custom color u would use
mainpoint.color=1//1 for road, 2 for water, else is custom
subpoints[0].x=1
subpoints[0].y=1
subpoints[0].tolerance=1
subpoints[0].color=1
[Path1]
//yadayadayada
[Path2]
...
[Path3]
...
[Path4]
...
//etc

Bobarkinator

2007-05-27 21:36:57

Good idea. BTW I love the form. It's almost like the actual DTM maker. Gonna be great when finished:D

masquerader

2007-05-27 23:09:37

any room for me in this project?
rs monkey's form thing looks pretty slick

what do you need?
im pretty sure i could write something that would turn this:
[SRLRoute]
RouteName=LumbridgeToDraynor
NumOfPaths=5
[Path0]
NumOfSubPoints=1
MainPoint.x=1
mainpoint.y=1
mainpoint.tolerance=1 //only if custom color u would use
mainpoint.color=1//1 for road, 2 for water, else is custom
subpoints[0].x=1
subpoints[0].y=1
subpoints[0].tolerance=1
subpoints[0].color=1
[Path1]
//yadayadayada
[Path2]
...
[Path3]
...
[Path4]
...
//etc
into a tdtm if thats whats left, although i dont think the "route name" would work

Wizzup?

2007-05-28 03:56:14

Masquerader, did you mean this?
function AddDTM(DTM: TDTM): Integer;
Load a dynamic deformable template model.

WT-Fakawi

2007-05-28 05:03:57

The_RS_Monkey: Incredible! You are really faaast with this. You are definately on the right track. IMHO we should now define what a Path is. Should all variables in the DDTM be assignable, or should we output a fixed set of type Path, I am asking because this program has lots potential.

Proposal, from my initial post:
Type Path

type
TDTMPoints = record
MainPoint : TPoint;
SubPoints : array[0..7] of Tpoint;
end;
var
Path: array[0..50] of TDTMPoints;

This would store 1 mainpoint and max 8 subpoints into an array. The PathMaker should output these values as a Pascal formatted procedure.

Or:

Maybe the Path should have a name too, or maybe we want fixed Paths, like up/down/left/right, T-split, 4-split. I have been experimenting with these, but so far not 100% hit.

At Least two functions are needed:

WalkPath(Path): Boolean;
FindPath(Path, Click: Boolean): Boolean;

where FindPath might input a PathName, so you could do:
repeat 
WalkPath(Path[6]);
until FindPath('T-Split');

Ideally we should have some "hooks" too. LumbridgeCastle is such a hook. But also the bifurcation above Draynor is a clear "hook"

These "hooks" then should be incorporated into a network of Paths, gradually unlocking the whole RS-Map. We will need other landmarks too, like Symbols (Observe Boreas WebWalker, I see a match here…)

Yes Masq, please jump aboard!

nielsie95

2007-05-28 05:36:37

From: WT-Fakawi
These "hooks" then should be incorporated into a network of Paths, gradually unlocking the whole RS-Map. We will need other landmarks too, like Symbols


A great help could be the area-sound of RS. Runescape basicly splits up the whole map with different sounds. Try it: varrock-west, varrock-east, out-of-town-varrock…they are all different sounds.

If you know the area, you can slink down your options of the place where you are. Then you could make it even more accurate by looking at symbols, landmarks, etc.

Fakawi: I updated your StatsLogger with an AreaDetecor in it. It has a little list of areasounds from the F2P city's, plus a funtion that returns the current playing sound. If it's ok I could post the script (non-members?), else I could post the list.

WT-Fakawi

2007-05-28 06:00:00

From: nielsie95
A great help could be the area-sound of RS. Runescape basicly splits up the whole map with different sounds. Try it: varrock-west, varrock-east, out-of-town-varrock…they are all different sounds.

If you know the area, you can slink down your options of the place where you are. Then you could make it even more accurate by looking at symbols, landmarks, etc.

Fakawi: I updated your StatsLogger with an AreaDetecor in it. It has a little list of areasounds from the F2P city's, plus a funtion that returns the current playing sound. If it's ok I could post the script (non-members?), else I could post the list.


You mean to say you have actually got a Sound Detector? I have been looking for one of those for one-and-a-halve year now, and the only one that has gotten even close to it was a guy named shocker. But I never got his plug-in to work properly. But, by all means, yes, throw in your code :)

nielsie95

2007-05-28 06:36:59

Umm… I actually ment area-music, sorry. :p
I just grab the current-playing song from the music-tab:


function GetPlayingMusic: String;
begin
GameTab(13);
Result := Trim(GetTextAtex(558, 240, 50, SmallChars, True, True, 0, 2, 65280, 50, False, tr_allChars));
end;

Few examples:


Music - Loc


spirit - Varrock West
garden - Varrock East
kharid - Al-Kharid
Harmony - Lumbridge

And there are about 200 more..


The area's aren't really big. It's a good way to shrink down your options.

shaunthasheep

2007-05-28 07:47:19

^^thats actually a great idea. iv'e never thought about that =S

and also more info about the form. It's been getting boringer (srry can't think this morning) the more it's developed. But, ive put it my top priority to get atleast 1 thing on the Check list done a day. So it might be done in a week, but i don't see no hurry to get it done yet. But this project is gonna rock either way ;)

WT-Fakawi

2007-05-28 09:42:35

From: The_Rs_Monkey
^^thats actually a great idea. iv'e never thought about that =S

and also more info about the form. It's been getting boringer (srry can't think this morning) the more it's developed. But, ive put it my top priority to get atleast 1 thing on the Check list done a day. So it might be done in a week, but i don't see no hurry to get it done yet. But this project is gonna rock either way ;)

All good things take their time. Take your time…..!, I am happy to have you aboard. Masq will proove to be a great addition too, if he wishes to step into things.

Boreas

2007-05-28 10:53:14

So what I was thinking was, that WebWalker Paths could be made with these. They would have to start and end with a symbol, so that a station (hook) can be written for it. So a series of clicks from DTM to DTM, starting and ending with a symbol,(and can use RRW, doors, etc in there too), makes up a Path. Then a series of Paths from symbol to symbol makes up a Route.

There will eventually be more than one combination of Paths to get from A to B, hence RoutePicker. The different shaped DTMs can also be used in station functions. They can be used in substations, which are within Paths. They can be used with symbols in stations, so that you can wander around when lost until you find one.

WT-Fakawi

2007-05-28 12:48:59

Station it is :). Yes we need to incorporate different methods, like RRW and SymbolWalkers.
As a mind game lets make Walk('Lumbridge2Draynor') (::l2d)

  • First we need Station LumbridgeCastle. I think I have got a reasonable Lumbridge DTM, but I am sure it can be found somewhere else on the map, like Falador West Bank, or Varrock Square. We will need some additional tests to check whether we are really in Lumbridge. This is where Symbols come in. Clearly the two WaterSymbols indicate we are at Lumbridge + a matched DDTM. We can safely walk the first Path out-of-Lumbridge.
  • Next, we need to move upwards until we find a: 1. bended DDTM indicating left turn, or if that doenst work, 2. a FurnaceSymbol check first, and then the bended DDTM.
  • Next, we RRW until draynor 4-bifurcation. Thats a long walk with just one operation.
  • Next we RRW down until Draynor BankDTM is found, or BankSymbol. Bingo!

Maybe make more mindpaths, like essencequester, might help.

Ejjman

2007-05-28 13:07:32

From: WT-Fakawi
Maybe make more mindpaths, like essencequester, might help.


Good idea right there!!

Boreas

2007-05-28 13:18:36

I jotted this down a while ago for double water stations

lumby station

2 water
no minimgame

1 or more water

al karid minigame
varrock palace 1 ladder, quest,
waters are horizxontal
edgeville max 3 doors, cooking,
general stroe, tree
fally east
>4 ladders, > 1 cook

nielsie95

2007-05-28 13:25:39

Umm… Area-Music?

Harmony (music) + DDTM is Lumbridge? :p

WT-Fakawi

2007-05-28 14:23:47

From: nielsie95
Umm… Area-Music?

Harmony (music) + DDTM is Lumbridge? :p

Woooo, thats a good idea. This will need to grow on me. It is a wonderful state change. I never noticed it!

Ejjman

2007-05-28 14:27:27

From: WT-Fakawi
Woooo, thats a good idea. This will need to grow on me. It is a wonderful state change. I never noticed it!


Lol, who listens to music >.<

shaunthasheep

2007-05-28 14:34:46

even if the music volume is off, it will still show the song playing.
By getting the name of the song playing. You could match it with the corresponding place. Then once the script knows where your are. It should then look for associated dtms with that area. It finds the dtm and walks to it. The script will know exactly where u r.

masquerader

2007-05-28 16:32:56

excuse me for backtracking a little bit, i think you guys are thinking too far ahead

the question i want to ask is what properties the path type will have

  • in the dtm editor, dtms have: coordinates, area size, area shape, tolerance, and color
  • in rsmonkey's prototype you have: coordinates, color and tolerance
  • in what fakawi posted above, you have just coordinates (everything is road color)

so… what level of do we want?
ive always been a fan of adding as much customizability as possible, but that has the side effect of complicating things and making less people use it

my vote: use what fakawi said, easier for everybody :p

as for the name, still workin it out, but i decided that at the start of the script, the array of tdtmpoints should be turned into an array of actual dtms with an array of corresponding names

then you would need to access it with a function instead of an array

function path(name:string):dtm
begin
for i:=0 to arraylength(dtmarray) do
begin
if(dtmnamearray[i]=name)then
begin
result:=dtmarray(i)
exit;
end
end
too much work?
probably

shaunthasheep

2007-05-28 17:16:46

Well I may add Area Resize.

I may add path finding customization.
  1. Loop Until Next Path Found
  2. Loop <num> Many Times
  3. Loop Until DTM Path Name Found (Eg "T-Split")
  4. Loop Until Found "Hook"
  5. Loop Until Found Symbol "namehere"
  6. Only search if last one not found
and I may add a check mark name "Exit if not found"

I may add more colors (i included previous colors as well):
  1. Road Color
  2. Water Color
  3. Tree pixel(User sets in script however)
  4. Ladder Color(same as above)
  5. Rock Color(same as above)
  6. Wall Color(same as above)
  7. Door Color(same as above)
  8. Fally Road Color(same as above)
  9. Varrock Road Color(same as above)
  10. Dirt Road Color(same as above)
  11. User set pixel(with tolerance) and user will set in script under a certain variable name
^ this number will be the color if the user picks these. Cause theres no such colors as 000001 or 000002
or etc[INDENT]12. Custom Color (with tolerance) this color is set in the path creator
[/INDENT]0 and anything above 11 will be the custom color.


However these are my ideas. You the one creating the actually scripts that read this.
If this is too over your head (or too much power lol) i can remove some. But if we want
a Ultra powerful map walker, i think we may need these options.

EDIT: i added more colors

WT-Fakawi

2007-05-28 19:05:04

Looks in order to me. Image making DDTMs of Rock, Road and Water. Dynamite! We should also seriously consider neilsie95's idea. The tunename-changes give a clear indication of our whereabouts…(even with sound off!) I think this is a brilliant way of callibrating…I bet there has got to be a TuneMap somewhere :)

shaunthasheep

2007-05-28 20:28:48

From: WT-Fakawi
Looks in order to me. Image making DDTMs of Rock, Road and Water. Dynamite! We should also seriously consider neilsie95's idea. The tunename-changes give a clear indication of our whereabouts…(even with sound off!) I think this is a brilliant way of callibrating…I bet there has got to be a TuneMap somewhere :)

maybe not a tunemap, but a list of places where u unlock them. Neilsie95 posts a link earlier in the thread (pg 2).. let me go get it real quick.

heres the link (edit) http://www.runehq.com/RHQSpecialReportsView.php?id=00239

Smartzkid

2007-05-28 20:38:07

May I suggest something?

Type Path

type
PathPiece = record
MainPoint : TPoint;
SubPoints : array[0..7] of Tpoint;
Music : String; //Maybe an Array of String?
end;
var
Path: array[0..50] of PathPiece;

shaunthasheep

2007-05-28 21:22:29

if i may edit it to work with my creator

type
PathPiece = record
MainPoint : TPoint;
SubPoints : array of Tpoint;
Music : String; //Maybe an Array of String?
end;

i didn't really change anything, but i dont wan't to limit the user on the amount of points it can have
but also. do u need to find the music while walk? And yes. it should be array of string, may be like right between a music change border,I think we should only find music if we arrive at destination. or "stations"

so i think it should be:

type
PathPiece = record
MainPoint : TPoint;
SubPoints : array of Tpoint;
end;

type
Path = record
Peices : Array Of PathPeice;
AreaMusic : Array Of string;
end;
var
LumbyToDraynor : Path

LumbyToDraynor.AreaMusic := ['somin', 'somin];

//we arrive at destination (supposebly)
if CheckMusicTab([PossibleMusic]) then
//we are at location

or

//we arrive at destination (supposebly)
if CheckMusicTab(['PossibleMusic', 'PossibleMusic2]') then
//we are at location

masquerader

2007-05-29 00:14:15

you cant really expand on something youre not finished with yet :p
ex: the delete button on the form doesnt work and you are talking about adding music features

im sorry for being kind of a buzzkill, but its very common around here for talented youngsters to burn themselves out and leave projects half finished.
pace yourself, lol (you coded 800 lines of the form in like 2 days?????)

so…. rs-monkey, i propose completing the form tool so that has basic functionality (refer to the first post)
-just use the road color, no picked colors or tolerance
-be able add points and delete points
-i dont think you would make more than one path point before moving to a different area, so maybe it needs some sort of "refresh" function (keeping the previews of previous points for future reference)

once thats done, you can get to adding as many features as you want

shaunthasheep

2007-05-29 07:37:49

From: masquerader
you cant really expand on something youre not finished with yet :p
ex: the delete button on the form doesnt work and you are talking about adding music features

im sorry for being kind of a buzzkill, but its very common around here for talented youngsters to burn themselves out and leave projects half finished.
pace yourself, lol (you coded 800 lines of the form in like 2 days?????)

so…. rs-monkey, i propose completing the form tool so that has basic functionality (refer to the first post)
-just use the road color, no picked colors or tolerance
-be able add points and delete points
-i dont think you would make more than one path point before moving to a different area, so maybe it needs some sort of "refresh" function (keeping the previews of previous points for future reference)

once thats done, you can get to adding as many features as you want


actually, i finished the delete button yesterday. and so the basic DTM editor shows. u can change, edit, create, move points, like the regular dtm editor. I just have no saving yet. Trust me, if i was getting to over MY head, i would of never suggested it.

Why no tolerance? Maybe the road looks the same in some spots, we need to add some colors (and btw if i was to remove the water color and custom color i have on the form now, it'd take me like 20 minutes, without harming the code)

There is a "refresh function"… here is the updated(but the one on the very top of this page shows it too):
First,
when u select "New path", it will open a new tabs, with an uptodate capture of the map.
Secondly, under "Edit", theres too menus (working rigth now too) that say "Redo Capture" and "Redo Capture All". this will refresh the capture on the current, and second will redo capture for them all.

Trust me, i'm actually thinking of the basics before i do the more complicated stuff. And even the Undo/Redo is on the front of my "check list", it aint gonna be done until after everything else is.



program PathMakerDeluxe;
{
/------------------------------------------------------------------------------\
' Path Maker Deluxe verion 0.0.1 '
' Design Dynamic DTM Walking Paths the easy way. Use Path Maker Deluxe! '
|------------------------------------------------------------------------------|
' About '
|------------------------------------------------------------------------------|
' This is a DDTM (Dynamic DTM) Creator. Dynamic DTM's are the newest path '
' walking routine. With this program, you can make paths like you never '
' would been able to do before.... And in just minutes! Dynamic Dtm's have '
' a HUGE advantage over regular Dtm's. They can be constructed during '
' RUN-TIME! I no this doesn't sound cool, but it is! Allowing us to create '
' DTM's inside the running script, we can make DTM's of intersections and '
' roads whilst changing the road color as it changes in the Rs Applet! '
' But thats not all! With FindDtmRotated, we can find the road at any angle! '
|------------------------------------------------------------------------------|
' Unofficial Moto: "Explore More" '
|------------------------------------------------------------------------------|
' This Creator was made by The_Rs_Monkey. All code belongs to him and may not '
' be used without his permission and/or posting credits. The code that executes'
' these paths created from this program are property of WT_Fawaki and the peop-'
' le who helped create the code. It is up to them if you may redistribute it. '
\------------------------------------------------------------------------------/ }
{
/------------------------------------------\
' My Check List '
|------------------------------------------|
' 1. Finish Undo/Redo '
' 2. Files Saving And Opening / New... '
' 3. Insert Path After '
' 4. Export To Test Script. '
' 5. Delete Path '
' 6. Add Help '
' 7. Add Loop to NextPath '
' 8. Main Point Box '
' 9. Add More Colors. Door, TreePixel, User'
' Set Pixel, Ladder Color, Rock Color '
\------------------------------------------/

}
var
frmPathMaker: TForm;
mnuPathMaker: TMainMenu;
mnuFile, mnuEdit, mnuPaths, mnuHelp, mnuMouseClick : TMenuItem;
{File - I don't want to use arrays}
mnuNew, mnuOpen, mnuSave, mnuSep1, mnuCreatePath, mnuSep2, mnuClose : TMenuItem;
{Edit}
mnuUndo, mnuRedo, mnuSep4, mnuRedoCapture, mnuRedoCaptureAll : TMenuItem;
{Mouse Does...}
mnuMovePoint, mnuCreatePoint : TMenuItem;
{Paths}
mnuAddPath, mnuDelPath : TMenuItem;
{Help}
mnuHowToUse, mnuSep3, mnuAbout : TMenuItem;
tbsContainer : TPageControl;
tbsPath : Array Of TTabSheet;
FoundRsYet : boolean;

{For tbsPaths Array}
var
imgMap, imgMagnified : Array Of TImage;
lblX, lblY, lblColor, lblTolerance : Array Of TLabel;
listPoints : Array Of TListBox;
btnAdd, btnDelete : Array Of TButton;
txtX, txtY : Array Of TEdit;
choiceRoad, choiceWater, choiceCustom : Array Of TRadioButton;
scrllTolerance : Array Of TScrollBar;
ThePathDtm : Array Of TDTM;


{For Script}
var
bmpCapturedMap : Array Of integer;
Capture : TCanvas;
Captured : Boolean;
AreWeCreatingMainDot : Array Of Boolean;
MouseDoesWhat : Boolean; //True = Creates Dot, Fasle = Moves Dot
ii : integer;
ProgramChanging : boolean;
OriginalColor : Array Of Array Of Integer;

const
X1 = 573;
Y1 = 5;
W = 156;
H = 150;

//Undo And Redo types... i no.. alot lol, Try to stay organized.. LOL
type TAction = (actNewPoint, actDeletedPoint, actChangePoint, actMovePoint, actDeletePath, actAddedPath);
type TColorType = (coltypeRoad, coltypeWater, coltypeCustom);
type TWhichVar = (varX, varY, varTolerance, varColor);
type TEvent = Record
//all the needed variables for any of these changes.
Kind : TAction;
WhichVar : TWhichVar;
X, Y, Tolerance : integer;
X2, Y2, Tolerance2 : integer;
Color : TColorType;
Color2 : TColorType;
CustomColor : integer;
PathIndex : integer;
OldPath : TDTM;
end;

var
History : Array Of TEvent;
//Variable to store Undo and Redo History.

function FindRsClient : boolean;
begin
Result := FindWindowBySize(766,504);
if((not FoundRsYet) and (Result)) then
begin
Writeln('Rs Handle Is := ' + inttostr(GetClientWindowHandle) + ';');
FoundRsYet := True;
end;
//so we only writeln the handle once.
end;

function CaptureMap(Index : integer) : Boolean;
begin
//Credits := Yakman, Thank you!
if FindRsClient then
begin
//Note... i had to skip bmpCapturedMap[0] due to a weird error. Thats y ull see all these + 1's after [Index] or [i] when next to bmpMapCaptured
SetArrayLength(bmpCapturedMap, GetArrayLength(tbsPath) + 1);

try //frees an older bitmap if it exists
FreeBitmap(bmpCapturedMap[Index + 1]);
except
//there was no older bitmap to free
end

bmpCapturedMap[Index + 1] := BitmapFromString(W, H, '');
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);

try
SafeCopyCanvas(GetClientCanvas, Capture, X1, Y1, X1 + W, Y1 + H, 0, 0, W, H);
Captured := True;
except
Writeln('Couldn''t Capture Map! Srry!!!');
end;
Result := True;
end;
end;

function SetMap(Index : integer) : Boolean;
begin
if Captured then
begin
try
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);
SafeCopyCanvas(Capture, ImgMap[Index].Canvas, 0, 0, W, H, 0, 0, W, H);
Result := True;
except
Writeln('Error!');
end;
end;
end;

procedure Magnify(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
i, a, b : integer;
begin
for i := 0 to GetArrayLength(ImgMap) - 1 do
begin
if Sender = ImgMap[i] then
begin
if Captured then
begin
try
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
SafeCopyCanvas(Capture, ImgMagnified[i].Canvas, X - 2, Y - 2, X + 3, Y + 3, 0, 0, 156, 156);
except
Writeln('Error drawing map for ImgMap[' + inttostr(i) + ']; Told ya!');
end;
a := (156 / 5) * 2 //middle pixel left and top
b := (156 / 5) * 3 //middle pixel left + width and top + height
ImgMagnified[i].Canvas.Pen.Color := 255;
ImgMagnified[i].Canvas.MoveTo(a, a);
ImgMagnified[i].Canvas.LineTo(a, b);
ImgMagnified[i].Canvas.LineTo(b, b);
ImgMagnified[i].Canvas.LineTo(b, a);
ImgMagnified[i].Canvas.LineTo(a, a);
end;
end;
end;
end;

procedure AskQuit(Sender: TObject; var CanClose: Boolean);
begin
Writeln('are u sure u want to quit');
end;

function GetColorType(Index : integer) : integer;
begin
if choiceRoad[Index].Checked then
begin
Result := 1;
end else
if choiceWater[Index].Checked then
begin
Result := 2;
end else
if choiceCustom[Index].Checked then
begin
try
Result := strtoint(choiceCustom[Index].Caption);
except
Writeln('Cannot pick custom color for some reason! Srry! Picking Road Color Instead!');
ProgramChanging := True;
choiceRoad[Index].Checked := True;
ProgramChanging := False;
Result := 1;
end;
end else
begin //If none are checked.
ProgramChanging := True;
choiceRoad[Index].Checked := True;
ProgramChanging := False;
Result := 1;
end;
end;

function CustomColor(Index : integer) : boolean;
begin
Result := ((GetColorType(Index) < 1) or (GetColorType(Index) > 2));
end;

procedure SetVariables(Index, xvalue, yvalue, tolerance, CustomColor : integer);
begin
ProgramChanging := True;
txtX[Index].Text := inttostr(xvalue);
txtY[Index].Text := inttostr(yvalue);
lblTolerance[Index].Caption := 'Tolerance: ' + inttostr(tolerance);
choiceCustom[Index].Caption := inttostr(CustomColor);
ProgramChanging := False;
end;

procedure DrawDtm(Index : integer);
var
i : integer;
begin
Capture := GetBitmapCanvas(bmpCapturedMap[Index + 1]);
SafeCopyCanvas(Capture, ImgMap[Index].Canvas, 0, 0, W, H, 0, 0, W, H);
ImgMap[Index].Canvas.Pen.Color := 255;
ImgMap[Index].Canvas.Pixels[ThePathDTM[Index].MainPoint.x, ThePathDTM[Index].MainPoint.y] := 255;
for i := 0 to GetArrayLength(ThePathDTM[Index].SubPoints) - 1 do
begin
ImgMap[Index].Canvas.MoveTo(ThePathDTM[Index].MainPoint.x, ThePathDTM[Index].MainPoint.y);
ImgMap[Index].Canvas.LineTo(ThePathDTM[Index].SubPoints[i].x, ThePathDTM[Index].SubPoints[i].y);
end;
end;
//add point to listbox that is
procedure AddPoint(Index, IndexSub : integer; MainPoint : boolean);
var
ColorStr : string;
begin
if MainPoint then
begin
listPoints[Index].Items.Clear;
ColorStr := inttostr(ThePathDTM[Index].MainPoint.Color);
case ThePathDTM[Index].MainPoint.Color of
1 : ColorStr := 'Road';
2 : ColorStr := 'Water';
end;
listPoints[Index].Items.Add('(' + inttostr(ThePathDTM[Index].MainPoint.x) +
', ' + inttostr(ThePathDTM[Index].MainPoint.y) +
' : ' + ColorStr + ')');
end else
begin
ColorStr := inttostr(ThePathDTM[Index].SubPoints[IndexSub].Color);
case ThePathDTM[Index].SubPoints[IndexSub].Color of
1 : ColorStr := 'Road';
2 : ColorStr := 'Water';
end;
listPoints[Index].Items.Add('(' + inttostr(ThePathDTM[Index].SubPoints[IndexSub].x) +
', ' + inttostr(ThePathDTM[Index].SubPoints[IndexSub].y) +
' : ' + ColorStr + ')');
end;
end;

procedure SetListBox(Index : integer; MoveToLastIndex : boolean);
var
i, a : integer;
begin
if not MoveToLastIndex then
a := listPoints[Index].ItemIndex;

//addpoint adds to list box fyi.
listPoints[Index].Items.Clear;
AddPoint(Index, 0, True);

for i := 0 to GetArrayLength(ThePathDTM[Index].SubPoints) - 1 do
AddPoint(Index, i, False);

if MoveToLastIndex then
a := listPoints[Index].Items.Count - 1;

listPoints[Index].ItemIndex := a;
end;

procedure CreateDot(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
i, a : integer;
begin
for i := 0 to GetArrayLength(ImgMap) - 1 do
begin
if Sender = ImgMap[i] then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
if AreWeCreatingMainDot[i] then
begin
SetArrayLength(OriginalColor[i], 1);
SetVariables(i, x, y, 0, Capture.Pixels[x, y]);
ThePathDTM[i].MainPoint.x := x;
ThePathDTM[i].MainPoint.y := y;
ThePathDTM[i].MainPoint.areasize:=1;
ThePathDTM[i].MainPoint.areashape:=0;
ThePathDTM[i].MainPoint.color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].MainPoint.tolerance:=0;
OriginalColor[i][0] := Capture.Pixels[x, y];
AreWeCreatingMainDot[i] := False;
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
if MouseDoesWhat then //We need to create dot
begin
SetArrayLength(ThePathDTM[i].SubPoints, GetArrayLength(ThePathDTM[i].SubPoints) + 1);
SetArrayLength(OriginalColor[i], GetArrayLength(ThePathDTM[i].SubPoints) + 2);
a := GetArrayLength(ThePathDTM[i].SubPoints) - 1
SetVariables(i, x, y, 0, Capture.Pixels[x, y]);
ThePathDTM[i].SubPoints[a].x := x;
ThePathDTM[i].SubPoints[a].y := y;
ThePathDTM[i].SubPoints[a].areasize:=1;
ThePathDTM[i].SubPoints[a].areashape:=0;
ThePathDTM[i].SubPoints[a].color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].SubPoints[a].tolerance:=0;
OriginalColor[i][a + 1] := Capture.Pixels[x, y];
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
if not MouseDoesWhat then
begin
if listPoints[i].ItemIndex <= -1 then
begin
//i need to remember to put in MessageBox
Writeln('No point selected to move. From menu "Mouse Click" ->');
Writeln('"Creates Point" to create point. Currently Moving Points!');
Exit;
end;
if listPoints[i].ItemIndex = 0 then //if we moving main point
begin
ProgramChanging := True;
txtX[i].Text := inttostr(x);
txtY[i].Text := inttostr(Y);
ProgramChanging := False;
ThePathDTM[i].MainPoint.x := x;
ThePathDTM[i].MainPoint.y := y;
OriginalColor[i][0] := Capture.Pixels[x, y];
ProgramChanging := True;
choiceCustom[i].Caption := inttostr(Capture.Pixels[x, y]);
ProgramChanging := False;
if CustomColor(i) then
begin
ThePathDTM[i].MainPoint.Color := Capture.Pixels[x, y];
end;
end;
if listPoints[i].ItemIndex > 0 then //if we moving sub points
begin
ProgramChanging := True;
txtX[i].Text := inttostr(x);
txtY[i].Text := inttostr(Y);
ProgramChanging := False;
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].x := x;
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].y := y;
OriginalColor[i][listPoints[i].ItemIndex] := Capture.Pixels[x, y];
ProgramChanging := True;
choiceCustom[i].Caption := inttostr(Capture.Pixels[x, y]);
ProgramChanging := False;
if CustomColor(i) then
begin
ThePathDTM[i].SubPoints[listPoints[i].ItemIndex - 1].Color := Capture.Pixels[x, y];
end;
end;
DrawDtm(i);
SetListBox(i, False);
Exit;
end;
//DeleteHardWork('All'); lol
end;
end;
end;

procedure SetStuff(sender : TObject);
var
i, a : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if Sender = listPoints[i] then
begin
a := listPoints[i].ItemIndex;
if a = 0 then
begin
ProgramChanging := True;
txtX[i].Text := inttostr(ThePathDTM[i].MainPoint.x)
txtY[i].Text := inttostr(ThePathDTM[i].MainPoint.y)
if ThePathDTM[i].MainPoint.Color = 1 then
choiceRoad[i].Checked := True;
if ThePathDTM[i].MainPoint.Color = 2 then
choiceWater[i].Checked := True;
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
if ((ThePathDTM[i].MainPoint.Color < 1) or (ThePathDTM[i].MainPoint.Color > 2)) then
begin
choiceCustom[i].Checked := True;
end;
scrllTolerance[i].Position := ThePathDTM[i].MainPoint.Tolerance;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(ThePathDTM[i].MainPoint.Tolerance);
ProgramChanging := False;
end;

if a > 0 then
begin
ProgramChanging := True;
txtX[i].Text := inttostr(ThePathDTM[i].SubPoints[a - 1].x)
txtY[i].Text := inttostr(ThePathDTM[i].SubPoints[a - 1].y)
if ThePathDTM[i].SubPoints[a - 1].Color = 1 then
choiceRoad[i].Checked := True;
if ThePathDTM[i].SubPoints[a - 1].Color = 2 then
choiceWater[i].Checked := True;
choiceCustom[i].Caption := inttostr(OriginalColor[i][a]);
if ((ThePathDTM[i].SubPoints[a - 1].Color < 1) or (ThePathDTM[i].SubPoints[a - 1].Color > 2)) then
begin
choiceCustom[i].Checked := True;
end;
scrllTolerance[i].Position := ThePathDTM[i].SubPoints[a - 1].Tolerance;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(ThePathDTM[i].SubPoints[a - 1].Tolerance);
ProgramChanging := False;
end;
end;
end;
end;

function TEditToInt(var myedit : TEdit) : integer;
begin
ProgramChanging := True;
myedit.Text := GetNumbers(myedit.Text);
if myedit.Text = '' then myedit.Text := '0';
try
Result := strtoint(myedit.text);
except
//Somehow we got an error. We shouldn't tho
end;
ProgramChanging := False;
end;

procedure HandleChange(sender : TObject);
var
i, a : integer;
begin
if ProgramChanging then Exit;

for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
a := listPoints[i].ItemIndex;
if a < 0 then
begin
if Sender = scrllTolerance[i] then
begin
ThePathDtm[i].MainPoint.Tolerance := scrllTolerance[i].Position;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(scrllTolerance[i].Position);
end;
end;

if not AreWeCreatingMainDot[i] then
begin
if a = 0 then
begin
case Sender of
txtX[i]: ThePathDtm[i].MainPoint.x := TEditToInt(txtX[i]);
txtY[i]: ThePathDtm[i].MainPoint.y := TEditToInt(txtY[i]);
scrllTolerance[i]: begin
ThePathDtm[i].MainPoint.Tolerance := scrllTolerance[i].Position;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(scrllTolerance[i].Position);
end;
choiceRoad[i]: ThePathDtm[i].MainPoint.Color := 1;
choiceWater[i]: ThePathDtm[i].MainPoint.Color := 2;
choiceCustom[i]: ThePathDtm[i].MainPoint.Color := OriginalColor[i][0];
end;
if ((Sender = txtX[i]) or (Sender = txtY[i])) then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
OriginalColor[i][0] := Capture.Pixels[strtoint(txtX[i].text), strtoint(txtY[i].text)];
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
if choiceCustom[i].Checked then
ThePathDtm[i].MainPoint.Color := OriginalColor[i][0];
end;
end;
if a > 0 then
begin
case Sender of
txtX[i]: ThePathDtm[i].SubPoints[a - 1].x := TEditToInt(txtX[i]);
txtY[i]: ThePathDtm[i].SubPoints[a - 1].y := TEditToInt(txtY[i]);
scrllTolerance[i]: begin
ThePathDtm[i].SubPoints[a - 1].Tolerance := scrllTolerance[i].Position;
lblTolerance[i].Caption := 'Tolerance: ' + inttostr(scrllTolerance[i].Position);
end;
choiceRoad[i]: ThePathDtm[i].SubPoints[a - 1].Color := 1;
choiceWater[i]: ThePathDtm[i].SubPoints[a - 1].Color := 2;
choiceCustom[i]: ThePathDtm[i].SubPoints[a - 1].Color := OriginalColor[i][0];
end;
if ((Sender = txtX[i]) or (Sender = txtY[i])) then
begin
Capture := GetBitmapCanvas(bmpCapturedMap[i + 1]);
OriginalColor[i][a - 1] := Capture.Pixels[strtoint(txtX[i].text), strtoint(txtY[i].text)];
choiceCustom[i].Caption := inttostr(OriginalColor[i][a - 1]);
if choiceCustom[i].Checked then
ThePathDtm[i].SubPoints[a - 1].Color := OriginalColor[i][a - 1];
end;
end;
SetListBox(i, False);
DrawDTM(i);
end;
end;
end;

procedure AddDelete(sender : TObject);
var
i, a, b, c : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if AreWeCreatingMainDot[i] then //no use deleting a point that isnt there, only add the main point.
begin
case Sender of
btnAdd[i]: begin
SetArrayLength(OriginalColor[i], 1);
OriginalColor[i][0] := Capture.Pixels[TEditToInt(txtX[i]), TEditToInt(txtY[i])];
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
ThePathDTM[i].MainPoint.x := TEditToInt(txtX[i]);
ThePathDTM[i].MainPoint.y := TEditToInt(txtY[i]);
ThePathDTM[i].MainPoint.areasize:=1;
ThePathDTM[i].MainPoint.areashape:=0;
ThePathDTM[i].MainPoint.color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].MainPoint.tolerance:= scrllTolerance[i].Position;
AreWeCreatingMainDot[i] := False;
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
end;
end else
begin
case Sender of
btnAdd[i]: begin
a := listPoints[i].Items.Count;
SetArrayLength(OriginalColor[i], GetArrayLength(OriginalColor[i]) + 1);
SetArrayLength(ThePathDTM[i].SubPoints, GetArrayLength(ThePathDTM[i].SubPoints) + 1);
OriginalColor[i][a - 1] := Capture.Pixels[TEditToInt(txtX[i]), TEditToInt(txtY[i])];
choiceCustom[i].Caption := inttostr(OriginalColor[i][0]);
ThePathDTM[i].SubPoints[a - 1].x := TEditToInt(txtX[i]);
ThePathDTM[i].SubPoints[a - 1].y := TEditToInt(txtY[i]);
ThePathDTM[i].SubPoints[a - 1].areasize:=1;
ThePathDTM[i].SubPoints[a - 1].areashape:=0;
ThePathDTM[i].SubPoints[a - 1].color:= GetColorType(i); //1 = road, 2 = water, other = custom color
ThePathDTM[i].SubPoints[a - 1].tolerance:= scrllTolerance[i].Position;
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
btnDelete[i]: begin
a := listPoints[i].Items.Count;
b := listPoints[i].ItemIndex;
if (a = 0) then Exit;
if ((a = 1) and (b = 0)) then //delete main point
begin
AreWeCreatingMainDot[i] := True;
ThePathDTM[i].MainPoint.x := -1;
ThePathDTM[i].MainPoint.y := -1;
ThePathDTM[i].MainPoint.Tolerance := 0;
ThePathDTM[i].MainPoint.Color := 0;
SetArrayLength(OriginalColor[i], 0);
listPoints[i].Items.Clear;
DrawDTM(i);
Exit;
end;
if ((a > 1) and (b = 0)) then
begin
ThePathDTM[i].MainPoint := ThePathDTM[i].SubPoints[0];
for c := 1 to GetArrayLength(ThePathDTM[i].SubPoints) - 1 do
begin
ThePathDTM[i].SubPoints[c - 1] := ThePathDTM[i].SubPoints[c]
end;
SetArrayLength(ThePathDTM[i].SubPoints, GetArrayLength(ThePathDTM[i].SubPoints) - 1);
DrawDtm(i);
SetListBox(i, False);
Exit;
end;
if ((a > 1) and (b > 0)) then
begin
for c := b to GetArrayLength(ThePathDTM[i].SubPoints) - 1 do
begin
ThePathDTM[i].SubPoints[c - 1] := ThePathDTM[i].SubPoints[c]
end;
SetArrayLength(ThePathDTM[i].SubPoints, GetArrayLength(ThePathDTM[i].SubPoints) - 1);
DrawDtm(i);
SetListBox(i, True);
Exit;
end;
end;
end;
end;
end;
end;

procedure LoadTabObjs(Index : integer);
begin
SetArrayLength(imgMap, Index + 1);
imgMap[Index] := TImage.Create(tbsPath[Index]);
imgMap[Index].Parent := tbsPath[Index];
imgMap[Index].OnMouseMove := @Magnify;
imgMap[Index].OnMouseUp := @CreateDot;
imgMap[Index].SetBounds(1, 1, 156, 150);

SetArrayLength(imgMagnified, Index + 1);
imgMagnified[Index] := TImage.Create(tbsPath[Index]);
imgMagnified[Index].Parent := tbsPath[Index];
imgMagnified[Index].SetBounds(1, 153, 156, 156);

SetArrayLength(lblX, Index + 1);
lblX[Index] := TLabel.Create(tbsPath[Index]);
lblX[Index].Parent := tbsPath[Index];
lblX[Index].SetBounds(160, 160, 10, 13);
lblX[Index].Caption := 'X:';

SetArrayLength(lblY, Index + 1);
lblY[Index] := TLabel.Create(tbsPath[Index]);
lblY[Index].Parent := tbsPath[Index];
lblY[Index].SetBounds(160, 184, 10, 13);
lblY[Index].Caption := 'Y:';

SetArrayLength(lblColor, Index + 1);
lblColor[Index] := TLabel.Create(tbsPath[Index]);
lblColor[Index].Parent := tbsPath[Index];
lblColor[Index].SetBounds(160, 254, 27, 13);
lblColor[Index].Caption := 'Color:';

SetArrayLength(lblTolerance, Index + 1);
lblTolerance[Index] := TLabel.Create(tbsPath[Index]);
lblTolerance[Index].Parent := tbsPath[Index];
lblTolerance[Index].SetBounds(160, 207, 63, 13);
lblTolerance[Index].Caption := 'Tolerance: 0 ';

SetArrayLength(listPoints, Index + 1);
listPoints[Index] := TListBox.Create(tbsPath[Index]);
listPoints[Index].Parent := tbsPath[Index];
listPoints[Index].SetBounds(160, 2, 121, 122);
listPoints[Index].ItemHeight := 13;
listPoints[Index].OnClick := @SetStuff;

SetArrayLength(btnAdd, Index + 1);
btnAdd[Index] := TButton.Create(tbsPath[Index]);
btnAdd[Index].Parent := tbsPath[Index];
btnAdd[Index].SetBounds(160, 127, 61, 25);
btnAdd[Index].Caption := 'Add';
btnAdd[Index].OnClick := @AddDelete;

SetArrayLength(btnDelete, Index + 1);
btnDelete[Index] := TButton.Create(tbsPath[Index]);
btnDelete[Index].Parent := tbsPath[Index];
btnDelete[Index].SetBounds(221, 127, 61, 25);
btnDelete[Index].Caption := 'Delete';
btnDelete[Index].OnClick := @AddDelete;

SetArrayLength(txtX, Index + 1);
txtX[Index] := TEdit.Create(tbsPath[Index]);
txtX[Index].Parent := tbsPath[Index];
txtX[Index].SetBounds(176, 157, 54, 21);
txtX[Index].Text := 'txtX';
txtX[Index].OnChange := @HandleChange;

SetArrayLength(txtY, Index + 1);
txtY[Index] := TEdit.Create(tbsPath[Index]);
txtY[Index].Parent := tbsPath[Index];
txtY[Index].SetBounds(176, 181, 54, 21);
txtY[Index].Text := 'txtY';
txtY[Index].OnChange := @HandleChange;

SetArrayLength(choiceRoad, Index + 1);
choiceRoad[Index] := TRadioButton.Create(tbsPath[Index]);
choiceRoad[Index].Parent := tbsPath[Index];
choiceRoad[Index].SetBounds(193, 253, 88, 16);
choiceRoad[Index].Caption := 'Road';
choiceRoad[Index].OnClick := @HandleChange;

SetArrayLength(choiceWater, Index + 1);
choiceWater[Index] := TRadioButton.Create(tbsPath[Index]);
choiceWater[Index].Parent := tbsPath[Index];
choiceWater[Index].SetBounds(193, 269, 88, 17);
choiceWater[Index].Caption := 'Water';
choiceWater[Index].OnClick := @HandleChange;

SetArrayLength(choiceCustom, Index + 1);
choiceCustom[Index] := TRadioButton.Create(tbsPath[Index]);
choiceCustom[Index].Parent := tbsPath[Index];
choiceCustom[Index].SetBounds(193, 286, 88, 17);
choiceCustom[Index].Caption := '0';
choiceCustom[Index].OnClick := @HandleChange;

SetArrayLength(scrllTolerance, Index + 1);
scrllTolerance[Index] := TScrollBar.Create(tbsPath[Index]);
scrllTolerance[Index].Parent := tbsPath[Index];
scrllTolerance[Index].SetBounds(161, 227, 121, 16);
scrllTolerance[Index].Min := 0;
scrllTolerance[Index].Max := 200;
scrllTolerance[Index].OnChange := @HandleChange;
end;


procedure AddATab;
begin
SetArrayLength(tbsPath, GetArrayLength(tbsPath) + 1);
tbsPath[GetArrayLength(tbsPath) - 1] := TTabSheet.Create(frmPathMaker);
TabSheetCaption(tbsPath[GetArrayLength(tbsPath) - 1], 'Path [ ' + inttostr(GetArrayLength(tbsPath) - 1) + ' ]');
tbsPath[GetArrayLength(tbsPath) - 1].PageControl := tbsContainer;
LoadTabObjs(GetArrayLength(tbsPath) - 1);
if CaptureMap(GetArrayLength(tbsPath) - 1) then
SetMap(GetArrayLength(tbsPath) - 1);
SetArrayLength(AreWeCreatingMainDot, GetArrayLength(tbsPath));
AreWeCreatingMainDot[GetArrayLength(tbsPath) - 1] := True;
SetArrayLength(ThePathDTM, GetArrayLength(tbsPath));
SetArrayLength(OriginalColor, GetArrayLength(tbsPath));
end;


procedure SetNewTab(Sender : TObject);
begin
AddATab;
end;

procedure ReDoCapture(sender : TObject);
var
i : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if tbsContainer.ActivePage = tbsPath[i] then
begin
if CaptureMap(i) then
begin
SetMap(i);
if not AreWeCreatingMainDot[i] then DrawDtm(i);
end;
end;
end;
end;

procedure ReDoCaptureAll(sender : TObject);
var
i : integer;
begin
for i := 0 to GetArrayLength(tbsPath) - 1 do
begin
if CaptureMap(i) then
begin
SetMap(i);
if not AreWeCreatingMainDot[i] then DrawDtm(i);
end;
end;
end;

procedure ChangeMouseClicks(Sender : TObject);
begin
case Sender of
mnuMovePoint : MouseDoesWhat := False;
mnuCreatePoint : MouseDoesWhat := True;
end;
mnuMovePoint.Checked := not(MouseDoesWhat);
mnuCreatePoint.Checked := (MouseDoesWhat);
end;

procedure InitializeForm;
begin
if not FindRsClient then
begin
Writeln('Must have Rs open first. Terminating Script! (ignore error)');
TerminateScript;
end;
frmPathMaker := CreateForm;
frmPathMaker.Left := 259;
frmPathMaker.Top := 132;
frmPathMaker.Width := 300;
frmPathMaker.Height := 384;
frmPathMaker.Caption := 'Path Maker Deluxe';
frmPathMaker.Color := clBtnFace;
frmPathMaker.Font.Color := clWindowText;
frmPathMaker.Font.Height := -11;
frmPathMaker.Font.Name := 'MS Sans Serif';
frmPathMaker.Font.Style := [];
frmPathMaker.Visible := False;
frmPathMaker.PixelsPerInch := 96;
frmPathMaker.Onclosequery := @AskQuit;

mnuPathMaker := TMainMenu.Create(frmPathMaker);
mnuFile := TMenuItem.Create(frmPathMaker);
mnuFile.Caption := 'File';
mnuPathMaker.Items.Add(mnuFile);
mnuNew := TMenuItem.Create(frmPathMaker);
mnuNew.Caption := 'New';
mnuPathMaker.Items.Items[0].Add(mnuNew);
mnuOpen := TMenuItem.Create(frmPathMaker);
mnuOpen.Caption := 'Open';
mnuPathMaker.Items.Items[0].Add(mnuOpen);
mnuSave := TMenuItem.Create(frmPathMaker);
mnuSave.Caption := 'Save';
mnuPathMaker.Items.Items[0].Add(mnuSave);
mnuSep1 := TMenuItem.Create(frmPathMaker);
mnuSep1.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep1);
mnuCreatePath := TMenuItem.Create(frmPathMaker);
mnuCreatePath.Caption := 'Create Test.scar';
mnuPathMaker.Items.Items[0].Add(mnuCreatePath);
mnuSep2 := TMenuItem.Create(frmPathMaker);
mnuSep2.Caption := '-';
mnuPathMaker.Items.Items[0].Add(mnuSep2);
mnuClose := TMenuItem.Create(frmPathMaker);
mnuClose.Caption := 'Exit';
mnuPathMaker.Items.Items[0].Add(mnuClose);
mnuEdit := TMenuItem.Create(frmPathMaker);
mnuEdit.Caption := 'Edit';
mnuPathMaker.Items.Add(mnuEdit);
mnuUndo := TMenuItem.Create(frmPathMaker);
mnuUndo.Caption := 'Undo';
mnuPathMaker.Items.Items[1].Add(mnuUndo);
mnuRedo := TMenuItem.Create(frmPathMaker);
mnuRedo.Caption := 'Redo';
mnuPathMaker.Items.Items[1].Add(mnuRedo);
mnuSep4 := TMenuItem.Create(frmPathMaker);
mnuSep4.Caption := '-';
mnuPathMaker.Items.Items[1].Add(mnuSep4);
mnuRedoCapture := TMenuItem.Create(frmPathMaker);
mnuRedoCapture.Caption := 'Do/Redo Capture This Path';
mnuRedoCapture.OnClick := @RedoCapture;
mnuPathMaker.Items.Items[1].Add(mnuRedoCapture);
mnuRedoCaptureAll := TMenuItem.Create(frmPathMaker);
mnuRedoCaptureAll.Caption := 'Do/Redo Capture All Paths';
mnuRedoCaptureAll.OnClick := @RedoCaptureAll;
mnuPathMaker.Items.Items[1].Add(mnuRedoCaptureAll);
mnuMouseClick := TMenuItem.Create(frmPathMaker);
mnuMouseClick.Caption := 'Mouse Click';
mnuPathMaker.Items.Add(mnuMouseClick);
mnuMovePoint := TMenuItem.Create(frmPathMaker);
mnuMovePoint.Caption := 'Moves Selected Point';
mnuMovePoint.OnClick := @ChangeMouseClicks;
mnuPathMaker.Items.Items[2].Add(mnuMovePoint);
mnuCreatePoint := TMenuItem.Create(frmPathMaker);
mnuCreatePoint.Caption := 'Creates New Point';
mnuCreatePoint.OnClick := @ChangeMouseClicks;
mnuCreatePoint.Checked := True;
mnuPathMaker.Items.Items[2].Add(mnuCreatePoint);
mnuPaths := TMenuItem.Create(frmPathMaker);
mnuPaths.Caption := 'Path';
mnuPathMaker.Items.Add(mnuPaths);
mnuAddPath := TMenuItem.Create(frmPathMaker);
mnuAddPath.Caption := 'Add new path (new tab)';
mnuAddPath.OnClick := @SetNewTab;
mnuPathMaker.Items.Items[3].Add(mnuAddPath);
mnuDelPath := TMenuItem.Create(frmPathMaker);
mnuDelPath.Caption := 'Delete path (current tab)';
mnuPathMaker.Items.Items[3].Add(mnuDelPath);
mnuHelp := TMenuItem.Create(frmPathMaker);
mnuHelp.Caption := 'Help';
mnuPathMaker.Items.Add(mnuHelp);
mnuHowToUse := TMenuItem.Create(frmPathMaker);
mnuHowToUse.Caption := 'How to use...';
mnuPathMaker.Items.Items[4].Add(mnuHowToUse);
mnuSep3 := TMenuItem.Create(frmPathMaker);
mnuSep3.Caption := '-';
mnuPathMaker.Items.Items[4].Add(mnuSep3);
mnuAbout := TMenuItem.Create(frmPathMaker);
mnuAbout.Caption := 'About';
mnuPathMaker.Items.Items[4].Add(mnuAbout);

tbsContainer := TPageControl.Create(frmPathMaker);
tbsContainer.Parent := frmPathMaker;
tbsContainer.Align := alClient;
CaptureMap(-1); //Its like initiallizing the bmpMapCaptured Array!

AddATab;

end;

procedure SafeInitializeForm;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('InitializeForm', v);
end;

procedure ShowFormModal;
begin
frmPathMaker.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;


begin
//so we don't piss of someone with important info in the debug. Just so no worrys.
for ii := 0 to 10 do
begin
Writeln('');
end;
Writeln('Moving stuff up in debug. ClearDebug + SaveWork kinda lol');
MouseDoesWhat := True;
try
SafeInitializeForm;
SafeShowFormModal;
except
Writeln('Error with form.');
finally
FreeForm(frmPathMaker);
end;
for ii := 0 to GetArrayLength(imgMap) - 1 do
begin
try
FreeBitmap(bmpCapturedMap[ii]);
except
end;
end;
end.

nielsie95

2007-05-29 09:09:02

From: WT-Fakawi
We should also seriously consider neilsie95's idea.


From: The_Rs_Monkey
Neilsie95 posts a link earlier in the thread


Cmon guys, it's Nielsie95 :rolleyes:

Nice work The_Rs_Monkey! :)

shaunthasheep

2007-05-29 10:18:55

From: nielsie95
Cmon guys, it's Nielsie95 :rolleyes:

Nice work The_Rs_Monkey! :)


actually i didn't know how to spell ur name off the top of my head, so i just copied wt-fawaki's spelling cause it was right there. lol

Killerdou

2007-05-29 14:03:12

mh… i got an idea, what about you make a long array of points, which indicates where it has to walk, about 10-20 pixels apart on the minimap, then have it chose 4 of those points everytime(or more) and when it cant find the dtm that is created this way, you can leave out the forth point, if thats not found, then leave out the 3th point but put back the 4th etc, that way it can find its way even if there are dots over the road color…

Smartzkid

2007-05-29 18:30:46

Actually, that's probably a pretty good idea….

Though it would be pretty hard (I think…) to implement now

Maybe later?

Rune Hacker

2007-05-29 20:27:58

This will be grea tonce its all up and working.

masquerader

2007-05-29 23:27:28

thanks for the update with the form..


you are amazing

Infantry001

2007-05-31 22:04:54

Know waht sucks? A couple of days after this, Fawki, KYAB news is heard, and i bet ddtm walking will never be heard from again (or a very long time). But if KYAB falls, i am sure everyone will fall back on this idea!

Boreas

2007-05-31 22:22:27

Both will be developed. I dunno bout RRW though :p

rkroxpunk

2007-05-31 22:49:12

Ya well I'm stuck with DDTM's for the moment with KYAB not working for me ah well would be sweet if it was still getting developed

shaunthasheep

2007-06-01 09:04:56

From: Infintry001
Know waht sucks? A couple of days after this, Fawki, KYAB news is heard, and i bet ddtm walking will never be heard from again (or a very long time). But if KYAB falls, i am sure everyone will fall back on this idea!


From: Boreas
Both will be developed. I dunno bout RRW though :p


Yah im still developing this xD
I know KYAB is crashing on people, they get frustrated, and give up thinking "This f@#$ing sucks". I know that happened to me and a few other people.

WT-Fakawi

2007-06-04 18:37:42

Made include Path.scar. Useful for DDTM-based RoadWalking. Until a better solution of interface pops up, this wil be the framework.

Usage:

Setup one Array of Paths using the "PathRecorder" ("" <- not really a pathrecorder but a very simple procedure…)
Use WalkPath and FindPath to navigate from and to DDTM's. We use it in conjunction with RRW. Maybe we build a PathWalker based of RRW that checks for the DDTM within walking aot endpoint.

Typical Usage:

Repeat
WalkPath(4);
Until FindPath(5, True);
This will be released under /Misc

// -------------------------------------------------------------------------- //
//-- Scar Standard Resource Library ------------ //
//-- ยป DDTM-Path Routines ------------ //
//--------------------------------------------------------------------------- //
// * Function SetPath(Number:Integer):Integer; //* by WT-Fakawi
// * Function WalkPath(ThePath:Integer):Boolean; //* by WT-Fakawi
// * Function FindPath(ThePath:Integer;Click: Boolean):Boolean; //* by WT-Fakawi
// * procedure PathRecorder(StartPath:Integer); //* by WT-Fakawi


{ Record TDTMPoints;
Description: Define Path structure. One Main Point ( any color ) and upto
10 SubPoint of the SAME color }

type
TDTMPoints = record
MainPoint : TPoint;
SubPoints : array[0..10] of Tpoint;
end;

{ var Path;
Description: Predefines Type array Path }

var
Path: array[0..50] of TDTMPoints;


{
procedure SetupPaths;
begin
// YOUR PATHS IN HERE
end;
}

{*******************************************************************************
Function SetPath(Number:Integer):Integer;
By: WT-Fakawi
Description: Assembles DTM from Path. Inputs Path-Index, outputs DTM.
Usage: TheDTM := SetPath(0); or FindDTMRotated(SetPath(4).....
*******************************************************************************}

Function SetPath(Number:Integer):Integer;

var
DTMSubPoints: array of TDTMPointDef;
DTMMainPoint: TDTMPointDef;
TempTDTM: TDTM;
NrofSubPoints, i:integer;
TheDTM :integer;

begin

for i := 0 to 9 do // Calculate ArrayLength
if ( ( Path[Number].SubPoints[i].x = 0 ) and
( Path[Number].SubPoints[i].y = 0 ) ) then
begin
NrofSubPoints := i;
break;
end;

SetArrayLength(DTMSubPoints, NrofSubPoints);

DTMMainPoint.x:=Path[Number].Mainpoint.x;
DTMMainPoint.y:=Path[Number].Mainpoint.y;
DTMMainPoint.areasize:=1;
DTMMainPoint.areashape:=0;
DTMMainPoint.color:=RoadColor;
DTMMainPoint.tolerance:=0;

for i := 0 to NrofSubPoints - 1 do
begin
DTMSubPoints[i].x:=Path[Number].SubPoints[i].x;
DTMSubPoints[i].y:=Path[Number].SubPoints[i].y;
DTMSubPoints[i].areasize:=1;
DTMSubPoints[i].areashape:=0;
DTMSubPoints[i].color:=RoadColor;
DTMSubPoints[i].tolerance:=0;
end;

TempTDTM.MainPoint := DTMMainPoint;
TempTDTM.SubPoints := DTMSubPoints;
TheDTM := AddDTM(TempTDTM);
Result := TheDTM;
end;

{*******************************************************************************
Function WalkPath(ThePath:Integer):Boolean;
By: WT-Fakawi
Description: Simple Roadclicker, checks for RoadColor changes using CountFlag.
Returns False if Path not found.
Usage: WalkPath(1);
*******************************************************************************}

Function WalkPath(ThePath:Integer):Boolean;
var
WhichAngle: Extended;
var
TheDTM:Integer;
begin

TheDTM := SetPath(ThePath);
if FindDtmRotated(TheDTM, x, y, MMX1, MMY1, MMX2, MMY2, Radians(-35), Radians(35), 0.05,
WhichAngle) then
begin
Mouse(x, y, 0, 0, True);
Wait(6000);
countflag(5);
Result := True;
end
else
Result := False;
FreeDTM(TheDTM);
end;

{*******************************************************************************
Function FindPath(ThePath:Integer; Click: Boolean):Boolean;
By: WT-Fakawi
Description: Returns True if Path was found.
Usage:
repeat
WalkPath(1);
until FindPath(2, True);
*******************************************************************************}

Function FindPath(ThePath:Integer; Click: Boolean):Boolean;
var WhichAngle: Extended;
var
TheDTM:Integer;
begin
TheDTM := SetPath(ThePath);
if FindDtmRotated(TheDTM, x, y, MMX1, MMY1, MMX2, MMY2, Radians(-35), Radians(35), 0.05,
WhichAngle) then
begin
Result:= True;
if Click then
begin
Mouse(x, y, 0, 0, True);
Wait(3000);
countflag(10);
end
end
else
Begin
Result := False;
end;
FreeDTM(TheDTM);
end;

{*******************************************************************************
procedure PathRecorder(StartPath:Integer);
By: WT-Fakawi
Description: Simple PathRecorder.
Usage: Enter StartPath.
- Click RightMouse Button for SubPoints
- Now hover Mouse over MainPoint and hit Q
- Copy Debug printout to your script.
- Choose Subpoints carefully. Upto 9 clicks are allowed,
but 4 Subpoints should well be sufficiant.
*******************************************************************************}

procedure PathRecorder(StartPath:Integer);
var
i, CurrentPath, SubPointCounter: Integer;
begin
CurrentPath := StartPath;
repeat
Wait(100);
if IsMouseButtonDown(False) then
begin
GetMousePos(x, y);
Path[CurrentPath].SubPoints[SubPointCounter].x :=x;
Path[CurrentPath].SubPoints[SubPointCounter].y :=y;
repeat
until not IsMouseButtonDown(False);
SubPointCounter := SubPointCounter + 1;
end

if IsKeyDown('q') then
begin
GetMousePos(x, y);
Path[CurrentPath].MainPoint.x :=x;
Path[CurrentPath].MainPoint.y :=y;
repeat
until not IsKeyDown('q');
writeln('Path['+IntToStr(CurrentPath)+'].Mainpoint.x:='+IntToStr(Path[CurrentPath].MainPoint.x)+';');
writeln('Path['+IntToStr(CurrentPath)+'].Mainpoint.y:='+IntToStr(Path[CurrentPath].MainPoint.y)+';');
for i := 0 to SubPointCounter -1 do
begin
writeln('Path['+IntToStr(CurrentPath)+'].Subpoints['+IntToStr(i)+'].x:='+IntToStr(Path[CurrentPath].Subpoints[i].x)+';');
writeln('Path['+IntToStr(CurrentPath)+'].Subpoints['+IntToStr(i)+'].y:='+IntToStr(Path[CurrentPath].Subpoints[i].y)+';');
end
SubPointCounter := 0;
CurrentPath := CurrentPath + 1;
end
until False;
end;



rkroxpunk

2007-06-05 12:50:40

awesomeness!!!
with the start path I don't get what u put in the params

R0b0t1

2007-06-06 15:58:33

I think that we should check the music+Symbols+Doors+ladders….

But thats me, and me thinks that the "stations" should have "checkpoints" in between them.

PS. How do you check an elephant? You don't. You check a duck because its so much easier.

Lorax

2007-06-08 16:25:59

Great project, sounds as a good idea.. I believe I understand ddtms now, and their use..

nielsie95

2007-06-10 13:36:26

I think we can come a lot further now..
I made a big AreaFinder + DDTM maker (and SKy also made one).

I think it'll be usefull if someone makes a list about what we really need to do from now…. organised (Fakawi/Boreas :)?)
Maybe a list of paths where people can choose from and make them?

Markus

2007-06-10 16:20:49

Already did that on the first page.
http://www.srl-forums.com/forum/paths-t11886.html#19

nielsie95

2007-06-10 16:39:05

Ah nice :)
Sorry, I didn't see it.. I edited it out :)

n3ss3s

2007-06-20 09:14:11

Why arent people using KYAB when solar and ben made something so good :(

nielsie95

2007-06-20 09:23:46

KYAB is members only..