You are here

Animated Statue

11 posts / 0 new
Last post
Yawgnor
Animated Statue

Hi. I've an idea of having a statue of a knight coming to 'life' and attacking if the player opens a sarcophagus. Any suggestions how to do this?

  • up
    50%
  • down
    50%
Werelynx

You can start with petrified NPC (simpler, just unpetrify him)

or with a placeable statue (destroy statue, spawn knight NPC in  the place of statue, eventually add some dust/breaking/falling rocks/explosion VFX to cover it).

  • up
    50%
  • down
    50%
Yawgnor

I like the second suggestion more.

Would you be willing to explain how to do this? And how to have it happen when another item is opened?

Please.

  • up
    50%
  • down
    50%
Werelynx

Damn, I have only just noticed it's NWN2. In NWN1 I would make the script and attach it on the following placeable events: OnDisturbed, OnOpened, OnAttacked, OnSpellCastAt. Maybe there is some analogue in Electron toolset?

  • up
    50%
  • down
    50%
rjshae

Here's some code from my toolset guide that I used to create a statue out of a creature:

// statue_from_creature
/*
  This script should be placed in the 'On Spawn In' script of a creature. When
  the creature is spawned into the game, animation is permanently turned off,
  a stoneskin visual effect is applied, and a death effect is used to make the
  creature non-living. Finally, a collision ball is placed in the location of
  the creature to prevent player movement through the object.
*/
// RJH 11sep10


const string COLLISION_BALL_TAG = "plc_collbox";

void main()
{
  // Stop the creature animating
  effect eFreeze = EffectVisualEffect( VFX_DUR_FREEZE_ANIMATION );
  ApplyEffectToObject( DURATION_TYPE_PERMANENT,
  SupernaturalEffect( eFreeze ), OBJECT_SELF );

  // Apply a stone skin visual effect
  effect eStone = EffectVisualEffect( VFX_DUR_PROT_STONESKIN );
  ApplyEffectToObject( DURATION_TYPE_PERMANENT, eStone, OBJECT_SELF );

  // Avoid fadeout on death and make it generally inert
  SetIsDestroyable( FALSE, FALSE, FALSE );
  SetBumpState( OBJECT_SELF, BUMPSTATE_UNBUMPABLE );
  SetCommandable( FALSE, OBJECT_SELF );
  SetOrientOnDialog( OBJECT_SELF, FALSE );

  // Apply the death effect
  ApplyEffectToObject( DURATION_TYPE_PERMANENT, EffectDeath(), OBJECT_SELF );


  // Flag the creature as a statue (for the Flesh to Stone spell)
  SetLocalInt( OBJECT_SELF, "NW_STATUE", 1 );


  // Create collision ball around the statue
  location loc = GetLocation( OBJECT_SELF );
  object oCollBall = CreateObject( OBJECT_TYPE_PLACEABLE, COLLISION_BALL_TAG, loc );

  // Scale the box to fit the statue size
  float fSS = 0.5f;
  SetScale( oCollBall, fSS, fSS, fSS );
}

 

To animate the 'statue', you'd undo those steps. For example, you could apply the SetEffectSpellID to the effects, then use that spell ID to remove it.

I'd recommend using this effect rather than the stoneskin.

If you want the statue to animate as a result of an event like opening a chest, then you'd need to run a script from the chest's On Open script slot. Alternatively, you could do it as part of a conversation with the placeable.

  • up
    50%
  • down
    50%
Yawgnor

I created a new script in my mod, copied and pasted the above into it, and named it statue_from_creature. Then I added this script to the On Spawn In Script slot in the NPC'c properties.

The NPC has the falling dirt effect from the stone skin; how do I change it to the stone_statue apperance as suggested (I had already downloaded and added it to my mod)?

rjshae ~ "To animate the 'statue', you'd undo those steps. For example, you could apply the SetEffectSpellID to the effects, then use that spell ID to remove it."

I have no idea how to do what you said. Nor do I know how to add it to the opening event of the chest. Could you explain in detain, please.

There would be 4 statues in the corners of the room containing the chest; would they all come to 'life' when the chest is opened?

  • up
    50%
  • down
    50%
rjshae

>> The NPC has the falling dirt effect from the stone skin; how do I change it to the stone_statue apperance as suggested (I had already downloaded and added it to my mod)? <<

You can use the EffectNWN2SpecialEffectFile function to create an effect based upon a file name. The effect file has to be in a location where the game can find it.

>> I have no idea how to do what you said. Nor do I know how to add it to the opening event of the chest. Could you explain in detain, please. <<

Mmm... well I could, but it sounds like you need some familiarity with the toolset and scripting first. I'd suggest delving into some tutorials and guides in order to learn how things work. Try Scripting for Noobs, for example, and perhaps the Toolset Guide.

>> There would be 4 statues in the corners of the room containing the chest; would they all come to 'life' when the chest is opened? <<

You would have to apply the 'activation' function in the script to each of the statues in turn. There are several ways to do this, but most of them require some knowledge of scripting.

  • up
    50%
  • down
    50%
Yawgnor

I appreciate your help rjshae.

 

Concidering that I already know most of what I need about the using the toolset (minus scripting), that part shouldn't take too long. As for learning scripting, I suppose that I'll have to put off finishing my project for a few months, because I figure that to be about how long it will take me to learn enough so that I can do this living statue problem on my own. And that's a plus for you good folk; you won't have to hear from me asking for help. :)

  • up
    50%
  • down
    50%
rjshae

The benefit of learning scripting is that you will be able to do other things besides just solving this one issue.

If you're familiar with the toolset then you should know about the property slots in the chest's blueprint where you can add event scripts. For example, have a look at how some of the triggers use scripts.

  • up
    50%
  • down
    50%
Yawgnor

Thanks a load, pal.

You know, before your suggestion, I was happy with the thought that I'd ask for something, and someone would make it for me. I was even willing to pay. But noooo... you had to steer me toward that PDF about scripting. And now I am interested in learning it. Thanks.

My wife's probably gonna divorce me now; I had planned on spending more time with her. But not now. I have scripting to learn. Yer a real friend.

 

 

 

Seriously, I do want to thank you. I can see why you pushed me in that direction. I might even get a smidge more satisfaction when I'm finished with my project.

 

  • up
    50%
  • down
    50%
rjshae

Well, I have plenty of things on my own plate that I need to finish without wasting a bunch of time scripting your module as well. cheeky

You're welcome.

  • up
    50%
  • down
    50%