Author Sticky: Post Working Scripts Here
Hotcarl44 Posted: Tuesday, 16 July 03:17AM
Name - Wand of Companions

What it does - Summons your current or previous henchman (if they have not since been hired) back to you. A nice spell effect and a greeting from the henchman will take place.

How to use - The first script below is placed on your module's OnActivateItem. The second script is placed on any henchman you have in your module in their "Actions Taken" section of their conversation tree, where they agree to join you. So, somewhere in the hiring part of the conversation.

Next, you will need to create an item to do the summoning. I used a wand, so let's take that as an example. Name it Wand of Companions, and make sure the tag is "wandofcompanions". Make it magical and give it the cast spell property, choosing unique self-only as the spell. Give it some charges.

Special notes - You MUST give your henchman a first name only, and the tag MUST match it exactly. For example, if you name your henchmam Tony, his tag must be "Tony". If you name him toNY, his tag must be "toNY". Remember, no last names - leave it blank.

Hope you like this one. I was getting sick of my henchman dying all the time... Enjoy.

Hotcarl

OnActivateItem in your module's events:

NWScript:
// This script allows a player to summon their current or former henchman

// to them.  If the henchman has been hired by someone else, a message

// will be given and the summoning will not occur.

//

// This script is very handy for those times when your henchman bites the dust,

// or if you need to do something without the henchman interfering, but want

// them back afterwards.

//

// Upon using the item that will be doing the summoning (this case it is a wand),

// a spell effect will fire and when the henchman arrives they will greet you.

// Don't forget to rehire them if they just died.

//

// *NOTES* - For this to work you MUST give your henchmen a first name only, and

// their tag MUST match exactly.  So, if you name your henchman Bob, the tag must

// be Bob.  If you name him bOB, the tag must be bOB, etc.  This will work for

// as many henchman as you want.  Remember, no last names - leave it blank.

//

// Next, create an item (I used a wand) and name its tag "wandofcompanions".

// Give it the cast spell ability, with the unique power - self only as the spell.

//

// Place this script in your module's OnActivateItem.

//

// Created by: Hotcarl

//



void main()

{

    // Get all of the names and location of the activator.

    string myhenchman;

    object oObject = GetItemActivator();

    location lLocation = GetLocation(oObject);

    object oActivated = GetItemActivated();

    string oMyhenchman = GetLocalString(oObject, myhenchman);

    string opcname = GetName(oObject);

    object oHench = GetObjectByTag(oMyhenchman);

    string oMymaster = GetLocalString(oHench, myhenchman);

    string oHenchname = GetName(oHench);



    // If the item used is the item we made

    if((GetTag(oActivated) == "wandofcompanions")) {

        // If the names match, go on.  If not, don't summon anything.

        if(oMyhenchman == oHenchname && oMymaster == opcname && oMyhenchman != "") {

            // Create a nice spell effect when the item is used.

            ApplyEffectToObject (DURATION_TYPE_INSTANT, EffectVisualEffect

                                (VFX_IMP_UNSUMMON), oObject);

            // Give the henchman a nice "coming back" line to say.

            DelayCommand (2.5, AssignCommand(oHench, SpeakString

                                            ("Good to see you again.")));

            // Summon the henchman.

            AssignCommand(oHench, JumpToLocation(lLocation));

        } // end if

        // No former henchman found, or they have been hired.  We don't want to

        // summon someone else's henchman.

        else

            AssignCommand(oObject, SpeakString("I have no former Henchmen, or they have since been hired."));

     } // end if

}// end main




This goes on the "Actions Taken" in the conversation tree of your henchman where they agree to join you.

NWScript:
// This script is placed on the "Actions Taken" section of your henchman's

// conversation tree where they say they will join you.  It sets a local

// variable on them with your name in it, and a local variable on you with

// their name in it.  This is how we will know who goes where, or if they

// have been hired since you last parted ways.  We don't want to summon

// someone else's henchman.

//

// Created by: Hotcarl

//

//



void main()

{

   // Get the names of those involved.

   object oMaster = GetMaster();

   object oHench = GetHenchman(oMaster);

   string oHenchname = GetName(oHench);

   string oMastername = GetName(oMaster);

   string myhenchman;

   // Save the henchman's name on the PC.

   SetLocalString(oMaster, myhenchman, oHenchname);

   // Save the PC's name on the henchman.

   SetLocalString(oHench, myhenchman, oMastername);

} // end main