Results 1 to 7 of 7

Thread: Question about script non-runescape related

  1. #1
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Question about script non-runescape related

    Hope this is the right section...

    So I'm still learning the VERY BASICS to scripting. I mean VERY VERY BASIC
    I've been trying to improve my scripting knowledge by working with flash games. They seem to be a great way to confirm that I understand how the script works

    Currently I've been trying to get a basic script to work for Storm the House 2. If you haven't played the game yet, you simply click the mouse on enemies charging to a house before they reach the house. If they reach the house they will start to damage it until the house reaches 0 health left.

    This is what I've got so far:

    EDIT: If it helps (I don't think it really makes a difference, expect for some coordinates) I'm playing the game off of addicting games instead of armor games or any other site hosting this one)

    Code:
    program StormTheHouse2;
    
    procedure StartGame;
    begin
      MoveMouse(89, 201);
      ClickMouse(89, 201, 1);
      Wait(500)
      MoveMouse(431, 290);
      ClickMouse(89, 201, 1);
    end;
    
    procedure StormHouse;
    var
      x, y:Integer;
    begin
      if FindColorSpiralTolerance(x, y, 10066329, 0, 40, 470, 380, 1) or
         FindColorSpiralTolerance(x, y, 13421772, 0, 40, 470, 380, 1) Then
      begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(900);
      end;
    end;
    
    
    
    
    
    begin
      StartGame;
      repeat
        StormHouse;
      until(false);
    end.
    So my question is, I want it to repeat the moving and clicking mouse until it's shot 7 times (you start with a gun that has only 7 bullets). Then I want it to press the space bar (which will reload the gun). How would I go about doing this?

    As far as I'm aware I'd have to add something after the Wait after ClickMouse to tell the script to repeat that part 7 times and then hit the space bar, then wait, then repeat the entire thing all over again. (PLEASE CORRECT ME IF I'M WRONG).

    Just need anyone with any knowledge of scripting to tell me how I can have my script repeat a certain section:
    Code:
     begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(900);
      end;
    7 times, and then make it hit the space bar and repeat all of that over again.

    Thanks! Sorry if I've confused anyone!


    EDIT 2: So I just added this to the script:

    Code:
    procedure Reload;
    begin
      SendKeys(' ',100);
      Wait(3000);
    end;
    Which ends up doing what I want, somewhat. The only problem is that the entire script will wait those three seconds, then repeat because I have the end of the script like this:
    Code:
    begin
      StartGame;
      repeat
        StormHouse;
        Reload;
      until(false);
    end.
    And when I make the end like this:
    Code:
    begin
      StartGame;
      repeat
        StormHouse;
      until(false);
      repeat
        Reload;
      until(false);
    end.
    It doesn't reload.

    So now I'm just looking for a better way to rewrite what I added so it ONLY presses the space bar after it's clicked 7 times, rather than typing it in intervals.
    Last edited by Roflme; 04-21-2012 at 05:37 PM.

  2. #2
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Simba Code:
    var
     i:Integer;
    for i := 0 to 6 do //Starts at 0
    begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(900);
    end;
    //Space bar code here

  3. #3
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Simba Code:
    var
     i:Integer;
    for i := 0 to 6 do //Starts at 0
    begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(900);
    end;
    //Space bar code here
    Something like this?
    Simba Code:
    begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(1200);
      end;
      SendKeys(' ',100);
    end;

    I'll test this after I grab my lunch

  4. #4
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Remember the for loop though.

  5. #5
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Simba Code:
    procedure StormHouse;
    var
      x, y:Integer;
      Click:Integer;
    begin
      if FindColorSpiralTolerance(x, y, 10066329, 0, 40, 470, 380, 1) or
         FindColorSpiralTolerance(x, y, 13421772, 0, 40, 470, 380, 1) Then
      for Click:=0 to 6 do
      begin
        repeat
          MoveMouse(x, y);
          ClickMouse(x, y, 1);
          Wait(1200);
          Inc(Click);
        until (Click=7)
        if (Click = 7) then
        begin
          SendKeys(' ', 100);
        end;
      end;
    end;

    I'm still a little confused. AND I think I messed up. I don't fully understand how to use loops

    Right now it will click 7 times and then reload, but the problem is that once it moves to coordinates where an enemy was, it will stay at those coordinates and shoot the air until it's shot 7 times. Then it will reload, target another enemy, and shoot 7 times there. I'm about to try to add another repeat and see if that works unless a better solution is known?


    EDIT: So it seems when there isn't anything on the screen it will wait. Once another enemy shows up it will target them and leave the reticle in that position for all the clicks. Why does my script stop trying to find the new x,y integer and why will it click 7 times instead of only once?

    The full script up to now:

    Simba Code:
    program StormTheHouse2;

    procedure StartGame;
    begin
      MoveMouse(89, 201);
      ClickMouse(89, 201, 1);
      Wait(500);
      MoveMouse(431, 290);
      ClickMouse(89, 201, 1);
      Wait(500);
    end;

    procedure StormHouse;
    var
      x, y:Integer;
      Click:Integer;
    begin
      if FindColorSpiralTolerance(x, y, 10066329, 0, 40, 470, 380, 1) or
         FindColorSpiralTolerance(x, y, 13421772, 0, 40, 470, 380, 1) Then
      begin
      repeat
          MoveMouse(x, y);
          ClickMouse(x, y, 1);
          Wait(1200);
          Inc(Click);
          writeln('Clicked' + IntToStr(Click) + 'times.');
      until(Click = 7);
      if (Click = 7) then
        begin
          SendKeys(' ', 100);
        end;
      end;
    end;


    procedure StartNewRound;
    var
      x, y:Integer;
    begin
      if FindColorSpiralTolerance(x, y, 1250181, 238, 275, 386, 319, 1) Then
      begin
        MoveMouse(128, 349);
        ClickMouse(128, 349, 1);
      end;
    end;



    begin
      StartGame;
      repeat
        StormHouse;
        StartNewRound;
      until(false);
    end.
    Last edited by Roflme; 04-21-2012 at 06:55 PM.

  6. #6
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Don't put the Repeat Until inside the For loop.
    The For loop does it for you, but 7 times.
    Simba Code:
    procedure StormHouse;
    var
      x, y:Integer;
    begin
      if FindColorSpiralTolerance(x, y, 10066329, 0, 40, 470, 380, 1) or
         FindColorSpiralTolerance(x, y, 13421772, 0, 40, 470, 380, 1) Then
      for Click:=0 to 6 do
      begin
          MoveMouse(x, y);
          ClickMouse(x, y, 1);
          Wait(1200);
      end
      SendKeys(' ', 100);
    end;

  7. #7
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    AHHHH alright!

    Simba Code:
    procedure StormHouse;
    var
      x, y:Integer;
      Click:Integer;
    begin
    for Click:=0 to 6 do
      if FindColorSpiralTolerance(x, y, 10066329, 0, 40, 470, 380, 1) or
         FindColorSpiralTolerance(x, y, 13421772, 0, 40, 470, 380, 1) Then
      begin
        MoveMouse(x, y);
        ClickMouse(x, y, 1);
        Wait(1200);
        writeln('clicked ' + IntToStr(Click) + 'times.');
      end;
        SendKeys(' ', 100);
    end;

    Works but is a little buggy still.

    Thank you so much for your help!

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
  •