//::///////////////////////////////////////////////
//:: 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()
{
    // * 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 (GetLocalInt(GetModule(),"MithPowered") ==8)

    {
    object oObject = GetObjectByTag("PodRoomDoor");
    SetLocked (oObject, FALSE);
    SetLocalInt(GetModule(), "MithPowered", GetLocalInt(GetModule(), "MithPowered") +1);

    ActionSpeakString ("System Powering..");
    AssignCommand(OBJECT_SELF, PlaySound("as_cv_boilergrn2"));

    DelayCommand(1.0, ActionSpeakString ("System Diagnostic.."));
    DelayCommand(1.0, AssignCommand(OBJECT_SELF, PlaySound("al_mg_crystalnt1")));

    DelayCommand(4.0, ActionSpeakString ("All Systems Functioning Within Specified Parameters."));

    DelayCommand(6.0, ActionSpeakString ("Charging Core."));
    DelayCommand(6.0, AssignCommand(OBJECT_SELF, PlaySound("al_mg_pillrlght1")));

    DelayCommand(10.0, ActionSpeakString ("Powering Hibernation Pods."));
    DelayCommand(10.0, AssignCommand(OBJECT_SELF, PlaySound("al_mg_ballmagic1")));

    DelayCommand(12.0, ActionSpeakString ("Flushing Inert Gases With Oxygen Mixture."));
    DelayCommand(12.0, AssignCommand(OBJECT_SELF, PlaySound("as_cv_pipeflush1")));
    DelayCommand(13.0, AssignCommand(OBJECT_SELF, PlaySound("as_na_steamlong1")));
    DelayCommand(14.0, AssignCommand(OBJECT_SELF, PlaySound("as_na_steamlong2")));

    DelayCommand(16.0, ActionSpeakString ("Hibernation System Is Now Online."));
    DelayCommand(16.0, AssignCommand(OBJECT_SELF, PlaySound("as_cv_boomdist1")));

    DelayCommand(20.0, ActionSpeakString ("Unlocking Access Door."));
    DelayCommand(20.0, AssignCommand(oObject, PlaySound("as_cv_shopmetal2")));
    DelayCommand(20.5, AssignCommand(oObject, PlaySound("as_hr_x2chnratl1")));

    DelayCommand(20.0, SetLocked (oObject, FALSE));

    }
else
{
    ActionSpeakString ("System Powering..");
    AssignCommand(OBJECT_SELF, PlaySound("as_cv_boilergrn2"));

    DelayCommand(1.0, ActionSpeakString ("System Diagnostic.."));
    DelayCommand(1.0, AssignCommand(OBJECT_SELF, PlaySound("al_mg_crystalnt1")));

    DelayCommand(4.0, ActionSpeakString ("Error.. Primary Systems are Offline.. Aborting Startup."));

}
}