#include "NW_O2_CONINCLUDE"

void main()
{
    // Get the creature who triggered this event.
    object oPC = GetLastOpenedBy();

    // Only fire once.
    if ( GetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF)) )
        return;
    SetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);

    // If the PC is a certain class.
    if ( GetLevelByClass(CLASS_TYPE_BARBARIAN, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_FIGHTER, oPC) > 0 )
    {
        // Give "magichainmail" to the PC.
        CreateItemOnObject("magichainmail", OBJECT_SELF);
    }

    // If the PC is a certain class.
    if ( GetLevelByClass(CLASS_TYPE_BARD, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_DRUID, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_RANGER, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_ROGUE, oPC) > 0 )
    {
        // Give "magicleatherar" to the PC.
        CreateItemOnObject("magicleatherar", OBJECT_SELF);
    }

    // If the PC is a certain class.
    if ( GetLevelByClass(CLASS_TYPE_CLERIC, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_PALADIN, oPC) > 0 )
    {
        // Give "magichalfplate" to the PC.
        CreateItemOnObject("magichalfplate", OBJECT_SELF);
    }

    // If the PC is a certain class.
    if ( GetLevelByClass(CLASS_TYPE_MONK, oPC) > 0 )
    {
        // Give "warmnkstnc" to the PC.
        CreateItemOnObject("warmnkstnc", OBJECT_SELF);
    }

    // If the PC is a certain class.
    if ( GetLevelByClass(CLASS_TYPE_SORCERER, oPC) > 0  ||
         GetLevelByClass(CLASS_TYPE_WIZARD, oPC) > 0 )
    {
        // Give "magicusersrob" to the PC.
        CreateItemOnObject("magicusersrob", OBJECT_SELF);
    }
    object oLastOpener = GetLastOpener();
    GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
    ShoutDisturbed();
}
