Converting npc to companion Help please

I recently took a head dive into nwn toolset to use it as a narrative for my irl dnd game. At first I was having issues with making it turn based. Instead I ended up using conversation actions to gain control of a creature in question. The issue with this method is the clutter. Having to rewrite a whole new conversation for every single potential enemy.

Is there a way to generalize the target? Some sort of get tag of the players target. I’ve tried every string and combination I can think of.

Better yet an item that adds target to my party.

Thanks in advance for the help

It’s possible to create an item that does pretty much anything, including fire up a generic dialog, add a creature to the player-party, take possession if you’re the DM, etc.

GetPlayerCurrentTarget(oPC)

for example

The problem I’m having is attaching either player target to actions in conversations.

Or assigning the scripts that add player target to roster (preferred) via macro or item.

this is extremely barebones

// 'addtargettoparty'
/*
    Console script that adds a creature to the Party of the player who runs this
    script.

    Right-click target the creature to add. Then at the console:

    `
    debugmode 1
    rs addtargettoparty
    debugmode 0
    `
*/

void main()
{
    object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
    if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
    {
        string sTag = GetTag(oTarget);

        if (GetRosterNameFromObject(oTarget) == "")
        {
            AddRosterMemberByCharacter(sTag, oTarget);
        }

        AddRosterMemberToParty(sTag, OBJECT_SELF);
    }
}

I tried to use your script but i couldnt figure how to implement it.
so i followed the item template and still had a hard time. I ended up with this

#include "ginc_item_script"
//i_DMcontrol_ac
/*
Template for an Activate item script.
This script will run each time an item's "custom activation" is used.

How to use this script:
Item needs an item property that will cause a custom activation such as Cast Spell:Unique Power
Replace the word "temp" (in line 1) with the tag of the item.  Rename the script with this name.  
 
Additional Info:
In general, all the item "tag-based" scripts will be named as follows:
- a prefix ("i_" by defualt)
- the tag of the item
- a postfix indicating the item event.

This script will be called automatically (by defualt) whether it exists or not.  If if does not exist, nothing happens.
 
Note: this script runs on the module object, an important consideration for assigning actions.
  -ChazM
*/
// Name_Date

void main()
{object oPC      	= GetItemActivator();
object oItem    	= GetItemActivated();
object oTarget  	= GetItemActivatedTarget();
location lTarget	= GetItemActivatedTargetLocation();
string sRosterName 	= GetTag(oTarget);
string sTarget 		= GetTag(oTarget);
string sCreature 	= GetTag(oTarget);

ExecuteScript("ga_roster_add_object",OBJECT_SELF);
ExecuteScript("ga_roster_selectable",OBJECT_SELF);
ExecuteScript("ga_roster_party_add",OBJECT_SELF);
ExecuteScript("ga_reset_level",OBJECT_SELF);

}

It successfully runs on the item activation, but crashes immediately. is it too much at once or is it missing something?

https://neverwintervault.org/project/nwn2/module/dnd-tbcs-true-turn-based-combat

you said you were having issues making it turn based, this might help.

Yes, I found this link before the download link isn’t working for me

hmm, just tested successfully.

This works with one exception… it only tracks the first target. If I target another creature i doesnt work. If i remove the first NPC and try again on the second it re adds the fisrt

#include "ginc_item_script"

void main(object oTarget, string sTarget,)
{
object oDM      	= GetItemActivator();
object oDMcontrol  	= GetItemActivated();	
object oTarget  	= GetPlayerCurrentTarget(oDM);
string sTarget 		= GetTag(oTarget);
	SetRosterNPCPartyLimit(9999);
	AddRosterMemberByCharacter(sTarget, oTarget);
	AddRosterMemberToParty(sTarget,oDM);

try dis

// item-activation script
void main()
{
    SetRosterNPCPartyLimit(9999);

    object oDM       = GetItemActivator();
    object oTarget   = GetItemActivatedTarget();
//  location lTarget = GetItemActivatedTargetLocation();
//  object oItem     = GetItemActivated();

    string sTag = GetTag(oTarget);

    AddRosterMemberByCharacter(sTag, oTarget);
    AddRosterMemberToParty(sTag, oDM);
}

It’s still just respawning the last creature

this is the same function, it just adds debug-feedback

void PrintRoster(object oDM, string sTagCurrent);

// item-activation script
void main()
{
    SetRosterNPCPartyLimit(9999);

    object oDM       = GetItemActivator();
    object oTarget   = GetItemActivatedTarget();
//  location lTarget = GetItemActivatedTargetLocation();
//  object oItem     = GetItemActivated();

    string sTag = GetTag(oTarget);

    SendMessageToPC(oDM, "\nsTag= " + sTag);
    PrintRoster(oDM, sTag);

    int bSuccess = AddRosterMemberByCharacter(sTag, oTarget);
    SendMessageToPC(oDM, "\n. tag is added to roster= " + IntToString(bSuccess));

    bSuccess = AddRosterMemberToParty(sTag, oDM);
    SendMessageToPC(oDM, ". tag is added to party= " + IntToString(bSuccess));
}

// debug funct.
void PrintRoster(object oDM, string sTagCurrent)
{
    string sRoster = GetFirstRosterMember();
    while (sRoster != "")
    {
        SendMessageToPC(oDM, "roster= " + sRoster);
        if (sRoster == sTagCurrent)
        {
            SendMessageToPC(oDM, "TAG IS ALREADY ON ROSTER");
        }

        sRoster = GetNextRosterMember();
    }
}

… if the tag is already on the rosterlist, i’m suspecting the engine gets unhappy

1 Like

Sick that pointed out exactly that the issues were ty! working wonderfully

k… i’ll point out that what you’re doing is nonstandard. Grabbing a creature and rather arbitrarily throwing it onto the roster and into the party – things like this are usually done only in more controlled conditions.

just saying, expect bugs

(they can usually be worked out tho.)

My intentions are kind of irregular. instead of using the module as an rpg. its more for the visuals and table top battle mapping. using a second computer and monitor load them in multiplayer lan DMcontrols for me and a regular account for them i expect bugs but even with bugs its not really a huge deal aslon as i can control the monsters

ah cool  :)