Author Sticky: Post Working Scripts Here
OndoFrigton Posted: Saturday, 29 June 04:14AM
Name: Whatever you want to call it =)

Function: Room with 3 levers, if all three get thrown into the activated position, then it spawns an object ( in this case, his custom red dragon ).

Notes: I wrote this for a gentleman when he was struggling on this situation. I personally haven't tested it, but it worked for him. It requires a few things - the 3 triggers, a waypoint, and an invisible object. In reality, the value stored in the invisible object can just be put in the waypoint and the object can be removed.

After the dragon spawns, the levers get locked in the activated position.

NWScript:
// Written by: OndoFrigton

// Date      : 06-26-2002

// Why       : appl requested it

// Description:

//

// The script is fired when each of 3 levers activate.

// After one is activated, it plays an animation and then

// checks an invisible object to see if all 3 levers are

// activated.  If they are, it spawns a monster, then sets

// a variable in the invisible object that disallows any

// more lever pulls.

// If you deactivate the lever, it will just play the

// animation and update the invisible object.

//

// This requires an invisible object that

// has a tag name of "level_counter".  That object will handle how many levers

// are pulled and if all 3 are pulled which will lock them down to prevent

// any more actions  Initialize the "nNumPulled" variable in it to 0 ( zero ).

//

// This script will go in each lever on their OnActivate() or OnUse script, or whatever

// that event is that fires when you pull the lever.

//

// I'm assuming a GetLocalInt() returns 0 ( zero ) if the variable doesn't exist when

// I check if the levers' actions should stop

//

// This script it untested.

void main()

{

  object oLeverCounter = GetObjectByTag( "lever_counter" );

  int nNumLeversPulled = GetLocalInt( oLeverCounter, "nNumPulled" );

  int nAllLeversPulled = GetLocalInt( oLeverCounter, "nAllPulled" );

  int bActivated = GetLocalInt( OBJECT_SELF, "m_bActivated" );

  if ( !nAllLeversPulled ) // Added in this to make it stop working after it is activated

  {

    if ( bActivated )

    {

      nNumLeversPulled--;

  

      SetLocalInt( OBJECT_SELF, "m_bActivated", FALSE );

  

      SetLocalInt( oLeverCounter, "nNumPulled", nNumLeversPulled );

  

      PlayAnimation( ANIMATION_PLACEABLE_DEACTIVATE );

   

      PrintString( "Deactivated Lever" );

    } else

    {

      nNumLeversPulled++;

  

      SetLocalInt( OBJECT_SELF, "m_bActivated", TRUE );

  

      SetLocalInt( oLeverCounter, "nNumPulled", nNumLeversPulled );

  

      PlayAnimation( ANIMATION_PLACEABLE_ACTIVATE );

  

      PrintString( "Activated Lever" );

  

    }

  

    PrintInteger( nNumberLeversPulled );

    if ( nNumLeversPulled == 3 )

    {

      PrintString( "Spawning the creature!" );

      SetLocalInt( oLeverCounter, "nAllPulled", 1 ); // Added in this to make it stop working after it is activated

      object oSpawnLocation = GetObjectByTag( "wp_dragon" );

      location lSpawnLoc = GetLocation( oSpawnLocation );

      CreateObject( OBJECT_TYPE_CREATURE, "drgred003", lSpawnLoc );    

    }

  }

}



_________________
Ondo Frigton - Bard of Many Seasons

Beware the Badgers!