SRL Archive - Research & Development Lounge

RunAway


rotflmfwao

2007-07-15 23:21:35

A result for FindFight, it just runs away in the specified direction and runs back. You could use it as an antiban if you put RandomDir in the direction slot. (RandomDir is a func I put in another one of my Snippet threads.)
Here is RunAway:
Procedure RunAway(Dir);//Lowercase or upper, doesn't matter
Begin
Case Dir of
'n':Begin
RunTo('n',False);
Wait(1000+Random(1500));
RunTo('s',False);
End;
's':Begin
RunTo('s',False);
Wait(1000+Random(1500));
RunTo('n',False);
End;
'e':Begin
RunTo('e',False);
Wait(1000+Random(1500));
RunTo('w',False);
End;
'w':Begin
RunTo('w',False);
Wait(1000+Random(1500));
RunTo('e',False);
End;
'N':Begin
RunTo('n',False);
Wait(1000+Random(1500));
RunTo('s',False);
End;
'S':Begin
RunTo('s',False);
Wait(1000+Random(1500));
RunTo('n',False);
End;
'E':Begin
RunTo('e',False);
Wait(1000+Random(1500));
RunTo('w',False);
End;
'W':Begin
RunTo('w',False);
Wait(1000+Random(1500));
RunTo('e',False);
End;
End;
End;

I know its kinda useless, but I like it as an antifight measure XD

itSchRis917

2007-07-16 01:06:12

condensed version:

Procedure RunAway(Dir:String);//Lowercase or upper, doesn't matter
Begin
Case UpperCase(Dir) of
'n':Begin
RunTo('n',False);
Wait(1000+Random(1500));
RunTo('s',False);
End;
's':Begin
RunTo('s',False);
Wait(1000+Random(1500));
RunTo('n',False);
End;
'e':Begin
RunTo('e',False);
Wait(1000+Random(1500));
RunTo('w',False);
End;
'w':Begin
RunTo('w',False);
Wait(1000+Random(1500));
RunTo('e',False);
End;

End;
End;

Smartzkid

2007-07-16 01:23:27

Itschris, you changed the input to uppercase, but all the letters you checked for are lowercase.

Procedure RunAway(Dir:String);
Begin
Case LowerCase(Dir) of
'n':Begin
RunTo('n',False);
Wait(1000+Random(1500));
RunTo('s',False);
End;
's':Begin
RunTo('s',False);
Wait(1000+Random(1500));
RunTo('n',False);
End;
'e':Begin
RunTo('e',False);
Wait(1000+Random(1500));
RunTo('w',False);
End;
'w':Begin
RunTo('w',False);
Wait(1000+Random(1500));
RunTo('e',False);
End;
else
writeln('Invalid Input');
End;
End;

One thought: Couldn't runback work instead of runing to the opposite direction?

itSchRis917

2007-07-16 01:34:03

That's what your supposed to do..

function Uppercase(s: string): string;
Returns the specified string in upper case.

It's in the SCAR manual.

Smartzkid

2007-07-16 01:39:29

Case UpperCase(Dir) of
'n'…
's'…
'e'…
'w'…


Notice that you only checked for lowercase letters? By converting all input to uppercase, you made sure that no input could possibly work.

itSchRis917

2007-07-16 12:07:20

Ah, i see what you are seeing. My bad. ;)
I meant to use Capitalize… lol. This one works, i just tested it.

Procedure RunAway(Dir:String);//Lowercase or upper, doesn't matter
Begin
Case Capitalize(Dir) of
'N':Begin
RunTo('n',False);
Wait(1000+Random(1500));
RunTo('s',False);
End;
'S':Begin
RunTo('s',False);
Wait(1000+Random(1500));
RunTo('n',False);
End;
'E':Begin
RunTo('e',False);
Wait(1000+Random(1500));
RunTo('w',False);
End;
'W':Begin
RunTo('w',False);
Wait(1000+Random(1500));
RunTo('e',False);
End;

End;
End;

rotflmfwao

2007-07-17 15:10:48

Well that works i gueus XD, but mine worked fine….

itSchRis917

2007-07-17 15:26:19

Yea, i know yours worked fine, just condensing it. :)