Author Topic: RE: How do you lock an NPC in a BUSY state?  (Read 925 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« on: December 08, 2014, 03:11:25 pm »


               

I have a musician playing a harp that I need to lock into a BUSY state - i.e. when the PC clicks on him they get the "character is busy" message and the NPC continues playing the harp. I want the NPC to ignore the PC, even if clicked on, and just play his harp. How do I do this?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #1 on: December 08, 2014, 04:38:25 pm »


               One way is to delete all the NPC scripts, or, if you want to use the normal AI later, give the NPC a custom script set that does nothing if a flag is set.

It's also possible to SetCommandable FALSE, but I'm not sure whether the AI always respects this.

The "associate busy" condition doesn't seem to work for regular NPCs.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #2 on: December 08, 2014, 07:56:05 pm »


               

I did this by editing the conversation script, and providing a check for a busy flag which I created myself. And then the NPC gives a busy response whenever that flag is checked.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #3 on: December 09, 2014, 02:30:16 am »


               

Thank God for old forum posts. I found this at the Ironworks site on their Aurora Toolset FAQ thread:


 


From Darkman


 


 



Alright. Here's a question. How do I disable stationary NPC's who don't have conversations from reacting to a player trying to speak to them? As it is, such NPC's will constantly pivot and re-pivot their bodies to follow the PC after being "clicked" on. This effect looks extremely silly when you have a group of stationary NPC's with no conversations. If the player goes through and tries to talk to each one of them, they will eventually all swivel at the same time trying to keep an eye on the player. Looks funny, but it's a bit distracting and probably isn't very helpful in maintaining any type of serious atmosphere.



 


...and the reply from Chewbacca


 


 



Hey Darkman put a script that looks like this in the on conversation event of the NPC:

 

void main()

{

}

 

Thats right! a blank script will hold the npc stationary and ignore the PC.


 


Much to my chagrin, it works! Sometimes the simplest things ARE that simple! 



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #4 on: December 09, 2014, 02:50:04 am »


               

Instead of a blank script, you can also just remove the NPCs OnConversation Event completely. Both the blanked script and removing it completely result in AI commands becoming broken (on that NPC at least) if they are functions that respond to shouts.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #5 on: December 09, 2014, 03:04:52 am »


               


Instead of a blank script, you can also just remove the NPCs OnConversation Event completely. Both the blanked script and removing it completely result in AI commands becoming broken (on that NPC at least) if they are functions that respond to shouts.




 


Not quite true. With no script in the slot, the NPC still was turning to face the PC whenever the PC tried to initiate a conversation, breaking the animation routine (they're musicians, they're paid to play music not talk to nosy PCs). Once i put a empty script (as above) into the slot, the NPC completely ignored the PC and any attempts to engage in conversation and just continued playing his harp.


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #6 on: December 09, 2014, 03:17:37 am »


               

I like a busy response, personally, like "p*ss off I'm busy" or something. Having them just keep playing like robots doesn't work for me. I use something like Henesua suggested.  You just need to restart the animation. I don't recall noticing a break in his playing animation when restarted there or turning to face. But I do it with speakstring not an actual dlg file.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #7 on: December 09, 2014, 03:46:08 am »


               

Yeah, I could add a SpeakString() call in there, but this guy isn't your normal bard strumming a harp - its an automaton, so the lack of a verbal response fits.


 


EDIT: Opted for SendMessageToPC(GetLastSpeaker(), "The object is busy and can not talk to you right now."); 


 


Sends the generic yellow highlighted message over the server channel. I can also configure the script to search the tag of the caller and use SpeakString() to do customized responses. Since its a generic OnConversation script, it need to be nonspecific.


 


And yes...I'm having tons of fun reverse engineering the X2 Ambient System and adding my own features to it. Nereng's guide is proving invaluable in helping me tailor the system to my needs.



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #8 on: December 09, 2014, 04:11:27 am »


               

Thanks for your tidbit. I'd not noticed they change facing.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #9 on: December 09, 2014, 03:51:54 pm »


               


And yes...I'm having tons of fun reverse engineering the X2 Ambient System and adding my own features to it. Nereng's guide is proving invaluable in helping me tailor the system to my needs.




 


Great! At the very least there's a lot of useful info in there. I re-did the whole thing as a learning tool and to reduce the number of scripts significantly, using variables instead of all the slightly different spawn scripts etc. The whole thing is great for flavor in a single player or small module, but it is a resource hog. There's a lot there...


               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #10 on: December 09, 2014, 07:21:14 pm »


               

The module will be a fairly small SP module. Thus, the number of NPCs will be considerably less than what you'd get in a PW. So far these are the ambient NPCs I've got setup:


 


Tavern


  • The Ungrateful Dead (3 Skeleton Musicians)

  • Waitress - heartbeat activity

  • 6 Patrons - heartbeat activity

  • Bartender

City


  • 4 Guards - heartbeat activity

  • Blacksmith - heartbeat activity

  • Lamplighter - heartbeat activity

  • Town Crier - heartbeat activity

I haven't really noticed any problems with resources as the NPCs only "perform" when there is a PC in the area. I'm curious to see how far I can push it. Once I've got the NPCs all placed, I'll work on fine tuning it. 


 


I know there are better systems out there, but that'd take out all the fun I'm having '<img'>



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #11 on: December 09, 2014, 09:21:25 pm »


               

Speaking of town criers - I need some blurbs for them to blurt out. Here's what I've come up with so far...


 


"Umberlee claims Warspite! All hands lost!"


"Tax revenues down! City Council votes to levy new taxes!"


"Luskan buccaneers plague Sword Coast anew! Waterdeep musters fleet!"


 


As you can see they're pretty generic - more for fluff than anything else. Anyone got some others?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #12 on: December 10, 2014, 04:04:49 pm »


               Incidentally, if you just want to stop turning (for example, a guard who faces straight ahead during conversation), in the OnConversation event, store the current facing, BeginConversation, then immediate SetFacing to the original value. If the conversation is null or has no valid nodes, this also has the "no action" effect desired in the OP.

More generally, I find it convenient to store NPC facing and location as local variables OnSpawn, then send them home whenever WalkWayPoints finds them idle. This is more general than POST, as the home location can change for plot reasons, and prevents the disarray that otherwise tends to happen over time.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: How do you lock an NPC in a BUSY state?
« Reply #13 on: December 10, 2014, 09:29:25 pm »


               

Well that was the longest bloody conversation I've ever scripted. ':wacko:'


 


My town crier now calls out 10 random cries, all of which can be explored further by the PC. I've rigged it so that the cries are called via SpeakOneLinerConversation(). When the crier speaks a cry he is tagged so that the conversation knows the cry has been called out, allowing the PC to ask further information about the cry. If the crier hasn't called a particular cry, then the PC can't ask about it. A neat alternative to the the annoying town criers I've found in other scripts.  '<img'>


 


Now on to the first quest and adventure area...a good old crypt crawl as requested by my 9 year-old son. He's into undead, especially zombies...