Problem with script
Grr.. I assigned this script to a sprite and whenever it runs it, it runs the die procedure after the main procedure and the sprite hasn't even died... makes me so frustrated...
void main( void )
{
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 2);
sp_timing(¤t_sprite, 0);
sp_defense(¤t_sprite, 4);
sp_base_walk(¤t_sprite, 380)
sp_strength(¤t_sprite, 4);
sp_touch_damage(¤t_sprite, 4);
sp_hitpoints(¤t_sprite, 100);
sp_target(¤t_sprite, 1);
sp_exp(¤t_sprite, 100);
unfreeze(1)
unfreeze(¤t_sprite)
screenlock(1)
}
void die( void )
{
if (get_sprite_with_this_brain(9, ¤t_sprite) == 0)
{
spawn("killer")
screenlock(0);
}
}
void main( void )
{
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 2);
sp_timing(¤t_sprite, 0);
sp_defense(¤t_sprite, 4);
sp_base_walk(¤t_sprite, 380)
sp_strength(¤t_sprite, 4);
sp_touch_damage(¤t_sprite, 4);
sp_hitpoints(¤t_sprite, 100);
sp_target(¤t_sprite, 1);
sp_exp(¤t_sprite, 100);
unfreeze(1)
unfreeze(¤t_sprite)
screenlock(1)
}
void die( void )
{
if (get_sprite_with_this_brain(9, ¤t_sprite) == 0)
{
spawn("killer")
screenlock(0);
}
}
Try putting semicolons ";" after the two unfreeze() statements, after the screenlock() and after the spawn() as well.
That didn't fix the problem.. it still runs the die procedure once you start fighting the sprite. However, the script now runs the die procedure again once the sprite has died
I'd tell you to throw a return; at the end of your main() proc, but although that _might_ solve the problem, you still wouldn't know why it happened.
The only thing I can think of, and this is too stupid to mention, is that you set the hitpoints to a negative number in the editor.
The only thing I can think of, and this is too stupid to mention, is that you set the hitpoints to a negative number in the editor.
Oh yeah, the sp_base_walk line is missing a semicolon, not that it matters...
It does. Without a semicolon the process_line() function will treat it as a function call (well, sorta). Anyway, it's a bad thing.