PDA

View Full Version : Multiple Timers?



Wu-Tang Clan
01-21-2014, 10:42 PM
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.

Hoodz
01-21-2014, 10:46 PM
cant you just use marktime? ps: i dont know srl-6

Wu-Tang Clan
01-21-2014, 10:51 PM
cant you just use marktime? ps: i dont know srl-6

I need 6 timers working differently, can marktime do that?

King
01-21-2014, 10:56 PM
Just use a timer like normal except define them as different variables?

MarkTime(t);
MarkTime(s);
ect...

Kevin
01-21-2014, 10:58 PM
I need 6 timers working differently, can marktime do that?

Sure, just have 6 different ints for the separate timers to go through marktime.

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;

Wu-Tang Clan
01-21-2014, 11:12 PM
Sure, just have 6 different ints for the separate timers to go through marktime.

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?


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;

Hoodz
01-21-2014, 11:16 PM
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?


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 :p

King
01-21-2014, 11:17 PM
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?


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;







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;

rj
01-21-2014, 11:23 PM
Wu-Tang Clan;

Could be shortened using arrays.
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

Ashaman88
01-21-2014, 11:29 PM
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

The Mayor
01-21-2014, 11:31 PM
There is no markTime in SRL6 (afaik)

E: Actually Spartan 117 posted this yesterday, might help?

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

Kevin
01-21-2014, 11:41 PM
There is no markTime in SRL6 (afaik)

GetSystemTime should still be a thing, like I used :p

Ashaman88
01-21-2014, 11:51 PM
T: TTimeMarker;


T.Start;
T.GetTime;

Wu-Tang Clan
01-22-2014, 12:25 AM
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.

bonsai
01-22-2014, 09:36 AM
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.

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;

Wu-Tang Clan
01-24-2014, 02:59 AM
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.

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;




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

Ashaman88
01-24-2014, 03:05 AM
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

bonsai
01-24-2014, 07:44 AM
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:

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.

Spartan 117
01-24-2014, 08:27 AM
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.

Wu-Tang Clan
01-24-2014, 02:49 PM
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?

Spartan 117
01-24-2014, 04:06 PM
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.

Wu-Tang Clan
01-25-2014, 03:18 PM
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.

Spartan 117
01-25-2014, 08:09 PM
Sweet. Can't wait to try it out!