Gaming
 

Drop items to corpse

From NWNWiki

When death occurs, this script strips a player character of equipment and puts it on a corpse at his/her feet. Then pops the death GUI.

[edit] The script

This script should be placed in the OnDeath slot for your module.

/**********************************
Script: Drop Items To Corpse
Created By: Jaden Wagener
Created On: 08/29/02
**********************************/
//Drops all player's equipment and half of gold onto the corpse.
//Combination of Diablo I and II death styles.
//Script should be placed in module's OnDeath slot
void main()
{
  //Set variables
  int xCount, xGold;
  object xPC, xCorpse, xItem;
  location xLoc;
  //Get player and find locations
  xPC = GetLastPlayerDying();
  xLoc = GetLocation(xPC);
  //Create corpse at player's feet
  xCorpse = CreateObject(OBJECT_TYPE_PLACEABLE,"corpse002",xLoc);
  //Drop equipment on corpse
  for (xCount = 1; xCount < 15; xCount++)
  {
    switch (xCount)
    {
      case 1: xItem = GetItemInSlot(INVENTORY_SLOT_ARMS,xPC); break;
      case 2: xItem = GetItemInSlot(INVENTORY_SLOT_ARROWS,xPC); break;
      case 3: xItem = GetItemInSlot(INVENTORY_SLOT_BELT,xPC); break;
      case 4: xItem = GetItemInSlot(INVENTORY_SLOT_BOLTS,xPC); break;
      case 5: xItem = GetItemInSlot(INVENTORY_SLOT_BOOTS,xPC); break;
      case 6: xItem = GetItemInSlot(INVENTORY_SLOT_BULLETS,xPC); break;
      case 7: xItem = GetItemInSlot(INVENTORY_SLOT_CHEST,xPC); break;
      case 8: xItem = GetItemInSlot(INVENTORY_SLOT_CLOAK,xPC); break;
      case 9: xItem = GetItemInSlot(INVENTORY_SLOT_HEAD,xPC); break;
      case 10: xItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,xPC); break;
      case 11: xItem = GetItemInSlot(INVENTORY_SLOT_LEFTRING,xPC); break;
      case 12: xItem = GetItemInSlot(INVENTORY_SLOT_NECK,xPC); break;
      case 13: xItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,xPC); break;
      case 14: xItem = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,xPC); break;
    }
    if (GetIsObjectValid(xItem))
    {
      AssignCommand(xCorpse,ActionTakeItem(xItem,xPC));
    }
  }
  //Now drop half of player's gold.
  xGold = (GetGold(xPC)/2);
  AssignCommand(xItem,TakeGoldFromCreature(xGold,xPC,FALSE));
  //Now let's pop the death GUI
  DelayCommand(2.5, PopUpDeathGUIPanel(xPC,TRUE,TRUE));
}