ff_u_plc_corpse
Prevent adding items to a corpse container.
Refuses any item a PC or DM tries to drop into a BodyBag or Remains container, and tells them why. Loot only comes out.
Variables
ENABLE__FF_U_PLC_CORPSE: (string) (opt-out) Set to "N" on module to disable the unit.
Source code
// @code
#include "ff_i_core"
const string ENABLE__FF_U_PLC_CORPSE = "ENABLE__FF_U_PLC_CORPSE";
// -----------------------------------------------------------------------------
const string MESSAGE = "Items cannot be added to this inventory.";
//! @brief Skip the add-item event and notify the PC if oObject is a BodyBag or Remains.
//! @param oObject The container receiving the item.
void PreventAddingToBodyBag(object oObject)
{
if ((GetTag(oObject) == TAG_BODY_BAG) || (GetTag(oObject) == TAG_REMAINS))
{
object oItem = StringToObject(NWNX_Events_GetEventData("ITEM"));
object oPC = GetPC(GetItemPossessor(oItem));
if (!GetIsPCorDM(oPC))
return;
// 67724 => "This container is full."
NWNX_Player_SetTlkOverride(oPC, 67724, MESSAGE, FALSE);
FloatingTextStringOnCreature(MESSAGE, oPC, FALSE, FALSE);
NWNX_Events_SkipEvent();
DelayCommand(0.6f, NWNX_Player_SetTlkOverride(oPC, 67724, "", FALSE));
}
}
// -----------------------------------------------------------------------------
void main()
{
if (!GetModuleFlag(ENABLE__FF_U_PLC_CORPSE, TRUE))
return;
string sEvent = NWNX_Events_GetCurrentEvent();
if (sEvent == ON_REGISTER)
SubscribeToEvent(ON_BEFORE_ADD_ITEM_INVENTORY, __FILE__);
else
PreventAddingToBodyBag(OBJECT_SELF);
}