SRL Archive - News and General

[Blog]YEMP (Yanille Essence Miner Pro)


Flight

2012-03-27 09:33:49

Hiya, I got the idea to do my first "script blog" posting each step I take to create a certain script, in this case an Essence-Miner for Yanille. I got the general idea from Sir RM's blog so I'm gonna have my own go at it. :)

Pure essence is increasing a crazy rate, and I'm sure my fellow Rune-Crafters would agree with me: enough is enough. Once completed the script will offer an alternative to the increasing market price, so let's keep our fingers crossed that the script turns out to be a success! :) By the way, it will be public, obviously.

-[3-27-12]-

8:30 PM
  • Script skeleton fabricated
  • Main script loop taking form

  • Procedure ScriptLoop;
    begin
    if not LoggedIn then Exit;
    FindNormalRandoms;

    if AboveGround then
    begin
    //Setup runescape_surface SPS

    if NearBank then
    begin

    end;

    if InGuild then
    begin

    end;

    end;

    if not AboveGround then
    begin
    //Setup essence_mine SPS
    end;

    end;
  • Added final branches of script loop

  • Procedure ScriptLoop;
    begin
    if not LoggedIn then Exit;
    FindNormalRandoms;

    if AboveGround then
    begin
    {Is there a way to check if our surface map is already set?}

    SPS_Setup(RUNESCAPE_SURFACE, ['5_10']);
    SPS_Continue := True;

    if NearBank then
    begin
    if InvFull then
    HandleBank
    else
    WalkToGuild;
    end;

    if InGuild then
    begin
    if InvFull then
    begin
    if HandleDoor then
    WalkToBank;
    end else
    TeleToMine;
    end;

    end;

    if not AboveGround then
    begin
    {Is there a way to check if our SPS map is already set?}

    SPS_Setup(ESSENCE_MINE, ['0_1']);
    SPS_Continue := True;

    if not InvFull then
    begin
    if WalkToMine then
    MineEssence;
    end else
    if WalkToPortal then
    ExitMine;
    end;

    end;
  • Added Function 'AboveGround'

  • Function AboveGround: Boolean;
    begin
    Result := (PercentBlackMM < 20);
    end;

10:00 PM
  • Imported RSG's MMToMS functions
  • Added GetPortalMM and FindPortal functions

  • Function GetPortalMM(Var X,Y: Integer): Boolean;
    var
    B: TBox;
    TPA,TPA2: TPointArray;
    i: Integer;
    ATPA: T2DPointArray;
    begin
    Result := False;
    ColorToleranceSpeed(1);
    SetColorSpeed2Modifiers(0.2, 0.2);

    {Find the basic MM symbol color}
    FindColorsSpiralTolerance(MMCX, MMCY, TPA, 12632256, MMX1, MMY1, MMX2, MMY2, 5);
    if (Length(TPA) < 1) then
    Exit;

    {Split the TPA into 10x10 boxes, each represent a MM symbol}
    ATPA := SplitTPAEx(TPA, 10, 10);
    SortATPAFromFirstPoint(ATPA, Point(MSCX,MSCY));

    for i := 0 to High(ATPA) do
    begin
    B := GetTPABounds(ATPA[i]);

    {Search inside each MM symbol for the unique, secondary color}
    with B do
    begin
    FindColorsSpiralTolerance(MMCX, MMCY, TPA2, 5001797, B.X1, B.Y1, B.X2, B.Y2, 5);
    if (Length(TPA2) > 0) then
    begin
    MiddleTPAEx(TPA2, X, Y);
    Result := True;
    Exit;
    end;
    end;
    end;
    end;

    Function FindPortal: Boolean;
    var
    TBA: TBoxArray;
    TIA: TIntegerArray;
    PortalMM,PortalMS,
    MidBox: TPoint;
    TPA: TPointArray;
    I,J: Integer;
    begin
    Result := False;
    ColorToleranceSpeed(1);
    SetColorSpeed2Modifiers(0.2, 0.2);

    {First we find the portal MM symbol and store the point}
    if not GetPortalMM(PortalMM.X, PortalMM.Y) then
    Exit;

    {Next, split the MS into 35x35 boxes}
    TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 35, 35);
    TIA := PixelShiftMulti(TBA, 300);
    for I := 0 to High(TBA) do
    begin
    {Search each box for a certain amount of pixelshift}
    if (TIA[I] > 100) then
    begin
    {For each 'shifting box' add the center point to a new TPA}
    MidBox := MiddleBox(TBA[I]);
    SetArrayLength(TPA, Length(TPA)+1);
    TPA[High(TPA)] := MidBox;
    end;
    end;

    if (Length(TPA) < 1) then Exit;

    {Now using the portal's MM symbol point we get a 'general' MS tile location}
    if MMToMSTileEx(PortalMS.X, PortalMS.Y, PortalMM.X, PortalMM.Y) then
    begin
    SortTPAFrom(TPA, PortalMS);

    {Sort the TPA starting from the portals MMToMS mid tile}
    for J := 0 to High(TPA) do
    begin
    HumanMMouse(TPA[J].X, TPA[J].Y, 5, 5);
    if WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'P'], 500) then
    begin
    Result := True;
    Exit;
    end;
    end;

    end;

    end;
