pija
2013-03-09 18:44:16
Here is a procedure I made, let me know what you think and if you detect any problem/bad practice.
I had a really tough time into structuring this procedure to add randomness without ever desynching the flicking, this is what I came up with.
I have commented the MouseBox and TabInventoryTab procedures because it is still up to the scripter's responsibility to set those up timely, they are better called outside the function in order not to mess up the timing.
Also, commented debug lines in brackets. TICK is a constant and has a value of 600, monster speed is a constant or variable that stores the attack speed of the monster, 4 for bloodvelds, 5 for mountain trolls. InCombat should be a function that returns true if the user is in combat.
This looks very bad, I would appreciate any better ideas.
procedure MeleeFlick(firstwait:integer);
var
desynch,des1,des2,waittime1,waittime2,randomwait1,randomwait2: integer;
begin
waittime2:= TICK
waittime1:= TICK*MSPEED;
randomwait1:= waittime1;
randomwait2:= waittime2;
des1:= 0;
desynch:=0;
writeln('Flicking');
//P07_TabInventoryTab(6)
//P07_MouseBox(669, 357, 690, 379, mouse_left);
wait(firstwait*TICK)
repeat
begin
//calculates the second waiting time
des2:= randomrange(-100,100)-desynch;
randomwait2:= waittime2+des2;
//calculates the first waiting time
des1:= random(200);
randomwait1:= waittime1-randomwait2+des1;
//actual clicking business
ClickMouse2(mouse_left);
{writeln(IntToStr(randomwait1));}
wait(randomwait2);
ClickMouse2(mouse_left);
{writeln(IntToStr(randomwait2));}
{writeln(IntToStr(randomwait1+randomwait2));}
desynch:= desynch-(2400-randomwait1-randomwait2);
{writeln(IntToStr(desynch));}
wait(randomwait1);
//randomwait is called last so there is no waiting the first time in the loop
end;
until (not InCombat)
I had a really tough time into structuring this procedure to add randomness without ever desynching the flicking, this is what I came up with.
I have commented the MouseBox and TabInventoryTab procedures because it is still up to the scripter's responsibility to set those up timely, they are better called outside the function in order not to mess up the timing.
Also, commented debug lines in brackets. TICK is a constant and has a value of 600, monster speed is a constant or variable that stores the attack speed of the monster, 4 for bloodvelds, 5 for mountain trolls. InCombat should be a function that returns true if the user is in combat.
This looks very bad, I would appreciate any better ideas.