UW2_PRC8/_module/nss/ac_namingtool.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

76 lines
1.8 KiB
Plaintext

////////////////////////////////////
//Created by Genisys / Guile 6/14/08
////////////////////////////////////
/*
This is a tagbased item script for
the item Tagnamed "namingtool"
which spawns a listener starts
a conversation with the PC to allow
them to name thier item they target.
*/
////////////////////////////////////
#include "x2_inc_switches"
void main()
{
// Check if we have the correct event firing the script
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;
object oPC;
object oTarget;
object oSpawn;
location lTarget;
object oItem;
object oListener;
oPC = GetItemActivator();
oTarget = oPC;
oItem = GetItemActivatedTarget();
lTarget = GetLocation(oTarget);
if (GetIsInCombat(GetItemActivator()))
{
SendMessageToPC(GetItemActivator(), "This item is not useable in combat!");
return;
}
if (GetObjectType(oItem)!= OBJECT_TYPE_ITEM)
{
SendMessageToPC(GetItemActivator(), "You must target an item!!");
return;
}
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "namer", lTarget);
oListener = oSpawn;
//Let's make sure that all of thier variables are clear..
DeleteLocalString(oPC, "ONID");
DeleteLocalString(oPC, "ONN");
DeleteLocalInt(oPC, "NUSER");
//Set this string on the item so we can ID it later..
SetLocalString(oItem, "ONID", "MEME");
//Set this string on the PC so we can Name the item if something goes wrong.
SetLocalString(oPC, "ONN", GetName(oItem));
//Set the name in the conversation.
SetCustomToken(6000, GetName(oItem));
//Set an Int on the PC to ID the PC as the user..
SetLocalInt(oPC, "NUSER", 1);
//To insure we don't have any problems later...
DelayCommand(80.4, DeleteLocalString(oPC, "ONID"));
DelayCommand(80.5, DeleteLocalString(oPC, "ONN"));
DelayCommand(80.6, DeleteLocalInt(oPC, "NUSER"));
DelayCommand(120.7, DestroyObject(GetObjectByTag("namer"), 0.0f));
}