121 lines
4.0 KiB
Plaintext
121 lines
4.0 KiB
Plaintext
//Script Name: genisys
|
|
//////////////////////////////////////////
|
|
// Created By: Genisys (Guile)
|
|
// Created On: 8/12/08 (My Birthday :)
|
|
//
|
|
// (TABASED ITEM SCRIPT)
|
|
/////////////////////////////////////////
|
|
/*
|
|
This is a tagbased item script for:
|
|
"The Tool" tagnamed "genisys", whic does
|
|
a lot of different things in a conversation
|
|
which is started privately with the PC.
|
|
*/
|
|
////////////////////////////////////////
|
|
#include "x2_inc_switches"
|
|
|
|
//Main Script
|
|
void main()
|
|
{
|
|
int nEvent = GetUserDefinedItemEventNumber(); //Which event triggered this
|
|
object oPC; //The player character using the item
|
|
object oItem; //The item being used
|
|
object oSpellOrigin; //The origin of the spell
|
|
object oSpellTarget; //The target of the spell
|
|
int iSpell; //The Spell ID number
|
|
object oTarget; //Define oTarget below
|
|
object oObject; //Define oObject below
|
|
int nInt; //Often used for visual effects (define below)
|
|
int nLvl; //Often used to define user or target's level (HD
|
|
object oSpawn;
|
|
object oListener;
|
|
location lTarget;
|
|
|
|
//Set the return value for the item event script
|
|
// * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done
|
|
// * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done
|
|
int nResult = X2_EXECUTE_SCRIPT_END;
|
|
|
|
switch (nEvent)
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
case X2_ITEM_EVENT_ACTIVATE:
|
|
// * This code runs when the Unique Power property of the item is used or the item
|
|
// * is activated. Note that this event fires for PCs only
|
|
{
|
|
oPC = GetItemActivator(); // The player who activated the item
|
|
oItem = GetItemActivated(); // The item that was activated
|
|
oTarget = GetItemActivatedTarget();
|
|
lTarget = GetLocation(oPC);
|
|
|
|
// Not useable in combat..
|
|
if (GetIsInCombat(GetItemActivator()))
|
|
{
|
|
SendMessageToPC(GetItemActivator(), "This item is not useable in combat!");
|
|
|
|
//Tell the system we are done resting!
|
|
SetLocalInt(oPC, "REST_STARTED", 0);
|
|
return;
|
|
}
|
|
|
|
if(GetObjectType(oTarget)==OBJECT_TYPE_ITEM && GetItemPossessor(oTarget) == oPC)
|
|
{
|
|
//Let's tell the script what the item is now!
|
|
oItem = GetItemActivatedTarget();
|
|
|
|
//Let's make sure that all of thier variables are clear..
|
|
DeleteLocalString(oPC, "ONIDC");
|
|
DeleteLocalString(oPC, "ONNC");
|
|
DeleteLocalString(oPC, "ONID");
|
|
DeleteLocalString(oPC, "ONN");
|
|
DeleteLocalInt(oPC, "NUSER");
|
|
|
|
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "namer", lTarget);
|
|
|
|
oListener = oSpawn;
|
|
|
|
//Set Strings on PC to ID the item later..
|
|
SetLocalString(oItem, "ONIDC", GetResRef(oItem));
|
|
SetLocalString(oPC, "ONNC", GetName(oItem));
|
|
|
|
//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);
|
|
|
|
DelayCommand(0.2, AssignCommand(GetObjectByTag("namer"),
|
|
ActionStartConversation(oPC, "", TRUE, TRUE)));
|
|
|
|
//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));
|
|
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
oTarget = oPC;
|
|
AssignCommand(oTarget, ActionStartConversation(oPC, "genisysconv", TRUE));
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
//Pass the return value back to the calling script
|
|
SetExecutedScriptReturnValue(nResult);
|
|
}
|
|
|