11:30 PM
  • Added FindDoor & HandleDoor functions

  • Function FindDoor(Var X, Y: Integer): Boolean;
    Var
    TPA,PBox: TPointArray;
    i,a,CTS: Integer;
    ATPA: T2DPointArray;
    Cols,Tols: TIntegerArray;
    HMods,SMods: Array of Extended;
    begin
    Result := False;
    if not LoggedIn then Exit;
    if BelowGround then Exit;

    if IsUpTextMultiCustom(['Open', 'agic', 'guild', 'door']) then
    begin
    Result := True;
    Exit;
    end;

    PBox := TPAFromBox(IntToBox(240, 130, 275, 185));
    CTS := GetColorToleranceSpeed;

    Cols := [2637658, 2177881];
    Tols := [5, 6];
    HMods := [0.07, 0.06];
    SMods := [0.24, 1.26];

    for i := 0 to High(Cols) do
    begin
    ColorToleranceSpeed(2);
    SetColorSpeed2Modifiers(HMods[i], SMods[i]);
    FindColorsSpiralTolerance(MSCX-50, MSCY, TPA, Cols[i], MSX1, MSY1, MSX2, MSY2, Tols[i]);
    ColorToleranceSpeed(CTS);
    SetColorSpeed2Modifiers(0.2, 0.2);

    TPA := ClearTPAFromTPA(TPA, PBox);
    if (Length(TPA) > 0) then break;

    end;

    if (Length(TPA) < 1) then Exit;

    ATPA := TPAToATPAEx(TPA, 30, 30);
    SortATPAFromFirstpoint(ATPA, Point(MSCX-50, MSCY));

    for a := 0 to High(ATPA) do
    begin

    MiddleTPAEx(ATPA[a], X, Y);
    HumanMMouse(X, Y, 7, 7);

    if WaitUpTextMulti(['Open', 'agic', 'guild', 'door'], 500) then
    begin
    Result := True;
    GetMousePos(X, Y);
    Exit;
    end;

    end;

    end;

    Function HandleDoor: Boolean;
    Var
    X,Y: Integer;
    Me_Start,Me_New: TPoint;
    label
    Search;
    begin
    Result := False;
    Me_Start := SPS_GetMyPos;

    Search:
    if not LoggedIn then Exit;
    if BelowGround then Exit;

    if FindDoor(X, Y) then
    begin
    ClickMouse2(True);
    if not DidRedClick then
    goto Search;

    WaitFunc(@IsMoving_F, 10, 1000);
    While IsMoving_F do
    Wait(1);

    if (Me_Start.X > 2220) then {Entering the guild}
    begin
    Me_New := SPS_GetMyPos;
    if (Me_New.X > 2220) then
    goto Search
    else if (Me_New.X <= 2220) then
    Result := True;
    end else if (Me_Start.X <= 2220) then {Exiting the guild}
    begin
    Me_New := SPS_GetMyPos;
    if (Me_New.X <= 2220) then
    goto Search
    else if (Me_New.X > 2220) then
    Result := True;
    end;

    end;

    end;


-[3-28-12]-

8:30 AM
  • Updated HandleDoor to work off SPS for both enter & exiting the guild
  • Added BelowGround (for the sake of WaitFunc) & NearGuild

  • Function BelowGround: Boolean;
    begin
    Result := (PercentBlackMM > 20);
    end;
    Function NearGuild: Boolean;
    Var
    Me: TPoint;
    Dist: Integer;
    begin
    Result := False;
    if not LoggedIn then Exit;
    if BelowGround then Exit;

    Me := SPS_GetMyPos;
    Dist := Distance(Me.X, Me.Y, 2220, 4315);
    Result := (Dist <= 20);
    end;
  • Added FindMage & TeleToMine

  • Function FindMage(Var X, Y: Integer): Boolean;
    Var
    TPA,PBox: TPointArray;
    i,a,CTS,F: Integer;
    ATPA: T2DPointArray;
    Cols,Tols: TIntegerArray;
    HMods,SMods: Array of Extended;
    begin
    Result := False;
    if not LoggedIn then Exit;
    if BelowGround then Exit;

    for F := 4 downto 1 do
    begin

    PBox := TPAFromBox(IntToBox(240, 130, 275, 185));
    CTS := GetColorToleranceSpeed;

    Cols := [14325800];
    Tols := [13];
    HMods := [0.01];
    SMods := [1.39];

    for i := 0 to High(Cols) do
    begin
    ColorToleranceSpeed(2);
    SetColorSpeed2Modifiers(HMods[i], SMods[i]);
    FindColorsSpiralTolerance(MSCX, MSCY, TPA, Cols[i], MSX1, MSY1, MSX2, MSY2, Tols[i]);
    ColorToleranceSpeed(CTS);
    SetColorSpeed2Modifiers(0.2, 0.2);

    TPA := ClearTPAFromTPA(TPA, PBox);
    if (Length(TPA) > 0) then break;

    end;

    if (Length(TPA) < 1) then Exit;

    ATPA := TPAToATPAEx(TPA, 20, 45);
    SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

    for a := 0 to High(ATPA) do
    begin

    MiddleTPAEx(ATPA[a], X, Y);
    HumanMMouse(X, Y, 5, 5);

    if WaitUpTextMulti(['Talk-t', 'izard', 'Diste', 'stent', 'entor'], 500) then
    begin
    Result := True;
    GetMousePos(X, Y);
    Exit;
    end;

    end;

    end;

    end;

    Function TeleToMine: Boolean;
    Var
    X,Y: Integer;
    Me: TPoint;
    label
    Search;
    begin
    Result := False;

    Search:
    if not LoggedIn then Exit;
    if BelowGround then Exit;

    Me := SPS_GetMyPos;
    if (Me.X > 2220) then
    HandleDoor;

    if FindMage(X, Y) then
    begin
    ClickMouse2(False);
    if not WaitOptionMulti(['Telep', 'elepo', 'leport'], 500) then
    goto Search;

    WaitFunc(@IsMoving_F, 10, 1000);
    While IsMoving_F do
    Wait(1);

    Result := WaitFunc(@BelowGround, 10, 5000);
    end;
    end;
