Jump to content

Home

How to make a trigger fire once?


R2-X2

Recommended Posts

I've used these script conditionals before:

// ST: Check if it's the player entering the trigger, and that it hasn't already fired

if (!GetLocalBoolean(OBJECT_SELF, 40) && (GetEnteringObject() == GetFirstPC())) {

 

and:

 

// ST: Make sure the trigger only fires once.

SetLocalBoolean(OBJECT_SELF, 40, TRUE);

 

 

Don't know if that helps at all.

Link to comment
Share on other sites

I'm sorry, it was part of a larger script. Here is the full script I use to fire a dialog only once when a trigger is entered:

 

void main() {

// ST: Check if it's the player entering the trigger, and that it hasn't already fired

if (!GetLocalBoolean(OBJECT_SELF, 40) && (GetEnteringObject() == GetFirstPC())) {

// ST: Get the two NPCs who should converse, set their tags below.

object oNPC1 = GetObjectByTag("xyz");

object oNPC2 = GetObjectByTag("abc");

// ST: Check if both NPCs who should converse are present in the area

if (GetIsObjectValid(oNPC1) && GetIsObjectValid(oNPC2)) {

// ST: Make sure the trigger only fires once.

SetLocalBoolean(OBJECT_SELF, 40, TRUE);

// ST: Start the dialog.

AssignCommand(oNPC1, ActionStartConversation(GetFirstPC(), "dialog name", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE));

}

}

}

Link to comment
Share on other sites

That's what I was looking for. Thanks for your help you two.

 

Edit: Is there a way to modify the script so it can be triggered by friendly2 and hostile2 (only f. and h. 2, not hostile1/friendly1) NPCs?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...