#include "rank"


void HouseKeep(object oPC)
{
int oStop = 0;
int oStop2 = 0;
int oCount = 0;
int oCount2 = 0;

object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"xill")==1)
          {
           ++oCount;
          }
       if (FindSubString(GetResRef(oItem),"zedy")==1)
          {
           ++oCount2;
           }
        oItem = GetNextItemInInventory(oPC);
       }

oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"xill")==1)
          {

           if ((oStop!=1)&&(oCount>1))
           {
            oStop = 1;
            DestroyObject(oItem);
           }
          }
       if (FindSubString(GetResRef(oItem),"zedy")==1)
          {

           if ((oStop2!=1)&&(oCount2>1))
              {
               oStop2 = 1;
               DestroyObject(oItem);
              }
           }

         oItem = GetNextItemInInventory(oPC);
      }
}

void HouseKeep2 (object oPC)
{
int oStop3 = 0;
int oStop4 = 0;
int oCount3 = 0;
int oCount4 = 0;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"rqcv")==1)
          {
           ++oCount3;
          }
       if (FindSubString(GetResRef(oItem),"gnpd")==1)
          {
           ++oCount4;
           }
        oItem = GetNextItemInInventory(oPC);
       }
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"rqcv")==1)
          {

       if ((oStop3!=1)&&(oCount3>1))
           {
            oStop3 = 1;
            DestroyObject(oItem);
           }
          }
       if (FindSubString(GetResRef(oItem),"gnpd")==1)
          {

           if ((oStop4!=1)&&(oCount4>1))
              {
               oStop4 = 1;
               DestroyObject(oItem);
              }
           }
        oItem = GetNextItemInInventory(oPC);
        }
}

void HouseKeep3 (object oPC)
{
int oStop3 = 0;
int oStop4 = 0;
int oCount3 = 0;
int oCount4 = 0;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"xcov")==1)
          {
           ++oCount3;
          }
       if (FindSubString(GetResRef(oItem),"sntf")==1)
          {
           ++oCount4;
           }
        oItem = GetNextItemInInventory(oPC);
       }
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"xcov")==1)
          {

       if ((oStop3!=1)&&(oCount3>1))
           {
            oStop3 = 1;
            DestroyObject(oItem);
           }
          }
       if (FindSubString(GetResRef(oItem),"sntf")==1)
          {

           if ((oStop4!=1)&&(oCount4>1))
              {
               oStop4 = 1;
               DestroyObject(oItem);
              }
           }
        oItem = GetNextItemInInventory(oPC);
        }
}


void HouseKeep4 (object oPC)
{
int oStop3 = 0;
int oStop4 = 0;
int oCount3 = 0;
int oCount4 = 0;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"huvp")==1)
          {
           ++oCount3;
          }
        if (FindSubString(GetResRef(oItem),"rsco")==1)
          {
           ++oCount4;
          }
        oItem = GetNextItemInInventory(oPC);
       }
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"huvp")==1)
          {
           if ((oStop3!=1)&&(oCount3>1))
              {
               oStop3 = 1;
               DestroyObject(oItem);
              }
          }
        if (FindSubString(GetResRef(oItem),"rsco")==1)
          {
           if ((oStop4!=1)&&(oCount4>1))
              {
               oStop4 = 1;
               DestroyObject(oItem);
              }
          }
        oItem = GetNextItemInInventory(oPC);
        }
}

void HouseKeep5 (object oPC)
{
int oStop3 = 0;
int oStop4 = 0;
int oCount3 = 0;
int oCount4 = 0;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"eitz")==1)
          {
           ++oCount3;
          }
       oItem = GetNextItemInInventory(oPC);
       }
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
      {
       if (FindSubString(GetResRef(oItem),"eitz")==1)
          {
           if ((oStop3!=1)&&(oCount3>1))
              {
               oStop3 = 1;
               DestroyObject(oItem);
              }
          }
         oItem = GetNextItemInInventory(oPC);
        }
}


