void main()
{
 object oPC = GetLastDisturbed();
 object oKeyNew  = GetObjectByTag("StrangeKeySE");
 object oKey     = GetObjectByTag("StrangeKey");
 object oBrace   = GetObjectByTag("Brace");
 object oTernion = GetObjectByTag("Ternion");
 int nInt=GetLocalInt(oPC, "NW_JOURNAL_ENTRYjt_keys");

 if (GetIsObjectValid(oPC) &&
 (GetInventoryDisturbType() == INVENTORY_DISTURB_TYPE_REMOVED) &&
 (GetInventoryDisturbItem() == oKeyNew))
 {
 //If PC already has the ternion, give the quadrangle
 if (!(GetItemPossessedBy(oPC, "Ternion") == OBJECT_INVALID))
  {
  SetPlotFlag(oKeyNew, FALSE);
  DestroyObject(oKeyNew, 0.0);
  SetPlotFlag(oTernion, FALSE);
  DestroyObject(oTernion, 0.0);
  CreateItemOnObject("quadrangle", oPC);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_MAGBLUE), oPC);
  if (nInt >= 1)
   {
   PlaySound("gui_journaladd");
   AddJournalQuestEntry("jt_keys", 5, oPC, TRUE, FALSE);
   }
  }
 //If PC already has the brace, give the ternion
 else if (!(GetItemPossessedBy(oPC, "Brace") == OBJECT_INVALID))
  {
  SetPlotFlag(oKeyNew, FALSE);
  DestroyObject(oKeyNew, 0.0);
  SetPlotFlag(oBrace, FALSE);
  DestroyObject(oBrace, 0.0);
  CreateItemOnObject("ternion", oPC);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_MAGBLUE), oPC);
  if (nInt >= 1)
   {
   PlaySound("gui_journaladd");
   AddJournalQuestEntry("jt_keys", 4, oPC, TRUE, FALSE);
   }
  }
 //If PC already has a key, give the brace
 else if (!(GetItemPossessedBy(oPC, "StrangeKey") == OBJECT_INVALID))
  {
  SetPlotFlag(oKeyNew, FALSE);
  DestroyObject(oKeyNew, 0.0);
  SetPlotFlag(oKey, FALSE);
  DestroyObject(oKey, 0.0);
  CreateItemOnObject("brace", oPC);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_MAGBLUE), oPC);
  if (nInt >= 1)
   {
   PlaySound("gui_journaladd");
   AddJournalQuestEntry("jt_keys", 3, oPC, TRUE, FALSE);
   }
  }
 //If PC does not have the key yet
 else if (GetItemPossessedBy(oPC, "StrangeKey") == OBJECT_INVALID)
  {
  SetPlotFlag(oKeyNew, FALSE);
  DestroyObject(oKeyNew, 0.0);
  CreateItemOnObject("strangekey", oPC);
  if (nInt >= 1)
   {
   PlaySound("gui_journaladd");
   AddJournalQuestEntry("jt_keys", 2, oPC, TRUE, FALSE);
   }
  }
 }
else return;
}
