Reply to Dinkc scripting problem
If you don't have an account, just leave the password field blank.
October 2nd 2009, 04:56 PM

Josko
Hello. I've been now trying to get the Ice Ball freeze effect from the Pota dmod to another Ice Ball script which don't make the enemies look freezed. I came that far that everything seemed to work just fine, I made dink equip the spell, cast it on a enemy without a problem. And the enemy in this case, a bonca, turned to a ' freezed bonca ' just like in the Pota Dmod. Now, if dink, or any other monster hits it while it's in it's ' frozed ' state, the game crashes and shuts down. I've spend hours to locate the source of this error, without any luck.
The game crashes only when dink or any other monsters attacks the frozen monster, so that must have to do something with the monster scripts I thought, but they seem alright. And one thing to mention too, I'm pretty new to scripting, so it's hard for me!
I'll post the scripts I use:
A monster script of a medium bonca, named to ''boncfroz'
//Bonca..medium strength
void main( void )
{
int &direction = 0;
int &melt;
int &mcounter;
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 1);
sp_distance(¤t_sprite, 50);
sp_timing(¤t_sprite, 33);
sp_exp(¤t_sprite, 30);
sp_base_walk(¤t_sprite, 530);
sp_base_death(¤t_sprite, 550);
sp_base_attack(¤t_sprite, 540);
sp_defense(¤t_sprite, 3);
sp_strength(¤t_sprite, 8);
sp_touch_damage(¤t_sprite, 4);
sp_hitpoints(¤t_sprite, 20);
preload_seq(531);
preload_seq(533);
preload_seq(537);
preload_seq(539);
preload_seq(542);
preload_seq(544);
preload_seq(546);
preload_seq(548);
preload_seq(881);
if (sp_hitpoints(¤t_sprite, -1)
{
goto end;
}
}
void hit( void )
{
if (&melt == 2)
{
sp_seq(¤t_sprite, 480);
sp_pseq(¤t_sprite, 480);
sp_pframe(¤t_sprite, 1);
sp_brain(¤t_sprite, 7);
playsound(67, 22050, 0, ¤t_sprite, 0);
die();
int &give_experience = sp_exp(¤t_sprite, -1);
add_exp(&give_experience, ¤t_sprite);
&melt = 3;
}
if (&melt == 3)
return;
playsound(29, 22050,0,¤t_sprite, 0);
sp_target(¤t_sprite, &enemy_sprite);
//lock on to the guy who just hit us
//playsound
if (&melt == 1)
{
freeze(¤t_sprite);
sp_frame(¤t_sprite, 1);
wait(1000);
&direction = sp_dir(¤t_sprite, -1);
sp_pseq(¤t_sprite, 881);
if (&direction == 1)
sp_pframe(¤t_sprite, 1);
if (&direction == 2)
sp_pframe(¤t_sprite, 2);
if (&direction == 3)
sp_pframe(¤t_sprite, 2);
if (&direction == 4)
sp_pframe(¤t_sprite, 3);
if (&direction == 6)
sp_pframe(¤t_sprite, 2);
if (&direction == 7)
sp_pframe(¤t_sprite, 3);
if (&direction == 8)
sp_pframe(¤t_sprite, 3);
if (&direction == 9)
sp_pframe(¤t_sprite, 4);
&melt = 2;
}
if (&melt >= 1)
{
wait(10000);
unfreeze(¤t_sprite);
&melt = 0;
}
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
external("emake","medium");
}
void attack( void )
{
playsound(31, 22050,0,¤t_sprite, 0);
&mcounter = random(4000,0);
sp_attack_wait(¤t_sprite, &mcounter);
}
void frozen( void )
{
&melt = 1;
}
void summon( void )
{
if (&target(¤t_sprite, -1) != 1)
{
if (&summon >= 1)
{
if (random(2,1) == 2)
{
sp_target(¤t_sprite, &summon);
}
}
}
}
Note: The summon void is for another spell I use, it dosnt have anything with this error to do with.
----------------------------------
The spell itself ''item-Iceb''
//iceball
void use( void )
{
&mydir = sp_dir(1, -1);
//disallow diagonal fireballs for now
if (sp_dir(1, -1) == 1)
sp_dir(1, 4);
if (sp_dir(1, -1) == 3)
sp_dir(1, 6);
if (sp_dir(1, -1) == 7)
sp_dir(1, 4);
if (sp_dir(1, -1) == 9)
sp_dir(1, 6);
&basehit = sp_dir(1, -1);
&basehit += 320;
sp_seq(1, &basehit);
sp_frame(1, 1); //reset seq to 1st frame
sp_kill_wait(1); //make sure dink will punch right away
sp_nocontrol(1, 1); //dink can't move until anim is done!
&magic_level = 0;
draw_status();
&mholdx = sp_x(1, -1);
&mholdy = sp_y(1, -1);
//freeze(1);
wait(100);
if (&mydir == 1)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_mx(&junk, -6);
sp_my(&junk, +2);
}
if (&mydir == 4)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_dir(&junk, 4);
}
if (&mydir == 6)
{
// &mholdy -= 10;
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_dir(&junk, 6);
}
if (&mydir == 3)
{
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_mx(&junk, +6);
sp_my(&junk, +2);
}
if (&mydir == 2)
{
&junk = create_sprite(&mholdx, &mholdy, 11, 852, 1);
sp_seq(&junk, 852);
sp_dir(&junk, 2);
}
if (&mydir == 7)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_mx(&junk, -6);
sp_my(&junk, -2);
}
if (&mydir == 8)
{
&junk = create_sprite(&mholdx, &mholdy, 11, 858, 1);
sp_seq(&junk, 858);
sp_dir(&junk, 8);
}
if (&mydir == 9)
{
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_mx(&junk, +6);
sp_my(&junk, -2);
}
//create fake shadow effect
playsound(51, 8000,0,&junk,0);
sp_timing(&junk, 0);
sp_speed(&junk, 4);
sp_strength(&junk, 0);
sp_range(&junk, 10);
//this makes it easier to hit stuff
sp_flying(&junk, 1);
sp_script(&junk, "dam-ice");
//when the fireball hits something, it will look to this script, this way
//we can burn trees when appropriate
&mshadow = create_sprite(&mholdx, &mholdy, 15, 432, 3);
sp_brain_parm(&mshadow, &junk);
sp_que(&mshadow, -500);
//will be drawn under everything
//set fireball to not be able to damage Dink or the shadow
sp_brain_parm(&junk, 1);
sp_brain_parm2(&junk, &mshadow);
unfreeze(1);
}
void disarm(void)
{
init("load_sequence graphics\dink\hit\magic\ds-m2- 322 30 60 84 -15 -9 16 7");
init("load_sequence graphics\dink\hit\magic\ds-m4- 324 30 61 86 -13 -7 15 8");
init("load_sequence graphics\dink\hit\magic\ds-m6- 326 30 60 86 -11 -8 13 9");
init("load_sequence graphics\dink\hit\magic\ds-m8- 328 30 61 83 -15 -4 15 14");
&magic_cost = 0;
kill_this_task();
}
void arm(void)
{
Debug("Preloading fireball");
int &basehit;
int &mholdx;
int &mholdy;
int &junk;
int &mshadow;
int &mydir;
&magic_cost = 1000;
init("load_sequence graphics\dink\hit\magic2\ds-m2- 322 30 60 84 -15 -9 16 7");
init("load_sequence graphics\dink\hit\magic2\ds-m4- 324 30 61 86 -13 -7 15 8");
init("load_sequence graphics\dink\hit\magic2\ds-m6- 326 30 60 86 -11 -8 13 9");
init("load_sequence graphics\dink\hit\magic2\ds-m8- 328 30 61 83 -15 -4 15 14");
preload_seq(852);
preload_seq(854);
preload_seq(856);
preload_seq(858);
preload_seq(322);
preload_seq(324);
preload_seq(326);
preload_seq(328);
}
void pickup(void)
{
Debug("Player now owns this item.");
kill_this_task();
}
void drop(void)
{
Debug("Item dropped.");
kill_this_task();
}
------------------------
And the script ''dam-ice''
//script for individual iceball
void main( void )
{
int &mcrap;
int &scrap;
int &rcrap;
int &junk;
}
void damage( void )
{
playsound(18, 8000,0,0,0);
&scrap = ¤t_sprite;
kill_shadow(&scrap);
sp_seq(&scrap, 480);
sp_pseq(&scrap, 480);
sp_frame(&scrap, 1);
sp_brain(&scrap, 7);
&mcrap = sp_y(&scrap, -1);
&mcrap -= 35;
sp_y(&scrap, &mcrap);
&rcrap = sp_brain(&missile_target, -1);
if (&rcrap == 9)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
if (&rcrap == 3)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
if (&rcrap == 4)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
&rcrap = sp_seq(&missile_target, -1);
if (&rcrap == 427)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "die");
}
}
The game crashes only when dink or any other monsters attacks the frozen monster, so that must have to do something with the monster scripts I thought, but they seem alright. And one thing to mention too, I'm pretty new to scripting, so it's hard for me!
I'll post the scripts I use:
A monster script of a medium bonca, named to ''boncfroz'
//Bonca..medium strength
void main( void )
{
int &direction = 0;
int &melt;
int &mcounter;
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 1);
sp_distance(¤t_sprite, 50);
sp_timing(¤t_sprite, 33);
sp_exp(¤t_sprite, 30);
sp_base_walk(¤t_sprite, 530);
sp_base_death(¤t_sprite, 550);
sp_base_attack(¤t_sprite, 540);
sp_defense(¤t_sprite, 3);
sp_strength(¤t_sprite, 8);
sp_touch_damage(¤t_sprite, 4);
sp_hitpoints(¤t_sprite, 20);
preload_seq(531);
preload_seq(533);
preload_seq(537);
preload_seq(539);
preload_seq(542);
preload_seq(544);
preload_seq(546);
preload_seq(548);
preload_seq(881);
if (sp_hitpoints(¤t_sprite, -1)
{
goto end;
}
}
void hit( void )
{
if (&melt == 2)
{
sp_seq(¤t_sprite, 480);
sp_pseq(¤t_sprite, 480);
sp_pframe(¤t_sprite, 1);
sp_brain(¤t_sprite, 7);
playsound(67, 22050, 0, ¤t_sprite, 0);
die();
int &give_experience = sp_exp(¤t_sprite, -1);
add_exp(&give_experience, ¤t_sprite);
&melt = 3;
}
if (&melt == 3)
return;
playsound(29, 22050,0,¤t_sprite, 0);
sp_target(¤t_sprite, &enemy_sprite);
//lock on to the guy who just hit us
//playsound
if (&melt == 1)
{
freeze(¤t_sprite);
sp_frame(¤t_sprite, 1);
wait(1000);
&direction = sp_dir(¤t_sprite, -1);
sp_pseq(¤t_sprite, 881);
if (&direction == 1)
sp_pframe(¤t_sprite, 1);
if (&direction == 2)
sp_pframe(¤t_sprite, 2);
if (&direction == 3)
sp_pframe(¤t_sprite, 2);
if (&direction == 4)
sp_pframe(¤t_sprite, 3);
if (&direction == 6)
sp_pframe(¤t_sprite, 2);
if (&direction == 7)
sp_pframe(¤t_sprite, 3);
if (&direction == 8)
sp_pframe(¤t_sprite, 3);
if (&direction == 9)
sp_pframe(¤t_sprite, 4);
&melt = 2;
}
if (&melt >= 1)
{
wait(10000);
unfreeze(¤t_sprite);
&melt = 0;
}
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
external("emake","medium");
}
void attack( void )
{
playsound(31, 22050,0,¤t_sprite, 0);
&mcounter = random(4000,0);
sp_attack_wait(¤t_sprite, &mcounter);
}
void frozen( void )
{
&melt = 1;
}
void summon( void )
{
if (&target(¤t_sprite, -1) != 1)
{
if (&summon >= 1)
{
if (random(2,1) == 2)
{
sp_target(¤t_sprite, &summon);
}
}
}
}
Note: The summon void is for another spell I use, it dosnt have anything with this error to do with.
----------------------------------
The spell itself ''item-Iceb''
//iceball
void use( void )
{
&mydir = sp_dir(1, -1);
//disallow diagonal fireballs for now
if (sp_dir(1, -1) == 1)
sp_dir(1, 4);
if (sp_dir(1, -1) == 3)
sp_dir(1, 6);
if (sp_dir(1, -1) == 7)
sp_dir(1, 4);
if (sp_dir(1, -1) == 9)
sp_dir(1, 6);
&basehit = sp_dir(1, -1);
&basehit += 320;
sp_seq(1, &basehit);
sp_frame(1, 1); //reset seq to 1st frame
sp_kill_wait(1); //make sure dink will punch right away
sp_nocontrol(1, 1); //dink can't move until anim is done!
&magic_level = 0;
draw_status();
&mholdx = sp_x(1, -1);
&mholdy = sp_y(1, -1);
//freeze(1);
wait(100);
if (&mydir == 1)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_mx(&junk, -6);
sp_my(&junk, +2);
}
if (&mydir == 4)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_dir(&junk, 4);
}
if (&mydir == 6)
{
// &mholdy -= 10;
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_dir(&junk, 6);
}
if (&mydir == 3)
{
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_mx(&junk, +6);
sp_my(&junk, +2);
}
if (&mydir == 2)
{
&junk = create_sprite(&mholdx, &mholdy, 11, 852, 1);
sp_seq(&junk, 852);
sp_dir(&junk, 2);
}
if (&mydir == 7)
{
&mholdx -= 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 854, 1);
sp_seq(&junk, 854);
sp_mx(&junk, -6);
sp_my(&junk, -2);
}
if (&mydir == 8)
{
&junk = create_sprite(&mholdx, &mholdy, 11, 858, 1);
sp_seq(&junk, 858);
sp_dir(&junk, 8);
}
if (&mydir == 9)
{
&mholdx += 30;
&junk = create_sprite(&mholdx, &mholdy, 11, 856, 1);
sp_seq(&junk, 856);
sp_mx(&junk, +6);
sp_my(&junk, -2);
}
//create fake shadow effect
playsound(51, 8000,0,&junk,0);
sp_timing(&junk, 0);
sp_speed(&junk, 4);
sp_strength(&junk, 0);
sp_range(&junk, 10);
//this makes it easier to hit stuff
sp_flying(&junk, 1);
sp_script(&junk, "dam-ice");
//when the fireball hits something, it will look to this script, this way
//we can burn trees when appropriate
&mshadow = create_sprite(&mholdx, &mholdy, 15, 432, 3);
sp_brain_parm(&mshadow, &junk);
sp_que(&mshadow, -500);
//will be drawn under everything
//set fireball to not be able to damage Dink or the shadow
sp_brain_parm(&junk, 1);
sp_brain_parm2(&junk, &mshadow);
unfreeze(1);
}
void disarm(void)
{
init("load_sequence graphics\dink\hit\magic\ds-m2- 322 30 60 84 -15 -9 16 7");
init("load_sequence graphics\dink\hit\magic\ds-m4- 324 30 61 86 -13 -7 15 8");
init("load_sequence graphics\dink\hit\magic\ds-m6- 326 30 60 86 -11 -8 13 9");
init("load_sequence graphics\dink\hit\magic\ds-m8- 328 30 61 83 -15 -4 15 14");
&magic_cost = 0;
kill_this_task();
}
void arm(void)
{
Debug("Preloading fireball");
int &basehit;
int &mholdx;
int &mholdy;
int &junk;
int &mshadow;
int &mydir;
&magic_cost = 1000;
init("load_sequence graphics\dink\hit\magic2\ds-m2- 322 30 60 84 -15 -9 16 7");
init("load_sequence graphics\dink\hit\magic2\ds-m4- 324 30 61 86 -13 -7 15 8");
init("load_sequence graphics\dink\hit\magic2\ds-m6- 326 30 60 86 -11 -8 13 9");
init("load_sequence graphics\dink\hit\magic2\ds-m8- 328 30 61 83 -15 -4 15 14");
preload_seq(852);
preload_seq(854);
preload_seq(856);
preload_seq(858);
preload_seq(322);
preload_seq(324);
preload_seq(326);
preload_seq(328);
}
void pickup(void)
{
Debug("Player now owns this item.");
kill_this_task();
}
void drop(void)
{
Debug("Item dropped.");
kill_this_task();
}
------------------------
And the script ''dam-ice''
//script for individual iceball
void main( void )
{
int &mcrap;
int &scrap;
int &rcrap;
int &junk;
}
void damage( void )
{
playsound(18, 8000,0,0,0);
&scrap = ¤t_sprite;
kill_shadow(&scrap);
sp_seq(&scrap, 480);
sp_pseq(&scrap, 480);
sp_frame(&scrap, 1);
sp_brain(&scrap, 7);
&mcrap = sp_y(&scrap, -1);
&mcrap -= 35;
sp_y(&scrap, &mcrap);
&rcrap = sp_brain(&missile_target, -1);
if (&rcrap == 9)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
if (&rcrap == 3)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
if (&rcrap == 4)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "frozen");
}
&rcrap = sp_seq(&missile_target, -1);
if (&rcrap == 427)
{
&junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "die");
}
}





