The Dink Network

How to script so your stuff can malfunction in ten different ways...

August 19th 2004, 12:22 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
If that would be a book, I would be the author. But now seriously, I've made a really cool boss (pillbug guy from BoE) and I've had a lot of bug reports on that one. Only problem is... they were all different . For some people, the computer froze, unable to do anything but resetting. With other players (including myself, 15 minutes ago) the boss freezes and acts like a dead pillbug-body (or it just disappears with the same effect: pillbugs won't drop anymore and you can't hit the guy out of the air). Now (after my own crash ) I'm desperate to get it work for everybody, so here's the three scripts which it uses:

Script attached to screen (s2-scr1.c):

void main( void )
{
if (&story > 19)
{
freeze(1);
say_stop("There's nothing more to see here.",1);
fade_down();
&player_map = 103;
load_screen(103);
draw_screen();
fade_up();
unfreeze(1);
kill_this_task();
}
int &xie;
int &yie;
int &crap;
int &brap;
&bosspoint = 80;
stopmidi();
&store = 0;
//Store = 0 --> Boss in air
//Store = 1 --> Boss on ground or floating down
//Store = 2 --> Boss floating up
freeze(1);
say_stop_xy("`% You'll never find me! HAHAHA!!",1,1);
unfreeze(1);
playmidi("5.mid");
set_callback_random("fallpill", 1000, 2000);
}

void fallpill( void )
{
if (&store == 0)
{
&xie = random(360, 1);
&xie += 120;
&yie = random(160, 1);
&yie += 120;
&crap = create_sprite(&xie, &yie, 0, 432, 1);
&brap = create_sprite(&xie, -50, 0, 131,1);
sp_base_walk(&brap, 130);
sp_speed(&brap, 5);
move_stop(&brap, 2, &yie, 1);
sp_nodraw(&crap, 1);
&target = &crap;
external("effect","killit");
sp_speed(&brap, 2);
sp_script(&brap, "en-pill");
unfreeze(1);
}
}

Script attached to walls (s2-hit.c):

void main( void )
{
int &xie;
int &yie;
int &crap;
int &brap;
sp_nodraw(&current_sprite, 1);
}

void hit( void )
{
if (&story > 19);
{
return;
}
if (&store == 0)
{
&store = 1;
&xie = random(360, 1);
&xie += 120;
&yie = random(160, 1);
&yie += 120;
&crap = create_sprite(&xie, &yie, 0, 432, 1);
&xie -= 7;
&yie -= 13;
&brap = create_sprite(&xie, -100, 0, 411, 1);
sp_speed(&brap, 5);
move_stop(&brap, 2, &yie, 1);
sp_nodraw(&crap, 1);
&target = &crap;
external("effect","killit");
sp_script(&brap, "s2-boss1");
}
}

Script of the boss (s2-boss1.c):

void main( void )
{
sp_brain(&current_sprite, 9);
sp_speed(&current_sprite, 2);
sp_target(&current_sprite, 1);
sp_base_walk(&current_sprite, 410);
sp_touch_damage(&current_sprite, 8);
preload_seq(70);
set_callback_random("beammeup",1000, 2000);
}

void hit( void )
{
unfreeze(1);
&bosspoint -= &strength;
if (&bosspoint < 1)
{
defeat();
return;
}
say("`% &bosspoint",&current_sprite);
beammeup();
unfreeze(1);
}

void beammeup( void )
{
//Where's Scotty when you need him?
&store = 2;
sp_touch_damage(&current_sprite, 0);
sp_que(&current_sprite, 2000);
//Set him floating
sp_brain(&current_sprite, 0);
int &xie = sp_x(1, -1);
int &yie = sp_y(1, -1);
&xie += 7;
&yie += 13;
&crap = create_sprite(&xie, &yie, 0, 432, 1);
sp_speed(&current_sprite, 5);
move_stop(&current_sprite, 8, 0, 1);
sp_nodraw(&current_sprite, 1);
sp_nodraw(&crap, 1);
&store = 0;
//He's up again, pillbugs may fall.
&target = &crap;
external("effect","killit");
&target = &current_sprite;
external("effect","killit");
unfreeze(1);
}

