#include "inc_item_tools"
void main()
    {
    object oItem = GetItemActivated();
    string sTag = GetTag (oItem);
    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    location lLoc = GetItemActivatedTargetLocation();
    object oTemp,oFall,oTrap;
    effect eEffect;
    int i,j,iDam;
    if (sTag == "ring005")
        {
        if (GetRacialType(oTarget) == RACIAL_TYPE_ANIMAL)
            ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectDominated(),oTarget);
        }
    else if (sTag == "ring022")
        JumpToLocation(lLoc);
    else if (sTag == "ring034"
        || sTag == "ring030"
        || sTag == "miscc004")
        {
        Fly();
        }
    else if (sTag == "ring039")
        {
        // Determine number of targets stop at 4.
        oTarget = GetNearestObject(OBJECT_TYPE_CREATURE,oPC,i = 1);
        while (GetIsObjectValid(oTarget) && j < 4)
            {
            if (GetIsEnemy(oTarget,oPC))
                j+=1;
            oTarget = GetNearestObject(OBJECT_TYPE_CREATURE,oPC,i+=1);
            }
        iDam = 5 - j;
        if (iDam == 5)// No targets shut down
            return;
        oTarget = GetNearestObject(OBJECT_TYPE_CREATURE,oPC,i = 1);
        while (i <= j)
            {
            if (GetIsEnemy(oTarget,oPC))
                AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectLinkEffects(EffectDamage(d6(iDam),DAMAGE_TYPE_ELECTRICAL),EffectVisualEffect(VFX_IMP_MIRV)),oTarget));
            oTarget = GetNearestObject(OBJECT_TYPE_CREATURE,oPC,i+=1);
            }
        }

    else if (sTag == "misca019")
        {
        if (GetObjectType(oTarget) == OBJECT_TYPE_DOOR
        && !GetLocked(oTarget))
            AssignCommand(oPC,MageHand(oTarget));
        }
    else if (sTag == "miscb034")
        {
        TurnUndead(oPC,4);
        }
    else if (sTag == "miscc040")
        {
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_FNF_TIME_STOP),GetLocation(OBJECT_SELF));
        oTarget = GetFirstObjectInArea();
        while (GetIsObjectValid(oTarget))
            {
            if (GetIsEnemy(oTarget))
                {
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_FNF_STRIKE_HOLY),lLoc);
                DestroyObject(oTarget);
                }
            oTarget = GetNextObjectInArea();
            }
        DestroyObject(oItem);
        }
    }
