SRL Archive - Research & Development Lounge

HoldArrows


Derek-

2008-01-12 14:43:54

I noticed that I couldn't find a function to hold down more than one arrow key at once.
Cuz' a lot of times in real life I hold down more than one arrow key :p

Didn't know if there is one of these already or not but I couldn't find one..
So I made some arrow using procedures :)

Remember that just like in the SCAR functions:
[INDENT] 0 = UP
1 = RIGHT
2 = DOWN
3 = LEFT[/INDENT]

Procedure HoldArrowKeys(Arrows: TIntegerArray; Time: Integer);
{will hold all ARROWS simultaneously for amount of TIME in milliseconds
0 = UP
1 = RIGHT
2 = DOWN
3 = LEFT }
var
i : Integer;
begin
for i := 0 to High(Arrows) do
begin
if (Arrows[i] = 3) then IncEx(Arrows[i], 34) else
IncEx(Arrows[i], 38);
KeyDown(Arrows[i]);
end;
Wait(Time);
for i := 0 to High(Arrows) do
KeyUp(Arrows[i]);
end;



Procedure RotateCamera(Limited: Boolean);
//randomly rotates camera angle
var
Rand : Integer;
begin
if Limited then Rand := 4
else Rand := 8;
Case Random(Rand) of
0 : HoldArrowKeys([0, 1], RandomRange(953, 1463)); //up-right
1 : HoldArrowKeys([0, 3], RandomRange(953, 1463)); //up-left
2 : HoldArrowKeys([1, 2], RandomRange(953, 1463)); //down-right
3 : HoldArrowKeys([2, 3], RandomRange(953, 1463)); //down-left

4 : HoldArrowKeys([0], RandomRange(953, 1463)); //up
5 : HoldArrowKeys([1], RandomRange(953, 1463)); //right
6 : HoldArrowKeys([2], RandomRange(953, 1463)); //down
7 : HoldArrowKeys([3], RandomRange(953, 1463)); //left
end;
end;
EXAMPLES:

begin
HoldArrowKeys([0, 1], 1000);
//will hold up and right arrows for 1 second
HoldArrowKeys([2, 3], 1000);
//will hold down and left arrows for 1 second

RotateCamera(True);
//randomly moves camera angle using ONLY "double" arrows (more than one)
RotateCamera(False)
//randomly moves camera angle using BOTH "double" or "single" arrows
end.

:):)

Raskolnikov

2008-01-12 14:54:01

I like this function. Simple but effective :D

Negaal

2008-01-13 05:41:46

Duh nice one…just planned to make obj finder what changes camera angle while moving pointer to object…but how should I do that?

KeyDown(X);
MMouse
KeyUp(X)

?

Too complicated for me

:p

n3ss3s

2008-01-13 11:01:47


KeyDown(X);
MMouse
KeyUp(X)


I've made it once, though I don't think it was very complicated, but it isn't accurate/good enough for moving mouse to an object - I built it for antiban purposes.

Anyways, if you want to look at it, search for "CompassMMouse".

King of Knives

2008-01-13 11:09:27

KeyUp and KeyDown with numbers don't always work that well. But these do:

KeyDown(VK_UP)
KeyDown(VK_DOWN)
KeyDown(VK_LEFT)
KeyDown(VK_RIGHT)
That way, you should also be able to hold 2 at the same time.

-Knives

Derek-

2008-01-13 14:55:37

From: King of Knives
KeyUp and KeyDown with numbers don't always work that well. But these do:

KeyDown(VK_UP)
KeyDown(VK_DOWN)
KeyDown(VK_LEFT)
KeyDown(VK_RIGHT)
That way, you should also be able to hold 2 at the same time.

-Knives

I originally had those.. :)
But I changed it