void StoreHits(object oPC)
{
location lPC = GetLocation(oPC);
string oHits = IntToString(GetLocalInt(oPC, "pc_hit"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"xcov")==1)
        {
         CopyObject(oItem,lPC, oPC, oHits);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}

void StoreSwings(object oPC)
{
location lPC = GetLocation(oPC);
string oHits = IntToString(GetLocalInt(oPC, "pc_swing"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"huvp")==1)
        {
         CopyObject(oItem,lPC, oPC, oHits);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}

void StoreDamage(object oPC)
{
location lPC = GetLocation(oPC);
string oDamage = IntToString(GetLocalInt(oPC, "player_dd"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"sntf")==1)
        {
         CopyObject(oItem,lPC, oPC, oDamage);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}



void StoreKills(object oPC)
{
location lPC = GetLocation(oPC);
string oKills = IntToString(GetLocalInt(oPC, "iKilled"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"xill")==1)
        {
         CopyObject(oItem,lPC, oPC, oKills);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}

void StoreDeaths(object oPC)
{
location lPC = GetLocation(oPC);
string oDeaths = IntToString(GetLocalInt(oPC, "iDied"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"zedy")==1)
        {
         CopyObject(oItem,lPC, oPC, oDeaths);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}


 void StoreAOCscore(object oPC)
{
location lPC = GetLocation(oPC);
string oDeaths = IntToString(GetLocalInt(oPC, "a_score"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"rsco")==1)
        {
         CopyObject(oItem,lPC, oPC, oDeaths);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}

 void StoreDeity(object oPC)
{
location lPC = GetLocation(oPC);
string oDeaths = IntToString(GetLocalInt(oPC, "dt_num"));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"eitz")==1)
        {
         CopyObject(oItem,lPC, oPC, oDeaths);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }
}

void GetScore(object oPC)
{
 int oKills;
 int oDeaths;
 int oChal;
 int oMonst;
 int oHit;
 int oDam;
 int oSwing;
 int oScore;
 int oDeity;
 object oLake = GetObjectByTag("lake_wp1");
 object oRug = GetObjectByTag("npc_rug");
 string oJourn;
 object oMod = GetModule();
 int oMode = GetLocalInt(oMod, "gamemode");
  if (GetItemPossessedBy(oPC, "duel_pass2")!=OBJECT_INVALID)
     {
      SetLocalInt(oPC, "starfall_dead", 1);
      if (oMode==1){AddJournalQuestEntry("mephisto", 1, oPC, FALSE, FALSE);}
      else{AddJournalQuestEntry("starfall", 1, oPC, FALSE, FALSE);}
     }
  if (oMode==1)
    {oJourn = "tyriel";}
 else
    {oJourn = "lucifer";}
 object oItem = GetFirstItemInInventory(oPC);
 while (GetIsObjectValid(oItem))
     {
      if (FindSubString(GetResRef(oItem),"xill")==1)
         {
          oKills = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"zedy")==1)
         {
          oDeaths = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"rqcv")==1)
         {
          oChal = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"gnpd")==1)
         {
          oMonst = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"xcov")==1)
         {
          oHit = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"sntf")==1)
         {
          oDam = StringToInt(GetTag(oItem));
         }
      if (FindSubString(GetResRef(oItem),"huvp")==1)
         {
          oSwing = StringToInt(GetTag(oItem));
         }
     if (FindSubString(GetResRef(oItem),"rsco")==1)
         {
          oScore = StringToInt(GetTag(oItem));
         }
     if (FindSubString(GetResRef(oItem),"eitz")==1)
         {
          oDeity = StringToInt(GetTag(oItem));
         }
     oItem = GetNextItemInInventory(oPC);
    }
  SetLocalInt(oPC, "iKilled", oKills);
  SetLocalInt(oPC, "iDied", oDeaths);
  SetLocalInt(oPC, "pc_hit", oHit);
  SetLocalInt(oPC, "player_dd", oDam);
  SetLocalInt(oPC, "pc_swing", oSwing);
  SetLocalInt(oPC, "a_score", oScore);
  SetLocalInt(oPC, "dt_num", oDeity);

 if (oMode==1)
 {
  switch (oChal)
  {
   case 1:
          {SetLocalInt(oMod, "d1_complete",1);
          AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
          }break;

   case 2:
          {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2_0", 1, oPC, FALSE, FALSE);
          }break;

   case 3:
           {SetLocalInt(oMod, "d1_complete",1);
           SetLocalInt(oMod, "d2_complete",1);
           SetLocalInt(oMod, "d2a_complete",1);
           AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
           AddJournalQuestEntry("boss2_0", 1, oPC, FALSE, FALSE);
           AddJournalQuestEntry("boss3_0", 1, oPC, FALSE, FALSE);
           }break;

   case 4:
          {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4_0", 1, oPC, FALSE, FALSE);
          }break;

  case 5:
         {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          SetLocalInt(oMod, "d4_complete",1);
          AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss5_0", 1, oPC, FALSE, FALSE);
          }break;
 case 6:
         {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          SetLocalInt(oMod, "d4_complete",1);
          SetLocalInt(oMod, "d5_complete",1);
          AddJournalQuestEntry("boss1_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss5_0", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss6_0", 1, oPC, FALSE, FALSE);
          if (GetLocalInt(oMod, "portthere")!=1)
          {SetLocalInt(oMod, "portthere", 1);
           Place("fw_portal1", "fw_portal_wp");}
          if ((GetLocalInt(oMod, "npchere")!=1)&&
              (GetItemPossessedBy(oPC, "show_ticket")==OBJECT_INVALID))
              {
               if (GetGender(oPC) == GENDER_MALE)
                  {PlaceCreature("dark_love_f", "lake_wp1");}
               else{PlaceCreature("dark_love_m", "lake_wp1");}
              }
          else if ((GetLocalInt(oMod, "npchere")!=1)&&
                   (GetItemPossessedBy(oPC, "show_ticket")!=OBJECT_INVALID))
                   {
                    if (GetGender(oPC) == GENDER_MALE)
                       {PlaceCreature("dark_love_f", "npc_rug");}
                    else{PlaceCreature("dark_love_m", "npc_rug");}
                   }
         }break;




 }
 }
 else
 {
  switch (oChal)
  {
   case 1:
          {SetLocalInt(oMod, "d1_complete",1);
          AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
          }break;

   case 2:
          {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2", 1, oPC, FALSE, FALSE);
          }break;

   case 3:
           {SetLocalInt(oMod, "d1_complete",1);
           SetLocalInt(oMod, "d2_complete",1);
           SetLocalInt(oMod, "d2a_complete",1);
           AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
           AddJournalQuestEntry("boss2", 1, oPC, FALSE, FALSE);
           AddJournalQuestEntry("boss3", 1, oPC, FALSE, FALSE);
           }break;

   case 4:
          {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4", 1, oPC, FALSE, FALSE);
          }break;

  case 5:
         {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          SetLocalInt(oMod, "d4_complete",1);
          AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss5", 1, oPC, FALSE, FALSE);
          }break;
 case 6:
         {SetLocalInt(oMod, "d1_complete",1);
          SetLocalInt(oMod, "d2_complete",1);
          SetLocalInt(oMod, "d2a_complete",1);
          SetLocalInt(oMod, "d3_complete",1);
          SetLocalInt(oMod, "d4_complete",1);
          SetLocalInt(oMod, "d5_complete",1);
          AddJournalQuestEntry("boss1", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss2", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss3", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss4", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss5", 1, oPC, FALSE, FALSE);
          AddJournalQuestEntry("boss6", 1, oPC, FALSE, FALSE);
          if (GetLocalInt(oMod, "portthere")!=1)
          {SetLocalInt(oMod, "portthere", 1);
           Place("fw_portal1", "fw_portal_wp");}
          if ((GetLocalInt(oMod, "npchere")!=1)&&
              (GetItemPossessedBy(oPC, "show_ticket")==OBJECT_INVALID))
              {
               if (GetGender(oPC) == GENDER_MALE)
                  {PlaceCreature("light_love_f", "lake_wp1");}
               else{PlaceCreature("light_love_m", "lake_wp1");}
              }
          else if ((GetLocalInt(oMod, "npchere")!=1)&&
                   (GetItemPossessedBy(oPC, "show_ticket")!=OBJECT_INVALID))
                   {
                    if (GetGender(oPC) == GENDER_MALE)
                       {PlaceCreature("light_love_f", "npc_rug");}
                    else{PlaceCreature("light_love_m", "npc_rug");}
                   }
          }break;
 }
 }
switch (oMonst)
{
case 1:
{SetLocalInt(oPC, "wurmdead",1);}break;


case 2:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);}break;

