From: YoHoJo
Please copy/paste script into your application, most people like it better that way!
Just saw the length of the script and the debug picture on your thread, WOW sweet debug this looks like AMAZING work!
How'd you learn this all :D!
yeah i didn't think it was wise to copy/paste 2866 lines :P
Edit: just gonna include some stuff - you can see the rest in script
function GetBackToRuneSpan : Boolean;
var CanUseFairy: Boolean;
var HasEdgevilleTeleport : Boolean;
var HasDraynorTeleport : Boolean;
var HasHoodEquipped : Boolean;
var HasHoodInventory : Boolean;
var EdgeVilleDTM : Integer;
var DraynorDTM : Integer;
var HoodDTM : Integer;
var edgeX, edgeY, drayX, drayY: Integer;
var hoodX, hoodY: Integer;
var RuneClear : Integer;
begin
// umm - no runes
for RuneClear := TYPE_RUNE_MIN to TYPE_RUNE_MAX do
begin
RUNE_LastKnownPosition[RuneClear] := -1;
COUNTER_RUNE[RuneClear] := 0;
end;
// not yet back
Result := false;
// some set up
CanUseFairy := CAN_USE_FAIRY_RINGS;
HasEdgevilleTeleport := false;
HasDraynorTeleport := false;
// check hood
HoodDTM := DTMFromString('mwQAAAHic42RgYHBhYmBwAmJPIHYAYhsgtmWCiHsBsSsQPwOqewTETxkQ7DdA/BGI3wHxbSA2k1NhcLVVZ9BWlWBQlJRmkBOXYJASEWXwd9VhkOITZPDQMGAQAaojhBmJwHAAAMO+D1Y=');
if (GetCurrentTab <> tab_Equip) then GameTab(tab_Equip);
HasHoodEquipped := FindDTM(HoodDTM, hoodX, hoodY, 600, 190, 680, 265);
Writeln('GOT ' + IntToStr(hoodX) + ' and ' + IntToSTr(Hoody));
HasHoodInventory := false;
if not HasHoodEquipped then
begin
WriteLn('Hood not equipped, checking inventory');
if (GetCurrentTab <> Tab_Inv) then GameTab(Tab_Inv);
HasHoodInventory := FindDTM(HoodDTM, hoodX, hoodY, MIX1, MIY1, MIX2, MIY2);
Writeln('GOT inventory ' + IntToStr(hoodX) + ' and ' + IntToSTr(Hoody));
end
else
begin
WriteLn('Hood found equipped, can only have one, skipping inventory check');
end;
FreeDTM(HoodDTM);
// hood makes simple
if ((HasHoodEquipped) or (HasHoodInventory)) then
begin
// teleport
MMouse(hoodX, hoodY, 5, 5);
sleep(50+random(100));
ClickMouse2(False);
if WaitOptionMulti(['Tele', 'lepo', 'port'],RandomRange(400,500)) then
begin
WriteLn('Teleporting with hood...');
// wait
Wait(8000 + Random(3000));
// done
WriteLn('Ok we should be in teleported, now get inside');
MakeCompass('W');
SetAngle(SRL_ANGLE_LOW);
// Enter Portal
Result := EnterPortal();
// done - either we are there or not
exit;
end;
end;
// spell setup
if (not SpellSetup) then SetupSpells();
ClickSpellMode(SpellMode_All);
if Cast('lumbridge home teleport', False) then
begin
// wait
wait(500 + Random(300));
// edgeville
EdgeVilleDTM := DTMFromString('mggAAAHicY2NgYFBhZGDQAGJtINYEYjkgVgTi2UC5uVA8CYqXAfHijTsZgsWlGHpmb2fg8vZgcCzKB9MiQDlsmBEHhgAAoZoL1A==');
HasEdgevilleTeleport := FindDTM(EdgeVilleDTM, edgeX, edgeY, 240, 90, 360, 210);
FreeDTM(EdgeVilleDTM);
// draynor
DraynorDTM := DTMFromString('mggAAAHicY2NgYDBhZGDQA2IrRgjbGEpfAspdhOIzQHwCiO8BcY+KCsMZbWOGYnVVMC0iLsvAyMjEIAKUw4YZcWAIAACSnArb');
HasDraynorTeleport := FindDTM(DraynorDTM, drayX, drayY, 280, 180, 340, 240);
FreeDTM(DraynorDTM);
end
else
begin
Writeln('Could not cast home teleport');
exit;
end;
// check if we can tele using fairy
if not HasEdgevilleTeleport then
begin
// nope we walk
CanUseFairy := False;
end;
// for now FORCE walker
CanUseFairy := False;
// check if we can use fairy
if (CanUseFairy) then
begin
// use it
Mouse(edgeX, edgeY, 5, 5, true);
// wait
Wait(17000 + Random(6000));
// done
WriteLn('Ok we should be in Edgeville, but the rest is not yet done');
exit;
end
else
begin
if not HasDraynorTeleport then
begin
// sorry you should go to draynor yourself and activate the lodestone
Exit;
end;
// use it
Mouse(drayX, drayY, 5, 5, true);
// wait
Wait(17000 + Random(6000));
// done
WriteLn('Ok we should be in Draynor, but the rest is not yet done');
exit;
end;
// if we have succeeded, we ought to reset certain counters as, for example,
// we will have lost all runes, and we couldn't read point balance.
// why? because we may have been ported out in middle of long run, we better
// then handle it properly
end;
procedure UpdateMap;
var Done : Boolean;
var MAXX : Integer;
var MAXY : Integer;
var indexX : Integer;
var indexY : Integer;
var NeedTesting : Boolean;
var TestResult : Integer;
begin
MAXX := Length(MAP);
MAXY := Length(MAP[0]);
// clear map and mark center point
ClearMap();
repeat
// assume done until proven otherwise
Done := true;
// go through the map
for indexX := 0 to MAXX - 1 do
begin
for indexY := 0 to MAXY - 1 do
begin
if (MAP[indexX][indexY] <> MAP_TYPE_UNTESTED) then continue;
NeedTesting := false;
if (indexX > 0) then
begin
if (MAP[indexX - 1][indexY] = MAP_TYPE_ISLAND) then NeedTesting := true;
end;
if (indexY > 0) then
begin
if (MAP[indexX][indexY - 1] = MAP_TYPE_ISLAND) then NeedTesting := true;
end;
if (indexX < MAXX - 1) then
begin
if (MAP[indexX + 1][indexY] = MAP_TYPE_ISLAND) then NeedTesting := true;
end;
if (indexY < MAXY - 1) then
begin
if (MAP[indexX][indexY + 1] = MAP_TYPE_ISLAND) then NeedTesting := true;
end;
if not NeedTesting then continue;
// test
TestResult := TestMapSquare(indexX, indexY);
MAP[indexX][indexY] := TestResult;
if (TestResult = MAP_TYPE_ISLAND) then Done := false;
end;
end;
until Done;
end;
const SLICE_SEGMENT_COUNT_3D = 10;
// integrating is probably the best method for x and z shift
// trick is to find the X to feed the integral
function GetPerspectivePointExact(X,Y,Z : Extended) : TPoint;
var CAMERA_Z_DISTANCE : Extended;
var CAMERA_Y_DISTANCE : Extended;
var CAMERA_Z_DISTANCE2 : Extended;
var CAMERA_Y_DISTANCE2 : Extended;
var CAMERA_X_DISTANCE2 : Extended;
var CAMERA_XZ_DISTANCE2 : Extended;
var CAMERA_YZ_DISTANCE2 : Extended;
var CAMERA_XZ_DISTANCE : Extended;
var CAMERA_YZ_DISTANCE : Extended;
var CAMERA_XYZ_DISTANCE : Extended;
var Integrate : Integer;
var IntegrateXValue : Extended;
var IntegralX : Extended;
var IntegrateYValue : Extended;
var IntegralY : Extended;
var ModZ : Extended;
begin
Result.X := MSCX;
Result.Y := MSCY;
CAMERA_Z_DISTANCE := PERSPECTIVE_CAMERA_Z - Z;
CAMERA_Y_DISTANCE := Y;
if (CAMERA_Z_DISTANCE < 1) then Exit;
CAMERA_Z_DISTANCE2 := Sqr(CAMERA_Z_DISTANCE);
CAMERA_Y_DISTANCE2 := Sqr(CAMERA_Y_DISTANCE);
CAMERA_X_DISTANCE2 := Sqr(X);
CAMERA_XZ_DISTANCE2 := CAMERA_X_DISTANCE2 + CAMERA_Z_DISTANCE2;
CAMERA_YZ_DISTANCE2 := CAMERA_Y_DISTANCE2 + CAMERA_Z_DISTANCE2;
CAMERA_XZ_DISTANCE := Sqrt(CAMERA_XZ_DISTANCE2);
CAMERA_YZ_DISTANCE := Sqrt(CAMERA_YZ_DISTANCE2);
IntegralX := 0;
IntegralY := 0;
for Integrate := 0 to SLICE_SEGMENT_COUNT_3D do
begin
IntegrateXValue := (Integrate * X) / 20.0;
CAMERA_XYZ_DISTANCE := Sqrt(CAMERA_YZ_DISTANCE2 + Sqr(IntegrateXValue));
IntegralX := IntegralX + (CAMERA_YZ_DISTANCE / CAMERA_XYZ_DISTANCE);
IntegrateYValue := (Integrate * CAMERA_Y_DISTANCE) / 20.0;
CAMERA_XYZ_DISTANCE := Sqrt(CAMERA_XZ_DISTANCE2 + Sqr(IntegrateYValue));
IntegralY := IntegralY + (CAMERA_XZ_DISTANCE / CAMERA_XYZ_DISTANCE);
end;
IntegralX := IntegralX / (SLICE_SEGMENT_COUNT_3D + 1.0); // number of slices
IntegralY := IntegralY / (SLICE_SEGMENT_COUNT_3D + 1.0);
// this one is the simple one
ModZ := PERSPECTIVE_CAMERA_Z * CAMERA_YZ_DISTANCE / CAMERA_Z_DISTANCE2;
Result.X := MSCX + Round(PERSPECTIVE_MAP_SQUARE * IntegralX * X * ModZ);
Result.Y := MSCY - Round(PERSPECTIVE_MAP_SQUARE * IntegralY * Y * ModZ);
end;
function GetPerspectivePoint(X,Y,Z : Extended) : TPoint;
var Y1, Z1 : Extended;
var PLAYERSHIFTEDY : Extended;
var DistanceZ : Extended;
var DistanceYZ : Extended;
var POINTEXACT : TPoint;
var ANGLE : Extended;
begin
// make runescape transform
DistanceZ := PERSPECTIVE_CAMERA_Z - Z;
PLAYERSHIFTEDY := Y - RUNESCAPE_PLAYER_HALF_HEIGHT;
DistanceYZ := Sqrt(Sqr(PERSPECTIVE_CAMERA_Y - PLAYERSHIFTEDY) + Sqr(DistanceZ));
ANGLE := ArcCos(DistanceZ / DistanceYZ);
Y1 := Sin(RUNESCAPE_ANGLE_HIGH_TRANSFORM - ANGLE) * DistanceYZ;
Z1 := PERSPECTIVE_CAMERA_Z - Cos(RUNESCAPE_ANGLE_HIGH_TRANSFORM - ANGLE) * DistanceYZ;
POINTEXACT := GetPerspectivePointExact(X,Y1,Z1);
Result.x := POINTEXACT.x;
Result.y := POINTEXACT.y;
end;
const MAXHEIGHT = 1.25;
procedure Initialize3DModelFromMap;
var MAXX : Integer;
var MAXY : Integer;
var indexX : Integer;
var indexY : Integer;
var X1,X2,Y1,Y2 : Integer;
var BOX : TBox;
var MidX, MidY : Extended;
var ChosenColor : Integer;
var XCenter, ZCenterFromY : Extended;
var PointOfInterest : TPoint;
var TotalPointCount : Integer;
begin
MAXX := Length(MAP);
MAXY := Length(MAP[0]);
SetLength(MAPPOINTS, MAXX * MAXY);
TotalPointCount := 0;
MidX := (MAXX shr 1) - 1.0;
MidY := (MAXY shr 1) - 0.75;
Sleep(1000);
for indexX := 0 to MAXX - 1 do
begin
X1 := MMX1 + (indexX shl 3) + 2;
X2 := X1 + 4;
for indexY := 0 to MAXY - 1 do
begin
Y1 := MMY1 + (indexY shl 3) + 2;
Y2 := Y1 + 4;
BOX.X1 := X1;
BOX.X2 := X2;
BOX.Y1 := Y1;
BOX.Y2 := Y2;
ChosenColor := clGray;
// check
case (MAP[indexX][indexY]) of
MAP_TYPE_OUTSIDE: ChosenColor := clPurple;
MAP_TYPE_UNTESTED: ChosenColor := clGray;
MAP_TYPE_EDGE: ChosenColor := clRed;
MAP_TYPE_ISLAND: ChosenColor := clGreen;
end;
XCenter := indexX - MidX;
ZCenterFromY := indexY - MidY;
// calculate
if (ZCenterFromY + 1.5 >= PERSPECTIVE_CAMERA_Z) then
begin
// too close to camera, not on screen, discard
MAP3D[indexX][indexY].X1 := -1;
MAP3D[indexX][indexY].Y1 := -1;
MAP3D[indexX][indexY].X2 := -1;
MAP3D[indexX][indexY].Y2 := -1;
continue;
end
else
begin
if (XCenter > -0.5) then
begin
// right edge is determined by front right top
PointOfInterest := GetPerspectivePoint(XCenter + 0.5, MAXHEIGHT, ZCenterFromY + 0.5);
MAP3D[indexX][indexY].X2 := PointOfInterest.x;
end
else
begin
// right edge is determined by back right bottom
PointOfInterest := GetPerspectivePoint(XCenter + 0.5, 0, ZCenterFromY - 0.5);
MAP3D[indexX][indexY].X2 := PointOfInterest.x;
end;
// bottom edge is determined by front right bottom
PointOfInterest := GetPerspectivePoint(XCenter + 0.5, 0, ZCenterFromY + 0.5);
MAP3D[indexX][indexY].Y2 := PointOfInterest.y;
if (XCenter < 0.5) then
begin
// left edge is determined by front left top
PointOfInterest := GetPerspectivePoint(XCenter - 0.5, MAXHEIGHT, ZCenterFromY + 0.5);
MAP3D[indexX][indexY].X1 := PointOfInterest.x;
end
else
begin
// left edge is determined by front left top
PointOfInterest := GetPerspectivePoint(XCenter - 0.5, MAXHEIGHT, ZCenterFromY + 0.5);
MAP3D[indexX][indexY].X1 := PointOfInterest.x;
end;
// top edge is determined by back left top
PointOfInterest := GetPerspectivePoint(XCenter - 0.5, MAXHEIGHT, ZCenterFromY - 0.5);
MAP3D[indexX][indexY].Y1 := PointOfInterest.y;
// check if in area
if (MAP3D[indexX][indexY].X1 >= MSX2) or (MAP3D[indexX][indexY].Y1 >= MSY2)
or (MAP3D[indexX][indexY].X2 <= MSX1) or (MAP3D[indexX][indexY].Y2 <= MSY1) then
begin
// outside of main screen
MAP3D[indexX][indexY].X1 := -1;
MAP3D[indexX][indexY].Y1 := -1;
MAP3D[indexX][indexY].X2 := -1;
MAP3D[indexX][indexY].Y2 := -1;
continue;
end;
end;
MAPPOINTS[TotalPointCount].X := IndexX;
MAPPOINTS[TotalPointCount].Y := IndexY;
Inc(TotalPointCount);
SMART_DrawBoxEx(false, BOX, ChosenColor);
DrawMapCube(XCenter, ZCenterFromY, ChosenColor);
SMART_DrawBoxEx(false, MAP3D[Indexx][Indexy], clBlue);
end;
end;
SetLength(MAPPOINTS, TotalPointCount);
end;