// v2.1.0 - Updated for new Rez system.
//::////////////////////////////////////////////////////////////////////////////
//:: FileName:  hark_d_rez_pc_19
//::////////////////////////////////////////////////////////////////////////////
/*
   This will give the PC either a Raise Dead or Resurrection Scroll to use on
  the corpse of the master.
*/
//::////////////////////////////////////////////////////////////////////////////
#include "hark_i0_henlvl"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
  object oPC = GetPCSpeaker();
  string sPCName = GetName(oPC);
  string sMyName = GetName(OBJECT_SELF);
  object oMaster = GetRealMaster();
  object oPCT = GetItemPossessedBy(OBJECT_SELF, "PlayerCorpse");
  object oRezScr1 = GetItemPossessedBy(OBJECT_SELF, "NW_IT_SPDVSCR702");
  object oRezScr2 = GetItemPossessedBy(OBJECT_SELF, "7ResurrectionD_C");
  object oRezScr3 = GetItemPossessedBy(OBJECT_SELF, "NW_IT_SPDVSCR501");
  object oRezScr4 = GetItemPossessedBy(OBJECT_SELF, "5RaiseDeadD_C");
  object oItem = OBJECT_INVALID;
  if (GetIsObjectValid(oRezScr1))
    { oItem = oRezScr1; }
  else if (GetIsObjectValid(oRezScr2))
    { oItem = oRezScr2; }
  else if (GetIsObjectValid(oRezScr3))
    { oItem = oRezScr3; }
  else if (GetIsObjectValid(oRezScr4))
    { oItem = oRezScr4; }


  if (GetIsObjectValid(oItem) && GetIsObjectValid(oPCT))
    {
     // Drop the PCT and set the locals.
     ActionPutDownItem(oPCT);
     SetLocalInt(OBJECT_SELF, HS_REZ_WAIT_CNT, 0);
     SetLocalInt(OBJECT_SELF, HS_REZ_WAITING, TRUE);
     SetLocalObject(OBJECT_SELF, HS_REZ_OFFERED, oPC);

     // Copy the scroll and destroy the original.
     object oNew = CopyItem(oItem, oPC);
     if (GetIsObjectValid(oNew))
       { DestroyObject(oItem); }

     // Give master some FeedBack.
     int bFeedback = GetLocalInt(GetObjectByTag(HS_VARS_OBJ), HS_VAR_REZ_FDB);
     if (bFeedback)
       { SendMessageToPC(oMaster, sMyName + REZ_MSG24 + sPCName + "."); }
    }
}
//::////////////////////////////////////////////////////////////////////////////
