//::///////////////////////////////////////////////
//:: OnUse: Toggle Activate
//:: x2_plc_used_act
//:: Copyright (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

    Simple script to toggle the placeable animation
    state for placeables that support Activate and
    DeActivate Animations

    Placeables are best set to be DeActivated by
    default with this script.

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-09-10
//:://////////////////////////////////////////////
void main()
{
    object oPC = GetLastUsedBy();
    object oArea = GetArea(oPC);
    int iTouched = GetLocalInt(OBJECT_SELF,"touched");
    // * note that nActive == 1 does  not necessarily mean the placeable is active
    // * that depends on the initial state of the object
    int nActive = GetLocalInt (OBJECT_SELF,"X2_L_PLC_ACTIVATED_STATE");
    // * Play Appropriate Animation
    if (!nActive)
    {
      ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
    }
    else
    {
      ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
    }
    // * Store New State
    SetLocalInt(OBJECT_SELF,"X2_L_PLC_ACTIVATED_STATE",!nActive);

     if (iTouched == 1) {FloatingTextStringOnCreature("This seems to do nothing.",oPC); return;}

     //ExploreAreaForPlayer(oArea,oPC);

     SetLocalInt(OBJECT_SELF,"touched",1);

     if (!GetIsPC(oPC)) return;

      object oTarget;
      oTarget = oPC;

      effect eEffect;
      eEffect = EffectDamageReduction(10, DAMAGE_POWER_PLUS_ONE);
      FloatingTextStringOnCreature("The device creates a force field around you.",oPC);
      eEffect = ExtraordinaryEffect(eEffect);

      ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 360.0f);
}