#include "x2_inc_itemprop"
void SetMagicGlow( object oItem )
{
  object oPC = OBJECT_SELF;
  if ( oItem == GetItemInSlot( INVENTORY_SLOT_RIGHTHAND, oPC ) ||
       oItem == GetItemInSlot( INVENTORY_SLOT_LEFTHAND, oPC ) )
  {
    object oOrc = GetNearestCreature( CREATURE_TYPE_IS_ALIVE,CREATURE_TYPE_PERCEPTION, oPC );
    if ( GetIsObjectValid( oOrc ) && GetAlignmentGoodEvil(oOrc)==ALIGNMENT_EVIL )
    {
      if ( !GetLocalInt( oItem, "glowing" ) )
      {
        IPSafeAddItemProperty( oItem, ItemPropertyVisualEffect(ITEM_VISUAL_EVIL), 0.0 );
        SetLocalInt( oItem, "glowing", 1 );
      }
    }
    else if ( GetLocalInt( oItem, "glowing" ) )
    {
      IPRemoveMatchingItemProperties( oItem, ITEM_PROPERTY_VISUALEFFECT, DURATION_TYPE_PERMANENT );
      DeleteLocalInt( oItem, "glowing" );
    }
    DelayCommand( 7.0, SetMagicGlow( oItem ) );
  }
}
void main()
{
  object oItem = GetPCItemLastEquipped();
  object oPC = GetPCItemLastEquippedBy();
  AssignCommand( oPC, SetMagicGlow( oItem ) );
}