Results 1 to 15 of 15

Thread: Math Functions/ New MMouse!

  1. #1
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default Math Functions/ New MMouse!


    Some Of My Procedures / Functions You May Find Usless Or Not Helpful at all so,
    the reason i would put them in here is because i use them my Self....

    press play to see my MMouse Function it's after BenMouse and RSN/ Mutant MMouse...







    SCAR Code:
    Program New;
    {.include srl/srl.scar}

      {
     
         ~~~  * Press Play to View My MMouse Function * ~~~
         
          Some Of My Procedures / Functions You May Find Usless Or Not Helpful at all
          so, the reason i would put them in here is because i use them my Self....
         
      }






    {*******************************************************************************
    Function Hypot(x, y: Extended) : Extended;
    By: Sky Scripter
    Description: it returns the Hypotenuse
    Example :   |\
             5' | \ <-- Hypotenuse = 5.3851648071345
                |__\
                  2'
    *******************************************************************************}

    Function Hypot(x, y:Extended):Extended;
    begin
     Result:= Sqrt(x*x + y*y);
    end;


    {*******************************************************************************
    Function Nott(E: Extended) : Extended;
    By: Sky Scripter
    Description: Kind of like abs() but works both ways ( nott(6) = -7,  Nott(-7) = 6 )
    *******************************************************************************}

    Function Nott(E:Extended):Extended;
    var s: String;
    begin
    s:= FloatToStr(E);
     if ( e < 0) then
       delete(S, 1, 1)
     else
       insert('-', S, 1);
    Result:= StrToFloat(s)-1;
    end;


    {*******************************************************************************
    Function Dividable(Int: Integer): Boolean;
    By: Sky Scripter
    Description: Returns True if the number is a even number.
    *******************************************************************************}

    Function Dividable(Int:Integer):Boolean;
    var i:Integer;
        e:Extended;
    begin
    Result:=False;
     for i:= 1 to int - (int div 2) do
       begin
        e:= Int div i;
          If ( e = 2) then
          begin
           Result:=True;
          exit;
         end;
       end;
    end;


    {*******************************************************************************
    Function Exp(Base, int : Extended):Extended;
    By: Sky Scripter
    Description: Gives the exponet number
    Example: Exp(10, 2) = 1000
    *******************************************************************************}

    Function Exp(Base, int : Extended):Extended;
    begin
        Result:= Base * Pow(10, int);
    end;


    {*******************************************************************************
    Function DeExp(Base, int : Extended) : Extended;
    By: Sky Scripter
    Description: Gives The Extended Exponet Number
    Example: DeExp(10, 2) = 0.001
    *******************************************************************************}

    Function DeExp(Base, int : Extended):Extended;
    begin
      Result:= Base / Pow(10, int * 2);
    end;


    {*******************************************************************************
    Function DrawEllipse(Centx, Centy, Width, Height, Inc, DegreeStop : Integer) : TPointArray;
    By: Sky Scripter
    Description: Draws Out a Ellipse In TPoints, use The Inc For the step
     in between Tpoints.
    *******************************************************************************}

    Function DrawEllipse(Centx, Centy, Width, Height, Inc : Integer) : TPointArray;
    Var P : TPointArray;
        i, Add: Integer;
    begin
     setarraylength(P,  360 / Inc);
      For i:= 1 to 360 / Inc do
       begin
         Add:= Add + Inc;
           P[i-1].x:= Trunc( Width * Sin((Pi / 180) * Add) + Centx);
           P[i-1].y:= Trunc(-Height * Cos((Pi / 180) * Add) + Centy);
       end;
     Result:= P;
    end;


    {*******************************************************************************
    Function DrawTriangle(Centx, Centy, width, height, inc:Integer): TPointArray;
    By: Sky Scripter
    Description: Draws Out a Triangle in TPoints, Use Inc For The Step Between TPoints.
    *******************************************************************************}

    Function DrawTriangle(Centx, Centy, width, height, inc, DegreeStop:Integer): TPointArray;
    Var P : TPointArray;
         i, add:Integer;
    begin
     SetArrayLength(P, 540 / Inc);
      for i:= 1 to 540 / Inc do
       begin
          add := add + Inc;
            P[i-1].x := Trunc(width * Cos((Pi/180) * Add) + Centx);
          if (add >= 180) then  P[i-1].x := Trunc(-width * Cos((Pi/180) * Add) + Centx-(width * 2));
             P[i-1].y := Trunc(height * Cos((Pi/180) * Add) + Centy);
          if (add >= 360) then
            begin
               P[i-1].x:= Trunc(-(Width * 2) * Cos((Pi/180) * add) + Centx-Width);
               P[i-1].y:= Trunc(height * Cos((Pi/180) * 0) + Centy);
           end;
        end;
       Result:= P;
    end;


    {*******************************************************************************
    Function DrawRect(dx, dy, Width, Height, Inc:Integer): TPointArray;
    By: Sky Scripter
    Description: Draws a Rectangle In TPoints, Use Inc For the step in between the TPoints.
    *******************************************************************************}

    Function DrawRect(dx, dy, Width, Height, Inc:Integer): TPointArray;
    Var P: TPointArray;
        i, add:Integer;
    begin
     SetArrayLength(P, 720 / Inc);
     Width:= width Shr 1;
     Height:= Height shr 1;
     dx := dx + Width;
     dy := dy + Height;
      For i:= 1 to 720 / Inc do
      begin
       Add:= Add + Inc;
       p[i-1].x:= Trunc(Width * Cos((Pi/180) * 0) + dx);
       p[i-1].y:= Trunc(Height * Cos((Pi/180) * Add) + dy);
     if (Add >= 180) then
     begin
       p[i-1].x:= Trunc(-Width * Cos((Pi/180) * Add) + dx);
       p[i-1].y:= Trunc(-Height * Cos((Pi/180) * 0) + dy);
     end;
     if (Add >= 360) then
      begin
        p[i-1].x:= Trunc(-Width * Cos((Pi/180) * 0) + dx);
        p[i-1].y:= Trunc(-Height * Cos((Pi/180) * Add) + dy);
      end;
       if (Add >= 540) then
      begin
        p[i-1].x:= Trunc(Width * Cos((Pi/180) * Add) + dx);
        p[i-1].y:= Trunc(Height * Cos((Pi/180) * 0) + dy);
      end;
     end;
     Result:= P;
    end;


    {*******************************************************************************
    Function DrawLine(sx, sy, dx, dy, inc : Integer): TPointArray;
    By: Sky Scripter
    Description: draw A Line From (sx, sy, To dx, dy) use Inc For the step between
     Tpoints. The Inc Doesn't work so well so (RECOMENDED inc = (1, 2 or 3))
    *******************************************************************************}

    Function DrawLine(sx, sy, dx, dy, inc : Integer): TPointArray;
    Var P: TPointArray;
        i, add, mx, my:Integer;
    begin
      SetArrayLength(P, 180 / Inc);
       mx:= Trunc(Nott(sx - dx)+1);
       my:= Trunc(Nott(sy - dy)+1);
       For i:= 1 to 180 / Inc do
         begin
          add:= add + inc;
     If (Not(P[i-1].x = dx)) then  p[i-1].x:= Trunc(sx - mx * Cos((Pi/180) * Add) + mx );
     If (Not(P[i-1].y = dy)) then  p[i-1].y:= Trunc(sy - my * Cos((Pi/180) * Add) + my );
       If (P[i-1].x = dx) and (P[i-1].y = dy) then
         begin
          SetArrayLength(P, i);
          Break;
        end;
      end;
     Result:= P;
    end;


    {*******************************************************************************
    Procedure TransMouse(dx, dy, rx, ry :Integer);
    By: Sky Scripter
    Description: Moves The Mouse Human Like.. (Alot like BenMouse and RsN / Mutant MMouse)
    *******************************************************************************}

    Procedure TransMouse(dx, dy, rx, ry :Integer);
    Var P: TPointArray;
        i, x, y, step, Slow: Integer;
    begin
     GetMousePos(x, y)
     If (Distance(dx, dy, x, y) = 0) then exit;
     Step := Trunc( Mousespeed / 10 )
     if ((step < 1) or (step > 3))  then  step:= Random(3)+1;
     dx:= dx + Random(Rx);
     dy:= dy + Random(Ry);
     If (dx <= 0) then dx:= 1 if (dy <= 0) then dy:= 1;
     P:= DrawLine(x, y, dx, dy, step);
     For i:= 0 to getarraylength(p)-1 do
       begin
        MoveMouse(P[i].x, P[i].y);
        if Distance(P[i].x, P[i].y, dx, dy) < 50 then  Slow := Slow + Random(Step);
        if (slow > MouseSpeed) then Slow:= MouseSpeed;
        Wait(MouseSpeed + Slow);
       end;
    end;


    {*******************************************************************************
    Procedure SnapMouse(dx, dy, rx, ry:Integer; Left:Boolean);
    By: Sky Scripter
    Description: Just like the (Procedure Mouse) but a little diffrent...
    *******************************************************************************}

    Procedure SnapMouse(dx, dy, rx, ry:Integer; Left:Boolean);
    Var i, x, y:Integer;
    begin
     TransMouse(dx, dy, rx, ry);
     Wait(50 + Random(50));
     GetMousePos(x, y);
     HoldMouse(x + 1, y, Left);
      For i:= 1 to 3 do
        Wait(10 + Random(10));
     GetMousePos(x, y);
     ReleaseMouse(x, y, Left);
     Wait(10+Random(10));
     TransMouse(x - Random(3), y - Random(3), 0, 0);
    end;


    {*******************************************************************************
    Function ColorsSimilar(Color1, Color2:Integer):Boolean;
    By: Sky Scripter
    Description: Without Tol it checks if The colors Are close   needs Work );
    *******************************************************************************}

    Function ColorsSimilar(Color1, Color2:Integer):Boolean;
    Var     // Im Not So Sure How Accurate This is :)
      H, S, L : Array [1..2] Of Extended;
    begin
    ColortoHSL(Color1, H[1], S[1], L[1]);
    ColortoHSL(Color2, H[2], S[2], L[2]);
     If ( Sqrt( Sqr(H[1] - H[2]) ) <= 15 ) And
        ( Sqrt( Sqr(S[1] - S[2]) ) <= 100 ) And
        ( Sqrt( Sqr(L[1] - L[2]) ) <= 50 ) then
        Result:= True;
    end;


    {*******************************************************************************
    Function FindColorRadial(Var x, y : Integer; Color, Centx, Centy, Width, Height:Integer): Boolean;
    By: Sky Scripter
    Description:  Finds a color in a Ellipse       SLOW!!!
    *******************************************************************************}

    Function FindColorRadial(Var x, y : Integer; Color, Centx, Centy, Width, Height:Integer): Boolean;
    Var
        P : TPointArray;
        Radialx, Radialy, i : Integer;
    begin
    repeat
        If (Not(radialx >= Width))  then  radialx:= radialx + 1;
        If (Not(radialy >= Height)) then  radialy:= radialy + 1;
          P:=  DrawEllipse(centx, Centy, radialx, radialy, 1);
      For i:= 0 to GetArrayLength(P)-1 do
      If (FindColor(x, y, Color, P[i].x, P[i].y, P[i].x, P[i].y)) then  // It's Speeds It By Using Find color
       Begin
        Result:= True;
        Exit;
       end;
    Until (radialx >= Width) And (radialy >= Height)
    end;


    {*******************************************************************************
    Function FindColorEllipseEx(Var x, y : Integer; Color, Centx, Centy, Width, Height, Inc, OutInc, Tol:Integer): Boolean;
    By: Sky Scripter
    Description:  Finds a color in a ellipse, Inc Is the Space Between The Tpoints
    OutInc The Gap between Each Ellipse.           SLOW!!!
    *******************************************************************************}

    Function FindColorEllipseEx(Var x, y : Integer; Color, Centx, Centy, Width, Height, Inc, OutInc, Tol:Integer): Boolean;
    Var
        P : TPointArray;
        Radialx, Radialy, i : Integer;
    begin
    repeat
    If (Not(radialx >= Width - radialx))  then  radialx:= radialx + OutInc else radialx:= radialx + 1;
    If (Not(radialy >= Height - radialy)) then  radialy:= radialy + OutInc else radialy:= radialy + 1;
          P:=  DrawEllipse(centx, Centy, radialx, radialy, Inc);
      For i:= 0 to GetArrayLength(P)-1 do
      If (FindColor(x, y, Color, P[i].x, P[i].y, P[i].x, P[i].y)) or
         (FindColorTolerance(x, y, Color, P[i].x, P[i].y, P[i].x, P[i].y, Tol)) then
       Begin
        Result:= True;
        Exit;
       end;
    Until (radialx >= Width) And (radialy >= Height)
    end;


    {*******************************************************************************
    Function FindColorBorder(Var x, y:Integer; Color, x1, y1, x2, y2, Tol:Integer):Boolean;
    By: Sky Scripter
    Description: Finds The Color Only on the borders of x1 y1 x2 y2
    Example:
            _____
           |Space| <-- Finds The Color on the borders only Not in the space.
           |_____|
           
    *******************************************************************************}

    Function FindColorBorder(Var x, y:Integer; Color, x1, y1, x2, y2, Tol:Integer):Boolean;
    Var P: TPointArray;
        i: Integer;
    begin
      P:= DrawRect(x1, y1, x2, y2, 1);
      Wait(3);
     For i:= 0 to getarraylength(p)-1 do
      If (FindColorTolerance(x, y, Color, P[i].x, P[i].y, P[i].x, P[i].y, Tol)) then
      begin
       Result:= True;
       Exit;
      end;
    end;


    {*******************************************************************************
    Function FindColorExcept(Var x, y : Integer; color, x1, y1, x2, y2, xx1, yy1, xx2, yy2, Tol:Integer):Boolean;
    By: Sky Scripter
    Description: Finds The Colors Except The "ExceptBounds"
    Example:  xx1, yy1, xx2, yy2 are the borders of the except bounds..
            ___________________
           |  _______          |       SLOW!!!
           | |Except |         |
           | |Bounds |         |
           | |_______|         |
           |___________________|
    *******************************************************************************}

    Function FindColorExcept(Var x, y : Integer; color, x1, y1, x2, y2, xx1, yy1, xx2, yy2, Tol:Integer):Boolean;
    begin
     repeat
     If (Not( x1 = xx1 )) Then If (x1 < xx1) then xx1 := xx1 - 1 else xx1:= xx1 + 1;
     If (Not( y1 = yy1 )) Then If (y1 < yy1) then yy1 := yy1 - 1 else yy1:= yy1 + 1;
     If (Not( x2 = xx2 )) Then If (x2 < xx2) then xx2 := xx2 - 1 else xx2:= xx2 + 1;
     If (Not( y2 = yy2 )) Then If (y2 < yy2) then yy2 := yy2 - 1 else yy2:= yy2 + 1;
     If (FindColorBorder(x, y, color, xx1, yy1, xx2, yy2, tol )) then
      begin
       Result:= True;
       Exit;
      end;
     Until (x1 = xx1) and (y1 = yy1) and (x2 = xx2) and (y2 = yy2)
    end;



    {*******************************************************************************
    Function CountSep(S:String; Seperater:Char) : Integer;
    By: Sky Scripter
    Description: Returns The Amout of Seperaters Ther are
    Example: CountSep('hello, wasup, hey', ',') = 2
    *******************************************************************************}

    Function CountSep(S:String; Seperater:Char) : Integer;
    var i:Integer;
    begin
     for i:= 1 to length(S) do
      if (S[i] = Seperater) then
        Result:= Result + 1;
    end;


    {*******************************************************************************
    Function BetweenSep(S:String; Seperater:Char): Array of String;
    By: Sky Scripter
    Description: Returns the strings between the seperater in array of string
    Example:
        S := PickString(BetweenSep('Wasup, hows it going dude, hey man, dude',','));
    *******************************************************************************}

    Function BetweenSep(S:String; Seperater:Char): Array of String;
    Var i, ST, c:Integer;
    begin
     ST:= CountSep(S, Seperater);
       If (St > 1 ) Then  St:= St + 1;
         setarraylength(Result, st);
           For i:= 1 to length(s) do
            if (S[i] = Seperater ) then  C:= c + 1
          else
        Result[c]:= Result[c] + S[i];
    end;




    Var i:Integer;

    begin
     MouseSpeed:= 15;
     BenMouse:= True;
     ClearDebug;
       Writeln('Watch The Diffrence between each MMouse Procedures / Functions!');
       Wait(1000);
       Writeln('');
         Writeln('Heres Ben MMouse!.');
           For i:= 1 to 4 do
            MMouse(0, 0, 800, 600);
            Wait(3000);
            Writeln('');
         Writeln('Heres Mutant/RsN MMouse!..');
            BenMouse:= False;
             For i:= 1 to 4 do
              MMouse(Random(800), Random(600), 0, 0);
              Wait(3000);
              Writeln('');
          Writeln('Heres Skys MMouse!...');
             For i:= 1 to 4 do
              TransMouse(0, 0, 800, 600);
            Writeln('');
    end.

  2. #2
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Nice! I like your mouse function
    Hup Holland Hup!

  3. #3
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Nice! I like your mouse function
    thanks very much

  4. #4
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    These look like great functions. I like the math ones that nobody has release yet. I like your mouse it's very human like. Does MouseSpeed:=... work with it?


  5. #5
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Does MouseSpeed:=... work with it?
    of course it does....
    i even tried to make it so that if you have only like
    mousespeed:= 5;
    it still will move some what human like...

  6. #6
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Wow, you never seize to amaze me SKy!
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  7. #7
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Nice procedures, If you add tolerance to ColorsSimilar, I won't have to make my own

    I like your MMouse, but I do think it's a bit too slow...actually, I think it accelerates too slow.
    Interested in C# and Electrical Engineering? This might interest you.

  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Wow. I think i couldnt do that...
    I need to find a good dictionary cuz im from finland and cant understand english words like "pow" and those...

  9. #9
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Nice procedures, If you add tolerance to ColorsSimilar, I won't have to make my own

    I like your MMouse, but I do think it's a bit too slow...actually, I think it accelerates too slow.
    yes.. i guess your kinda right...
    Edit : Turn the mouse speed down then ...

    Wow. I think i couldnt do that...
    I need to find a good dictionary cuz im from finland and cant understand english words like "pow" and those...
    pow is the power for example :

    pow(6, 2) would equal
    6*6
    pow(6, 3) would equal
    6*6*6


    Wow, you never seize to amaze me SKy!
    Thanks,

  10. #10
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    very nice sky, good work

    heres just one thing i noticed
    SCAR Code:
    Function Dividable(Int:Integer):Boolean;
    var i:Integer;
        e:Extended;
    begin
    Result:=False;
     for i:= 1 to int - (int div 2) do
       begin
        e:= Int div i;
          If ( e = 2) then
          begin
           Result:=True;
          exit;
         end;
       end;
    end;

    you dont have to do that, this also works

    SCAR Code:
    Function Dividable(Int:Integer):Boolean;
    begin
    Result := (Int mod 2 = 0);
    end;

    im quite sure you know what it does
    in case you dont know, mod takes away multiples of a number (in this case 2) until the number is 0 < n < number-1

    a clock would use it, after 12, it doesnt go to 13, it goes back to 1, a clock is

    (Hour mod 12) + 1
    Join the Official SRL IRC channel. Learn how to Here.

  11. #11
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    yah i new what "Mod" does i just think of that Yakman .
    Good Job.

  12. #12
    Join Date
    Mar 2006
    Location
    United States, -7:00 GMT
    Posts
    1,790
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Sky, I'm jelous of ur sexyness. Good job :P

    hakuna matata ;)

  13. #13
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Sky, I'm jelous of ur sexyness. Good job :P
    Lmfo, that just made my day! thanks

  14. #14
    Join Date
    Mar 2007
    Posts
    3,681
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    im jealous too i like the smoothness of it very human !

  15. #15
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't think I can tell the different between BenMouse and SKyMouse...I might be stupid though

    Good work SKy
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Writing Functions With Math
    By NiCbaZ in forum OSR Intermediate Scripting Tutorials
    Replies: 8
    Last Post: 07-05-2009, 03:42 AM
  2. Two Math Functions I made.
    By Sandstorm in forum Research & Development Lounge
    Replies: 30
    Last Post: 01-21-2009, 03:52 PM
  3. MMouse()
    By Dude in forum OSR Help
    Replies: 20
    Last Post: 08-20-2007, 02:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •