Results 1 to 5 of 5

Thread: Space Invaders Script + Access violations

  1. #1
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Space Invaders Script + Access violations

    Rawr
    I'm about to /wrist myself

    I'm getting these weird Access violations having to do with this script I'm writing, and I can't figure it out.

    SCAR Code:
    program SpaceInvaders;


    Procedure Mouse(x, y: Integer; click, left: Boolean);
    var i: Integer;
    begin
      movemousesmooth(x, y);
      wait(30);
      if not click then
        exit;
      getmousepos(x, y);
      holdmouse(x, y, left);
      for i := 0 to 3 do
        wait(20+random(10));
      getmousepos(x, y);
      ReleaseMouse(x, y, left);
    end;
     
     



    Function InHomeScreen: Boolean;
    begin
      result := CountColor(255, 180, 222, 224, 244) = 256;
    end;



    Procedure StartGame;
    var
      x, y: Integer;
    begin
      wait(100);
      if InHomeScreen then
      begin
        mouse(250, 284, false, false);
        wait(200);
        if not CountColor(65331, 136, 272, 359, 292) > 100 then
        begin
          getmousePos(x, y);
          mouse(x, y, true, true);
          wait(100);
        end;
        mouse(250, 284, true, true);
      end;
    end;


    Function ProjectileInRange: Boolean;
    var TPA: TPointArray;
    begin
      If InHomeScreen then exit;
      Result := FindColorsTolerance(TPA, 16777215, 0, 246, 500, 283, 0);
    end;


    Function GetMyPos: TPoint;
    var
      TPA: TPointArray;
    begin
      If InHomeScreen then exit;
      if FindColorstolerance(TPA, 65331, 0, 335, 500, 375, 0) then
        middleTPAEX(TPA, Result.x, Result.y);
    end;



    Function NearestCover: TPoint;
    var
      TPA: TPointArray;
      ATPA: Array of Array of TPoint;
      i, x, y, LowestDistance, Mark: Integer;
      Distances: TIntegerArray;
      MyPos: TPoint;
    begin
      If InHomeScreen then exit;
      MyPos := GetMyPos;
      FindColorsTolerance(TPA, 65331, 61, 285, 440, 332, 0);
      ATPA := TPAtoATPAEx(TPA, 110 - 61, 322 - 285);
      For i := 0 to high(ATPA) do
      begin
        if Length(ATPA[i]) > 200 then
        begin
          middleTPAEx(ATPA[i], x, y);
          SetArrayLength(Distances, Length(Distances) + 1);
          Distances[i] := Distance(MyPos.x, MyPos.y, x, y);
        end;
      end;
      LowestDistance := distances[0];
      For i := 0 to high(Distances) do
        if Distances[i] < LowestDistance then
          LowestDistance := Distances[i];
      For i := 0 to high(Distances) do
        if Distances[i] = LowestDistance then
          middleTPAEx(ATPA[i], Result.x, Result.y);
    end;



    Procedure MoveToNearest;
    var
      Nearest, MyPos: TPoint;
      Keyz: Byte;
    begin
      Nearest := NearestCover;
      MyPos := GetMyPos;
      If Nearest.x > MyPos.x then
        keyz := VK_Right
      else
        keyz := VK_Left;


      KeyDown(keyz);
      repeat
        wait(50);
        MyPos := GetMyPos;
      until MyPos.x = NearestCover.x;
      KeyUp(keyz);
    end;

         

    var
      Point: TPoint;
    begin
      //ActivateClient;
      MoveToNearest;
    end.

    Error]: Access violation at address 00529608 in module 'scar.exe'. Read of address 0000006C
    [Error]: Access violation at address 00529608 in module 'scar.exe'. Read of address 000000F8
    [Error]: Access violation at address 00000025. Read of address 00000025
    Errors^

    Help please

    btw the errors are comming from MoveToNearest;

    Thanks
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Redownload SCAR? Associate .scar files? One of those should fix it.

  3. #3
    Join Date
    Dec 2007
    Location
    Williston, ND
    Posts
    3,106
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I LOVE SPACE INVADERS!

    Well, I did back on the SNES
    Proud owner of "Efferator" my totally boted main account!
    "You see, sometimes, science is not a guess" -Xiaobing Zhou (my past physics professor, with heavy Chinese accent)

  4. #4
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    I'm only getting "[Error]: Access violation at address 0000001F. Read of address 0000001F
    "

    For which space invaders is this ?_?

    The Error is here: "Commented Part" ... And when i comment that part, theres another OutOfRange error in Line 91

    Code:
    Procedure MoveToNearest;
    var
      Nearest, MyPos: TPoint;
      Keyz: Byte;
    begin
      Nearest := NearestCover;
      MyPos := GetMyPos;
    
      If Nearest.x > MyPos.x then
      begin
        keyz := VK_Right
      end else
      begin
        keyz := VK_Left;
      end;
    
      KeyDown(keyz);
    {  repeat
        wait(50);
        MyPos := GetMyPos;
      until MyPos.x = NearestCover.x;
      }KeyUp(keyz);
    end;
    // EDIT:

    you probably want to use:

    "until MyPos.x = Nearest.x;"
    instead of
    "until MyPos.x = NearestCover.x;"
    Last edited by caused; 07-16-2009 at 02:10 AM.

  5. #5
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by caused View Post
    I'm only getting "[Error]: Access violation at address 0000001F. Read of address 0000001F
    "

    For which space invaders is this ?_?

    The Error is here: "Commented Part" ... And when i comment that part, theres another OutOfRange error in Line 91

    Code:
    Procedure MoveToNearest;
    var
      Nearest, MyPos: TPoint;
      Keyz: Byte;
    begin
      Nearest := NearestCover;
      MyPos := GetMyPos;
    
      If Nearest.x > MyPos.x then
      begin
        keyz := VK_Right
      end else
      begin
        keyz := VK_Left;
      end;
    
      KeyDown(keyz);
    {  repeat
        wait(50);
        MyPos := GetMyPos;
      until MyPos.x = NearestCover.x;
      }KeyUp(keyz);
    end;
    // EDIT:

    you probably want to use:

    "until MyPos.x = Nearest.x;"
    instead of
    "until MyPos.x = NearestCover.x;"
    You hit the nail right on the head

    Thanks man.

    Repp'd

    Edit: Here the working one

    SCAR Code:
    Procedure MoveToNearest;
    var
      MyPos: TPoint;
      Nearest: array [0..1] of TPoint;
      Keyz: Byte;
    begin
      If InHomeScreen then exit;
      Nearest[0] := NearestCover;
      MyPos := GetMyPos;
      Nearest[1] := Point(Nearest[0].x, MyPos.y);
      If Nearest[0].x > MyPos.x then
        keyz := VK_Right
      else
        keyz := VK_Left;
      KeyDown(keyz);
      repeat
        wait(30);
        MyPos := GetMyPos;
        Nearest[1] := Point(Nearest[0].x, MyPos.y);
      until (Distance(MyPos.x, Mypos.y, Nearest[1].x, Nearest[1].y) < 7);
      KeyUp(keyz);
    end;
    Last edited by noidea; 07-16-2009 at 02:54 AM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

Thread Information

Users Browsing this Thread

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

Posting Permissions

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