The Dink Network

Re: Spawning a Monster From a Barrel

September 30th 2007, 08:42 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Yep, that's right. Another question. What I want to do, is have Dink punch a barrel, and a monster spawns from it. I just got the barrel script bar-e.c and copy & pasted everything from it, into my new script. Then before kill_this_task();, I have my monster spawn bit. This is how it goes:

// main.c excerpt

make_global_int("&dd-barx1",0);
make_global_int("&dd-barx2",0);
make_global_int("&dd-barx3",0);
make_global_int("&dd-bary1",0);
make_global_int("&dd-bary2",0);
make_global_int("&dd-bary3",0);

// script excerpt

if (&rand == 1)
{
// Bad barrel
// Save X and Y coordinates for monster spawn
&dd-barx1 = sp_x(&current_sprite,-1);
&dd-bary1 = sp_y(&current_sprite,-1);
// Monster spawn
// Weak monster: Bonca
int &bonc = create_sprite(&dd-barx1,&dd-bary1,9,533,1);
sp_script(&bonc,"en-bonc");
}

I think I might be doing the "Save X and Y corrdinates" bit wrong. But I'm not sure.
September 30th 2007, 08:50 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
Maybe it would be easier to modify the make.c script and spawn the monster the same way normal barrels spawn hearts and such. All you would have to do is make a new procedure in it.

Instead of copying from the empty barrel script, you probably should've looked at a barrel script that actually spawns an item. I've made some sample script for what you're trying to accomplish. BTW in the barrel hit script I only modified the procedure name of the external script and cut out the comments.

//hit procedure for barrel script
void hit ( void )
{
playsound(37, 22050, 0,0,0);
int &hold = sp_editor_num(&current_sprite);

if (&hold != 0)
{
editor_type(&hold, 3);
editor_seq(&hold, 173);
editor_frame(&hold, 6);
}
sp_seq(&current_sprite, 173);
sp_brain(&current_sprite, 5);
sp_notouch(&current_sprite, 1);
sp_nohit(&current_sprite, 1);

&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
external("make", "wbonc");

sp_hard(&current_sprite, 1);
draw_hard_sprite(&current_sprite);
kill_this_task();
}

//new procedure for make.c
void wbonc( void )
{
int &mcrap = random(1,5);
if (&mcrap == 1)
{
int &bonc = create_sprite(&save_x,&&save_y,9,533,1);
sp_script(&bonc,"en-bonc");
}
}
October 1st 2007, 12:16 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
That looks good. I'll try it, thanks.