// FinalAlert2:YR Script file
// Name: FlyingZ Waypoint Grid Script v1.0
// Written By: James Zais aka FlyingZ

RequiresMP();
SetSafeMode("FALSE","Necessary for moving waypoints");

UInputGetInteger("%Dist%","Distance between waypoints?                            {4 close - 10 far}   I recomend a distance of 5","4","10");
Message("On very large maps FA2 will prompt you to run over 300 loops,   Click Yes", "FlyingZ");

SetVariable("%Z%", "%Width%");
Mod("%Z%","%Dist%");
SetVariable("%AS%", "%Dist%");
Add("%AS%", "%Z%");

SetVariable("%Num%", "10");
SetVariable("%Xtop%", "%AS%");
SetVariable("%X%", "%AS%");
SetVariable("%Ytop%", "%Width%");
SetVariable("%Y%", "%Width%");
SetVariable("%V%", "%IsoSize%");
Substract("%V%", "%Dist%");

// Loop
:BeginLoop:

SetWaypoint("%Num%", "%X%", "%Y%");

Add("%X%", "%Dist%");
Add("%Y%", "%Dist%");
Add("%Num%", "1");

Is("%Y%",">","%V%","%LoopDone%");
JumpTo("EndLoop", "%LoopDone%");
JumpTo("BeginLoop");
:EndLoop:

Add("%Xtop%", "%Dist%");
Substract("%Ytop%", "%Dist%");
Substract("%V%", "%Dist%");

SetVariable("%X%", "%Xtop%");
SetVariable("%Y%", "%Ytop%");

Is("%Ytop%","<","%Dist%","%AllDone%");
JumpTo("EndAll", "%AllDone%");
JumpTo("BeginLoop");
:EndAll:

Message("Waypoint Grid Script Successfully Completed", "FlyingZ");