SRL Archive - OSR Help

Need some help


DeSnob

2010-06-06 15:24:15

As usual.. dumb little Des comes here for help. This time, when trying to create my custom mmouse proc it kept moving the mouse to the same spot it started in! I looked through, adjusted things, deleted things, and switched things around to come to no result. It keeps doing the same thing! Would someone care to look over my code..and see if something is repeated? I've been looking at the same thing all day, so I can't really tell. Thanks!

WARNING: Messy and noobish coding up ahead!

procedure DMMouse(x, y: integer; speedmin, speedmax: Extended);
var
cx, cy, i: integer;
wind: Extended;
x1, x2, x3, dx: integer; //dx = distance from position to destination.
y3, dy: integer;//dy = same as above.
a, b, c: integer;//a, b, c are used to make a 15% chance of "messing" up
Moved: integer;//Counts how many times it has "moved".
begin
if speedmax = 0 then
speedmax := 0.01;
GetMousePos(cx, cy);

dx := x - cx;
if dx < 0 then
dx := cx - x;
dy := y - cy;
if dy < 0 then
dy := cy - y;
x1 := x/y;
x2 := Round(x1);
wind := 5.0;
Moved := 1;

for i:= 0 to 3 do
begin

case (Moved) of
0 :
begin
x3 := (x2*dx)/16 + cx/x2+random(10);
y3 := (x2*dy)/16 + cy/x2+random(10);
end;
1 :
begin
x3 := (x2*dx)/8 + cx/x2+random(10);
y3 := (x2*dy)/8 + cy/x2+random(10);
end;
2 :
begin
x3 := (x2*dx)/4 + cx/x2+random(10);
y3 := (x2*dy)/4 + cy/x2+random(10);
end;
3 :
begin
x3 := (x2*dx)/2 + cx/x2+random(10);
y3 := (x2*dy)/2 + cy/x2+random(10);
end;
4 :
begin
x3 := (x2*dx) + cx/x2+random(10);
y3 := (x2*dy) + cy/x2+random(10);
end;
end;

a := 0+random(150);
b := 0+random(100);
c := a / b;
if a = 0 then a := 1;
Inc(Moved);

if c < 30 then
begin
WindMouse(cx, cy, x3+random(7), y3+random(5), 9.0, wind, speedmax+random(1), speedmin+random(3), 2, 10.0);
end else
if c > 30 then
begin
if c < 40 then
begin
wind := wind + 6.0;
WindMouse(cx, cy, x3, y3, 9.0, wind, speedmax, speedmin, 2, 10.0);
end else
WindMouse(cx, cy, x3, y3, 9.0, wind, speedmax, speedmin, 2, 10.0);
end else
WindMouse(cx, cy, x3, y3, 9.0, wind, speedmax, speedmin, 2, 10.0);
end;
end;

Frement

2010-06-06 15:28:33

Did you edit the code?

Anyway, you got some problems with divide by 0 errors etc.

EDIT: Mind telling the idea of this also?

DeSnob

2010-06-06 15:50:41

From: Frement
Did you edit the code?

Anyway, you got some problems with divide by 0 errors etc.

EDIT: Mind telling the idea of this also?


No, I coded it from it from scratch.(That's why it isn't that good)

The divide by 0 errors happens in this section, that problem can be easily fixed though.
a := 0+random(150);
b := 0+random(100);

The idea of this was kinda to make the mmouse function more "humanly" If you look at it, it goes directly to the point. When does a human do that ALL the time? Whenever i see someone else move a mouse, they never actually go directly to the point. Instead, the cursor "wobbles" pretty often, and you never move the mouse in a straight line.

Sex

2010-06-06 20:47:12

No reason for 0 + random just put random.
And to solve it you can change it to either 1 + random or randomrange.