Awesome. Thank you for actually reading through that mess. Ok...
_Knightmare_ wrote...
I think your problem might be with this line in the OnDeath:
nInt -= -1;
Subtracting a negative value is the same as adding a positive value. 1 - (-1) = 2
Fixed the double negative.
In your HB script, you have it set to return out if the value is greater than or equal to 1. Change the -1 to a positive 1 and see what happens.
This shouldn't matter, actually, because I set the variable to 0 in the on death script if the gladiator find no enemies. Or I would, if this would fire right.
Also, you might want to move the ExecuteScript to the end of your script. Firing off the default script may cause it to do some actions or whatever that you did not intend or interfere with the rest of your script. Do what you need to do first, then have it execute the default.
If I do that, it cuts the player out of any experience rewards for kills during the battle.
Secondary questions...
Is there a way, while within a loop, to kick out of the entire script similar to the way 'return' does outside of the loop?
You can use a return inside a loop in the same manner you can use it outside a loop. You did this in your line:
if (GetIsEnemy(oSpectater, oKiller))
return;
This might be why the gates are not closing, etc. It could be that the script is detecting that oSpectater and oKiller are enemies and ending the script (firing off the return).
It is quite sloppy. I want it to end the script until the last hostile faction member is killed, at which point it will find no enemy and the script should run all the way through.
I made an improved version, because my 'GetNearestCreature' was picking people in the audience. So here it is...
// Gladiator's OnDeath script by Robert Donald Paiser
void main()
{
ExecuteScript("nw_c2_default7", OBJECT_SELF);
object oArea;
oArea = GetArea(GetNearestObjectByTag("ArenaCenter"));
int nInt;
nInt = GetLocalInt(oArea, "Gladiators In Game");
nInt -= 1;
SetLocalInt(oArea, "Gladiators In Game", nInt);
object oKiller;
object oSpectater;
object oSgate;
oSgate = GetObjectByTag("SouthGameGate");
oKiller = GetLastKiller();
int iSpectaters = 1;
while (iSpectaters <= 15)
{
iSpectaters++;
oSpectater = GetNearestObjectByTag("Gladiator", oKiller, 1);
if (GetIsEnemy(oSpectater, oKiller))
return;
}
SetLocked(oSgate, FALSE);
AssignCommand(oSgate, ActionOpenDoor(oSgate));
DelayCommand(20.0, AssignCommand(oSgate, ActionCloseDoor(oSgate)));
DelayCommand(20.0, SetLocked(oSgate, TRUE));
AssignCommand(oKiller, ClearAllActions());
AssignCommand(oKiller, ActionMoveToObject(GetObjectByTag("SouthGameExit")));
AssignCommand(oKiller, ActionJumpToObject(GetObjectByTag("BigExit")));
DelayCommand(30.0, SetLocalInt(oArea, "Gladiators In Game", 0));
}
However, nothing fires outside my loop. Therefore, the check for enemies must be so quick that it detects the dead guy. I'm open for suggestions here!
In the 'GetNearestCreature', the second criteria is aparently mandatory but what in the Nine Hells does it mean? I don't understand it. I threw ''4'' in there just to make it compile.It references which nearest creature to the target.
So, as written, you have it set to look for the 4th nearest creature to oKiller.
Excellent. I see now!