pkmnfrk
07-31-2007, 12:15 AM
Let's say you've got a totally awesome, fully scripted boss. Let's pretend, theoretically that its name is "King Gleeok". And that it's awesome, etc.
A possible implementation, which is totally theoretical, mind you, is as such:
Each head spawns an enemy (Head) which is invisible, and has HP corresponding to the head's HP. The script, each frame, places the enemy onto the location of its FFC, so that Link may attack the head, and do damage. Fine.
There is also a separate enemy (Body) which is also invisible, invincible, has 1 HP, and sits in the very top-left corner. It is marked as the boss. Each head, upon having its enemy die, checks to see if there is only one enemy left in the room before terminating. If so, it sets the Body's HP to 0. The Body dies, the door opens, etc.
Further, the head script (the only script needed), checks to see if there are any enemies in the room in the first place, to avoid spawning heads without a body, if its already been defeated.
Problems
1. Each head keeps a pointer to its enemy:
npc nme = Screen->CreateNPC(178);
The idea is that each head checks to see if all heads are dead, and kills the body if so:
if(Screen->NumNPCs() < nmes) {
//something died.
if(nme->HP > 0) {
//phew, not us. update, and ignore
nmes = Screen->NumNPCs();
} else {
//crap, it's us. We bite the dust.
npc master = Screen->LoadNPC(1);
if(Screen->NumNPCs() == 1) {
master->HP = 0;
}
break;
}
}
Right now, when Link kills a Head enemy, each Head after it moves down a slot, and the head script is none the wiser. Which ever head had the last enemy then notices that its enemy is now dead. The net result is that after Link kills X heads, X being the total number of heads, the body dies, and he wins. However, they die in the wrong order.
Is there some way to fix this? (DD, you would be the best to answer this, I think)
2. If #1 is not possible, can anyone else think of a workable solution? I don't care about changing the structure, I just want it to, overall, act like any other boss (the door opens when all heads are dead, does not return when killed, etc.)
I do have a script written that mostly works (except for the above issues), but there is no point in posting it, since 99% of everything I haven't posted above is just presentation.
A possible implementation, which is totally theoretical, mind you, is as such:
Each head spawns an enemy (Head) which is invisible, and has HP corresponding to the head's HP. The script, each frame, places the enemy onto the location of its FFC, so that Link may attack the head, and do damage. Fine.
There is also a separate enemy (Body) which is also invisible, invincible, has 1 HP, and sits in the very top-left corner. It is marked as the boss. Each head, upon having its enemy die, checks to see if there is only one enemy left in the room before terminating. If so, it sets the Body's HP to 0. The Body dies, the door opens, etc.
Further, the head script (the only script needed), checks to see if there are any enemies in the room in the first place, to avoid spawning heads without a body, if its already been defeated.
Problems
1. Each head keeps a pointer to its enemy:
npc nme = Screen->CreateNPC(178);
The idea is that each head checks to see if all heads are dead, and kills the body if so:
if(Screen->NumNPCs() < nmes) {
//something died.
if(nme->HP > 0) {
//phew, not us. update, and ignore
nmes = Screen->NumNPCs();
} else {
//crap, it's us. We bite the dust.
npc master = Screen->LoadNPC(1);
if(Screen->NumNPCs() == 1) {
master->HP = 0;
}
break;
}
}
Right now, when Link kills a Head enemy, each Head after it moves down a slot, and the head script is none the wiser. Which ever head had the last enemy then notices that its enemy is now dead. The net result is that after Link kills X heads, X being the total number of heads, the body dies, and he wins. However, they die in the wrong order.
Is there some way to fix this? (DD, you would be the best to answer this, I think)
2. If #1 is not possible, can anyone else think of a workable solution? I don't care about changing the structure, I just want it to, overall, act like any other boss (the door opens when all heads are dead, does not return when killed, etc.)
I do have a script written that mostly works (except for the above issues), but there is no point in posting it, since 99% of everything I haven't posted above is just presentation.