A script problem
Here is a script that is attached to a gaurd sprite. The purpose of the gaurd is to follow you and when he touches you prompt a message from there he takes you to jail or he begin to hurt you with touch damage. At first I use the editor_seq trick to get the variable for the touch but that was not working so I changed it to a global variable and that did not work either. I relized after some testing checking with the variables that anything after the choice_end() doesn't execute. No matter what choice I pick he doesn't say anything. He does not prompt the choice again so I guess the variable is working. I have tried many things but nothing seems to work.
void main(void)
{
//int &ed = sp_editor_num(¤t_sprite);
//int &gaurdtouch = editor_seq(&ed, -1);
//&gaurdtouch = 0;
//editor_seq(&ed, &gaurdtouch);
&crimex = 1;
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 1);
sp_frame_delay(¤t_sprite, 50);
sp_timing(¤t_sprite, 0);
sp_exp(¤t_sprite, 1500);
sp_base_walk(¤t_sprite, 290);
sp_defense(¤t_sprite, 10);
sp_strength(¤t_sprite, 40);
sp_hitpoints(¤t_sprite, 300);
sp_base_death(¤t_sprite, 295);
sp_touch_damage(¤t_sprite, -1);
sp_target(¤t_sprite, 1);
}
void touch(void)
{
if(&crimex == 1)
{
&crimex += 1;
//editor_seq(&ed, &gaurdtouch);
choice_start()
title_start();
You have been charged with a crime, time to go to jail
title_end();
"Ok I will go &crimex"
"You will never take me alive"
choice_end()
if(&result != 1)
{
say_stop("`5 OK then follow me to jail &result", ¤t_sprite);
}
if(&result == 2)
{
say("`5Fine you will DIE!!", ¤t_sprite);
wait(100);
sp_touch_damage(¤t_sprite, 50);
}
}
}
void main(void)
{
//int &ed = sp_editor_num(¤t_sprite);
//int &gaurdtouch = editor_seq(&ed, -1);
//&gaurdtouch = 0;
//editor_seq(&ed, &gaurdtouch);
&crimex = 1;
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 1);
sp_frame_delay(¤t_sprite, 50);
sp_timing(¤t_sprite, 0);
sp_exp(¤t_sprite, 1500);
sp_base_walk(¤t_sprite, 290);
sp_defense(¤t_sprite, 10);
sp_strength(¤t_sprite, 40);
sp_hitpoints(¤t_sprite, 300);
sp_base_death(¤t_sprite, 295);
sp_touch_damage(¤t_sprite, -1);
sp_target(¤t_sprite, 1);
}
void touch(void)
{
if(&crimex == 1)
{
&crimex += 1;
//editor_seq(&ed, &gaurdtouch);
choice_start()
title_start();
You have been charged with a crime, time to go to jail
title_end();
"Ok I will go &crimex"
"You will never take me alive"
choice_end()
if(&result != 1)
{
say_stop("`5 OK then follow me to jail &result", ¤t_sprite);
}
if(&result == 2)
{
say("`5Fine you will DIE!!", ¤t_sprite);
wait(100);
sp_touch_damage(¤t_sprite, 50);
}
}
}
Well I guess its not so much a problem with my script but a problem with dink engine. It seems that after the knight touched dink it continually looped the touch command causing it never to be able to get to the end of the script. Dink I guess does not let you finish a touch script before it intializes another touch script if you are still touching while the first one went off. The only solution is to move the choice command to the main method and then just have it start once the knight spawns. This is not exactly what I wanted I wanted the knight to have to catch you before he asks you something but I guess this still works.
This is a very well known problem. There are two possible solutions:
Add a sp_touch_damage(¤t_sprite, 0) at the very beginning of the touch() procedure.
OR use brain 14. Set the sprite's brain to 14 in main() and then add a buttonon() procedure (I may have that wrong, I've only used this once.)
Add a sp_touch_damage(¤t_sprite, 0) at the very beginning of the touch() procedure.
OR use brain 14. Set the sprite's brain to 14 in main() and then add a buttonon() procedure (I may have that wrong, I've only used this once.)