Visit the Ironworks Gaming Website Email the Webmaster Graphics Library Rules and Regulations Help Support Ironworks Forum with a Donation to Keep us Online - We rely totally on Donations from members Donation goal Meter

Ironworks Gaming Radio

Ironworks Gaming Forum

Go Back   Ironworks Gaming Forum > Ironworks Gaming Forums > Neverwinter Nights 1 & 2 Also SoU & HotU Forum
FAQ Calendar Arcade Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 06-01-2003, 01:06 PM   #1
Dreamer128
Dracolisk
 

Join Date: March 21, 2001
Location: Europe
Age: 39
Posts: 6,136
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.
Dreamer128 is offline   Reply With Quote
Old 06-01-2003, 03:29 PM   #2
SpiritWarrior
Jack Burton
 

Join Date: May 31, 2002
Location: Ireland
Posts: 5,854
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:
void main()
{

object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);

AssignCommand(oPC, ClearAllActions());

object oTarget;
SpeakString("I've got best prices this side of Amn!");
}
The problem with the Onheartbeat and string text is that the duration the text floats never ctaches up with the heartbeat so..in-game the text will just continuosuly float over the NPC's head without actually dissapearing.
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.
__________________
Still I feel like a child when I look at the moon, maybe I grew up a little too soon...
SpiritWarrior is offline   Reply With Quote
Old 06-01-2003, 03:55 PM   #3
philip
Galvatron
 

Join Date: June 24, 2002
Location: aa
Posts: 2,101
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 ]
philip is offline   Reply With Quote
Old 06-02-2003, 11:13 AM   #4
Dreamer128
Dracolisk
 

Join Date: March 21, 2001
Location: Europe
Age: 39
Posts: 6,136
Thanks guys. I'll test them as soon as possible [img]smile.gif[/img]
Dreamer128 is offline   Reply With Quote
Old 06-02-2003, 02:19 PM   #5
Legolas
Jack Burton
 

Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
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:
...
if(nUser == 1001) //HEARTBEAT
{
if (GetDistanceToObject(oPC) 'smaller than symbol' 25.0) && (GetTag(OBJECT_SELF) == "speaker")
{
int iSpeakRand5 = Random(5);
if(iSpeakRand5 == 1)
{
SpeakString("Line number 1");
}
else if(iSpeakRand5 == 2)
{
SpeakString("Another line");
}
else if(iSpeakRand5 == 3)
{
SpeakString("The final line!");
}
else
{
}
}
}
else if(nUser == 1002) // PERCEIVE
...
Some things you may or may not note. First, the
Quote:
else
{
}
line is not necessary for the script to work. You could leave it out. I keep it because it feels more complete, and you can more easily test to see if the script runs by inserting a 'PrintString("...");' command.
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 ]
Legolas is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CEP Weapons Script... Mozenwrathe NWN Mod: Escape from Undermountain 30 04-23-2007 12:28 PM
i need some help about set items script deeper NWN Mod: Escape from Undermountain 8 07-06-2004 04:26 PM
A Script Request ~Chapter 6 Spoilers~ Dundee Slaytern Baldurs Gate II: Shadows of Amn & Throne of Bhaal 3 02-22-2003 04:36 PM
Script help Lord Splynncryth Dungeon Craft - RPG Game Maker 2 09-15-2002 11:35 PM
Script Wedin Icewind Dale | Heart of Winter | Icewind Dale II Forum 3 04-06-2002 02:14 PM


All times are GMT -4. The time now is 05:04 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved