SRL Archive - First Scripts

[BETA] SeanJohn's ChickenKiler


SeanJohn

2010-04-04 22:44:35

So here is my first script that I am posting. I've made multiple little examples ones by following the tutorials posted on these forums, but none were close to this, and this is nowhere close to done.

Anyways the basis of the script is simply a Chicken Killer. That is all it does. It is still only _v.01 and by the end of this project I hope to have something of good quality enough to apply for membership.

Things that I will add once I get there include:
[ ] Feather Picking
[ ] Feather / Chicken Counting
[ ] Better, much better, Chicken Finding / Attacking
[ ] Improved use of TPAs and ATPAs.

Eventually this script will be the basis for a Multi-Fighter of my own.

Any ideas anyone has to improve or add to it, please feel free to express them.

_v.02 - - Added basic TPA / ATPA use. Altered WhileFight and AttackChicken procedures/functions, added a few more failsafes. Still looking for a guide or tutorial or someone that can give me a push in the right direction in the Find/fight/in fighting chicken areas.

i luffs yeww

2010-04-04 22:57:22


x := MSCX;
y := MSCY;

Why do that? You're just changing those variables right after. You don't need to set them at all. ;)

You don't need ActivateClient, as SMART will be the client no matter what. (Sorry I can't explain it very well, but you don't need it. :p)


ChooseOption('Attack Chicken');

You should do


ChooseOption('ack');

For a couple reasons. One, capital letters take longer than lowercase letters, two, there's much more chance that something will be misread with such a long string, and three, it will take long for a string that long in general. ;)

I'm excited to see how you add all those extra things. ^^

Well actually, you're using CTS(2), which I would suggest CTS(0) or CTS(1). Probably CTS(1), and the reason for that is because CTS(2) takes the longest, while being the most accurate, isn't really needed for a chicken killer. If, however, you added bone/feather support, it might be necessary so you don't get things mixed up. Just a suggestion.

(And I don't know how much it (CTS(2) vs CTS(1)/CTS(0)) affects the time, but you might want to try it out. :))

(Also, if you're checking the reds/browns from the chickens rather than the white (still thinking about a few years ago when all chickens looked the same :p), then CTS(1) will definitely suffice.)

Infantry001

2010-04-04 23:01:40

From: i luffs yeww

x := MSCX;
y := MSCY;

Why do that? You're just changing those variables right after. You don't need to set them at all. ;)


Actually, because he's using those variables in conjunction with FindColorSpiralTolerance, setting them as the Main Screen Center will start the search from the center, spiraling outward. If they were still undefined (and therefore defaulted to 0), the search would start at (0,0), spiraling outwards. ;)

Awkwardsaw

2010-04-04 23:02:12

cts2 is better than 1-0. :) it may be slower, but its really not noticeable, and and accuracy makes up for it anyways

also, although its not nessessary, you can change your declareplayers from


Players[0].Name :=''; // First Player's login information.
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active := True;

to
  with players[0] do
begin
Name :=''; // First Player's login information.
Pass :='';
Nick :='';
Active := True;
end;

it just looks nicer, and better standards tbh.

speaking of standards, begins arent double spaced after if-thens,


if this then
begin
writeln('yay');
dothis;
end;

should be


if this then
begin
writeln('yay');
dothis;
end;

i luffs yeww

2010-04-04 23:07:33

Hm. I always thought it was a noticeable difference. :p I was thinking it would be better to use CTS(1) because the chickens move and he doesn't want to waste time and misclick. He has no failsafe for that.

And Infantry, that's not true. He sets x to 259 and y to 170. That's all fine and dandy, but in the search he doesn't use x or y. The first two parameters of FindColorSpiralTolerance are variables, which are what get set to the x and y of the color found.

Infantry001

2010-04-04 23:40:35

From: i luffs yeww
And Infantry, that's not true. He sets x to 259 and y to 170. That's all fine and dandy, but in the search he doesn't use x or y. The first two parameters of FindColorSpiralTolerance are variables, which are what get set to the x and y of the color found.


Yes, they are variables that return the x and y coordinate of the color found. But their initial values are also taken into account by FindColorSpiralTolerance, and those initial values are the "center" of the spiral search. If you don't believe me, you can take a look at the function description in the SCAR manual or something ;)

i luffs yeww

2010-04-04 23:48:59

If those are taken into account then what would xs, ys, xe, and ye be used for? :/ I'm 99% sure I'm right.

Infantry001

