ff_d_plc_onoff
Toggle a placeable light on and off.
When used, a placeable that is off plays its activate animation and gets a permanent yellow light (radius 20). When used again, it plays its deactivate animation and loses all its visual effects.
Scripts
OnUsed: ff_d_plc_onoff
Variables
NW_L_AMION: (int) Set by the script on the placeable: 1 when on, 0 when off.
Source code
// @code
#include "ff_i_core"
// -----------------------------------------------------------------------------
//! @brief Toggle the placeable light on or off.
//! @param oSelf The placeable. Must be OBJECT_SELF, as PlayAnimation() acts on the caller.
void OnUsed(object oSelf)
{
if (GetLocalInt(oSelf, "NW_L_AMION") == 0)
{
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
SetLocalInt(oSelf, "NW_L_AMION", 1);
effect eLight = EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_20);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLight, oSelf);
return;
}
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
SetLocalInt(oSelf, "NW_L_AMION", 0);
effect eEffect = GetFirstEffect(oSelf);
while (GetIsEffectValid(eEffect))
{
if (GetEffectType(eEffect) == EFFECT_TYPE_VISUALEFFECT)
RemoveEffect(oSelf, eEffect);
eEffect = GetNextEffect(oSelf);
}
}
// -----------------------------------------------------------------------------
void main()
{
int nEvent = GetCurrentlyRunningEvent();
if (nEvent == EVENT_SCRIPT_PLACEABLE_ON_USED)
OnUsed(OBJECT_SELF);
}