Again on NPC statues....
#1
Posté 20 juillet 2010 - 03:22
void MakeStatue (object oTarget)
{
effect eStatue = SupernaturalEffect (EffectNWN2SpecialEffectFile ("fx_statue_npc"));
effect eFreeze = SupernaturalEffect (EffectVisualEffect (VFX_DUR_FREEZE_ANIMATION ));
ApplyEffectToObject (DURATION_TYPE_PERMANENT, eFreeze, oTarget);
ApplyEffectToObject (DURATION_TYPE_PERMANENT, eStatue, oTarget);
SetBumpState (oTarget, BUMPSTATE_UNBUMPABLE);
SetCommandable (FALSE, oTarget);
SetPlotFlag (oTarget, TRUE);
SetOrientOnDialog(oTarget, FALSE);
}
void main ()
{
object oNPC = OBJECT_SELF;
float fDelay = GetLocalFloat (oNPC, "Delay");
string sAnim = GetLocalString (oNPC, "Animation");
PlayCustomAnimation (oNPC, sAnim, 1, 1.0f);
DelayCommand (fDelay, MakeStatue (oNPC));
}
The addition is that i put variables on the NPC saying it what animation to use and at what point in the animation it should stop and freeze it. (The Delay and Animation name come properly on the NPC, tested by making the NPC shout them when clicked. [0.686667 and touchheart for this particular try-out]
So I place this script on the OnSpawn of the NPC and what happens? Then animation never starts (tested by commenting out the DelayCommand line) It does however give the stoneskin and freeezs the NPC.
Oddly if i put the script on a trigger and change the oNPC = OBJECT_SELF -> oNPC = GetObjectByTag ("NPC_X")... then it DOES work...
What am I doing wrong for OnSpawn????
#2
Posté 20 juillet 2010 - 06:48
#3
Posté 20 juillet 2010 - 10:15
#4
Posté 20 juillet 2010 - 10:42
But I think you are running into the same problem you would would have with the onclient enter event. The NPC is not yet in an area when you are telling it to do the action. he is still being created.
Also the MakeStatue function gets excuted while this script is running.
Where the PlayCustomAnimation (); is getting put into the action Que of the npc. So woll start at an indertemint amount after the 1.0 delay. Assuming that the que has not been cleared befor it gets a chance to run. At least in NWN1 it would not hurt to clear all actions before assigning the action
#5
Posté 21 juillet 2010 - 04:58
I put this little script on the OnSpawn event.
void main ()
{
DelayCommand (20.0, ExecuteScript ("NPC_to_statue", OBJECT_SELF);
}
The other script then runs as per the idea of it. Just wish it could have been done within one script...
Soooo if someone can think of a way i dont need this second script... I am open to suggestions.
Modifié par Freeze01, 21 juillet 2010 - 04:59 .
#6
Posté 24 juillet 2010 - 06:13
You could just delay the running of your original script:
Sonething like this.
void MakeStatue (string oTarget)
{
effect eStatue = SupernaturalEffect (EffectNWN2SpecialEffectFile ("fx_statue_npc"));
effect eFreeze = SupernaturalEffect (EffectVisualEffect (VFX_DUR_FREEZE_ANIMATION ));
ApplyEffectToObject (DURATION_TYPE_PERMANENT, eFreeze, oTarget);
ApplyEffectToObject (DURATION_TYPE_PERMANENT, eStatue, oTarget);
SetBumpState (oTarget, BUMPSTATE_UNBUMPABLE);
SetCommandable (FALSE, oTarget);
SetPlotFlag (oTarget, TRUE);
SetOrientOnDialog(oTarget, FALSE);
}
void main ()
{
if (!GetLocalInt(OBJECT_SELF,"FirstRunDelayed"))
{
DelayCommand( 6.0, ExecuteScript("name of this script", OBJECT_SELF));
SetLocalInt([OBJECT_SELF,"FirstRunDelayed", TRUE);
return;
}
string oNPC = OBJECT_SELF;
float fDelay = GetLocalFloat (oNPC, "Delay");
string sAnim = GetLocalString (oNPC, "Animation");
PlayCustomAnimation (oNPC, sAnim, 1, 1.0f);
DelayCommand (fDelay, MakeStatue (oNPC));
[/list]}
Modifié par Lightfoot8, 24 juillet 2010 - 06:24 .
#7
Posté 24 juillet 2010 - 08:00
Going to give it a go.
----
edit: It works, with the side note that i had to fine tune the delay to 18.0f
Apparently one or two rounds isnt sufficient.
Still THANKS!
Modifié par Freeze01, 24 juillet 2010 - 08:24 .
#8
Posté 25 juillet 2010 - 01:23
#9
Posté 25 juillet 2010 - 08:09
How did you fix this then, if you did indeed fix it?
Thanks for the answer in advance.
#10
Posté 25 juillet 2010 - 05:09
Freeze01 wrote...
Indeed after testing i found that the player should be in the same in area for the animation to correctly kick in... and as far as i can figure out, its ONLY the animation as I let the statues shout their fDelay, sAnim and tag AFTER the animation should have taken place... this -does- fire whether you are in the area or not.
How did you fix this then, if you did indeed fix it?
Thanks for the answer in advance.
There is indeed an issue with running scripts with no PC present. To preserve system resources, when the last PC leaves an area, the engine automatically lowers all NPCs AI level in that area to VERY_LOW. I'm not 100% sure whether this is through OnExit or OnHeartBeat for that area. The area OnHB continues to run, but the creatures' OnHB immediately exits (check _default1.nss and you'll see the quick exit).
Look at that thread I linked to for some work-around ideas. One way could be doing the animations from the area OnEnter. The statues don't necessarily have to be prepped ahead of time, they just need to be ready before a PC sees them.
#11
Posté 25 juillet 2010 - 08:57
So i think i will just make the NPCs spawn in when a player enters the area.
Oh well, good thing the delay before they turn to stone is commonly under a second, so it is nearly impossible for a player to notice it.
Too bad the engine is limited on this, on the other hand i dont want to know what the effect on lag would be if AI was constantly set to a higher lvl
Modifié par Freeze01, 25 juillet 2010 - 08:57 .
#12
Posté 25 juillet 2010 - 09:47
Freeze01 wrote...
Thanks, I think there is just no way around it...
So i think i will just make the NPCs spawn in when a player enters the area.
Oh well, good thing the delay before they turn to stone is commonly under a second, so it is nearly impossible for a player to notice it.
So I don't know exactly when the area OnEnter runs, but I believe it is before the player can actually even see the screen, probably while they're looking at the loading screen.
If this still isn't early enough, I believe that the area OnClientEnter runs even before OnEnter (but don't quote me on this). Either way, I don't really think you'll have a problem with players getting a glimpse.
#13
Posté 30 juillet 2010 - 02:47
Freeze01 wrote...
effect eStatue = SupernaturalEffect (EffectNWN2SpecialEffectFile ("fx_statue_npc"));
effect eFreeze = SupernaturalEffect (EffectVisualEffect (VFX_DUR_FREEZE_ANIMATION ));
...
SetPlotFlag (oTarget, TRUE);
I just wanted to note that setting the plot flag to TRUE will cause the cursor to change shape when you mouse over the statue and allow a 'shift-right click' menu activation. You can use a "SetIsDestroyable( FALSE, FALSE, FALSE ))" before applying an EffectDeath effect to keep it from fading away, and that will prevent mouse pointer interaction.
#14
Posté 03 août 2010 - 09:54





Retour en haut






