#include "x0_i0_secret"
#include "nw_i0_tool"

void main()
{
    object oKeyHolder = GetItemActivator();

    if (HasItem(oKeyHolder, "AmonDT05"))
        {
            FloatingTextStringOnCreature("You already have a key.", oKeyHolder);

        }
else
    {
    if (HasItem(oKeyHolder, "AmonDT02"))
        {
    if (HasItem(oKeyHolder, "AmonDT03"))
        {
    if (HasItem(oKeyHolder, "AmonDT04"))
        {
        object oItemToTake1;
        object oItemToTake2;
        object oItemToTake3;
        object oItemToTake4;

        oItemToTake1 = GetItemPossessedBy(oKeyHolder, "AmonDT01");
        oItemToTake2 = GetItemPossessedBy(oKeyHolder, "AmonDT02");
        oItemToTake3 = GetItemPossessedBy(oKeyHolder, "AmonDT03");
        oItemToTake4 = GetItemPossessedBy(oKeyHolder, "AmonDT04");

        DestroyObject(oItemToTake1);
        DestroyObject(oItemToTake2);
        DestroyObject(oItemToTake3);
        DestroyObject(oItemToTake4);

        location lLocation = GetLocation(oKeyHolder);
        effect eEffect1 = EffectVisualEffect(VFX_DUR_DEATH_ARMOR);

        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect1, lLocation);
        AssignCommand(oKeyHolder, PlaySound("as_an_hawk1"));

        GiveXPToCreature(oKeyHolder, 5000);
        CreateItemOnObject("AmonDT05", oKeyHolder, 1);

        }
            else
            {
            FloatingTextStringOnCreature("You must have all four pieces of the Tomb Key before combining them.", oKeyHolder);
            }
        }
            else
            {
            FloatingTextStringOnCreature("You must have all four pieces of the Tomb Key before combining them.", oKeyHolder);
            }
        }
            else
            {
            FloatingTextStringOnCreature("You must have all four pieces of the Tomb Key before combining them.", oKeyHolder);
            }
    }
}