PDA

View Full Version : RunAway



rotflmfwao
07-16-2007, 03:21 AM
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
07-16-2007, 05:06 AM
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
07-16-2007, 05:23 AM
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
07-16-2007, 05:34 AM
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
07-16-2007, 05:39 AM
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
07-16-2007, 04:07 PM
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
07-17-2007, 07:10 PM
Well that works i gueus XD, but mine worked fine....

itSchRis917
07-17-2007, 07:26 PM
Yea, i know yours worked fine, just condensing it. :)