REO-EE/_module/nss/td_it_quillpen.nss
Jaysyn904 f82740bbbd Initial commit
Initial commit
2024-02-22 13:22:03 -05:00

336 lines
13 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name: Quill Pen Item Event Script
//:: FileName: td_it_quillpen
//:://////////////////////////////////////////////
/*
This is an example on how to use the
new default module events for NWN to
have all code concerning one item in
a single file.
Note that this system only works, if
the following events set on your module
OnEquip - x2_mod_def_equ
OnUnEquip - x2_mod_def_unequ
OnAcquire - x2_mod_def_aqu
OnUnAcqucire - x2_mod_def_unaqu
OnActivate - x2_mod_def_act
This is the on aquired and on activate script
for the player book writing quill
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-09-10
//:: Modified By: Thales Darkshine (Russ Henson)
//:: Modified On: 07-20-2008
//:://////////////////////////////////////////////
#include "x2_inc_switches"
#include "td_quill_inc"
#include "inc_mysql_tables"
#include "inc_system_const"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
object oPC;
object oItem;
object oItem2;
object oItem3;
object oTarget;
int iType;
location lTargetLoc;
oPC = GetItemActivator();
oItem = GetItemActivated();
oTarget = GetItemActivatedTarget();
lTargetLoc = GetItemActivatedTargetLocation();
iType = GetBaseItemType(oTarget);
string sTag = GetTag(oTarget);
string sLastChat = GetLocalString(oPC,"TD_QUILLCHAT");
object oDatabase = GetItemPossessedBy(oPC, "database");
int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER);
//Persistent NPCs Storage - Drakaden 13/06/11
if (GetIsDM(oPC) && !GetIsDM(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
{
if (GetStringLeft(sLastChat, 8)=="npcsave-")
{
int iText = (GetStringLength(sLastChat)-8);
string sText = GetStringRight(sLastChat,iText);
//StoreCampaignObject("REO_Persistent_NPCs", "Pers_NPC_" + sText + "", oTarget);
StoreMySQLObjectKeyString("dm_saved_npcs", "NPC", sText, oTarget, "UniqueName");
FloatingTextStringOnCreature("Pers_NPC_" + sText + " saved. NOTE: Those can be overwrote by any DMs, make sure you do not overwrite each others.", oPC, FALSE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
if (GetIsDM(oPC))
{
if (GetStringLeft(sLastChat, 8)=="npcload-")
{
int iText = (GetStringLength(sLastChat)-8);
string sText = GetStringRight(sLastChat,iText);
//RetrieveCampaignObject("REO_Persistent_NPCs", "" + sText + "", lTargetLoc);
RetrieveMySQLObjectKeyString("dm_saved_npcs", "NPC", sText, "UniqueName");
FloatingTextStringOnCreature("" + sText + " loaded.", oPC, FALSE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
//NPC name changer - Drakaden 29/05/11
// check to see if pen was used on an NPC and the user is a DM
if (GetIsDM(oPC) && !GetIsPC(oTarget) && !GetIsDM(oTarget))
{
if (GetStringLeft(sLastChat, 5)=="name-")
{
int iText = (GetStringLength(sLastChat)-5);
string sText = GetStringRight(sLastChat,iText);
SetName(oTarget, sText);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
//DM commands - Drakaden 29/06/07
if (GetIsDM(oPC))
{
if (GetObjectType(oTarget) == OBJECT_TYPE_ITEM)
{
if (GetStringLeft(sLastChat, 10)=="duplicate-")
{
int iText = (GetStringLength(sLastChat)-10);
string sText = GetStringRight(sLastChat,iText);
int iNumber1 = StringToInt(sText);
int iNumber2 = 0;
if (iNumber1 >= 21)
{
iNumber1 = 20;
FloatingTextStringOnCreature("You cannot duplicate more than a quantity of 20 at a time to prevent lag and unwanted behaviors.", oPC, FALSE);
}
if (iNumber1 >= 2)
{
while (iNumber2 < iNumber1)
{
CopyItem(oTarget, oPC, TRUE);
iNumber2 = iNumber2 + 1;
}
}
else
{
CopyItem(oTarget, oPC, TRUE);
}
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 7)=="update-")
{
CreateItemOnObject(GetResRef(oTarget), GetItemPossessor(oTarget), GetItemStackSize(oTarget));
DestroyObject(oTarget);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 6)=="curse-")
{
SetItemCursedFlag(oTarget, TRUE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 8)=="uncurse-")
{
SetItemCursedFlag(oTarget, FALSE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 7)=="destroy-")
{
DestroyObject(oTarget);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 5)=="plot-")
{
SetPlotFlag(oTarget, TRUE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 7)=="unplot-")
{
SetPlotFlag(oTarget, FALSE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
//For debug purposes, get the nearest placeable tag
if (GetStringLeft(sLastChat, 8)=="plactag-")
{
object oPlaceable = GetNearestObject(OBJECT_TYPE_PLACEABLE, oPC);
SendMessageToAllDMs(GetTag(oPlaceable));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
//Character description changer - Drakaden 29/05/11
//Updated by Drakaden, allows the DMs to use delete-, desc-, newpara- on anything, for editing items, placeables NPCs and players descriptions.
if (oTarget == oPC || GetIsDM(oPC))
{
if (GetStringLeft(sLastChat, 7)=="delete-")
{
SetDescription(oPC, " ", TRUE);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 5)=="desc-")
{
int iText = (GetStringLength(sLastChat)-5);
string sText = GetStringRight(sLastChat,iText);
WriteDesc(oTarget, sText);
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
if (GetStringLeft(sLastChat, 8)=="newpara-")
{
int iText = (GetStringLength(sLastChat)-8);
string sText = GetStringRight(sLastChat,iText);
WriteDesc(oTarget, "\n\n");
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
// make PC examine quill
//DeleteLocalString(oPC,"TD_QUILLCHAT");
//AssignCommand(oPC,ActionExamine(oItem));
//return;
}
//:://////////////////////////////////////////////
/*
if pen was used on a blank book either set the books
new name or update its descritpion with the players
last chat message.
*/
//:://////////////////////////////////////////////
if (iType == BASE_ITEM_BOOK)
{
//Modified by Drakaden, notebooks can now be wrote on like blank books
if (sTag == "td_it_blankbook" || sTag == "notebook") //blank book allow writing
{
if (GetStringLeft(sLastChat, 5)=="name-")
{
int iTitle = (GetStringLength(sLastChat)-5);
string sName = GetStringRight(sLastChat,iTitle);
SetBookName(oTarget, sName);
FloatingTextStringOnCreature(NAME_BOOK,oPC,FALSE);
//SendMessageToPC(oPC,NAME_BOOK);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
else if(GetStringLeft(sLastChat, 6)=="write-")
{
int iText = (GetStringLength(sLastChat)-6);
string sText = GetStringRight(sLastChat,iText);
WriteBook(oTarget, sText);
FloatingTextStringOnCreature(WRITE_BOOK,oPC,FALSE);
SendMessageToPC(oPC,WRITE_BOOK);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
else //do if is published book
{
//* if item is book but not a blank one tell pc that you cant write in this book
FloatingTextStringOnCreature(BOOK_DONE,oPC,FALSE);
//SendMessageToPC(oPC,BOOK_DONE);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}//* done with books
//:://////////////////////////////////////////////
/*
section for sheets of parchment, they can be writen on
but not named like books
*/
//:://////////////////////////////////////////////
else if (iType == BASE_ITEM_MISCMEDIUM)
{
if (sTag == "td_it_blankparch")//* if item is the blank parchemnt do this
{
if (GetStringLeft(sLastChat, 5)=="name-")
{
int iTitle = (GetStringLength(sLastChat)-5);
string sName = GetStringRight(sLastChat,iTitle);
SetNoteName(oTarget, sName);
FloatingTextStringOnCreature(NAME_NOTE,oPC,FALSE);
//SendMessageToPC(oPC,NAME_NOTE);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
else if(GetStringLeft(sLastChat, 6)=="write-")
{
int iText = (GetStringLength(sLastChat)-6);
string sText = GetStringRight(sLastChat,iText);
WriteNote(oTarget, sText);
FloatingTextStringOnCreature(WRITE_NOTE,oPC,FALSE);
//SendMessageToPC(oPC,WRITE_NOTE);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
else
//Added by Drakaden, allows new paragraph
if (GetStringLeft(sLastChat, 8)=="newpara-")
{
int iText = (GetStringLength(sLastChat)-8);
string sText = GetStringRight(sLastChat,iText);
WriteDesc(oTarget, "\n\n");
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
}
//:://////////////////////////////////////////////
/*
all other items, tell PC that this cant be written on
*/
//:://////////////////////////////////////////////
else
{
//tell pc they cant write on this item
FloatingTextStringOnCreature(NOT_BOOK,oPC,FALSE);
//SendMessageToPC(oPC,NOT_BOOK);
AssignCommand(oPC,PlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD,1.0,4.0));
DeleteLocalString(oPC,"TD_QUILLCHAT");
return;
}
}
}