Spawn Placeable, Conversation, and Export Scripts

Morning all,

Back again with a new set of challenges… I am in the final act of my mod and have about 90% done and working correctly. Now I’ve run into a new set of problems.

First, I want to spawn in a placeable with an item inside for the character to retrieve. The script I am using is below:


I want the script to fire when the PC enters a trigger ONLY when carrying the item tagged “treaty2.” For some reason I cannot get it to work. I am able to spawn in secret placeables, w/ & w/o inventories, with no problem. It’s probably some minor adjustment I’m ignorant of.

Next, I want a pair of short conversations to start when the PC enters the triggers only when carrying the same item “treaty2.” In one case, the first conversation WILL NOT fire as I want it to. The script I’m using is here:


In the second case, it fires no problem:

As you can see, the only difference btw scripts is the title of the conversation file. The only other notable difference is one the one that fires correctly is in an interior setting, the script that will not fire is in an exterior setting. I doubt that has anything to do with it.

I also thought it might have something to do with the script set I’m using on the NPC. But I tried it with both the standard script set on the NPC and the companion script set on the NPC with the same results.

Finally, at the end of the mod I would like to export the player’s character after the last conversation. I can find the “ExportSingleCharacter” in the script assist, but can’t figure out how to use it. Is that the correct script? If so, how do I open it, use it?

Thanks!

The scripts look correct to me…

Could it have something to do with what trigger you use perhaps? I’m just guessing here.

Ok, here’s a crude script I just made (based on one of my brother’s scripts) and it works at least for me.

#include "ginc_object"

void main()
{

object oPC = GetEnteringObject();

if(!GetIsPC(oPC)) return;

	
	int SomeoneHasTheObject = FALSE;
	
	if (GetIsObjectValid(GetItemPossessedBy(oPC,"treaty2")))
	{
	SomeoneHasTheObject = TRUE;
	}	
	
	
	if (!SomeoneHasTheObject) return;
	


       if(SomeoneHasTheObject == TRUE)
       {
	
       object oObject = SpawnPlaceableAtWP("deadnote1", "deadnote_wp");

        }

}

Assuming “helf_conv_2.dlg” exists in the module, I suspect you have maybe two instances of the NPC with tag “halfelf1”, and the first one NWN2 finds is not the one you’d like to use.

2 Likes

To start the conversation… Maybe try this (It worked for me when I tested it):

#include "ginc_ipspeaker"

void main()
{

object oPC = GetEnteringObject();

if(!GetIsPC(oPC)) return;

int SomeoneHasTheObject = FALSE;
	
	if (GetIsObjectValid(GetItemPossessedBy(oPC,"treaty2")))
	{
	SomeoneHasTheObject = TRUE;
	}	
	
	
	if (!SomeoneHasTheObject) return;
	


    if(SomeoneHasTheObject == TRUE)
    {

	CreateIPSpeaker("halfelf1", "check_room_conv", GetLocation(GetFirstPC()), 1.0f);
	
	}
	
}

For exporting your character, try this (I tried it ingame and it worked for me):

void ExportCharacter(object oPC)
{

ExportSingleCharacter(oPC);

}


void main()
{

object oPC = GetEnteringObject();

if(!GetIsPC(oPC)) return;

oPC = SetOwnersControlledCompanion(oPC);

DelayCommand(1.0, ExportCharacter(oPC));

}

Ok, I just read that you wanted to export the character at the end of a conversation. Then maybe it should look like this:

void ExportCharacter(object oPC)
{

ExportSingleCharacter(oPC);

}


void main()
{

object oPC = GetPCSPeaker();

//Would probably work with GetFirstPC() too, and maybe you don't need to use SetOwnersControlledCompanion

if(!GetIsPC(oPC)) return;

oPC = SetOwnersControlledCompanion(oPC);

DelayCommand(0.1, ExportCharacter(oPC));

}
  1. Is the player only controlling a single Main PC that carries the item? If you control another PC (who may be carrying the item), it won’t fire because it may not be the Main PC carrying the item being checked.

  2. Is the item being checked the only instance in the module? Is there a test item or another copy of the item left somewhere in the module? A duplicate will break the check.

  3. Check the spelling of the conversation file that does not fire. Does it contain a space per chance? i.e. Try testing it with a third (control) conversation.

  1. This may not fire for similar reasons to the above with respect to are you playing just a Main PC, or are you potentially controlling a second PC in a test?

  2. Try applying a ClearAllActions to both the Target and the oPC prior trying to start the conversation.

Cheers, Lance.

1 Like

If it is like Lance is saying then you could try a script like this:

#include "ginc_object"

void main()
{

object oPC = GetEnteringObject();

if(!GetIsPC(oPC)) return;


	object oFM = GetFirstFactionMember(oPC, FALSE);
	int SomeoneHasTheObject = FALSE;
	
		while(GetIsObjectValid(oFM))
	{
		if (GetIsObjectValid(GetItemPossessedBy(oFM,"treaty2")))
		{
			SomeoneHasTheObject = TRUE;
		}	
		oFM = GetNextFactionMember(oPC, FALSE);
	}
	
	if (!SomeoneHasTheObject)
	{
		return;
	}
	
	
	


       if(SomeoneHasTheObject == TRUE)
       {
	
       object oObject = SpawnPlaceableAtWP("deadnote1", "deadnote_wp");

        }
		


}

@andgalf, @Lance_Botelle, @4760, thank you all for the help! It turns out the scripts I was using were in fact firing just fine. The real problem was an unrelated error on my part. When I created the placeable that was to spawn in, I did not choose an appearance! DOH!

It only took a Philly cheesesteak and Sam Adams to spur my epiphany, but worth it in the end…

And the conversation scripts work perfectly! I’ll try the export script in the morning. Thanks again for all the help!

Dave

2 Likes

Finally finished and posted here:

https://neverwintervault.org/project/nwn2/module/hermits-chalice-final

Thanks and enjoy!

6 Likes

Congratulations on the release, @angry_yard_gnome!

1 Like

Congrats AYG, and thanks for all of your work!

1 Like

Congratulations on this release!

1 Like

THANK YOU all for the well wishes and for all of the help you provided!

2 Likes

Congratulations on the release! I am what I would guess is halfway through now. So far, it has been quite enjoyable. I haven’t run into any problems beyond a few spelling errors and some really long map load times.

1 Like

@Quixal, Thank you for downloading my mod! Glad you’re enjoying it so far. Yes, I know a few areas do take quite a while to load… The North Woods and the Swamp in particular. Sorry 'bout that, but they are exceedingly dense areas in term of placeables. The spelling errors, yeah I did my best on reading through everything a few times before I posted it, but I knew I was gonna miss a few. I haven’t had a chance to download and install a spellcheck add-on yet.

I hope you continue to have fun with it. When you complete it, let me know what kind of character you used and what your favorite part of the module was. Thanks again!

2 Likes