2010-04-05 00:20:23

From: SCAR Manual
function FindColorSpiral(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
Find color in box specified by xs, ys, xe, ye but start from x,y.

function FindColorSpiralTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean;
Works like the regular FindColorSpiral but with a tolerance parameter for finding any similar color. Tolerance is used to find a color in range of the color you are looking for. The greater color range you want, the higher the tolerance parameter should be.


Well… ;)

SeanJohn

2010-04-06 19:08:30

Updated. Check first post.

Bionicle

2010-04-06 19:39:48

LOL posted this in the wrong thread by accident ^.^

Neway..

First thing i saw:
   Time := GetSystemTime;
TimeOut := (1000 + Random(2000));
while not InFight and (TimeFromMark(Time) < TimeOut) do
I don't use GetSystemTime, i usually use MarkTime, but I am next to positive you need to do:
   Time := GetSystemTime;
TimeOut := (1000 + Random(2000));
while not InFight and ((GetSystemTime - TimeFromMark(Time)) < TimeOut) do
or if you want to use MarkTime:
   MarkTime(Time);
TimeOut := (1000 + Random(2000));
while not InFight and ((GetSystemTime - TimeFromMark(Time)) < TimeOut) do

Also line 102 and 221 should have random in the Wait procedure.
Can't wait to see the rest of this script! Good luck!

@I Luffs Yeww: x, y are the return points, and xe, ye, xs, ys are the box points to look in. He is just getting the points returned to MSCX and MSCY instead of x and y.

Infantry001

2010-04-06 21:23:07

I think it would be:

   Time := GetSystemTime;
TimeOut := (1000 + Random(2000));
while not InFight and ((GetSystemTime - Time) < TimeOut) do

or:

   MarkTime(Time);
TimeOut := (1000 + Random(2000));
while not InFight and ((TimeFromMark(Time)) < TimeOut) do

If you look through the TimeFromMark and MarkTime procedures, you'll find that TimeFromMark actually does GetSystemTime - [Insert Mark Here].

Moral of the story, SeanJohn, is that one can learn a lot from looking at manuals and source code ;)

Sorry I'm just sorta correcting things here and not providing any constructive criticism :/

i luffs yeww

2010-04-06 21:30:05

Wait. :p Bionicle, you're agreeing with me to some extent, but disagreeing with Infantry.

Bionicle

2010-04-06 21:33:00

From: i luffs yeww
Wait. :p Bionicle, you're agreeing with me to some extent, but disagreeing with Infantry.


Lol i don't even know what I'm saying :p

@ Infantry, yea i forgot that you didn't need TimeFromMark using GetSystemTime :p

Infantry001

2010-04-06 23:24:57

Yeah, no prob. I'm just lurking around, trying to help XD

aran armath

2010-04-26 18:29:33

ChooseOptionMulti(['ttack', 'ack', 'ttac']);

Or

WaitOption('tack', 2000);

Instead of

ChooseOption('tack');

Just a suggestion. Then if I remember right, the script called "feathers", was an excellent chicken fighter, and I am sure you could check it out for how to pickup feathers.

Raskolnikov

2010-04-30 20:56:56

From: aran armath
ChooseOptionMulti(['ttack', 'ack', 'ttac']);

Or

WaitOption('tack', 2000);

Instead of

ChooseOption('tack');

Just a suggestion. Then if I remember right, the script called "feathers", was an excellent chicken fighter, and I am sure you could check it out for how to pickup feathers.


called "forefeathers" by munk. Personally, one of the greatest scripts of a all time. Got 2 week long progress reports. I recommend it highly. (offtopic)

A couple of suggestions


for i := 0 to h do
begin
Writeln('Length: ' + IntToStr(Length(ATPA[i])));
MiddleTPAEx(ATPA[i],x,y);
MMouse(x,y,0,0);
if WaitUpText('tack',300) then
begin
Writeln('Found Chicken!');
Mouse(x,y,0,0,False);
ChooseOption('tack');
Result := True;
WhileFight;
end else
Writeln('Could not find the right uptext.');
Result := False;
end;

from the for to do and begin, no indentation needed, for example


for i:=0 to 3 do
begin
//code
end;

//or

if Something then
begin
//code
end;

I hate to nitpick, that stuff just bugs me.
Another thing, add multiplayer. The script runner has the option to add multiple players, but it won't go to the next player.
hint for members: If you add multiplayer and maybe some DTM finding, you can definitely get into members.