Aller au contenu

Photo

Opening a dusty sarcophagus


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
rjshae

rjshae
  • Members
  • 4 508 messages
I wanted to create an effect that would produce a small cloud of dust the first time that a sarcophagus is opened. This was about as close as I could get:

// som_sarcophagus_open
/*
  Place this script in the "On Open Script" field of a
  useable sarcophagus. The first time the sarcophagus is
  opened, a puff of dirt is released over the opening.
  Thereafter the effect is disabled.
*/
// 14jan12 RJH

const string somHasOpened = "hasOpenedSarc";
const string somDirtPuff = "fx_dirt_puff";

void DoDirtPuff()
{
  // Gather data
  object oArea = GetArea( OBJECT_SELF );
  location locSelf = GetLocation( OBJECT_SELF );
  string sResRef = GetResRef( OBJECT_SELF );
  float fFacing = GetFacing( OBJECT_SELF );
	
  // Set positional parameters based on the blueprint
  float fHeight = 0.5f;
  if ( ( StringCompare( sResRef, "plc_mc_sarcoph1" ) == 0 ) ||
       ( StringCompare( sResRef, "plc_mc_sarcoph2" ) == 0 ) )
   {
     fFacing += 255.0f;
   } else if (
       ( StringCompare( sResRef, "plc_mc_sarcoph3" ) == 0 ) ||
       ( StringCompare( sResRef, "plc_mc_sarcoph5" ) == 0 ) )
   {
     fFacing += 300.0f;
     fHeight = 0.6f;
   }
	
  // Compute the effect placement
  float fSin = 1.0f * sin( fFacing );
  float fCos = 1.0f * cos( fFacing );
  vector vSelf = GetPositionFromLocation( locSelf );
  vector vOffset = Vector( fCos, fSin, fHeight );
  location locEffect = Location( oArea, vSelf + vOffset, fFacing );
	
  // Apply the puff of smoke at the location
  effect eCloud = EffectNWN2SpecialEffectFile(  somDirtPuff );
  ApplyEffectAtLocation( DURATION_TYPE_INSTANT, eCloud, locEffect );
}

void main()
{
   int nHasOpened = GetLocalInt( OBJECT_SELF, somHasOpened );
   if ( nHasOpened == FALSE ) {
     // Trigger a puff of smoke over the opening
     DoDirtPuff();
     SetLocalInt( OBJECT_SELF, somHasOpened, TRUE );
   }
}

Modifié par rjshae, 16 janvier 2013 - 04:57 .


#2
Morbane

Morbane
  • Members
  • 1 883 messages
cool scripting  :innocent:

Modifié par Morbane, 16 janvier 2013 - 11:06 .


#3
Shaughn78

Shaughn78
  • Members
  • 637 messages
Very nice. Another fun little touch would be to add two more variables. An undead ref and percentage chance int. That way you could have that puff and a percent chance to have an undead spawn and try to eat the curious adventurer.

#4
Hellfire_RWS

Hellfire_RWS
  • Members
  • 623 messages

Shaughn78 wrote...

Very nice. Another fun little touch would be to add two more variables. An undead ref and percentage chance int. That way you could have that puff and a percent chance to have an undead spawn and try to eat the curious adventurer.


+1

:)

#5
rjshae

rjshae
  • Members
  • 4 508 messages
Thanks. :) Something similar could probably be done with old chests and unused secret doors. I'll probably add a few cobwebs as well.

#6
kamal_

kamal_
  • Members
  • 5 260 messages
There is a script out there for spawning undead on sarcophagi. I've seen it somewhere.

#7
MokahTGS

MokahTGS
  • Members
  • 946 messages
It's on the Vault