Script that does not work
What I'm trying to do in the script below is to get the bonca run away before he is killed - but unfortunately the script doesn't work. So what's wrong?
//blood bonca that lives in the cellar
void main( void )
{
int &mcounter;
sp_brain(&current_sprite, 9);
sp_speed(&current_sprite, 2);
sp_distance(&current_sprite, 50);
sp_timing(&current_sprite, 0);
sp_exp(&current_sprite, 100);
sp_base_walk(&current_sprite, 860);
sp_base_death(&current_sprite, 880);
sp_base_attack(&current_sprite, 870);
sp_defense(&current_sprite, 0);
sp_strength(&current_sprite, 10);
sp_touch_damage(&current_sprite, 5);
sp_hitpoints(&current_sprite, 100);
sp_target(&current_sprite, 1);
preload_seq(861);
preload_seq(863);
preload_seq(867);
preload_seq(869);
preload_seq(872);
preload_seq(874);
preload_seq(876);
preload_seq(878);
preload_seq(881);
preload_seq(883);
preload_seq(887);
preload_seq(889);
mainloop:
int &rough = sp_hitpoints(&current_sprite, -1);
if (&rough < 20)
{
end();
}
wait(1);
goto mainloop;
}
void hit( void )
{
playsound(29, 22050,0,&current_sprite, 0);
sp_target(&current_sprite, &enemy_sprite);
}
void talk( void )
{
if (sp_target(&current_sprite, -1) == 1)
{
say("`#Now you will die!", &current_sprite);
}
if (sp_target(&current_sprite, -1) != 1)
{
playsound(29, 22050,0,&current_sprite, 0);
say("`#Get away from me!", &current_sprite);
}
}
void end( void )
{
script_attach(1000);
say("`#Arruunk!", &current_sprite);
sp_speed(&current_sprtie, 4);
sp_timing(&current_sprite, 0);
move_stop(&current_sprite, 4, 0, 1);
sp_active(&current_sprite, 0);
freeze(1);
sp_dir(1, 4);
wait(1000);
say_stop("Stupid bonca...", 1);
wait(250);
unfreeze(1);
if (&get_sprite_with_this_brain(9 == 0)
{
screenlock(0);
if (&story == 13)
{
playmidi("winter.mid");
}
}
}
void attack( void )
{
playsound(31, 22050,0,&current_sprite, 0);
&mcounter = random(1000,0);
sp_attack_wait(&current_sprite, &mcounter);
}
//blood bonca that lives in the cellar
void main( void )
{
int &mcounter;
sp_brain(&current_sprite, 9);
sp_speed(&current_sprite, 2);
sp_distance(&current_sprite, 50);
sp_timing(&current_sprite, 0);
sp_exp(&current_sprite, 100);
sp_base_walk(&current_sprite, 860);
sp_base_death(&current_sprite, 880);
sp_base_attack(&current_sprite, 870);
sp_defense(&current_sprite, 0);
sp_strength(&current_sprite, 10);
sp_touch_damage(&current_sprite, 5);
sp_hitpoints(&current_sprite, 100);
sp_target(&current_sprite, 1);
preload_seq(861);
preload_seq(863);
preload_seq(867);
preload_seq(869);
preload_seq(872);
preload_seq(874);
preload_seq(876);
preload_seq(878);
preload_seq(881);
preload_seq(883);
preload_seq(887);
preload_seq(889);
mainloop:
int &rough = sp_hitpoints(&current_sprite, -1);
if (&rough < 20)
{
end();
}
wait(1);
goto mainloop;
}
void hit( void )
{
playsound(29, 22050,0,&current_sprite, 0);
sp_target(&current_sprite, &enemy_sprite);
}
void talk( void )
{
if (sp_target(&current_sprite, -1) == 1)
{
say("`#Now you will die!", &current_sprite);
}
if (sp_target(&current_sprite, -1) != 1)
{
playsound(29, 22050,0,&current_sprite, 0);
say("`#Get away from me!", &current_sprite);
}
}
void end( void )
{
script_attach(1000);
say("`#Arruunk!", &current_sprite);
sp_speed(&current_sprtie, 4);
sp_timing(&current_sprite, 0);
move_stop(&current_sprite, 4, 0, 1);
sp_active(&current_sprite, 0);
freeze(1);
sp_dir(1, 4);
wait(1000);
say_stop("Stupid bonca...", 1);
wait(250);
unfreeze(1);
if (&get_sprite_with_this_brain(9 == 0)
{
screenlock(0);
if (&story == 13)
{
playmidi("winter.mid");
}
}
}
void attack( void )
{
playsound(31, 22050,0,&current_sprite, 0);
&mcounter = random(1000,0);
sp_attack_wait(&current_sprite, &mcounter);
}
How about placing something in the hit() procedure of the monster script? Like:
void hit(void)
{
playsound(29, 22050,0,&current_sprite, 0);
int &crap = sp_hitpoints(&current_sprite, -1);
if (&crap <= 25)
{
end();
}
}
Every time Dink hits the monsters, it checks the health of that monster. You could set it to less than 25 or something like that
void hit(void)
{
playsound(29, 22050,0,&current_sprite, 0);
int &crap = sp_hitpoints(&current_sprite, -1);
if (&crap <= 25)
{
end();
}
}
Every time Dink hits the monsters, it checks the health of that monster. You could set it to less than 25 or something like that
Simeon's idea is probably the best way to go about it.
But the reason your script doesn't work is because of the way Dink works. First of all, a wait(1); loop will generally make the game run a bit... jumpy. Usually do wait(50); or wait(100); loops.
Anyway, every time a procedure is referenced in a script, you can think of it as interrupting the loop. One second its going through the loop as you told it to in the main procedure, but as soon as you hit it or talk to it, it stops going through the loop and does what you told it to do. So you just need to put goto mainloop; lines in your hit and talk procedures.
But like I said before, Simeon's idea is a lot better.
But the reason your script doesn't work is because of the way Dink works. First of all, a wait(1); loop will generally make the game run a bit... jumpy. Usually do wait(50); or wait(100); loops.
Anyway, every time a procedure is referenced in a script, you can think of it as interrupting the loop. One second its going through the loop as you told it to in the main procedure, but as soon as you hit it or talk to it, it stops going through the loop and does what you told it to do. So you just need to put goto mainloop; lines in your hit and talk procedures.
But like I said before, Simeon's idea is a lot better.
[b]Uhm... Why this loop doesn't work?
The script skips the wait-thing and goes right into what happens below... After 1 second, anyway. Shouldn't I have a global named könö or what? [/b]
&köno = 10;
hoowoo:
wait(1000);
if (&könö > 0)
{
&könö -= 1;
goto hoowoo;
}
The script skips the wait-thing and goes right into what happens below... After 1 second, anyway. Shouldn't I have a global named könö or what? [/b]
&köno = 10;
hoowoo:
wait(1000);
if (&könö > 0)
{
&könö -= 1;
goto hoowoo;
}
I think you can use < B > or [ B ] but the forum only recognizes the [ B ] so it changes the < B > to [ B ] so it can recognize it. Same with me to be honest
Wow. Ol' Morph is actually half-right! Of course, that means he's half-wrong too
He's correct in his assertion that the code changes < b > into [ b ]. However, the reason why it didn't work for you is because the board expects the < b > and < /b > tags to be on the same line... otherwise it doesn't convert them back. It does so to prevent people from creating un-closed < b > tags and such.
He's correct in his assertion that the code changes < b > into [ b ]. However, the reason why it didn't work for you is because the board expects the < b > and < /b > tags to be on the same line... otherwise it doesn't convert them back. It does so to prevent people from creating un-closed < b > tags and such.
&köno = 10;
hoowoo:
wait(1000);
if (&könö > 0)
{
&könö -= 1;
goto hoowoo;
}
if &könö is a global int then it should work, if its not, then use
int &könö = 10
or
make it a global.
I found another error in your script, at the if statement you wrote &köno not &könö
hoowoo:
wait(1000);
if (&könö > 0)
{
&könö -= 1;
goto hoowoo;
}
if &könö is a global int then it should work, if its not, then use
int &könö = 10
or
make it a global.
I found another error in your script, at the if statement you wrote &köno not &könö