![]() |
Does anyone know how to make an NPC fire a random Speakstring OnHeartbeat (or every x seconds)? I'm asking, because triggers will work only once and I'm working on part of an MP mod.
Thanks in advance. |
I ain't sure whether by 'random' you mean from a list of assigned strings or you just have the one string that you want the NPC to speak. Either way the one I made for you has only one string in it (you can add more if you wish).
Quote:
I don't know exactly what you arte wanting to do but maybe if you call the script from the Onperceived lines it will work better for you (that is everytime a PC is seen by an NPC he/she will utter the string of text). Let me know if this is what you need and i'll make one up for you. |
nRandom = Random(4)
switch(nRandom) { case 0: SpeakString(""); break; case 1: SpeakString(""); break; case 2: SpeakString(""); break; case 3: SpeakString(""); break; } edit: wrong function. you can add any number in Random(), results are the value in random - 1, so 4 would give results 0,1,2,3 [ 06-01-2003, 03:57 PM: Message edited by: philip ] |
Thanks guys. I'll test them as soon as possible [img]smile.gif[/img]
|
I'd actually try changing the OnSpawn script by deleting the '//' in front of the 'SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);' line, then editing the OnUserDefined script as follows.
Quote:
Quote:
Second, I'm using a random giving 5 answers instead of just three. That's because you probably do not want to have a new line on every single OnHeartbeat event. You can change it to higher numbers and that will decrease the frequency even further. Third, this script only works when you are near the NPC, within 25 meters in this case. Fourth, you'll need to define a speaker (just insert the tag of the NPC there) and an 'oPC'. SpiritWarrior's definition is rather complete, and also includes the distance factor which means you could leave it out here. Fifth, I had to type 'smaller than symbol' because IW wouldn't allow the symbol in what it recognises to be html. Not even in the text down here. Virus protection, I assume. It's the V with the opening to the right, should you be unaware of what it looks like. Third key left of the rightshift. Finally, it's put in the OnUserDefined script rather than inserted directly into the OnHeartbeat script. That's because I have found the OnHeartbeat script may cause your game to stutter when you put lines into it (like a ClearAllActions() for everyone every six seconds), whereas this should not. Using the UserDefined events is also the more organised way of doing things (although the switch is also more organised than the if-then-else procedure, you may want to mix the two of them). [ 06-02-2003, 02:20 PM: Message edited by: Legolas ] |
All times are GMT -4. The time now is 11:16 PM. |
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved