The Dink Network

Need help with a duck script

September 14th 2007, 03:29 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
I'm making a script for a special duck. When you hit the duck, the speed increases by 1. But, after hitting it about 5 times, I want Dink to chase the duck around the screen about once or twice. I just can't get it right, so, I was wondering if anyone here could help me?
September 14th 2007, 04:54 AM
duckdie.gif
That doesn't sound like too hard to do. Do you wish to script a full cutscene with move lines or do you wish to let the engine handle the chasing? Also, should Dink eventually catch/destroy/hit/whatever the duck or just give up?
September 14th 2007, 05:12 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Well, sometimes, Dink will be above the duck, and when they start runing around the screen, Dink will be running just above the duck, not behind him like I want him to.

"Do you wish to script a full cutscene with move lines or do you wish to let the engine handle the chasing?"

Whichever is easiest.

"Also, should Dink eventually catch/destroy/hit/whatever the duck or just give up?"

Well, Dink will end up just behind the duck, then the duck will call for it's Mama. After that I have a short cut-scene I've already worked out.
September 14th 2007, 05:24 AM
duckdie.gif
Whichever is easiest.

*scratches head* Well, for what you want to do, I'm guessing the best way to do it would be with move and/or move_stop lines for Dink and the duck. You might have to use sp_x and sp_y to make it work exactly the way you want to though... If you really want Dink to be just above the duck (i.e., their x values would be the same, only the y values would differ), you'd have to check the duck's x value to make Dink's be the same (with move), and you'd have to make the duck start running quickly almost at the same time, and Dink would start chasing after it (down the screen I suppose, if he's always above it) soon after. Use wait lines for synchronisation.
September 14th 2007, 05:33 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
No, I don't want Dink to be above the duck. I want Dink to be in line with the duck. So, give me an example. Say I want Dink and the duck to be at X 250. So, the duck is in position X = 250, but say Dink is X = 230. Dink hits the duck, and they begin the chase. What would I do to make them line up?
September 14th 2007, 05:39 AM
duckdie.gif
Whoops. Sorry about that.

Tell ya what, I'll make an example script as soon as possible and post it.

(Which way should they be running though? Upwards? Should they change direction or just run straight?)
September 14th 2007, 05:43 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
They run around the screen once or twice. I guess you could just make them move to a certain X positiong near the bottom then move to the left, then up, then right, then down, etc.
September 14th 2007, 05:47 AM
duckdie.gif
Oh, that.Check back in an hour or so, it should be more than ready by then. I just have to take care of a few things first, and then I'm on it.
September 14th 2007, 07:12 AM
duckdie.gif
Urg. I'm an idiot. I had completely forgotten that Dink and the duck can be just about anywhere on the screen when the cutscene starts. I'm still going to do it, though - I'm basically going to have the chase start in the screen's lower half if Dink and the duck are currently in the upper half, and so on. Something like that. It'll take a bit more time, but at the very worst, it should be ready by the end of the day, unless I suck totally and utterly.
September 14th 2007, 08:33 AM
pq_cthunik.gif
GOKUSSJ6
Peasant He/Him Poland
Everyone should get a pizza for free in each week. 
DD95 maybe try to do this.

void main(void)
{
int &duck = create_sprite(250, 150, 3, 21, 1);
sp_speed(&duck, 1);
sp_base_walk(&duck, 20);
sp_script(&duck, "duck");
}

the duck script:

void main(void)
{
int &duckx = sp_x(&current_sprite, -1);
int &ducky = sp_y(&current_sprite, -1);
}
void hit(void)
{
sp_speed(&current_sprite, 5);
move_stop(1, 4, &duckx, 1);
move_stop(1, 6, &duckx, 1);
move_stop(1, 8, &ducky, 1);
move_stop(1, 2, &ducky, 1);
}
September 14th 2007, 09:40 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Well, I think the easiest way to do it is this:
Duck script:

void main(void)
{
int &speed = 1;
sp_speed(&current_sprite,&speed);
}
void hit(void)
{
&speed += 1;
if (&speed <= 5)
{
sp_speed(&current_sprite,&speed);
}
if (&speed >= 6)
{
freeze(1);
set_smooth_follow(1);
//set_smooth_follow isn't neccessary,
//but it might make it look more pretty.
sp_follow(1,&current_sprite);
//Move around the duck as much as you want here
unfreeze(1);
}
}
September 14th 2007, 02:58 PM
duckdie.gif
Well, since my script won't be ready before tomorrow, DD95 can use metatarasal's in the meantime.

While I'm at it, I've set the duck's brain to 3 and its hitpoints to 0 (so it doesn't lose its head) but I'm using a blood script from CC2 that makes the duck bleed when you hit it. You can remove it if you wish - it's just a little extra.
September 14th 2007, 07:24 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Thanks metatarasl, that looks like it should do.

And Ducklord, don't give up. I'd like the bleeding thing.
September 15th 2007, 06:42 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
If there is any hardness on the screen where Dink chases the duck (i.e. trees, hills, water), you'll need to be careful that Dink doesn't get 'stuck' anywhere.
September 16th 2007, 02:35 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Well, there's no water, neither are there any hills. But I haven't thought of trees yet. Is there any way to make Dink or the duck go in an opposite direction if he hits hardness, though?
September 16th 2007, 02:39 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Or you could use the script, watch where Dink goes while he chases the duck. Then you could build the map. After you've seen, where Dink goes.
September 16th 2007, 05:30 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
But, it'll always be different. It depends on where Dink and the duck are when they begin chasing.

And metatarasal, your script doesn't work. The duck does get faster, but Dink doesn't follow him, whether I put move_stop lines in there or not.
September 18th 2007, 03:55 PM
duckdie.gif
Here it is, at last. Enjoy, and apologies for the delay.

