Party Leader Script

I have a conversation that needs some party leader scripts added. I’m wanting players to have the option to join their party leader’s quest.

The first part I need help with, is a starting conditional that only displays the conversation option if the player is NOT the party leader.

If they aren’t the party leader, then when selecting that option in the conversation, they’ll be teleported to a waypoint. However, they can only teleport to the party leader if the party leader has an item in their inventory.

If party leader has an item with the tag “quest” and that item has a local int (“PC_QUEST”, 1), then teleport the player to “waypoint001”
else if party leader has an item with the tag “quest” and that item has a local int (“PC_QUEST”, 2), then teleport the player to “waypoint002”
else do nothing and send a floating text over the player’s head “Your party leader is not currently on a quest.”

Any help would be great!

I think that’s done with GetFactionLeader(), Lexicon be praised.

Try this:

int StartingConditional()
object oPC = GetPCSpeaker();
return GetFactionLeader(oPC) != oPC;

And this:

void main()
    object oPC     = GetPCSpeaker();
    object oLeader = GetFactionLeader(oPC);
    object oItem   = GetItemPossessedBy(oLeader, "quest");

    // If the party leader possesses the item:
    if (oItem != OBJECT_INVALID)
        string sTargetWP;
        int nJump;
        int nQuest = GetLocalInt(oItem, "PC_QUEST");

        switch (nQuest)
        	case 1:
				nJump = TRUE;
				sTargetWP = "waypoint001";

			case 2:
				nJump = TRUE;
				sTargetWP = "waypoint002";
				SendMessageToPC(oPC, "This quest is not listed as joinable.");

        if (nJump)
			AssignCommand(oPC, ClearAllActions());
			AssignCommand(oPC, JumpToObject(GetWaypointByTag(sTargetWP)));
		// The party leader does not possess the quest item.
        SendMessageToPC(oPC, "Your party leader is not currently on a quest.");
1 Like

Awesome thanks!

Another question, where do you add scripts to fire when players join and leave a party?

I don’t think there are events for that. :thinking: What exactly do you need to happen on party join/leave, and why? :smiley: Maybe there are alternatives. Party management usable item? If party joining/leaving was handled via an item or custom spells, you could tie scripted events into the item/spell script.

Possibly a case for the archmage rungs of NWN wizardry. @Shadooow, I invoke you! The question is “How to have stuff happen when players join or leave a party?”.

1 Like

*Who summons me? Ah @TheBarbarian, what do you need old friend? I see, okay I will share my knowledge with you then."

Reliable? Only with NWN©X. If this is singleplayer that makes it quite unusable option - players tends to avoid NWNCX and if it is for NWN:EE then this is not even option.

If this is persistent world it would be doable easier as player doesn’t need the nwnx plugin.

I guess, you need to do it via hearbeat which obviously won’t be as precise. And are you tracking henchmans or players? Anyway, it would be something like this:
in henchman heartbeat:

  • check if GetMaster() is valid
  • if yes
    – check if master matches last master stored in local variable, if yes return
    – if no, set master into local variable, run OnPartyLeft on last master, run OnPartyJoin on current master
  • if no
    – check if there is a valid master stored in local variable, if no return
    – if yes, run OnPartyLeft on him and delete the variable containing master

If you want to track players leaving party, you cannot use GetMaster, it would be bit more complicated. Also you need to use script named ‘default’.


Thank you both. I think I can get away with storing everything I need into that “quest” item players will have anyway!

Another problem I’m trying to get working right is an onenter area script.

void main()
object oTarget = OBJECT_SELF;
object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

ExploreAreaForPlayer(GetArea(oPC), oPC);

int nBosscount = GetLocalInt(oTarget, "BOSS_COUNTER");
SetLocalInt(oTarget, "BOSS_COUNTER", nBosscount);


This works great, it’s adding the int on the area as needed for each player that enters. However, I’m trying to also have the int count a specific creature that may enter the area with players also.

I tried changing the

if (!GetIsPC(oPC)) return;


string sTarget = GetTag(oPC);
string sPrefix = GetStringLeft(sTarget, 4);
if (sPrefix != “wolf” || !GetIsPC(oPC)) return;

But, it’s not working!

(Note that there are multiple wolves, wolf001, wolf002, wolf003, etc which is why I’m just getting the first 4 letters of the names.

The correct check shoud be:

if (sPrefix != "wolf" && !GetIsPC(oPC)) return;
1 Like

If it’s && then what happens if the player enters the area without the wolf?

I find it can be helpful to read out what the code says in english.

If entering PC is not the wolf AND PC is not a pc then return and do nothing else.


if PC is not the wolf AND PC is a PC then we don’t return and we continue with the script.

It’s basic boolean algebra. !(a || b) becomes (!a && !b).

1 Like

One thought here. You could probably do to download a couple of ebooks that I wrote - “TR’s Basics - Boolean Algebra” and “TR’s Basics - Decisions”. These should help you to understand how these things work.


1 Like

Thanks all!