Aller au contenu

Photo

Trigger Help


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
Barnabas2

Barnabas2
  • Members
  • 65 messages
Today I placed some trigger on one of my maps. Unfortunally none of my triggers worked. I placed two kinds of triggers:
the first kind is a generic trigger. The trigger should close and lock a door, when the player enters the trigger. For that I set the ga_door_close script OnEnter and set two variables: sTag for the door tag and nLock = 1 in ther properties of the trigger. As Isaid before, the trigger do not work.
The other trigger I used was a start conversation trigger. I wrote a conversation and set the tag for the talking npc and the name of the conversation in the variables in the trigger properties.
That do not work neither. What did I do wrong?

#2
kamal_

kamal_
  • Members
  • 5 258 messages
without further details, it's impossible to tell. You can post the code at http://pastebin.myrror.net/

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
GA_ scripts that accept variable input only work from within conversations.

To get them to work from a trigger with its own local variables, you'd have to get rid of the input variables from within the main() brackets and redefine them using GetLocalxxx functions.

So instead of this:

void main(string sTag)
{
// do something
}

You would have:

void main()
{
string sTag = GetLocalString(OBJECT_SELF, "VariableName");
// do something
}

#4
Barnabas2

Barnabas2
  • Members
  • 65 messages
Ok, I saw, that I put the wrong script into the first kind of trigger - I cannot put the ga_door_close script on a trigger - I need to modify it.
But the second kind of trigger makes me nervous, because I cannot see, where the mistake is.
I placed the SpeakTrigger and unchecked the Onetimetrap (don´t know if this option is right - I use the german version, so I don´t know how to translate) and the trap disarming and checked TrapRecoverable in the properties of the trap. The Onenter script gtr_speak_node is set by default.
Now I put the following variables:
NPC_tag=(the tag of my npc)
Conversation=(Conversationfile name)
Node=0
Run=-1 (thought it would make the NPC stay, where he was placed=
TalkNow=1 (thought it would start the conversation immidiatly, without moving the NPC first)
Cutscenebars =0
OnlyOnce=0
MultiUse=1
CombatCutscene=0
I thought the trigger should be run like this, when the PC enters the trigger: The set conversation starts immidiatly and the NPC stays where he was placed. When the PC enters the trigger again, the conversation starts again, but it runs like this:
When the PC enters the trigger, the NPC moves slowly to the PC, then the conversation starts one time. When the conversation finished, the trigger does not work anymore. The NPC does not move anymore, no conversation starts.
What I wanted to do is, that if the player wants to leave the area and has a special item in his inventory, the conversation starts. For this I placed the trigger in front of the door that leads to the next area.

P.S. I ran the module as a campain, where I set the conversation distance to 999.

Modifié par Barnabas2, 12 octobre 2011 - 08:33 .


#5
Dorateen

Dorateen
  • Members
  • 477 messages

Barnabas2 wrote...
I thought the trigger should be run like this, when the PC enters the trigger: The set conversation starts immidiatly and the NPC stays where he was placed. When the PC enters the trigger again, the conversation starts again, but it runs like this:
When the PC enters the trigger, the NPC moves slowly to the PC, then the conversation starts one time. When the conversation finished, the trigger does not work anymore. The NPC does not move anymore, no conversation starts.
What I wanted to do is, that if the player wants to leave the area and has a special item in his inventory, the conversation starts. For this I placed the trigger in front of the door that leads to the next area.

P.S. I ran the module as a campain, where I set the conversation distance to 999.


If I gather what you are looking to do, it sounds like you need one conversation that will be the one called from the trigger.

The first RED NPC line of this conversation (the Root) should have a conditional check for the special item in the Player's inventory.

Then there should be a second RED NPC line, another Root, under this that would be when the PC enters the trigger without the item, presumably for the first time.

In this way, there will be a "Fall through" because the player doesn't have the item, and it will default to the second NPC Root. It looks like you have the trigger set to Multi-use, so it wil fire again when the PC enters it. And if he has the item, the conversation will fire from the first NPC Root, the one requiring the special item.

Again, these are both part of the same conversation, which will be the one attached to your trigger.

Also, on the NPC Root when the Player enters for the first time, you can also change the node property to "once per game", this way it will not display again, whether the PC has the item of not.

Finally, once you are completely finished with this NPC interaction and do not need the trigger anymore, you can also destroy the Speak Trigger.

Hopefully, that makes some sense.

#6
Barnabas2

Barnabas2
  • Members
  • 65 messages
I have the conversation with conditions, that check the players inventory, my main problems with the trigger are, that the conversation only starts one time and I want to start the conversation everytime the player enters the trigger. I want to prevent, that the player leaves the area with this item in the inventory. The other problem is, that I want the NPC to stay where he is and not come to the pc for the conversation.
With my understanding of the script, this should work with the variables I set.

#7
Dann-J

Dann-J
  • Members
  • 3 161 messages
When you set Run to -1 and Talk Now to 1, did you make sure you put the values in the Integer slot? They won't work if you put them in the Float or String slots.

#8
Barnabas2

Barnabas2
  • Members
  • 65 messages
I checked it, after I read your answer, but yes, all variables are set where they belong. It still does not work as planned.

For my initial problem with triggers ( a trigger, that should close and maybe lock a door, when the player enters the trigger) I tried to write a script:

void main (string sTag, int nLock)
{
object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

object oDoor = GetObjectByTag ( sTag );

DelayCommand ( 0.1, AssignCommand( oDoor, ActionCloseDoor( oDoor ) ) );
if ( nLock == 1 ) SetLocked( oDoor, TRUE );


}

I put the script as the OnEnter script of the trigger and set the variables sTag and nLock, but the script does not work. Every door stays open. What did I do wrong with the script?

#9
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Get rid of your parameter, a trigger is NOT a conversation script, you have to use the functions and features that work in the type of script you are doing. This is a very basic script for jumping a character to a waypoint, which you could adapt ( instead of moving to a waypoint, the tag could be used to get and open a door. )

/*
This is a basic trigger to allow jumping to locations.

The ladder has an onuse event which this is put in. The variable is put on the ladder trigger with
the name of "TG_LADDER_WP", this contains the tag of a waypoint. Entering the trigger moves the character
 directly to the way point. Ideally the waypoint is set so it makes sense ( bottom of a hill, other side of a bridge, etc.
*/
//#include "_CSLCore_Environment"

void main()
{
	object oPC =  GetEnteringObject();
	object oLadder = OBJECT_SELF;
	string sWaypointName = GetLocalString( oLadder, "TG_LADDER_WP");
	string sMessage = GetLocalString( oLadder, "TG_LADDER_MESSAGE");
	object oWayPoint = GetObjectByTag( sWaypointName );
	
	//SpeakString("Taking character to "+sWaypointName);
	if ( GetIsObjectValid( oWayPoint ) )
	{
		location lWaypoint = GetLocation( oWayPoint );
		lWaypoint = CalcSafeLocation( oPC, lWaypoint, 10.0f, FALSE, FALSE );
		AssignCommand(oPC, JumpToLocation(lWaypoint));
		if ( sMessage != "" )
		{
			SendMessageToPC( oPC, sMessage );
		}
		
		// this stuff i never got working properly, the companions just don't listen fast enough :)
		object oPM = GetFirstFactionMember( oPC, FALSE );
		while ( GetIsObjectValid( oPM ) == TRUE )
		{
			if ( GetMaster( oPM ) == oPC && GetDistanceBetween(oPM, oPC) < RADIUS_SIZE_ASTRONOMIC )
			{
				AssignCommand( oPM, ClearAllActions() );
				AssignCommand( oPM, ActionForceMoveToLocation(GetLocation(oLadder), TRUE, 60.0f));
				
				//if ( GetIsPlaceableObjectActionPossible(oLadder, PLACEABLE_ACTION_USE) )
				//{
				//	AssignCommand(	oPM, ActionInteractObject(oLadder)); // assuming this gets the pets to use the placeable
					//AssignCommand(	oPM, ActionDoCommand(ExecuteScript("TG_Ladder_OnUse", oPM)));
				//}
			}
			oPM = GetNextFactionMember( oPC, FALSE );
		}
	}
}

Modifié par painofdungeoneternal, 12 octobre 2011 - 11:56 .


#10
Barnabas2

Barnabas2
  • Members
  • 65 messages
Ok, I changed the script now like this:

void main ()
{
object oPC = GetEnteringObject();
object oDoor = GetObjectByTag ( "sTag" );
string sTag = GetLocalString ( oDoor, "" );
int nLock = GetLocalInt (oDoor, "" );

if (!GetIsPC(oPC)) return;


DelayCommand ( 0.1, AssignCommand( oDoor, ActionCloseDoor( oDoor ) ) );
if ( nLock == 1 ) SetLocked( oDoor, TRUE );


}

I know, it won´t work - tried it yet - but I want to understand why.

And what do I have to set, if I want a trigger to fire everytime the PC enters?

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages
Here's a version that will work:

void main ()
{
object oPC = GetEnteringObject();
string sTag = GetLocalString (OBJECT_SELF, "sTag" );// get string variable from trigger
int nLock = GetLocalInt (OBJECT_SELF, "nLock" );// get int variable from trigger
object oDoor = GetObjectByTag(sTag);

if (!GetIsPC(oPC)) return;


DelayCommand ( 0.1, AssignCommand( oDoor, ActionCloseDoor( oDoor ) ) );
if ( nLock == 1 ) SetLocked( oDoor, TRUE );

}

#12
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
DannJ's script should work for you - but just to explain how/why it works - set the tag of the door on the trigger as a string variable. The script will read that string and then look for the door with that tag, once it finds it, it will lock that specific door. The door needs to have a unique tag, if more than one door (in the entire module) has the same tag as this door, it may lock the wrong door.

#13
Barnabas2

Barnabas2
  • Members
  • 65 messages
Will this script work everytime the player enters the trigger, or only one time? I ask because this is really a problem I have with triggers, they work only one time.

#14
Dann-J

Dann-J
  • Members
  • 3 161 messages
Unless you script it to work only once (such as setting and checking a local or global variable, or deleting the trigger entirely), it should fire every time. If you unlock the door another way, it will keep relocking every time the PC enters the trigger.