(To make it worse, it got corrupted while I was copying & pasting. Hopefully it's fixed now.)

void main(void)
{
int &duckspeed;
int &duckx;
int &ducky;
sp_hitpoints(&current_sprite, 0);
sp_brain(&current_sprite, 3);
sp_base_walk(&current_sprite, 20);
sp_speed(&current_sprite, 1);
}

void hit(void)
{
&duckspeed = sp_speed(&current_sprite, -1);
&duckspeed += 1;
if (&duckspeed == 6)
{
goto chase;
}
sp_speed(&current_sprite, &duckspeed);

//Bleeding script
&duckx = sp_x(&current_sprite, -1);
&ducky = sp_y(&current_sprite, -1);
int &bledir = random(2, 1);
if (&bledir == 1)
{
int &junk1 = create_sprite(&duckx, &ducky, 0, 188, 1);
sp_seq(&junk1, 188);
}
else
{
int &junk1 = create_sprite(&duckx, &ducky, 0, 189, 1);
sp_seq(&junk1, 189);
}

return;

chase:
freeze(1);

//Make Dink disappear and have his clone chase the duck
//The clone will appear where Dink currently is
int &duck = &current_sprite;
int &dx = sp_x(1, -1);
int &dy = sp_y(1, -1);
sp_nodraw(1, 1);
int &clone = create_sprite(&dx, &dy, 16, 12, 1);
sp_base_walk(&clone, 70);
sp_speed(&clone, 6);
sp_timing(&clone, 33);
sp_follow(&clone, &duck);
set_smooth_follow(1);
freeze(&current_sprite);

//You can increase the numbers below to make the chase faster
//Remember that the duck is faster than Dink at first
sp_speed(&current_sprite, 12);
sp_speed(&clone, 9);

&duckx = sp_x(&current_sprite, -1);
&ducky = sp_y(&current_sprite, -1);
if (&duckx <= 320)
{
goto chase1;
}
else
{
goto chase2;
}
chase1:
if (&ducky <= 200)
{
//The duck is in the upper-left quarter of the screen

//Chase - you can make it last longer if you wish
move_stop(&current_sprite, 2, 318, 1);
move_stop(&current_sprite, 6, 450, 1);

//Have Dink catch up with the duck
sp_speed(&current_sprite, 8);
move_stop(&current_sprite, 8, 90, 1);

//Get the real Dink back and destroy the clone
int &dinkx = sp_x(&clone, -1);
int &dinky = sp_y(&clone, -1);
int &dinkdir = sp_dir(&clone, -1);
sp_x(1, &dinkx);
sp_y(1, &dinky);
sp_dir(1, &dinkdir);
sp_nodraw(1, 0);
sp_kill(&clone, 1);

//Insert mother duck cutscene here

return;

}
else
{
//The duck is in the lower-left quarter of the screen

//Chase - you can make it last longer if you wish
move_stop(&current_sprite, 6, 450, 1);

//Have Dink catch up with the duck
sp_speed(&current_sprite, 8);
move_stop(&current_sprite, 8, 90, 1);

//Get the real Dink back and destroy the clone
int &dinkx = sp_x(&clone, -1);
int &dinky = sp_y(&clone, -1);
int &dinkdir = sp_dir(&clone, -1);
sp_x(1, &dinkx);
sp_y(1, &dinky);
sp_dir(1, &dinkdir);
sp_nodraw(1, 0);
sp_kill(&clone, 1);

//Insert mother duck cutscene here

return;
}


chase2:
if (&ducky <= 200)
{
//The duck is in the upper-right quarter of the screen
//Chase - you can make it last longer if you wish
move_stop(&current_sprite, 2, 318, 1);
move_stop(&current_sprite, 4, 130, 1);

//Have Dink catch up with the duck
sp_speed(&current_sprite, 8);
move_stop(&current_sprite, 8, 90, 1);

//Get the real Dink back and destroy the clone
int &dinkx = sp_x(&clone, -1);
int &dinky = sp_y(&clone, -1);
int &dinkdir = sp_dir(&clone, -1);
sp_x(1, &dinkx);
sp_y(1, &dinky);
sp_dir(1, &dinkdir);
sp_nodraw(1, 0);
sp_kill(&clone, 1);

//Insert mother duck cutscene here

return;
}
else
{
//The duck is in the lower-right quarter of the screen
//Chase - you can make it last longer if you wish
move_stop(&current_sprite, 4, 130, 1);

//Have Dink catch up with the duck
sp_speed(&current_sprite, 8);
move_stop(&current_sprite, 8, 90, 1);

//Get the real Dink back and destroy the clone
int &dinkx = sp_x(&clone, -1);
int &dinky = sp_y(&clone, -1);
int &dinkdir = sp_dir(&clone, -1);
sp_x(1, &dinkx);
sp_y(1, &dinky);
sp_dir(1, &dinkdir);
sp_nodraw(1, 0);
sp_kill(&clone, 1);

//Insert mother duck cutscene here

return;
}
}
September 18th 2007, 04:51 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
That's awesome!! Thanks Ducklord!

Metatarasal, I figured out that Dink didn't chase the duck because Dink's brain is 1, and if you look in the DinkC.chm file, you'll see that the sprite needs a brain of 0, 3, 16, 9, 10, and a few others. But 1 wasn't in there.

But, Ducklord, that's fantastic man!! Thanks!!
September 19th 2007, 02:47 AM
duckdie.gif
You're welcome! Glad you like it.

It appears that sp_follow just doesn't apply to Dink, even if you attempt to change his brain.
September 19th 2007, 04:32 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Actually, I changed his brain to 16 and he followed the duck, so it turns out that he does.
September 19th 2007, 09:08 AM
duckdie.gif
Well, it certainly didn't work when I tried it, but perhaps I didn't try hard enough. I'm glad for you, anyway - it might help to make the chase run more smoothly.
September 19th 2007, 02:45 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Ah, well I just threw some commands together and didn't test it...

Anyway, it's not of much use anyway since the colossus Ducklord produced is probably far superior...