RoT2_PRC8/_module/nss/pws_nodropunique.nss
Jaysyn904 499aba4eb3 Initial upload
Initial upload
2023-09-25 18:13:22 -04:00

224 lines
7.3 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name Ultimate NoDrop and Unique Items
//:: FileName pws_nodropunique
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Ultimate NoDrop and Unique Items v1.1
Description:
NoDrop items are items you cant get rid from your inventory.
Quest items cannot be dropped or traded but can be destroyed in trashcan.
You can have only one Unique item of a type in your inventory.
If you have any doubts check out demo module.
Script Setup:
1. If u have custom onAcquire and/or onUnAcquire events
Open your onAcquire event script.
Add this line at the beggining of file
#include "pws_nodropunique"
Add this line to your main function
void CheckForUnique();
Open your onUnAcquire event script.
Add this line at the beggining of file
#include "pws_nodropunique"
Add this line to your main function
void CheckForNoDrop();
In Module Setup
Put "!!! NODROP ITEMS !!!", "!!! UNIQUE ITEMS !!!" and "!!! QUEST ITEMS !!!"
someplace players cant reach them. Blueprints included in erf.
Place some trashcans around your module to let players get rid of not
wanted quest items.
Then put items you want to be nodrop and/or unique into proper chest.
This script checks item tag so if you change it with CopyObject it will NOT work
Changes:
v1.1
- Added Quest items
- Added checking for nodrop/quest items inside dropped traded container.
*/
//:://////////////////////////////////////////////
//:: Created By: Phervers
//:: Created On: 25.06.03
//:://////////////////////////////////////////////
// Edit this messages to yout liking
// Remember to compile your onAcquired and onUnacquired scripts afterward !!!!!!
const string PWS_MESSAGE_NODROP = "You can't drop or trade this item";
const string PWS_MESSAGE_UNIQUE = "This item is unique you can't have two";
const string PWS_MESSAGE_QUEST = "This is a quest item you can't drop or trade it";
const string PWS_MESSAGE_CONTENTS = " and it's contents";
const string PWS_MESSAGE_DESTROYED = " is trashed.";
const int PWS_FLOATY_TEXT = 1; // 1 - FloatyText 0 - SendMessageToPC
// Do not change that unless u know what ur doing
const string PWS_UNIQUE_CHEST_TAG = "pws_unique_objects";
const string PWS_NODROP_CHEST_TAG = "pws_nodrop_objects";
const string PWS_QUEST_CHEST_TAG = "pws_quest_objects";
const string PWS_TRASHCAN_TAG = "pws_trashcan";
const string PWS_CONVERSATION_RESREF = "pws_trashcan";
// Function Proto
// Checks if item acquired by player is unique
// Put into onAcquired event of your module
void CheckForUnique();
// Checks if item dropped by player is nodrop
// Put into onUnacquired event of your module
void CheckForNoDrop();
// Function Implementation
void PWS_TellPC(object oPC, string sMessage) {
if(PWS_FLOATY_TEXT)
FloatingTextStringOnCreature(sMessage, oPC);
else
SendMessageToPC(oPC, sMessage);
}
void CheckForUnique() {
object oItem = GetModuleItemAcquired();
object oPC = GetItemPossessor(oItem);
string sTag = GetTag(oItem);
object oUniquItemsChest = GetObjectByTag(PWS_UNIQUE_CHEST_TAG);
if(!GetIsPC(oPC))
return;
if(GetIsObjectValid(GetItemPossessedBy(oUniquItemsChest, sTag))){
object oItem1;
int n = 0;
oItem1 = GetFirstItemInInventory(oPC) ;
while(oItem1 != OBJECT_INVALID) {
if(GetTag(oItem1)==sTag)
n++;
oItem1 = GetNextItemInInventory(oPC);
}
if(n>1) {
PWS_TellPC(oPC, PWS_MESSAGE_UNIQUE);
CopyObject(oItem, GetLocation(oPC));
DestroyObject(oItem);
}
}
}
void CheckForNoDrop(){
object oContainer = GetModuleItemLost();
object oItem;
object oPC = GetModuleItemLostBy();
object oNODROP_chest = GetObjectByTag(PWS_NODROP_CHEST_TAG);
object oQUEST_chest = GetObjectByTag(PWS_QUEST_CHEST_TAG);
string sTag;
int bQuest, bNoDrop;
if(!GetIsPC(oPC))
return;
if(GetTag(GetItemPossessor(oContainer))==PWS_TRASHCAN_TAG) // If player is
return; // trashing stuff return
if(GetHasInventory(oContainer)){ // Browse through container inventory
oItem = GetFirstItemInInventory(oContainer);
while(oItem!=OBJECT_INVALID){
sTag = GetTag(oItem);
bQuest = GetIsObjectValid(GetItemPossessedBy(oQUEST_chest, sTag));
bNoDrop = GetIsObjectValid(GetItemPossessedBy(oNODROP_chest, sTag));
if( bQuest|| bNoDrop ){
PWS_TellPC(oPC, (bNoDrop?PWS_MESSAGE_NODROP:PWS_MESSAGE_QUEST));
CopyObject(oItem, GetLocation(oPC), oPC);
DestroyObject(oItem);
}
oItem = GetNextItemInInventory(oContainer);
}
}
oItem = oContainer;
sTag = GetTag(oItem);
bQuest = GetIsObjectValid(GetItemPossessedBy(oQUEST_chest, sTag));
bNoDrop = GetIsObjectValid(GetItemPossessedBy(oNODROP_chest, sTag));
if( bQuest|| bNoDrop ){
PWS_TellPC(oPC, (bNoDrop?PWS_MESSAGE_NODROP:PWS_MESSAGE_QUEST));
CopyObject(oItem, GetLocation(oPC), oPC);
DestroyObject(oItem);
}
}
// Trashcan functions
void TrashAnItem() {
object oContainer = GetInventoryDisturbItem();
object oItem;
object oPC = GetLastUsedBy();
object oNODROP_chest = GetObjectByTag(PWS_NODROP_CHEST_TAG);
string sTag;
if(!GetIsPC(oPC))
return;
// Browse through container inventory
if(GetHasInventory(oContainer)){
oItem = GetFirstItemInInventory(oContainer);
while(oItem!=OBJECT_INVALID){
sTag = GetTag(oItem);
if(GetIsObjectValid(GetItemPossessedBy(oNODROP_chest, sTag))){
PWS_TellPC(oPC, PWS_MESSAGE_NODROP);
CopyObject(oItem, GetLocation(oPC), oPC);
DestroyObject(oItem);
}
oItem = GetNextItemInInventory(oContainer);
}
}
oItem = oContainer;
sTag = GetTag(oItem);
if(GetIsObjectValid(GetItemPossessedBy(oNODROP_chest, sTag))){
PWS_TellPC(oPC, PWS_MESSAGE_NODROP);
CopyObject(oItem, GetLocation(oPC), oPC);
DestroyObject(oItem);
return;
}
SetLocked(OBJECT_SELF, TRUE);
SetLocalObject(OBJECT_SELF, "PWS_ITEM_TO_TRASH", oItem);
SetLocalObject(OBJECT_SELF, "PWS_PC_TRASHING", oPC);
string sToken = GetName(oItem);
if(GetHasInventory(oItem))
sToken = sToken + PWS_MESSAGE_CONTENTS;
SetCustomToken(10001, sToken);
ActionStartConversation(oPC, PWS_CONVERSATION_RESREF);
}
void DoTrash(){
object oItem = GetLocalObject(OBJECT_SELF, "PWS_ITEM_TO_TRASH");
object oPC = GetLocalObject(OBJECT_SELF, "PWS_PC_TRASHING");
PWS_TellPC(oPC, GetName(oItem) + PWS_MESSAGE_DESTROYED);
DestroyObject(oItem);
SetLocked(OBJECT_SELF, FALSE);
}
void CancelTrash(){
object oItem = GetLocalObject(OBJECT_SELF, "PWS_ITEM_TO_TRASH");
object oPC = GetLocalObject(OBJECT_SELF, "PWS_PC_TRASHING");
CopyObject(oItem, GetLocation(oPC), oPC);
DestroyObject(oItem);
SetLocked(OBJECT_SELF, FALSE);
}