Jump to content

Home

How to make a trigger fire once?


R2-X2

Recommended Posts

Posted

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.

Posted

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));

}

}

}

Posted

Sorry, but can you do a script that only checks, and doesn't do anything else? I need it for other things, which I'm going to insert in the script.

Posted

Try this.

 

void main() {
  if( !GetLocalBoolean( OBJECT_SELF, 40 ) && GetEnteringObject() == GetFirstPC() ) {
     // Stuff
     SetLocalBoolean( OBJECT_SELF, 40, TRUE );
  }
  else {
     // Stuff
  }
}

 

- Star Admiral

Posted

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?

Archived

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

×
×
  • Create New...