#include "inc_misc_tools"
void main()
    {
    object oPC = GetLastPlayerDied();
    if (!GetIsObjectValid(GetItemPossessedBy(oPC,"DeathToken")))
        SetItemCursedFlag(CreateItemOnObject("deathtoken",oPC),TRUE);
    object oLuckBlade = GetItemPossessedBy(oPC,"ssword602");
    if (GetIsObjectValid(oLuckBlade) && GetLocalInt(oLuckBlade,"iUses") > 0)
        {
        SendMessageToAllDMs(GetName(oPC)+ " " + GetPCPlayerName(oPC) + " " + "has died.");
        PopUpDeathGUIPanel(oPC,TRUE,TRUE,TRUE,"You have died wait for a fellow adventurer to Raise you from the dead. Hitting respawn will send you back to town and lower the remaining uses on your luck blade.");
        }
    else
        {
        object oBag = GetLocalObject(oPC,"LootBag");
        if (GetDistanceBetween(oPC,oBag) > 1.0
            || GetArea(oPC) != GetArea(oBag)
            || !GetIsObjectValid(oBag))
            oBag = GeneratePCLootBag(oPC,TRUE);
        AssignCommand(oBag, LootPC(oPC,oBag));
        SendMessageToAllDMs(GetName(oPC)+ " " + GetPCPlayerName(oPC) + " " + "has died.");
        PopUpDeathGUIPanel(oPC,TRUE,TRUE,TRUE,"You have died make a new character or wait for a fellow adventurer to Raise you from the dead. Hitting respawn will start you over as a level 1 character.");
        }
    }
