// Throne Ownership Script
// SoulFlame

// Assign a string variable as Owner for the player account name to the throne.
// Assign a string variable as Alias for the players nickname.

// This script will use a variety of effects based on the option set on the chairs variables.

/*
Visual Effect "Strike" options:  LocalInt "eVisual"
  0 none
  1 lightning
  2 holy
  3 flame

Player Effect options:           LocalInt "eAction"
  0 none
  1 stun
  2 death
*/

void main()
{
   object oChair = OBJECT_SELF;
   string sOwner = GetLocalString(OBJECT_SELF, "Owner");
   string sOwner2 = GetLocalString(OBJECT_SELF, "Owner2");
   string sAlias = GetLocalString(OBJECT_SELF, "Alias");
   effect eVisual, eAction;

   if (sAlias == "") sAlias = sOwner;

   switch (GetLocalInt(OBJECT_SELF, "eVisual")) {
      case 0: eVisual; break;
      case 1: eVisual = EffectVisualEffect(VFX_IMP_LIGHTNING_M, FALSE); break;
      case 2: eVisual = EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_HOLY, FALSE); break;
      case 3: eVisual = EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_FIRE, FALSE); break;
   }

   switch (GetLocalInt(OBJECT_SELF, "eAction")) {
      case 0: eAction; break;
      case 1: eAction = EffectStunned(); break;
      case 2: eAction = EffectDeath(); break;
   }

   if(!GetIsObjectValid(GetSittingCreature(oChair)))
   {
      if((GetPCPlayerName(GetLastUsedBy()) == sOwner) || (GetPCPlayerName(GetLastUsedBy()) == sOwner2))
      {
         AssignCommand(GetLastUsedBy(), ActionSit(oChair));
         SpeakString("Greetings " + sAlias + "!");
      }
      else
      {
         SpeakString("This throne is for " + sAlias + ", and " + sAlias + " only.");
         ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, GetLastUsedBy(), 0.0f);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAction, GetLastUsedBy(), 15.0f);
      }
   }
}