The Dink Network

Making a Boss with special attacks

November 8th 2010, 09:54 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Ok, so I'm getting more into difficult (well, difficult for someone like me, anyway) scripts now. I've had a go at making my own enemies and stuff, and now I'm making a boss. But I didn't want the boss to just be a fast/invincible enemy, so I'm trying to give him special attacks (Yays!). Anyway, for some reason that is beyond me, my code doesn't actually work...

(Bear with me on all the random capitals here, the boss is meant to be insane... )

attacks:
&appear = 0;
&attack = 0;
&pillbugs = 0;
&pillbugs2 = 0;
wait(1500);
&appear = random(5000, 4000);
&attack = random(5, 0);

//This attack is the goblin-eating-pillbug summon
//en-pilg is not a typo
if (&attack == 3)
{
say("`4I tHiNk I mAy iNviTe a FeW pILLbuGs tO CoMe aND heLp OuT!!", &current_sprite);
wait(200);
&pillbugs = create_sprite(417, 185, 0, 0, 0);
&pillbugs2 = create_sprite(206, 174, 0, 0, 0);
sp_script(&pillbugs, "en-pilg");
sp_target(&pillbugs, 1);
sp_script(&pillbugs2, "en-pilg");
sp_target(&pillbugs2, 1);
}

//This is the temporary speed boost
if (&attack == 2)
{
say("`4CaN YoU sTiLL EvaDe Me iF I sPeEd uP!?!?", &current_sprite);
wait(200);
sp_speed(&current_sprite, 3);
wait(&appear);
sp_speed(&current_sprite, 1);
}

//This is the temporary invisibility
if (&attack == 1)
{
say("`4LetS SeE iF yOu Can kiLL WhaT yOu Can'T SeE!!", &current_sprite);
wait(200);
sp_nodraw(&current_sprite, 1);
wait(&appear);
sp_nodraw(&current_sprite, 0);
}

//This one makes him talk
if (&attack == 0)
{
&insult = random(3, 0);
if (&insult == 0)
{
say("`4WhY DiD tHiS hAVe tO HapPeN To mE? It hUrTS So mUcH!!", &current_sprite);
}

if (&insult == 1)
{
say("`4tHiS pLaCe sHaLL BecOmE yOUr GraVe, ApPLe ThiEf!!", &current_sprite);
}

if (&insult == 2)
{
say("`4GiVe uP NoW, ChiLd!!", &current_sprite);
}

}

goto attacks;


The whole script I deemed too large for me to post, the above is just an excerpt (is that the word?) So all that is inside the boss's main procedure, looping around. But I'm getting several issues such as the boss staying permanently invisible and the boss sometimes using no more special attacks after summoning pillbugs. Any help's appreciated Also, the script is attatched to the boss via an sp_script() command in a different script, if that affects anything.
November 8th 2010, 10:16 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
I haven't looked at the script very thoroughly, but in general loops in the main procedure are problematic. The problem is that when the enemy is hit the hit procedure is run and the main procedure aborted. This means that the script rarely ever gets to the 'goto attacks;' line.

The solution is to make a separate script run these special attacks. You'll need a way to check if the boss is still alive though. The easiest way for this is to use a global variable (I hope you have a spare one around that can be freely modified in the fight and used for something else later) and to set it to wether or not the boss is alive.

So when I'm using a global called '&boslife' I use this in the boss's main procedure:
&boslife = 1;

And this in his die procedure:
&boslife = 0;

Then you can built in a check in the other script:
if (&boslife == 0)
{
//Abort the loop:
kill_this_task();
}

EDIT: Feel free to ask if something isn't clear. I kinda rushed this answer, so if I'm not clear on something I (or someone else) can probably clarify things.
November 8th 2010, 10:32 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Thanks, I'm trying that out now... Would I attach the new special attacks script to the boss as well? Or to something else? Oh, and the global variable thing's fine, there was already one controlling when the boss appears, so I'll just use that one to check if he's dead as well

EDIT: I attached it to the boss along with the normal attacks script (the one with the brain and speed and stuff) and everything seems to be working perfectly now... Huzzah! Thanks Meta!
November 9th 2010, 02:35 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
This bug is the bane of my existence. I've contacted Seth about it before, he's interested in fixing it since it also affects a few original Dink scripts. However, he's been inactive again for quite some time, it would greatly help if you also submitted a request to fix this bug