The Dink Network

Reply to help wanted: script bug

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
January 13th 2009, 02:32 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
While making a script for animal feed (works on only ducks thus far) I've come to a problem. When I have multiple feed piles active, the ducks won't go back to being ducks until all piles are eaten. Here's the script if anyone cares to look into it.

//Animal Feed seed

void main ()
{
//so it doesn't disappear
wait(200);
sp_brain(&current_sprite,0);
sp_que(&current_sprite,-10);

//big box for attracting animals
int &top = sp_y(&current_sprite,-1);
&top -= 40;
int &bottom = sp_y(&current_sprite,-1);
&bottom += 90;
int &left = sp_x(&current_sprite,-1);
&left -= 50;
int &right = sp_x(&current_sprite,-1);
&right += 90;

//smaller 'feeding' box
int &fleft = sp_x(&current_sprite,-1);
&fleft -= 20;
int &ftop = sp_y(&current_sprite,-1);
&ftop -= 20;
int &fright = sp_x(&current_sprite,-1);
&fright += 20;
int &fbottom = sp_y(&current_sprite,-1);
&fbottom += 20;

int &box;
int &duck;
int &dx;
int &dy;
int &count = 100;

//check for animals near feed to be attracted
duckcall:
wait(75);

&duck = get_rand_sprite_with_this_brain(3,0);
&dx = sp_x(&duck,-1);
&dy = sp_y(&duck,-1);
&box = inside_box(&dx,&dy,&left,&top,&right,&bottom);
if (&box)
{
if (sp_target(&duck,-1) == 0)
{
if sp_gold(&duck,-1) == 0)
{
//brain 9 needed for targeting
sp_brain(&duck,9);
sp_target(&duck,&current_sprite);
}
}
}

//feed depletion
&duck = get_rand_sprite_with_this_brain(9,0);
&dx = sp_x(&duck,-1);
&dy = sp_y(&duck,-1);

if (sp_target(&duck,-1) == &current_sprite)
{
&box = inside_box(&dx,&dy,&fleft,&ftop,&fright,&fbottom);
if (&box)
{
//say("<Nom>",&duck);
&count -= 1;
}
}

//it shrinks!
sp_size(&current_sprite,&count);

if (&count > 1)
goto duckcall;

//fixing brains and go back to business
&duck = 0;
reduck:
wait(25);
&duck = get_next_sprite_with_this_brain(9,0,&duck);
if (sp_target(&duck,-1) == &current_sprite)
{
//Target feed? It's a duck!
sp_brain(&duck,3);
//say("imaduck",&duck);
}
if (&duck > 0)
goto reduck;

//byebye feed
sp_active(&current_sprite,0);
sp_kill(&current_sprite,1);
}