The Dink Network

WinDinkEdit Plus: How to make a thing die? With a conditon.

September 19th 2007, 02:09 PM
slayer.gif
void hit(void)

If the &story == is, say, 0, the pig should live.
If the &story == is, say, 1, the pig should die.

The problem is, the pig dies even with &story == 0.

By the way I have done Rudiments of Scripting many times.
September 19th 2007, 02:16 PM
slayer.gif
...then again, let's do this the 2006 way.

void hit(void)

{
if (&story == 0);
{
freeze(1);
say_stop("`8H", &current_sprite);
unfreeze(1);
}
}

{
if (&story == 1);
{
freeze(1);
say_stop("`8H", &current_sprite);
sp_kill(&current_sprite);
wait(200);
say_stop("H", 1);
&story = 2;
unfreeze(1);
}
}

The pig now runs both scripts - it seems to ignore the &story command.

Also, it won't die.
September 19th 2007, 02:38 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Three things:

a)
if (&story == 0);
Remove semicolons, that's why the game ignores the value of the &story variable.

b)
sp_kill(&current_sprite);
Use sp_active(&current_sprite,0); instead. Though sp_kill(); should work if you would give it the right variables, it's just less direct.

c)
always put unfreeze(1); and &story = 2; before the sp_active(); command. When &current_sprite dies, so does the script and the last part will not be executed.
September 19th 2007, 03:30 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
d) Why are you messing around with so many braces? You only need one to open the function, one to open a condition, one to close the function and one to close a condition... Right now you coded things in such a way that you close the function before the next condition gets a chance to be executed.
September 19th 2007, 04:39 PM
slayer.gif
Where should I put the braces? Oh wait, I figured it out... I don't even know why I posted this part, but...

The pig just disappears, not really dies. I know how to make a blood explosion, but however I set the coordinates it spawns the blood in the very upper left corner?
September 19th 2007, 04:48 PM
dinkdead.gif
Instead of using sp_kill or sp_active try hurt(&current_sprite, #); where # is the amount of hitpoints the sprite has. It will kill it properly, as if it was hit.

Edit: Btw what Metatarasal pointed out in c) still applies here.
September 20th 2007, 07:44 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Rudiments of Scripting totally sucks! I tried once to make ONE script by copying it straight from the text, and still, it didn't work.
September 20th 2007, 09:48 AM
slayer.gif
Which script? Some of them are incorrect / misspelled on purpose.
September 20th 2007, 04:01 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
TROS is intended to help you learn scripting, not copy scripts directly from it. And it works great for learning to script.