Something Wrong in Math.scar

Discussion in 'Scar/Simba Help' started by demonicknight666, Aug 15, 2008.

Something Wrong in Math.scar
  1. Unread #1 - Aug 15, 2008 at 4:13 AM
  2. demonicknight666
    Referrals:
    0

    demonicknight666 Guest

    Something Wrong in Math.scar

    I am using SCAR 3.15. When i try run a script it refers to
    Line 205: [Error] (365:1): Semicolon (';') expected in script C:\Program Files\SCAR 3.15\includes\SRL/SRL/Core/Math.scar

    I have no idea what to do.



    //-----------------------------------------------------------------//
    //-- Scar Standard Resource Library --//
    //-- » Math Routines --//
    //-----------------------------------------------------------------//
    // * procedure LoadCoSineArrays; // * by Mutant Squirrle
    // * function GetSplinePt(Points: TPointArray; Theta: Extended): TPoint; // * by BenLand100
    // * function MakeSplinePath(Points: TPointArray; ThetaInc: Extended): TPointArray; // * by BenLand100
    // * function MidPoints(Path: TPointArray; MaxDist: Integer): TPointArray; // * by BenLand100
    // * function InAbstractBox(x1, y1, x2, y2, x3, y3, x4, y4: Integer; x, y: Integer): Boolean; // * by BenLand100
    // * function inAngle(Origin: TPoint; Angle1, Angle2, Radius1, Radius2: Extended; X, Y: Integer): Boolean; // * by BenLand100
    // * function Randomize(Original, RandomN: Integer): Integer; // * by Mutant Squirrle
    // * function SimilarFloats(tFloat1, tFloat2: Extended; tTol: Integer): Boolean; // * by Lorax
    // * function Hash(Str: String): LongInt; // * by BenLand100
    // * function AvgAngles(A, B: Extended; Wa, Wb: Integer): Extended; // * by BenLand100
    // * function Sine(degrees: Integer): Extended; // * by ?
    // * function Cose(degrees: Integer): Extended; // * by ?
    // * function NormDist(MaxNum: Integer): Integer; // * by Flyboy / inspired by lardmaster

    Var
    SineArray, Cosearray: Array[0..360] Of Extended;

    {*******************************************************************************
    procedure LoadCoSineArrays;
    By: Mutant Squirrle
    Description: Loads arrays for use with Radial- and LinearWalk.
    *******************************************************************************}

    procedure LoadCoSineArrays;
    var
    i: Integer;
    begin
    for i := 0 to 360 do
    begin
    Sinearray := Sin(i * Pi / 180);
    Cosearray := Cos(i * Pi / 180);
    end;
    end;

    {*******************************************************************************
    function GetSplinePt(Points: TPointArray; Theta: Extended): TPoint;
    By: BenLand100
    Description: Returns the point on a spline, defined by control points Points, at Theta
    *******************************************************************************}

    function GetSplinePt(Points: TPointArray; Theta: Extended): TPoint;
    var
    i, n: Integer;
    XTemp, YTemp: Extended;
    begin
    n := GetArrayLength(Points) - 1;
    for i := 0 to n do
    begin
    XTemp := XTemp + (BinCoe(n, i) * Points.x * Pow((1 - Theta), n - i) *
    Pow(Theta, i));
    YTemp := YTemp + (BinCoe(n, i) * Points.y * Pow((1 - Theta), n - i) *
    Pow(Theta, i));
    end;
    Result.x := Round(XTemp);
    Result.y := Round(YTemp);
    end;

    {*******************************************************************************
    function MakeSplinePath(Points: TPointArray; ThetaInc: Extended): TPointArray;
    By: BenLand100
    Description: Returns a spline, defined by control points Points, incrementing theta by ThetaInc
    *******************************************************************************}

    function MakeSplinePath(Points: TPointArray; ThetaInc: Extended): TPointArray;
    var
    i: Integer;
    t: Extended;
    temp, last: TPoint;
    done: Boolean;
    begin
    repeat
    if t >= 1 then
    begin
    t := 1;
    done := True;
    end;
    temp := GetSplinePt(Points, t);
    if ((temp.x <> last.x) and (temp.y <> last.y)) then
    begin
    i := i + 1;
    SetArrayLength(Result, i);
    Result[i - 1] := temp;
    last := temp;
    end;
    t := t + ThetaInc;
    until (done)
    end;

    {*******************************************************************************
    function MidPoints(Path: TPointArray; MaxDist: Integer): TPointArray;
    By: BenLand100
    Description: Adds midpoints to Path so no distance on it is greater than MaxDist
    *******************************************************************************}

    function MidPoints(Path: TPointArray; MaxDist: Integer): TPointArray;
    var
    i, c: Integer;
    last: TPoint;
    done: Boolean;
    begin
    if (getarraylength(path) > 0) then
    begin
    repeat
    last := Path[0];
    done := True;
    for i := 1 to GetArrayLength(Path) - 1 do
    begin
    if Sqrt(Pow((Path.x - last.x), 2) + Pow((Path.y - last.y), 2)) >
    MaxDist then
    begin
    done := False;
    SetArrayLength(Path, GetArrayLength(Path) + 1);
    for c := GetArrayLength(Path) - 1 downto i + 1 do
    begin
    Path[c] := Path[c - 1];
    end;
    Path.x := Round((last.x + Path[i + 1].x) / 2);
    Path.y := Round((last.y + Path[i + 1].y) / 2);
    end;
    last := Path;
    end;
    until (done);
    end;
    Result := Path;
    end;

    {*******************************************************************************
    function InAbstractBox(x1, y1, x2, y2, x3, y3, x4, y4: Integer; x, y: Integer): Boolean;
    By: BenLand100
    Description: Returns true if point x, y is in an abstract box defined by x1, y1, x2, y2, x3, y3, x4, y4
    An abstract box example:

    x1, y1 x2, y2
    +--------+
    \ /
    \ /
    +--+
    x4, y4 x3, y3
    *******************************************************************************}

    function InAbstractBox(x1, y1, x2, y2, x3, y3, x4, y4: Integer; x, y: Integer):
    Boolean;
    var
    U, D, R, L: Boolean;
    UB, DB, LB, RB, UM, DM, LM, RM: Extended;
    begin
    UM := (-y1 - -y2) div (x1 - x2);
    DM := (-y4 - -y3) div (x4 - x3);
    if x1 - x4 <> 0 then
    begin
    LM := (-y1 - -y4) div (x1 - x4);
    end else
    begin
    LM := Pi;
    end;
    if x2 - x3 <> 0 then
    begin
    RM := (-y2 - -y3) div (x2 - x3);
    end else
    begin
    RM := Pi;
    end;
    UB := -(UM * x1) + -y1
    RB := -(RM * x2) + -y2;
    DB := -(DM * x3) + -y3;
    LB := -(LM * x4) + -y4;
    if (UM * x + UB >= -y) then U := True;
    if (DM * x + DB <= -y) then D := True;
    if (RM <> Pi) and (RM >= 0) and (RM * x + RB <= -y) then R := True;
    if (RM <> Pi) and (RM < 0) and (RM * x + RB >= -y) then R := True;
    if (RM = Pi) and (x < x2) then R := True;
    if (LM <> Pi) and (LM >= 0) and (LM * x + LB >= -y) then L := True;
    if (LM <> Pi) and (LM < 0) and (LM * x + LB <= -y) then L := True;
    if (LM = Pi) and (x > x1) then L := True;
    if U and D and L and R then Result := True;
    end;

    {*******************************************************************************
    function inAngle(Origin: TPoint; Angle1, Angle2, Radius1, Radius2: Extended; X, Y: Integer): Boolean;
    By: BenLand100
    Description: Returns True if X and Y fall within Radius1 to Radius2 and Angle1 to Angle2
    Note1: EVERYTHING IS RELATIVE TO ORIGIN!!!
    Note2: This checks in the smallest segment of the circle formed by Angle1 and Angle 2
    Example: (Assume the origin is 0,0)
    inAngle(0, 90, 5, 10, origin, 5, 5) = true;
    inAngle(0, 90, 0, 5, origin, 5, 5) = false;
    inAngle(90, 0, 5, 10, origin, 5, 5) = false;
    *******************************************************************************}

    function inAngle(Origin: TPoint; Angle1, Angle2, Radius1, Radius2: Extended; x,
    y: Integer): Boolean;
    var
    PTemp: PPoint;
    OTemp: TPoint;
    MinAngle, MaxAngle, MinRadius, MaxRadius: Extended;
    begin
    Angle1 := FixD(Angle1);
    Angle2 := FixD(Angle2);
    MinAngle := Angle1;
    if Angle1 > Angle2 then MinAngle := Angle2
    MaxAngle := Angle1;
    if Angle1 < Angle2 then MaxAngle := Angle2
    MinRadius := Radius1;
    if Radius1 > Radius2 then MinRadius := Radius2
    MaxRadius := Radius1;
    if Radius1 < Radius2 then MaxRadius := Radius2
    OTemp.x := x;
    OTemp.y := y;
    PTemp := ToPolarOffset(OTemp, Origin);
    if (PTemp.R >= MinRadius) and (PTemp.R <= MaxRadius) then
    if (PTemp.T >= MinAngle) and (PTemp.T <= MaxAngle) then
    Result := True;
    end;

    {*******************************************************************************
    function Randomize(Original, RandomN: Integer): Integer;
    By: Mutant Squirrle
    Description: Returns Random number within RandomN bounds from Original
    *******************************************************************************}

    function Randomize(Original, RandomN: Integer): Integer;
    var
    Math: Integer;
    begin
    RandomN := Random(RandomN) + 1;
    math := Random(2) + 1;
    case math of
    1: Result := Original + RandomN;
    2: Result := Original - RandomN;
    end;
    end;

    {*******************************************************************************
    function SimilarFloats(tFloat1, tFloat2: Extended; tTol: Integer): Boolean;
    By: Lorax
    Description: Returns true if the floats are in range of each other
    *******************************************************************************}

    function SimilarFloats(tFloat1, tFloat2: Extended; tTol: Integer): Boolean;
    var
    Delta: Extended;
    begin
    Delta := tTol * (tFloat1 div 1000);
    if (tFloat2 <= tFloat1 + Delta) and
    (tFloat2 >= tFloat1 - Delta) then
    Result := True;
    end;

    {*******************************************************************************
    function Hash(Str: String): LongInt;
    By: BenLand100
    Description: For your hashing pleasures ;) Returns a hash value for a string
    *******************************************************************************}

    function Hash(Str: string): LongInt;
    var
    i, x: Integer;
    begin
    Result := 0;
    for i := 1 to Length(Str) do
    begin
    Result := (Result shl 4) + Ord(Str);
    x := Result and $F0000000;
    if (x <> 0) then
    begin
    Result := Result xor (x shr 24);
    Result := Result and (not x);
    end;
    end;
    Result := (Result and $7FFFFFFF);
    end;

    {*******************************************************************************
    function AvgAngles(A, B: Extended; Wa, Wb: Integer): Extended;
    By: BenLand100
    Description: Averages angles A (with a weight of Wa) and B (with a weight of Wb)
    *******************************************************************************}

    function AvgAngles(A, B: Extended; Wa, Wb: Integer): Extended;
    begin
    A := Radians(A);
    B := Radians(B);
    Result := Degrees(ArcTan2((Sin(A) * Wa) + (Sin(b) * Wb), (Cos(A) * Wa) +
    (Cos(b) * Wb)));
    end;

    {*******************************************************************************
    function Sine(degrees: Integer): Extended;
    By:
    Description:
    *******************************************************************************}

    function Sine(Degrees: Integer): Extended;
    begin
    Result := sinearray[Trunc(FixD(Degrees))];
    end;

    {*******************************************************************************
    function Cose(degrees: Integer): Extended;
    By:
    Description:
    *******************************************************************************}

    function Cose(Degrees: Integer): Extended;
    begin
    Result := cosearray[Trunc(FixD(Degrees))];
    end;

    {*******************************************************************************
    function NormDist(MaxNum: Integer): Integer;
    By: Flyboy / inspired by lardmaster
    Description: This returns a number number +/- MaxNum. If graphed out, the
    results would form a graph formain a normal distribution curve. What this means
    is that it is most likly to return 0 (zero) with a lessonen chance of returning
    a number as it approaches the MaxNum.
    *******************************************************************************}

    function NormDist(MaxNum: Integer): Integer;
    var
    i, Temp, Offset: Integer;
    begin
    MaxNum := MaxNum + 1;
    Offset := MaxNum * MaxNum;
    for i := 0 to (MaxNum + 1) do
    begin
    Temp := Random(Offset);
    if Temp <= i then
    begin
    Result := Temp;
    if Temp = 0 then
    begin
    if Random(100) < 52 then //play with these numbers to adjust Zero (0)
    Break;
    end else
    begin
    if Random(2) = 0 then
    Result := Result * (-1);
    Break;
    end;
    end; //if Temp <= i
    if Offset > MaxNum then
    Offset := Offset - MaxNum
    else
    Offset := MaxNum; //FailSafe... can't be too careful :)
    end; //for i..
    //FailSafe
    if ((Result < (-MaxNum)) or (Result > MaxNum)) then
    Result := ((Random(MaxNum * 2 + 1)) - MaxNum);
    end;
     
  3. Unread #2 - Aug 19, 2008 at 8:29 PM
  4. Runescapian321
    Joined:
    Sep 19, 2007
    Posts:
    179
    Referrals:
    0
    Sythe Gold:
    0

    Runescapian321 Active Member

    Something Wrong in Math.scar

    Make sure you have downloaded the latest SRL using Subversion. If you already have, try doing a Checkout again.
     
  5. Unread #3 - Aug 19, 2008 at 8:31 PM
  6. wcer2552
    Joined:
    Feb 23, 2008
    Posts:
    1,462
    Referrals:
    0
    Sythe Gold:
    0

    wcer2552 Guru
    $25 USD Donor

    Something Wrong in Math.scar

    im not good with these things but would it have anything to do with new rs updates? just a suggestion maybe its an outdated script or something
     
  7. Unread #4 - Aug 19, 2008 at 8:54 PM
  8. Runescapian321
    Joined:
    Sep 19, 2007
    Posts:
    179
    Referrals:
    0
    Sythe Gold:
    0

    Runescapian321 Active Member

    Something Wrong in Math.scar

    Math.h is an SRL Include. It works fine for me, so it's nothing to do with SRL. It's a problem on his end (like maybe he didn't download SRL with SvN) or there was a bug when downloading it.
     
< help! | Compiles fine, findcolor doesnt seem to do its job? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site