ff_u_inv_remains

TODO.

Prevent adding objects to BodyBag inventory.

Source code

// @code


#include "ff_i_core"

const string ENABLE__FF_U_INV_REMAINS = "ENABLE__FF_U_INV_REMAINS";


// -----------------------------------------------------------------------------

const string MESSAGE = "Items cannot be added to this container.";

//! @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 = GetItemPossessor(oItem);
    if (!GetIsPC(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()
{
  object oModule = GetModule();
  if (!GetModuleFlag(ENABLE__FF_U_INV_REMAINS, FALSE))
    return;

  string sEvent = GetCurrentEvent();
  if (sEvent == ON_REGISTER)
    SubscribeToEvent(ON_BEFORE_ADD_ITEM_INVENTORY, __FILE__);
  else if (sEvent == ON_BEFORE_ADD_ITEM_INVENTORY)
    PreventAddingToBodyBag(OBJECT_SELF);
}