Aller au contenu

Photo

On Spawn Event


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

#1
Calva64

Calva64
  • Members
  • 16 messages
Hi All,

I created a custom on spawn script and attached it to certain characters. Such as a drunk which when loaded into the area appears drunk. Problem is when your in the area and you save and then load or leave and then reenter, because they have been spawned once they will not exhibit the drunk animation. You would think that adding the routine to a custom userdef script would work for the heartbeat event. But it doesnt so I created an onclient script for the area which tries to force the behavior again for some reason it doesn't work. The code is a bit complicated but I show it to you anyway.  Theres a bunch of debug code in there as speakstrings. Heres is the onclient code: I dont know why the heartbeat event isnt firing its as if though it is only playing the idle animation.

void main()
{
 location lPatron1 = GetLocation(GetObjectByTag("NW_PATRON1"));
 location lPatron2 = GetLocation(GetObjectByTag("NW_PATRON2"));
 object oPC = GetFirstEnteringPC();
 if (GetLocalInt(OBJECT_SELF,"iclient")==1)
 {
  object oPatron1 = GetObjectByTag("n_patron1");
  object oPatron2 = GetObjectByTag("n_patron2");
  
  if (GetCommandable(oPatron1))
  {
   AssignCommand(oPC,ActionSpeakString("Commandable"));   
  }
  else 
  {
   AssignCommand(oPC,ActionSpeakString("Not Commandable"));   
   SetCommandable(TRUE,oPatron1);
  } 
  AssignCommand(oPatron1,ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_DRUNK,1.0,9999999.0));
  AssignCommand(oPatron2,ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_DRUNK,1.0,9999999.0));
  
  if (oPatron1 != OBJECT_INVALID)
  {
   AssignCommand(oPC,ActionSpeakString("Patron1"));   
  }
  
  if (oPatron2 != OBJECT_INVALID)
  {
   AssignCommand(oPC,ActionSpeakString("Patron2"));  
  }
 } 
 else if (GetLocalInt(OBJECT_SELF,"iclient")==0)
 {
  CreateObject(OBJECT_TYPE_CREATURE,"n_patron",lPatron1,FALSE,"n_patron1");
  CreateObject(OBJECT_TYPE_CREATURE,"n_patron",lPatron2,FALSE,"n_patron2");
  SetLocalInt(OBJECT_SELF,"iclient",1);
 }
}

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Did you put the script on the OnClientEnter event or the AreaOnEnter event. If you only did on the OnClientEnter, try the AreaOnEnter.

I also see that you are creating "n_patron". Are these new patrons or are they the ones that are supposed to appear drunk? If they are the ones that are supposed to appear drunk, you need to assign the animations after they have been created. You may need to put a delay in there, I can't remember for sure, though.

#3
Calva64

Calva64
  • Members
  • 16 messages
Hi M.Rieder,

You're idea's brought some insight but I tried them and still on a Save then Load the Drunks are IDLE Animation. I even tried to assign the animation on a area heartbeat event no luck. Any Idea why the created objects would fall in a idle animation state even with animation commands being given?

Regards,

Calva64

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages
Have you stuck in lots of SendMessageToPC(oPC, "Here's where we are in the script: ") calls for debugging?

#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
You should be able to do this with heartbeat scripts on the individuals. In the OC area 2100_Crossroad_Keep_A2 has entertainers controlled by the heartbeat scripts 21_flutewoman_hb, 21_guitarman_hb, and 31_joy_dance_hb. You can look at those or download my King's Festival campaign and look at my campaign script bb_entertainer_hb which is a combined and enhanced version of the OC scripts.

Regards

#6
Dann-J

Dann-J
  • Members
  • 3 161 messages
Looping animations are notoriously unreliable at the best of times. Even using PlayCustomAnimation rather than ActionPlayAnimation, which allows you to assign a new idle animation (rather than playing the animation for 9999999 seconds), still occasionally fails if you use OnSpawn scripts. Heartbeat scripts are the only way to reliably reset the idle animation, since if things go wrong it recorrects them within six seconds.

Feel free to tinker with the hearbeat scripts I used in my Baggin's Hollow prefab area, which keep halfling tavern patrons seated in between fire-and-forget animations (like drinking, gesticulating or eating). Here's a screen shot of them behaving themselves:
http://nwvault.ign.c...e.php?id=163221

Modifié par DannJ, 08 novembre 2011 - 11:28 .


#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

Calva64 wrote...

Hi M.Rieder,

You're idea's brought some insight but I tried them and still on a Save then Load the Drunks are IDLE Animation. I even tried to assign the animation on a area heartbeat event no luck. Any Idea why the created objects would fall in a idle animation state even with animation commands being given?

Regards,

Calva64



Instead of using the standard animations, try using custom animations.  There are many of the standard animations that just don't work.  It is to the point that I usually just default to custom animations because they are more reliable.  Try them.  If you can't find a good one, I have used a drinking animation with some belching barkstrings and the occastional flatulence and green cloud to simulate drunkenness.

#8
Calva64

Calva64
  • Members
  • 16 messages
Hi All,

Thanks for your input its been very insightfull, but it appears that M. Reider has seen some of the problems I have working with animations. Reider your right looping animations cause problems. So in the heartbeat event I did a drink action (FIREANDFORGET) then the drunk animation on a delay and sure enought it worked. I'm not to sure what is going on with the looping animations? Is KEMOS customs animations good, haven't tried them.

Thanks,

Calva64

#9
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I've never messed with KEMOS custom animations. I've done all my animations with the PlayCustomAnimation() function directly in scripting.