case 3:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);}break;

case 4:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);}break;

case 5:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);}break;

case 6:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);
SetLocalInt(oPC, "paledead",1);}break;

case 7:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);
SetLocalInt(oPC, "paledead",1);
SetLocalInt(oPC, "marilithdead",1);}break;

case 8:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);
SetLocalInt(oPC, "paledead",1);
SetLocalInt(oPC, "marilithdead",1);
SetLocalInt(oPC, "bossdead",1);}break;

case 9:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);
SetLocalInt(oPC, "paledead",1);
SetLocalInt(oPC, "marilithdead",1);
SetLocalInt(oPC, "bossdead",1);
SetLocalInt(oPC, "lorddead",1);}break;

case 10:
{SetLocalInt(oPC, "wurmdead",1);
SetLocalInt(oPC, "balrogdead",1);
SetLocalInt(oPC, "doppledead",1);
SetLocalInt(oPC, "pitfienddead",1);
SetLocalInt(oPC, "hdfienddead",1);
SetLocalInt(oPC, "paledead",1);
SetLocalInt(oPC, "marilithdead",1);
SetLocalInt(oPC, "bossdead",1);
SetLocalInt(oPC, "lorddead",1);
SetLocalInt(oPC, "luciferdead",1);
AddJournalQuestEntry(oJourn, 1, oPC, FALSE, FALSE);
}break;
}
switch (oDeity)
{
case 1:
{SetDeity(oPC, "Baccob");}break;

case 2:
{SetDeity(oPC, "Corellon");}break;

case 3:
{SetDeity(oPC, "Ehlonna");}break;

case 4:
{SetDeity(oPC, "Erythnul");}break;

case 5:
{SetDeity(oPC, "Fharlanghn");}break;

case 6:
{SetDeity(oPC, "Garl Glittergold");}break;

case 7:
{SetDeity(oPC, "Gruumish");}break;

case 8:
{SetDeity(oPC, "Heironeous");}break;

case 9:
{SetDeity(oPC, "Hextor");}break;

case 10:
{SetDeity(oPC, "Kord");}break;

case 11:
{SetDeity(oPC, "Moradin");}break;

case 12:
{SetDeity(oPC, "Nerull");}break;

case 13:
{SetDeity(oPC, "Obad-Hai");}break;

case 14:
{SetDeity(oPC, "Olidammara");}break;

case 15:
{SetDeity(oPC, "Pelor");}break;

case 16:
{SetDeity(oPC, "Saint Cuthburt");}break;

case 17:
{SetDeity(oPC, "Vecna");}break;

case 18:
{SetDeity(oPC, "Wee Jas");}break;

case 19:
{SetDeity(oPC, "Yondalla");}break;

case 20:
{SetDeity(oPC, "Mystra");}break;

case 21:
{SetDeity(oPC, "Tyr");}break;
}
if (GetDeity(oPC)==""){SendMessageToPC(oPC, "You are godless.");}
else {SendMessageToPC(oPC, GetDeity(oPC)+" watches over you.");}

