void main()
{
    object oActivated = GetItemActivated();
    object oRing = GetObjectByTag("TARNISHEDRING");

    object oPC = GetItemActivator();
    object oFirstMember = GetItemActivator();
    object oPartyMember = GetFirstFactionMember(oFirstMember, TRUE);
    object oAnimal = GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION, oPC);
    int iAnimal = GetIsObjectValid(oAnimal);
    object oDominated = GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC);
    int iDominated = GetIsObjectValid(oDominated);
    object oFamiliar = GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oPC);
    int iFamiliar = GetIsObjectValid(oFamiliar);
    object oHenchman = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
    int iHenchman = GetIsObjectValid(oHenchman);

    SetLocalInt(OBJECT_SELF, "duration", DURATION_TYPE_TEMPORARY);
    int duration = GetLocalInt(OBJECT_SELF, "duration");
    SetLocalInt(OBJECT_SELF, "vfx", VFX_IMP_AC_BONUS);
    int vfx = GetLocalInt(OBJECT_SELF, "vfx");
    effect eEffect = EffectVisualEffect(vfx);
    {
        if(oActivated == oRing)
        {
        while (GetIsObjectValid (oPartyMember))
            {
            object oPartyMemberArea = GetArea(oPartyMember);
            if (!GetIsDead (oPartyMember))
            {
            ApplyEffectToObject(duration, eEffect, oPartyMember, 4.0);
            }
            oPartyMember = GetNextFactionMember (oFirstMember, TRUE); //Set oPartyMember to the next person in the party.
            }
            ApplyEffectToObject(duration, eEffect, oFirstMember, 4.0);
            ApplyEffectToObject(duration, eEffect, OBJECT_SELF, 4.0);

            if (iAnimal == TRUE)
            {
              ApplyEffectToObject(duration, eEffect, oAnimal, 4.0);
            }
            if (iDominated == TRUE)
            {
              ApplyEffectToObject(duration, eEffect, oDominated, 4.0);

            }
            if (iFamiliar == TRUE)
            {
              ApplyEffectToObject(duration, eEffect, oFamiliar, 4.0);

            }
            if (iHenchman == TRUE)
            {
              ApplyEffectToObject(duration, eEffect, oHenchman, 4.0);

            }

            DelayCommand(1.0, ExportAllCharacters());
            DelayCommand(2.0, EndGame("credits"));
        }
    }
}

