homing missile (alternative)
I think I found an alternative (or two) to making a homing missile opposed to what theprophet did. Instead of complex scripting, I've utilized sp_target(); to take care of all of that.
1)Set brain to 9, target Dink, use set_smooth_follow(1); In the touch procedure, set the brain to 11 and set a strength. Now you can successfully have a damage procedure for the "enemy".
2)Create a brain 9 sprite from the missile sprite and make a loop so that the missile sprite is always at the coordinate of the brain 9 sprite. Here's a script of the second alternative.
//guided fireball
void main( void )
{
int &cur_x = sp_x(¤t_sprite, -1);
int &cur_y = sp_y(¤t_sprite, -1);
int &cur_seq = sp_pseq(¤t_sprite, -1);
int &cur_dir;
int &fake = create_sprite(&cur_x, &cur_y, 9, &cur_seq, 1);
int &shadow;
sp_brain(¤t_sprite, 11);
sp_strength(¤t_sprite, 10);
sp_flying(¤t_sprite, 1);
sp_brain_parm(¤t_sprite, &check_vars);
sp_nodraw(¤t_sprite, 1);
sp_brain(&fake, 9);
sp_speed(&fake, 4);
sp_timing(&fake, 22);
sp_base_walk(&fake, 500);
sp_flying(&fake, 1);
sp_nohit(&fake, 1);
preload_seq(502);
preload_seq(504);
preload_seq(506);
preload_seq(508);
sp_target(&fake, 1);
set_smooth_follow(1);
&shadow = create_sprite(1,1, 15, 432, 3);
sp_brain_parm(&shadow, ¤t_sprite);
sp_que(&shadow, -1);
sp_brain_parm2(¤t_sprite, &shadow);
sp_dir(¤t_sprite, 2);
loop:
wait(1);
&cur_x = sp_x(&fake, -1);
sp_x(¤t_sprite, &cur_x);
&cur_y = sp_y(&fake, -1);
sp_y(¤t_sprite, &cur_y);
&cur_seq = sp_pseq(&fake, -1);
sp_pseq(¤t_sprite, -1);
&cur_dir = sp_dir(&fake, -1);
sp_dir(¤t_sprite, &cur_dir);
goto loop;
}
void damage( void )
{
&cur_y = sp_y(&fake, -1);
playsound(18, 8000,0,0,0);
wait(1);
sp_strength(¤t_sprite, 0);
kill_shadow(¤t_sprite);
sp_seq(&fake, 70);
sp_pseq(&fake, 70);
sp_frame(&fake, 1);
sp_brain(&fake, 7);
&cur_y -= 35;
sp_y(&fake, &cur_y);
sp_kill(¤t_sprite, 1);
}
1)Set brain to 9, target Dink, use set_smooth_follow(1); In the touch procedure, set the brain to 11 and set a strength. Now you can successfully have a damage procedure for the "enemy".
2)Create a brain 9 sprite from the missile sprite and make a loop so that the missile sprite is always at the coordinate of the brain 9 sprite. Here's a script of the second alternative.
//guided fireball
void main( void )
{
int &cur_x = sp_x(¤t_sprite, -1);
int &cur_y = sp_y(¤t_sprite, -1);
int &cur_seq = sp_pseq(¤t_sprite, -1);
int &cur_dir;
int &fake = create_sprite(&cur_x, &cur_y, 9, &cur_seq, 1);
int &shadow;
sp_brain(¤t_sprite, 11);
sp_strength(¤t_sprite, 10);
sp_flying(¤t_sprite, 1);
sp_brain_parm(¤t_sprite, &check_vars);
sp_nodraw(¤t_sprite, 1);
sp_brain(&fake, 9);
sp_speed(&fake, 4);
sp_timing(&fake, 22);
sp_base_walk(&fake, 500);
sp_flying(&fake, 1);
sp_nohit(&fake, 1);
preload_seq(502);
preload_seq(504);
preload_seq(506);
preload_seq(508);
sp_target(&fake, 1);
set_smooth_follow(1);
&shadow = create_sprite(1,1, 15, 432, 3);
sp_brain_parm(&shadow, ¤t_sprite);
sp_que(&shadow, -1);
sp_brain_parm2(¤t_sprite, &shadow);
sp_dir(¤t_sprite, 2);
loop:
wait(1);
&cur_x = sp_x(&fake, -1);
sp_x(¤t_sprite, &cur_x);
&cur_y = sp_y(&fake, -1);
sp_y(¤t_sprite, &cur_y);
&cur_seq = sp_pseq(&fake, -1);
sp_pseq(¤t_sprite, -1);
&cur_dir = sp_dir(&fake, -1);
sp_dir(¤t_sprite, &cur_dir);
goto loop;
}
void damage( void )
{
&cur_y = sp_y(&fake, -1);
playsound(18, 8000,0,0,0);
wait(1);
sp_strength(¤t_sprite, 0);
kill_shadow(¤t_sprite);
sp_seq(&fake, 70);
sp_pseq(&fake, 70);
sp_frame(&fake, 1);
sp_brain(&fake, 7);
&cur_y -= 35;
sp_y(&fake, &cur_y);
sp_kill(¤t_sprite, 1);
}