void defeat( void )
{
&store = 2;
//Floating status means now inactive.
sp_touch_damage(&current_sprite, 0);
freeze(1);
&life = &lifemax;
sp_brain(&current_sprite, 0);
sp_que(&current_sprite, -2000);
int &xie = sp_x(&current_sprite, -1);
int &yie = sp_y(&current_sprite, -1);
&xie += 20;
&yie -= 70;
int &crap = create_sprite(&xie, &yie, 7, 70, 1);
sp_seq(&crap, 70);
playsound(24, 22025, 0, 0, 0);
wait(250);
&xie -= 30;
&yie += 40;
int &crap = create_sprite(&xie, &yie, 7, 70, 1);
sp_seq(&crap, 70);
playsound(24, 22025, 0, 0, 0);
wait(250);
&xie +=20;
&yie += 20;
int &crap = create_sprite(&xie, &yie, 7, 70, 1);
sp_seq(&crap, 70);
playsound(24, 22025, 0, 0, 0);
wait(250);
&xie -= 25;
&yie -= 50;
int &crap = create_sprite(&xie, &yie, 7, 70, 1);
sp_seq(&crap, 70);
playsound(24, 22025, 0, 0, 0);
wait(250);
&xie += 15;
&yie += 30
int &crap = create_sprite(&xie, &yie, 7, 70, 1);
sp_seq(&crap, 70);
playsound(24, 22025, 0, 0, 0);
wait(250);
sp_nodraw(&current_sprite, 1);
script_attach(1000);
&story = 20;
say("I've got the key to the main boss room!",1);
add_item("item-key", 850, 6);
wait(1000);
fade_down();
&player_map = 103;
load_screen(103);
draw_screen();
fade_up();
unfreeze(1);
kill_this_task();
}

The "effect","killit" procedure looks like this:

void killit ( void )
{
//Removes a sprite permanently from the map
int &hold = sp_editor_num(&target);
if (&hold != 0)
{
editor_type(&hold, 3);
}
sp_brain(&target, 5);
sp_notouch(&target, 1);
sp_nohit(&target, 1);
sp_hard(&target, 1);
draw_hard_sprite(&target);
sp_nodraw(&target, 1);
sp_active(&target, 0);
kill_this_task();
}

&target, &bosspoints, &story and &store are all globals initted in main.c.

I hope it's in my scripting and not in the engine, because scripting can be fixed, and the engine... can be fixed too, but I'd rather fix my scripting (which I understand) than the engine (which I don't)
If anyone finds the bug, I'd really really REALLY appreciate it!
August 19th 2004, 01:43 PM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
Well, first of all, before such a complicated script is used, I typically make sure to preload all the new sprites that are going to be used in the next room before I actually load the area itself. I've been amazed at how many times this has solved seemingly unsolvable problems.

However, this probably wouldn't solve all of your problems. You have a ton of scripts running here, and I can't really find anything wrong based on the few quick glances I've given it. The only other thing I can suggest is try to find a way to cut down on the number of scripts and callbacks that are running. Dink is not a very efficient engine and has a tendancy to start shatting itself when too much is going on.
August 19th 2004, 02:19 PM
goblinm.gif
I'm not sure that you can call defeat that way.
August 19th 2004, 02:22 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I'll preload_seq() the pillbugs, the guy and the shadows, and try to merge s2-hit and s2-scr1 into s2-hit only...

Do you say I use set_callback_random("fallpill",100, 2000) or a fallpill(); with a random wait in the end. I'm afraid that when you hit the walls, it won't continue letting the pillbugs fall. That's the reason I split up the scripts...
August 19th 2004, 02:24 PM
anon.gif
MiloBones
Ghost They/Them
 
You can just call procedures the C++ way???

Why did Seth bother with that myproc crap then? (I've only used run_script_by_number and external)
August 19th 2004, 02:31 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
To be honest, I've never used run_script_by_number, except when copy/past-ed... external is holy
August 19th 2004, 02:40 PM
pq_skull.gif
Drake
Peasant He/Him
 
Are you sure you can use += in DinkC?
August 19th 2004, 02:43 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
&crap += &brap;
&crap -= &brap;
&crap * &brap;
&crap / &brap;

In all these 4 cases &crap holds the result, and it works!
August 19th 2004, 02:54 PM
pq_skull.gif
Drake
Peasant He/Him
 
Well I'm an idiot
August 19th 2004, 03:36 PM
goblinm.gif
As a matter of fact, you are (allegedly) not allowed to do &crap = &crap+&brap; or whatever.