Add npc to roater via spell

Hi, how can I add an npc to become a companion via a spell (or just create a spell that you could possess an npc just like you can do with companions)? I found a script that adds an npc with a converstaion and tried using execute script via a spell on target npc but no go… any script I could use with a spell to target npc to them add to roster and join me?

I guess you could have an item with the Item Property Cast Spell Unique Power(Single Use) and then do a script called i_itemtag_ac (with your item’s tag replacing “itemtag”). Within that script you have the adding of the companion. The script could look something like this:

Adds a Companion NPC and sets their XP equal to the PC's if they
are below. This script merges four scripts together so that you
don't have to setup all four script calls in a conversation.

This script also has a convention: the RosterName is the same as
the creature's TAG, resref, etc. They should all be named
the same.
#include "ginc_param_const"
#include "ginc_debug"
#include "ginc_misc"

void main(string sCompanionTag)
//FROM: ga_roster_add_object
//Adds a NPC to the global roster of NPCs available to be added to
//a player's party. Roster Name is a 10-character name used to
//reference that NPC in other Roster related functions.
//The NPC will be left in the game world, but will now exist
//in the roster as well.

object oCompanion = GetObjectByTag(sCompanionTag);
int bResult = AddRosterMemberByCharacter(sCompanionTag, oCompanion);

//FROM: ga_roster_selectable
SetIsRosterMemberSelectable(sCompanionTag, 1);

//FROM: ga_roster_party_add
object oPC = GetFirstPC();
AddRosterMemberToParty(sCompanionTag, oPC);

	// Make the companion visible on the Roster GUI
	SetIsRosterMemberCampaignNPC(sCompanionTag, 0);
	// Just in case we forgot to set this, when we add a
	// companion to our party, we've met them. 
	SetLocalInt(oPC, "met_" + sCompanionTag, TRUE);

int nXP = GetPCAverageXP();
SetXP(oCompanion, nXP);
1 Like

Question: why would this be deferent (if the script itself is the same) from using this script with a spell that commands execute script on oTarget? Btw - the target will not have the normal companion scripts so would it be possible to possess it? What Im trying to do is actually a dominate monster that gives full control over the target and not just a few commands…

Not sure. I think you have be more specific of how you have done that if I’m to try and give an answer. How does the script look? Where is it situated? Is it on the NPC itself, on the spell somehow…?

Don’t exactly know. I think I have made companions where I’ve forgotten to attach the companion scripts, and if my memory serves correctly, they wouldn’t follow the PC around but you were able to control the NPC. Just try ingame to recruit the NPC without the companion scripts and then you’ll have your answer.

Im using the exact script you posted. I created a new spell and in that spell (lets say we call it dominatmon2) I use a script that has oTarget as the spell target object and then i use ExecuteScript on oTarget and the script i put in to execute is rhe script you posted. But it does nothing… So my Q was if there is a way or reason for it to work with item power

this might help

DM-helper | The Neverwinter Vault

it’s a Gui (loaded from the console) that can add a creature to the party and change its scripts

1 Like

Well Im trying to create a spell not just to control the npc… This looks like a way to edit scripts ingame… can this be used to only take the add to party command via script? This would be perfect. btw is it possible to add npcs that are not a playable race like monsters and such?

ah i see …

well if you’re good with code, the command(s) can be factored out and turned into a spell/spellscript. Unfortunately i don’t have the time to do it myself atm …

I believe so …

You saved me SO MUCH TIME!!! solved with Dm gu!! I did edited the scripts and it just works! Just edit the script to spell target and first pc. Dominate monster would be 100% better now

1 Like

Ok, I have never ever created a totally new spell before. My guess is that if you create a whole new spell then you need to alter some stuff in Spells.2da or something…Or perhaps you meant you created an item that can cast a spell? I’m sorry that I don’t fully understand.

@kevL_s has a ton more deep knowledge than I have, so he will be able to help you.

EDIT: Sorry, I posted this at the same time as you posted your post.

Thanks! Solved!