Author Sticky: Post Working Scripts Here
gesellschaft Posted: Thursday, 25 July 11:56PM
Script Names: lightoffondeath,lightfadeonattack

What They Do: reset area lighting after bashed,simulate temporary dimming of light when hit in an attempt to bash.

Notes: I'm new to this and cannot take credit for the scripting, I simply modified those provided by David Gaider in his tutorial section regarding animation. While trying out the script on a Torch Bracket in a cave.. I bashed the torch, and the area was still lit as if the torch remained.. adding lightoffondeath to OnDeath for the torch brackets properties remedied this. I tried an experiment to see if I could get the light to (flicker) when attacked.. instead I got a decent alternative.. OnPhysicalAttack the light goes through the script routine twice without the animation lines, this dims the global lighting which in effect dims the actual flame on the torch bracket.. giving the appearance that the torch produces less light when disturbed.. until the flame regains control.. adding a tiny amount more realism.

On Death: lightoffondeath
NWScript:
void main()

{

  if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 0)

  {

  }

  else

  {

    SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);

    PlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);

    SetPlaceableIllumination (OBJECT_SELF, FALSE);

    RecomputeStaticLighting (GetArea(OBJECT_SELF));

  }

}



OnPhysicalAttacked: lightfadeonattack

NWScript:
void main()

{

  if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 0)

  {

    SetLocalInt (OBJECT_SELF,"NW_L_AMION",1);

    SetPlaceableIllumination (OBJECT_SELF, TRUE);

    RecomputeStaticLighting (GetArea(OBJECT_SELF));

  }

  else

  {

    SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);

    SetPlaceableIllumination (OBJECT_SELF, FALSE);

    RecomputeStaticLighting (GetArea(OBJECT_SELF));

  }

  if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 0)

  {

    SetLocalInt (OBJECT_SELF,"NW_L_AMION",1);

    SetPlaceableIllumination (OBJECT_SELF, TRUE);

    RecomputeStaticLighting (GetArea(OBJECT_SELF));

  }

  else

  {

    SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);

    SetPlaceableIllumination (OBJECT_SELF, FALSE);

    RecomputeStaticLighting (GetArea(OBJECT_SELF));

  }

}