Results 1 to 23 of 23

Thread: Multiple Timers?

  1. #1
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default Multiple Timers?

    I'm working on a cavefighter bot and I need to set up timers for the abilities. Is there a function to set up a timer and have multiple timers run at the same time? Thanks.
    You have permission to steal anything I've ever made...

  2. #2
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    cant you just use marktime? ps: i dont know srl-6

  3. #3
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    cant you just use marktime? ps: i dont know srl-6
    I need 6 timers working differently, can marktime do that?
    You have permission to steal anything I've ever made...

  4. #4
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Just use a timer like normal except define them as different variables?

    Simba Code:
    MarkTime(t);
    MarkTime(s);
    ect...

  5. #5
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by Wu-Tang Clan View Post
    I need 6 timers working differently, can marktime do that?
    Sure, just have 6 different ints for the separate timers to go through marktime.

    Simba Code:
    procedure MarkTime(var time: integer);//this is what the actual marktime does
    begin
      time:= GetSystemTime();
    end;

    var
      time1, time2, time3, time4: integer;

    begin
      MarkTime(time1);
      //other code
      MarkTime(time2);
      //Now both time1 and time2 are representative of their current times as of the mark.
      //Use TimeFromMark(integer); to determine how long has passed since the mark.
    end;

  6. #6
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by Kevin View Post
    Sure, just have 6 different ints for the separate timers to go through marktime.

    Simba Code:
    procedure MarkTime(var time: integer);//this is what the actual marktime does
    begin
      time:= GetSystemTime();
    end;

    var
      time1, time2, time3, time4: integer;

    begin
      MarkTime(time1);
      //other code
      MarkTime(time2);
      //Now both time1 and time2 are representative of their current times as of the mark.
      //Use TimeFromMark(integer); to determine how long has passed since the mark.
    end;
    I utterly butchered this because I did it fast, but is this in the ballpark of what it should look like?
    How do I get them all to work at once so that if 15 seconds passed for the other one before 10 passed for the other it will use the 15 second one?

    Simba Code:
    procedure UseAbility;
    var
      time1, time2, time3, time4, time5, time6: integer;
    begin
      MarkTime(time1);
      MarkTime(time2);
      MarkTime(time3);
      MarkTime(time4);
      MarkTime(time5);
      MarkTime(time6);

          if TimeFromMark(3000) then
            begin
              mouseBox(actionBar.getSlotBox(1),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(2),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(3),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(4),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(5),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(6),MOUSE_RIGHT,MOUSE_HUMAN);
            end;
    end;
    You have permission to steal anything I've ever made...

  7. #7
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Wu-Tang Clan View Post
    I utterly butchered this because I did it fast, but is this in the ballpark of what it should look like?
    How do I get them all to work at once so that if 15 seconds passed for the other one before 10 passed for the other it will use the 15 second one?

    Simba Code:
    procedure UseAbility;
    var
      time1, time2, time3, time4, time5, time6: integer;
    begin
      MarkTime(time1);
      MarkTime(time2);
      MarkTime(time3);
      MarkTime(time4);
      MarkTime(time5);
      MarkTime(time6);

          if TimeFromMark(3000) then
            begin
              mouseBox(actionBar.getSlotBox(1),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(2),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(3),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(4),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(5),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(6),MOUSE_RIGHT,MOUSE_HUMAN);
            end;
    end;
    Use it like this: if timefrommark(timer1) > 3000 then...

    Edit: dont have simba on my phone so i cant send everything to you

  8. #8
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Wu-Tang Clan View Post
    I utterly butchered this because I did it fast, but is this in the ballpark of what it should look like?
    How do I get them all to work at once so that if 15 seconds passed for the other one before 10 passed for the other it will use the 15 second one?

    Simba Code:
    procedure UseAbility;
    var
      time1, time2, time3, time4, time5, time6: integer;
    begin
      MarkTime(time1);
      MarkTime(time2);
      MarkTime(time3);
      MarkTime(time4);
      MarkTime(time5);
      MarkTime(time6);

          if TimeFromMark(3000) then
            begin
              mouseBox(actionBar.getSlotBox(1),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(2),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(3),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(4),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(5),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(6),MOUSE_RIGHT,MOUSE_HUMAN);
            end;
    end;




    Simba Code:
    procedure UseAbility;
    var
      time1, time2, time3, time4, time5, time6: integer;
    begin
      MarkTime(time1);
      MarkTime(time2);
      MarkTime(time3);
      MarkTime(time4);
      MarkTime(time5);
      MarkTime(time6);

          if (TimeFromMark(time1) >= 3000) then // Do them like this. You call the timer you set.
            begin
              mouseBox(actionBar.getSlotBox(1),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(2),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(3),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(4),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(10000) then
            begin
              mouseBox(actionBar.getSlotBox(5),MOUSE_RIGHT,MOUSE_HUMAN);
            end;

          if TimeFromMark(15000) then
            begin
              mouseBox(actionBar.getSlotBox(6),MOUSE_RIGHT,MOUSE_HUMAN);
            end;
    end;

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    @Wu-Tang Clan;

    Could be shortened using arrays.
    Simba Code:
    procedure useAbility;
    var
      Timers, cooldowns:TIntegerarray;
      i:integer;
    begin
      cooldowns := [3000, 15000, 10000, 15000, 10000, 15000];
      setLength(timers, 6);
      for i := 0 to high(timers) do
        marktime(timers[i]);
      for i := 0 to high(timers) do
        if (timeFromMark(timers[i]) > cooldowns[i]) then
          mouseBox(actionBar.getSlotBox(1 + (1 * i)),MOUSE_RIGHT,MOUSE_HUMAN);
    end;


    Timers should probably be global though.t

  10. #10
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Look at bonsai's fighter. You should be able to use the include to get the ability cooldown and know when to use the ability from that instead of this way...If I'm understanding it correctly

  11. #11
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  12. #12
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    There is no markTime in SRL6 (afaik)
    GetSystemTime should still be a thing, like I used

  13. #13
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

  14. #14
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Thanks for all the help guys, but I have 2 exams to study for so I'm going to put the script on hold for 2 days and bot penguins instead. I'll return to this in 2 days.
    You have permission to steal anything I've ever made...

  15. #15
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Look at bonsai's fighter. You should be able to use the include to get the ability cooldown and know when to use the ability from that instead of this way...If I'm understanding it correctly
    This is the function so you don't have to hunt around.

    The getAbilityCooldown() function is a little buggy but it's fairly reliable about returning 1 or 100 when the ability is ok to select.

    Simba Code:
    procedure Tnpc._doAbilities();

    var
       i, pct: integer;
       keyStr: string;
       
    begin
       for i := (ACTION_BAR_SLOT_HIGH - 2) downto 1 do
       begin
          pct := actionBar.getAbilityCooldown(i);
          {$IFDEF DEBUG_ON}
             writeln('***** Tnpc._doAbilities: ability[', i, '] returned cooldown ', pct);
          {$ENDIF}
          if ((pct = 1) or (pct = 100)) then
          begin
             case i of
                0..9:    keyStr := intToStr(i);
                10:      keyStr := '0';
                11:      keyStr := '-';
                12:      keyStr := '=';
             end;
         
             SendKeys(keyStr[1], 60 + Random(60), 60 + Random(60));

             {$IFDEF DEBUG_ON}
                writeln('***** Tnpc._doAbilities: activated ability[', i, ']');
             {$ENDIF}
             exit;  // only do one ability
          end;
       end;
    end;

  16. #16
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    T: TTimeMarker;


    T.Start;
    T.GetTime;
    How would I get this to work with action bars though? I tried using more than one but they end up resetting and stuff.
    Simba Code:
    procedure useAbility;
    var
      A: TTimeMarker;
      B: TTimeMarker;
      C: TTimeMarker;
      D: TTimeMarker;
      E: TTimeMarker;
      F: TTimeMarker;
    begin
      A.Start;
      B.Start;
      C.Start;
      D.Start;
      E.Start;
      F.Start;
      A.GetTime;
      if (A.GetTime < 5000) then
        begin
          Writeln('A: ' +IntToStr (A.GetTime));
        end;
    end;

    Code:
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    A: 0
    You have permission to steal anything I've ever made...

  17. #17
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Well you are starting the timer and immediately calling get time... It's a local variable so it gets reset every time you leave that procedure... yeah.

    But regardless you shouldn't be using timers - you should use the include like @bonsai; said above

  18. #18
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Your problem here is putting the timer as a local variable and not giving it any chance to accumulate time. I reorganized and added parens to the function calls:

    Simba Code:
    program new;
    {$i srl-6/srl.simba}

    var
      A: TTimeMarker;
      B: TTimeMarker;
      C: TTimeMarker;
      D: TTimeMarker;
      E: TTimeMarker;
      F: TTimeMarker;

    procedure useAbility();
    begin
      Writeln('A: ' +IntToStr (A.GetTime()));
    end;

    begin
      A.Start();
      B.Start();
      C.Start();
      D.Start();
      E.Start();
      F.Start();
      while (true) do
      begin
        useAbility();
      end;
    end.

  19. #19
    Join Date
    Dec 2011
    Location
    Lubbock, Texas
    Posts
    225
    Mentioned
    3 Post(s)
    Quoted
    93 Post(s)

    Default

    http://villavu.com/forum/showthread.php?t=107690

    I'm sure you saw Mayor posted this already, but I just wanted to comment on it to see if it may be right for you. It finds the best ability (basic being worst, ultimate begin best) that is ready to use. I have watched in action for probably around 6-10 hours now. I have found that it is actually pretty fast for not using timers or being ready for the ability to be ready (if that makes any sense). There is close to no delay between when the ability is ready and when it is clicked. I never use any ammo unless I'm eating. It may or may not be right for your situation, but I think it could help simplify things.
    Previously known as grahambr*SigPic compliments of Clarity
    Spartan Scripts

    Scripts: AutoPlankMake **** AIOEdgeSmelter

  20. #20
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by Spartan 117 View Post
    http://villavu.com/forum/showthread.php?t=107690

    I'm sure you saw Mayor posted this already, but I just wanted to comment on it to see if it may be right for you. It finds the best ability (basic being worst, ultimate begin best) that is ready to use. I have watched in action for probably around 6-10 hours now. I have found that it is actually pretty fast for not using timers or being ready for the ability to be ready (if that makes any sense). There is close to no delay between when the ability is ready and when it is clicked. I never use any ammo unless I'm eating. It may or may not be right for your situation, but I think it could help simplify things.
    I tried it out but it doesn't do anything is there any more code to it? I added const and everything but it just doesn't seem to use the abilities. I think the problem lies in getcooldown because I tried that alone and it doesn't return anything.

    EDIT: F*** YEAH IT WORKS LIKE A F***ING CHARM!
    Breh your my breh. The Wutang is strong with this one. We should keep him.

    EDTI2: Is there a way to randomize the clicking by once in a while using sendkey and then clicking the next one?
    You have permission to steal anything I've ever made...

  21. #21
    Join Date
    Dec 2011
    Location
    Lubbock, Texas
    Posts
    225
    Mentioned
    3 Post(s)
    Quoted
    93 Post(s)

    Default

    You could use a switch of like case(random(5)) of 0..1 click and 2..4 send key for the ability. That would be a pretty good addition.

    EDIT: @Wu-Tang Clan I have edited the snippet I posted that I linked earlier. I included randomly sending the key or clicking on the slot. I tested it and still works fast and great with the new addition! when the wait times are removed it's hella fast. I put those in there for some added human-likeness.
    Last edited by Spartan 117; 01-25-2014 at 09:27 AM.
    Previously known as grahambr*SigPic compliments of Clarity
    Spartan Scripts

    Scripts: AutoPlankMake **** AIOEdgeSmelter

  22. #22
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by Spartan 117 View Post
    You could use a switch of like case(random(5)) of 0..1 click and 2..4 send key for the ability. That would be a pretty good addition.

    EDIT: @Wu-Tang Clan I have edited the snippet I posted that I linked earlier. I included randomly sending the key or clicking on the slot. I tested it and still works fast and great with the new addition! when the wait times are removed it's hella fast. I put those in there for some added human-likeness.
    Alright man! Thanks for that. I'll be sure to add that. Right now the script is going pretty smoothly and should be out in about a week.
    You have permission to steal anything I've ever made...

  23. #23
    Join Date
    Dec 2011
    Location
    Lubbock, Texas
    Posts
    225
    Mentioned
    3 Post(s)
    Quoted
    93 Post(s)

    Default

    Sweet. Can't wait to try it out!
    Previously known as grahambr*SigPic compliments of Clarity
    Spartan Scripts

    Scripts: AutoPlankMake **** AIOEdgeSmelter

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
  •