11:30 PM
  • Added full support for pouch-handling & repairing
  • Banking routines completed

If you have any suggestions let 'em roll in.

shstiger2009

2012-03-27 09:53:07

Nice! This will help me and I'm sure many others, it's nice to see steps from step 1 on what goes into a script from start to finish.

Also, nice job at trying to fight the rising essence prices, I think you'll succeed. ;)

Ibotlots8D

2012-03-27 10:01:32

Can you give me an explanation about AboveGround?
Seems useful.

shstiger2009

2012-03-27 10:07:53

From: Ibotlots8D
Can you give me an explanation about AboveGround?
Seems useful.


Correct me if I'm wrong anyone, but I'm pretty sure AboveGround just returns True or False if you're on the main Runescape surface.

Flight

2012-03-27 10:09:50

From: shstiger2009
Correct me if I'm wrong anyone, but I'm pretty sure AboveGround just returns True or False if you're on the main Runescape surface.


Yes it's just something I whipped up quick and used in ZMI-Extreme. If less than 20% of your MiniMap is black then the function returns True, otherwise, False.

Quintessence

2012-03-27 10:24:43

Awesome idea. I'll be sure to check up on this blog every now and then. :D

Good luck with your script!

Kyle Undefined

2012-03-27 10:28:33

Can't wait to see this progress and finished. If you need any help, let me know :) Good luck!

Harry

2012-03-27 10:30:50

Time for me to dump my ess :p

Flight

2012-03-27 10:40:09

From: Harry
Time for me to dump my ess :p


Lol. :spot:

Most of this blog will be great for newer scripters to learn from. The portal-finding will be super unique, as I plan on using a combination of ReadySteadyGo's MMToMS 3DPoint (to get a good general location to start the portal search) and then icing on the cake using Home's Area-To-TBA with pixelshift for finding the on-screen portal. This would be a bit complex for the normal scripter to follow along. :p

ReadySteadGo if you stumble across this post I'd like to once again say you did an amazing job on MMToMS. It's a work of art and it's really a shame it's not getting the attention it deserves.

Ibotlots8D

2012-03-27 10:45:03

May I have permission to use AboveGround in my scripts?
It seems useful, you should submit it! :)

Flight

2012-03-27 11:01:14

From: Ibotlots8D
May I have permission to use AboveGround in my scripts?
It seems useful, you should submit it! :)


Yes be my guest.

Er1k

2012-03-27 11:37:49

I so wanted one of these :) Pure ess has never been so attractive thanks to injection bots.

Flight

2012-03-28 01:45:02

Added door-finding & handling last night and pouch-handling this morning as well as partial banking. Working on Wizard-finding / teleporting now.

typestyle

2012-03-28 23:04:07

Can't wait for the release, 190gp per ess wtf ._.

lilcmp1

2012-03-28 23:34:08

Brilliant lol. You will receive a huge pat on the back if you drive ess back down.

Flight

2012-03-28 23:47:35

From: lilcmp1
Brilliant lol. You will receive a huge pat on the back if you drive ess back down.


That's my goal. Should I have made the script for personal gain I'd either keep it to myself or release it only to the Members section. But just in my own personal opinion, Pure Essence is one of those items that should also be low in price. That's just my own opinion though.

Also, I've used most of putonajonny's essence mine walking routines for navigating through the mine, all 4 of them. On top of that I just finished the rock-finding and mining routines. The script will hold support for all 4 pouches to maximize our essence-per-run.

All I lack now from a complete test run is walking to & from the bank. After that I'll give it it's first go 'round.

brandon8081

2012-03-29 00:36:16

This is going to help so much with understanding scripting.