PDA

View Full Version : Help with UserDefineNumbers


Ulic and Cay
07-11-2007, 06:13 AM
Can someone explain some basics of UserDefineNumbers? I'm having some trouble...
During the arena battle with Bendak Starkiller in KotOR I want to stop combat and launch a dialog when he gets down to 1hp.
I know that in his particular UserDefine script the arena battle starts at User Defined Event Number 6000. I edited his UserDefine script there adding the "SetMinOneHP()" command, (for the purposes of the mod I'm building I only want this to happen if a particular Global Number I created has been set so that's in there too).
This part works fine. The part I can't get to work is the pause combat, start a dialog, part. I know that this is because I'm checking for his HP at the beginning of combat before any damage has been done (If I switch the "GetCurrentHitPoints(oBendakstar021) == 1" line to "GetCurrentHitPoints(oBendakstar021) > 1" the dialog will start up but at the beginning of the battle).
What I, think, I need to know is how to then advance to another Event Number when he gets down to 1hp so I can have new commands run.
Here's a portion of the script I'm using, ignore the sub1 line, it is working fine.

void main() {
int int1 = GetUserDefinedEventNumber();
if ((int1 == 6000)) {
ChangeToStandardFaction(OBJECT_SELF, 1);
sub1(GetFirstPC());
object oBendakstar021 = GetObjectByTag("Bendakstar021", 0);
if ((GetGlobalNumber("Tar_LSBenBou") == 1)) {
SetMinOneHP(oBendakstar021, 1);
if ((GetCurrentHitPoints(oBendakstar021) == 1)) {
AssignCommand(oBendakstar021, ActionStartConversation(oBendakstar021, "", 0, 0, 1, "", "", "", "", "", ""));
}
}
}
}

I realize that this question isn't very clear but that's because I'm not sure what I'm really asking. Are UserDefinedEvent the way to go about accomplishing what I want to do? If so, can someone help me with the scripting, if not, can someone point me in the right direction?
Thanks in advance

Tupac Amaru
07-11-2007, 01:16 PM
I suppose this user defined event is only run once. You can trigger user defined events with the SignalEvent command like this:

void main() {
int int1 = GetUserDefinedEventNumber();
if ((int1 == 6000)) {

{snip}

if ((GetCurrentHitPoints(oBendakstar021) == 1)) {
AssignCommand(oBendakstar021, ActionStartConversation(oBendakstar021, "", 0, 0, 1, "", "", "", "", "", ""));
} else {
DelayCommand(3.0, SignalEvent(OBJECT_SELF, EventUserDefined(6000)));
}
}
}
}

This would make the game call the event every 3 seconds. You don't need user defined events here, though. The part that checks for low hit points and starts the conversation would be better placed in Bendak's onDamage event since it is run automatically every time he takes damage.

Activate the onDamage event (if it isn't already active) by adding this line to his spawn script (k_ptar_bendak_sp.ncs):
GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED);I n his user defined event script look for event number 1006 (the number for onDamage) and add your code there.

Ulic and Cay
07-11-2007, 06:50 PM
I really should have thought of that... That's obviously a much more elegant solution. I guess I was just hung up on trying to do it with UserDefinedNumbers. Ok cool well thanks.