DelayCommand(4.0, GetRank(oPC));
}


void StoreChall(object oPC)
{
int oChal;
object oMod = GetModule();

if (GetLocalInt(oMod, "d1_complete")==1){oChal = 1;}
if (GetLocalInt(oMod, "d2_complete")==1){oChal = 2;}
if (GetLocalInt(oMod, "d2a_complete")==1){oChal = 3;}
if (GetLocalInt(oMod, "d3_complete")==1){oChal = 4;}
if (GetLocalInt(oMod, "d4_complete")==1){oChal = 5;}
if (GetLocalInt(oMod, "d5_complete")==1){oChal = 6;}

location lPC = GetLocation(oPC);
string oKills = IntToString(oChal);
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"rqcv")==1)
        {
         CopyObject(oItem,lPC, oPC, oKills);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }



}

void StoreMon(object oPC)
{
int oMonDead;

if (GetLocalInt(oPC, "wurmdead")==1){oMonDead = 1;}
if (GetLocalInt(oPC, "balrogdead")==1){oMonDead = 2;}
if (GetLocalInt(oPC, "doppledead")==1){oMonDead = 3;}
if (GetLocalInt(oPC, "pitfienddead")==1){oMonDead = 4;}
if (GetLocalInt(oPC, "hdfienddead")==1){oMonDead = 5;}
if (GetLocalInt(oPC, "paledead")==1){oMonDead = 6;}
if (GetLocalInt(oPC, "marilithdead")==1){oMonDead = 7;}
if (GetLocalInt(oPC, "bossdead")==1){oMonDead = 8;}
if (GetLocalInt(oPC, "lorddead")==1){oMonDead = 9;}
if (GetLocalInt(oPC, "luciferdead")==1){oMonDead = 10;}
location lPC = GetLocation(oPC);
string oKills = IntToString(oMonDead);
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
    {
     if (FindSubString(GetResRef(oItem),"gnpd")==1)
        {
         CopyObject(oItem,lPC, oPC, oKills);
         DelayCommand(0.5, DestroyObject(oItem));
         return;
        }
     oItem = GetNextItemInInventory(oPC);
    }



}




//void main () {}