PDA

View Full Version : Scripting help


Silveredge9
06-28-2007, 09:02 AM
Hi, I'm having some trouble trying to determine what kind of script I would need to perform a function I intend to use.

What I'm trying to do is to have an event activate (For examples sake: Dialogue) when all 3 (and not just 1 or 2) of enemy NPC's have been killed in a fight.

Wondering if anybody could suggest a possible script? Any help is appreciated. :)

stoffe
06-28-2007, 10:30 AM
Hi, I'm having some trouble trying to determine what kind of script I would need to perform a function I intend to use.

What I'm trying to do is to have an event activate (For examples sake: Dialogue) when all 3 (and not just 1 or 2) of enemy NPC's have been killed in a fight.

Wondering if anybody could suggest a possible script? Any help is appreciated. :)

You could give the three enemy NPCs a custom OnDeath event script that checks if all three are dead or gone and if so triggers a conversation. For example:


void main() {
// Set the tags of the three NPCs here.
object oNPC1 = GetObjectByTag("FirstNPCTag");
object oNPC2 = GetObjectByTag("SecondNPCTag");
object oNPC3 = GetObjectByTag("ThirdNPCTag");

// Check if all three NPCs are dead or removed.
if ((!GetIsObjectValid(oNPC1) || GetIsDead(oNPC1))
&& (!GetIsObjectValid(oNPC2) || GetIsDead(oNPC2))
&& (!GetIsObjectValid(oNPC3) || GetIsDead(oNPC3)))
{
// Assign the tag of the NPC who dialog should start with here.
object oTalker = GetObjectByTag("NPCToTalkTo");
AssignCommand(oTalker, ClearAllActions());

// Set the name of the DLG file to use here
AssignCommand(oTalker, ActionStartConversation(GetFirstPC(), "AllDeadDialog", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE));
}

// Standard AI OnDeath shouts and custom event signals.
SpeakString("GEN_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
SpeakString("GEN_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}

Silveredge9
06-29-2007, 10:49 AM
Yup, the script works fine. Thanks for the help again. :)