The Dink Network

Dinkc scripting problem

October 2nd 2009, 04:56 PM
anon.gif
Josko
Ghost They/Them
 
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(&current_sprite, 9);
sp_speed(&current_sprite, 1);
sp_distance(&current_sprite, 50);
sp_timing(&current_sprite, 33);
sp_exp(&current_sprite, 30);
sp_base_walk(&current_sprite, 530);
sp_base_death(&current_sprite, 550);
sp_base_attack(&current_sprite, 540);
sp_defense(&current_sprite, 3);
sp_strength(&current_sprite, 8);
sp_touch_damage(&current_sprite, 4);
sp_hitpoints(&current_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(&current_sprite, -1)
{
goto end;
}

}

void hit( void )
{
if (&melt == 2)
{
sp_seq(&current_sprite, 480);
sp_pseq(&current_sprite, 480);
sp_pframe(&current_sprite, 1);
sp_brain(&current_sprite, 7);
playsound(67, 22050, 0, &current_sprite, 0);
die();
int &give_experience = sp_exp(&current_sprite, -1);
add_exp(&give_experience, &current_sprite);
&melt = 3;
}
if (&melt == 3)
return;

playsound(29, 22050,0,&current_sprite, 0);
sp_target(&current_sprite, &enemy_sprite);
//lock on to the guy who just hit us
//playsound

if (&melt == 1)
{
freeze(&current_sprite);
sp_frame(&current_sprite, 1);
wait(1000);
&direction = sp_dir(&current_sprite, -1);

sp_pseq(&current_sprite, 881);
if (&direction == 1)
sp_pframe(&current_sprite, 1);
if (&direction == 2)
sp_pframe(&current_sprite, 2);
if (&direction == 3)
sp_pframe(&current_sprite, 2);
if (&direction == 4)
sp_pframe(&current_sprite, 3);
if (&direction == 6)
sp_pframe(&current_sprite, 2);
if (&direction == 7)
sp_pframe(&current_sprite, 3);
if (&direction == 8)
sp_pframe(&current_sprite, 3);
if (&direction == 9)
sp_pframe(&current_sprite, 4);
&melt = 2;
}

if (&melt >= 1)
{
wait(10000);
unfreeze(&current_sprite);
&melt = 0;
}
}

void die( void )
{
int &hold = sp_editor_num(&current_sprite);
if (&hold != 0)
editor_type(&hold, 6);

&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
external("emake","medium");
}

void attack( void )
{
playsound(31, 22050,0,&current_sprite, 0);
&mcounter = random(4000,0);
sp_attack_wait(&current_sprite, &mcounter);
}

void frozen( void )
{
&melt = 1;
}

void summon( void )
{
if (&target(&current_sprite, -1) != 1)
{
if (&summon >= 1)
{
if (random(2,1) == 2)
{
sp_target(&current_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 = &current_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");
}
}
October 2nd 2009, 05:07 PM
anon.gif
Josko
Ghost They/Them
 
One thing to mention aswell, the game dosnt crash if I hit it with the Ice ball/Ice orb spell while it's frozen. So it has to do with everything else, fist, swords, bow(But I havnt tested to hit with a bow) and if a monster like bonca hits and I dont know if the game will crash if I hit the frozen monster with another spell like hellfire
October 2nd 2009, 06:39 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
It sounds like a problem with playsound(). Since you copied the script from another DMOD, it most likely uses sounds that are not defined in your DMOD. This will result in a game crash.

You should either copy the proper sounds into your sound folder and define them in start.c, or just remove/replace the playsound() instances.
October 2nd 2009, 07:33 PM
anon.gif
Josko
Ghost They/Them
 
Oh yeah! I'll look into it. It did the same thing before when I killed a monster with the spell and the game crashed and that was a case of playsound() problem. Thanks
October 2nd 2009, 09:25 PM
anon.gif
Josko
Ghost They/Them
 
Alright! it worked! Looks like it really was a playsound() problem =D

Thanks.