|
||
|
|
#1 (permalink) |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
Summary:
This NPC can be configured through a gump to respond to keywords with a number of lines of speech. Useful in quests. Description: This must be the first real script I ever wrote, I found it lying somewhere on my HD and figured I could share it. This should come in handy in quests, or to give players directions. When added, the npc will appear hidden and standing still. Double click it to enter configuration mode. The first gump allows you to manage and add new speech entries. Each entry consists of a number of keywords and a number of lines of text considered as the NPC's speech. You can specify whether the NPC will react to any keyword, or if all keywords must be present in the player's line for the NPC to react. When the NPC reacts to the player's speech, it will perform the speech defined for the given entry. Lines of text will be spoken in the same order as they appear in the entry configuration, and the delay between the lines can be configured on the NPC props. You can add an infinite number of entries, so you can actually get the NPC to simulate a conversation (within limits of course) when configured correctly. This works esepcially well when using it as a scared to death looking for help NPC ![]() You can also edit entries. The interface for this is somewhat unintuitive but it was the best I could come up with at the time. You can move up and down between keywords (or speech lines) and once you select one you have buttons to modify and delete it. The NPC can be configured by only one person at a time. Also if you get disconnected while configuring the NPC, the NPC will remain hidden and immovable, but other staff will be able to configure it. Installation: Place anywhere in your Scripts folder. Use [Add Speaker to add to the world. Updates May 30: Implemented sequencing of entries. When the Sequence property is set to true, the player will have to match the entries in the same order as they're entered in the configuration gump. The sequence feature has a timeout as well, accessed through the properties. If the NPC doesn't receive any matches within the timeout timespan, it will reset back to index 0 (this so that it doesn't get stuck and prevent other players from using it properly). Also added a switch to make the NPC wait a short while (SpeechDelay seconds) before responding to a matched keyword. New properties (All AccessLevel.GameMaster):
I have also added a link to the speaker's props in the configuration gump, and sequence numbers for each entry in the main gump.
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
#2 (permalink) |
|
Forum Novice
Join Date: Jun 2003
Posts: 165
|
Thanks Arya this is so cool. I've been waiting for someone to script this in RunUO. Very nice not only for quests, also for RP Shards.
Is there any way to make the NPC mantain a conversation, and at the end of it respond to the "main" keyword? I mean, If I want the NPC to say where is a treasure, but I want my players to ask the NPC first about the legend of the world, about the ships that used to sail in sosaria's seas... and finally, when the NPC reaches the part of the history concerning treasures, when you say whatever+treasure she answers. I just dont want players to tell his friends the keyword, go there and get the location and stuff inmediately... thanks in advance ![]() |
|
|
|
|
#3 (permalink) |
|
Moderate
Join Date: Nov 2002
Location: USA
Posts: 6,598
|
OK, Now your just showing off...
Thanks Arya!
__________________
David Forum Moderator The RunUO.com Forum Moderator Team Forum Rules and Guidelines RunUO Forum Search Engine Download RunUO 2.0 RC2 |
|
|
|
|
#4 (permalink) |
|
Forum Expert
Join Date: Jan 2003
Location: California
Age: 39
Posts: 3,260
|
Awesome now I have someone to spew forth rumors
__________________
My Scripts: HoodableRobe CellarAddon SeigeUpdates Refresh/CloneMe Commands VooDoo Dolls Lost Alchemy SVN 187 Updates: Bard System + Upgrade Ultima VII |
|
|
|
|
#6 (permalink) | |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
Quote:
Entry 1: Keywords: hail, hello, greetings, hi Speech: - Hello traveler, would you like to hear some legends of the old world? Entry 2: Keywords: yes, sure, legeng, of course Speech: [ A number of lines of speech mentioning a treasure on wyvern island ] Entry 3 Keywords: treasure, wyvern Speech: [ Explain about the treasure ] You can try to pilot a conversation like this. It would be acutually a nice idea to make the NPC follow the sequence of speech entries, so that you can have more control on what it says. Maybe I'll do this sometimes. Keep in mind that you can add more than one keyword, and your players usually don't know which ones match. Also even if they probably realize they're talking to a NPC, they'll still use full sentences most likely.
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
|
#8 (permalink) |
|
Join Date: Jun 2003
Location: Poland, Zgierz
Age: 23
Posts: 173
|
Awesome script.
Very useful...P.S. I was wondering - can you improve your script a bit... After saying keyword the Speaker will turn to player, wait one or two seconds and after that time answer... It will be more realistic... Yes I now, I wonder about stupid things, but .... I dunno... Maybe you will be able to do that... Sorry for eng. |
|
|
|
|
#9 (permalink) |
|
Master of the Internet
Join Date: Aug 2003
Posts: 5,688
|
very nice indeed. One thing you might consider is adding in a property that indicates which entry has just been matched.
With that, external agents like the xmlspawner can monitor the conversation as well and trigger when they reach a designated state. I just threw in that minor mod and it works great for setting up mini-quests and for conversationally triggered item/mob spawns. More flexible than the fixed keyword triggering. Code:
private int m_CurrentMatchedEntry; Code:
[CommandProperty( AccessLevel.GameMaster )]
public int CurrentMatchedEntry
{
get { return m_CurrentMatchedEntry; }
set { m_CurrentMatchedEntry = value; }
}
Code:
private SpeechEntry SelectEntry( string speech )
{
CurrentMatchedEntry = 0;
foreach ( SpeechEntry entry in m_Speech )
{
CurrentMatchedEntry++;
if ( entry.Match( speech ) )
return entry;
}
return null;
}
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. " For questions, information, and support for XmlSpawner and its addons, visit the XmlSpawner Support Forum |
|
|
|
|
#10 (permalink) |
|
Shard Director: Britannia
|
As always, another masterful work by Arya. On behalf of the Britannia shard and the community, I thank you!
![]() Keep up the good work!
__________________
Coming Soon! §Britannia§ Roleplaying, Ultima-based shard. Professionally Staffed and Designed. Epic Quests and Storyline. Based on Ultima lore. Massive support for player communities of all sorts. |
|
|
|
|
#11 (permalink) |
|
Moderate
Join Date: Nov 2002
Location: USA
Posts: 6,598
|
*begins to hack apart this script so he can see how to do his version better*
__________________
David Forum Moderator The RunUO.com Forum Moderator Team Forum Rules and Guidelines RunUO Forum Search Engine Download RunUO 2.0 RC2 |
|
|
|
|
#12 (permalink) | |
|
Quote:
Code:
private class SpeechEntry
{
// Means all keywords must be matched for the NPC to respond
private bool m_MatchAll = false;
Then just add most of the sentence: Player: Can you tell me where is Morgan's treasure chest hidden? keywords: where morgan's chest hidden? That should make the NPC match everything and keep it from one keyword. That is, if I read the code and description right. ------------------------------------------------------------------------------------------------------------------------------------- "Wrong is wrong, even if everybody is doing it, and right is right, even if nobody is doing it." -Bishop Fulton J. Sheen |
||
|
|
|
|
#14 (permalink) |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
I have posted an update, implementing the sequence feature. All details are in the first post, including a description of the new properties. This moves the NPC to version 1 in serialization, and should make it easier to use for conversations that should follow a predefined path.
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
#15 (permalink) |
|
Master of the Internet
Join Date: Aug 2003
Posts: 5,688
|
very nice. SpeechIndex works great for triggering.
One note, I think you need to add in the HandlesOnSpeech override since this is a basecreature and they dont normally listen to anyone except their mommas, their GMs, or their masters - actually, scratch their mommas.
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. " For questions, information, and support for XmlSpawner and its addons, visit the XmlSpawner Support Forum |
|
|
|
|
#16 (permalink) | |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
Quote:
![]()
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
|
#17 (permalink) |
|
Join Date: Oct 2003
Location: Wyoming
Age: 27
Posts: 62
|
Could you possibly add a property to specify a proximity saying?
Like, for example, if a player walks near this npc he would say something like "Psst...I may be willing to part with some valuable information if you can tell me Lord British's middle name." Just something to get the conversation started basically. It would be nice to inherit my BaseVendor from this mobile and make shopkeepers greet people when they walk in the door. A proximity range would be nice also. -Davil |
|
|
|
|
#18 (permalink) |
|
Forum Novice
|
ok, I`m a little bit lazy today to review the commands...Is there a way to create a second speaker with the same properties as one that already existis? Or I would have to create a script that copies it(just wondering that it wouldnt be too hard)?
Would be nice for quests that would need the same speaker in three places. Or after you have been testing lots of props configs for a while for one kind of permanent npc that will be in lots of places. Just ideas... And, anyway...great, great script. Really useful. |
|
|
|
|
#19 (permalink) |
|
God of Pandora
Join Date: Jun 2003
Location: Gainesville GA
Age: 31
Posts: 2,000
|
oh hell yeah, I posted long ago about adding true AI to UO and with this, the Squire script and a few others, that goal is getting near.
I too have a suggestion (don't you love how when you submit a script it seems everyone has an idea on how it should be done? ) An addition to the Sequence of keywords, could it branch out to other lines of conversations? for example (and a simple one at that) Player says hi NPC say greetings, do you know the password? option 1 = Player says yes NPC says oh, wonderful, what is it? Player says password NPC says oh thats correct, here's a cookie option 2 = player says no NPC says I heard a rumor that in Yew there is a man who.......... and it can just get more AI like and complex from there I have yet to test this out so if this can be done already, please disregard if not, I imagine I could actually do this if you don't feel like doing so.
__________________
The Den of KillerBeeZ...Kender's Komments, uncensored commentary from the Kender. Plus anything else the Kender might have in his pouches.
|
|
|
|
|
#20 (permalink) | |
|
God of Pandora
Join Date: Jun 2003
Location: Gainesville GA
Age: 31
Posts: 2,000
|
Quote:
Now, granted, noone will ever use even a 10th of that number, but its not infinite (everything that deals with puters is finite) I'm not trying to be rude, I just wanted to point that out. In fact, (again correct me if I'm wrong) you might be able to use a ushort and have 65,535 entries I really don't think anyone can use even that many lol but if you have a crew of about 2000 people working on the entries (not that they could) you might use a ulong and have 18,446,744,073,709,551,615 entries imagine the AI then he he heok I'm done rambling, tis an awsome script and a fine addition to any shard
__________________
The Den of KillerBeeZ...Kender's Komments, uncensored commentary from the Kender. Plus anything else the Kender might have in his pouches.
|
|
|
|
|
|
#21 (permalink) |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
Ehm ok I guess. Let me rephrase that: "For any practical purposes you can add an infinite number of entries". It's clear that I wasn't using the mathematical meaning of the word infinite, but it meant 'as many as you wish' which is actually true because no real world person would ever write over 4 billion entries. And FYI, only one person can configure the NPC at a given time.
And in response to your previous post: that's actually a very good idea, but it would pure hell to implement using gumps (well the configuration part). Maybe I'll give it a shot with an external program though.
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
#22 (permalink) | |
|
God of Pandora
Join Date: Jun 2003
Location: Gainesville GA
Age: 31
Posts: 2,000
|
Quote:
Sorry, sometimes I'm too logical for my own good, and people often find it difficult to tell between when I'm joking and when I'm not.I know only one can edit it at a time thats why I said "not that they could" in regards to 2000 people working on it. As for the branches for the convo, after thinking about it, this would likely be better if done in the script for 2 reasons. 1) its actually easier in most cases to edit script, than a gump in game 2) if something bad happens and the saves folder gets deleted and your shard gets wiped or something, at least the hours and hours you spent configuring what the NPC would say wont be lost, granted its just as easy to back up a saves folder as it is to back up the scripts, but you know how things go, and in this world Murphy's law rings true. Besides I personally enjoy looking in the script to see the conversation myself, notepad is much easier to use to edit a script, then a gump is to edit the entries Now, if done in the script, it cant be changed on the fly, but a branched quest like this will likely not be something you will edit too often. With all that being said, maybe its a better idea to impliment the branch style speech with another NPC However, this external program you mentioned, this would be awsome if it could edit any one of the NPC speech in the world, like Speaker #1 or #2 or #3 and so on, you could actually create a program that is very powerful, not just for this script, but for others as well. Making programs however is beyond my scope of expertice so if I say something stupid, please forgive my ignorance. (* pours us another cup of coffee *) This program, would it be possible to use this to aid in the AI for the Squire script? What I mean is, the maker of that script has a damn fine AI system going, but it requires too much CPU power and that may be its downfall. He was talking about having the players run a small program on their computers to aid in the processing of the AI, but this is not the best way to do it. I personally would never trust a shard enough to run a program like this and I wouldn't expect others to either. The implimentation would be best if it was possible to run this AI assist program on another server at the location of the UO server. This program might act as a client and connect to the server in that way via the network. This is starting to get into the multiple server setup, and may break ground in implimenting multiple servers to run RunUO. It has been said that RunUO is so well written that you need only one computer to run it, but this is not true for those of us with systems like "P4 2.5 GHz w/ 512 MB ddr 266 ram" While this seems like a fairly fast system, I still cannot spawn the entire world without the server lagging, so even though RunUO can be run on a single server, multiple servers would still be better. I'm not asking you to write that, just saying that it might pave the way for it in the future. let me know what you think.
__________________
The Den of KillerBeeZ...Kender's Komments, uncensored commentary from the Kender. Plus anything else the Kender might have in his pouches.
|
|
|
|
|
|
#23 (permalink) |
|
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
|
What I had in mind was a software that would allow to edit the conversation skeleton and export it to an xml file. Then the NPC (which would not be the Speaker of course) would dynamically read the xml file and configure itself, so it wouldn't take a server restart to get the NPC working, just place the file in some folder on the server. This is just an idea which I might do if I have enough free time, but I'm not really sure about it yet.
By the way, I think 512 Mb of RAM isn't really that much for a server machine. I suggest you get at least 1 GB if you want to run a small shard... once it gets bigger getting 2-3 Gb is a must.
__________________
Oxygen should be regarded as a drug. |
|
|
|
|
#24 (permalink) | |
|
God of Pandora
Join Date: Jun 2003
Location: Gainesville GA
Age: 31
Posts: 2,000
|
Quote:
My shard is small for the moment, I have Trammel fully spawned, Fel about half way spawned and Ish partly spawned, and a little over 500 accounts, generally about 10 to 15 players at any time the problem with getting more memory is money.... as in I have none left, what with paying for the 512 Kbit upload speed, the various other expenses such as the RunUO subscription, and web hosting, domain names (2 of them), there are a great many small things that add up... and I run it all for free, so its all out of my own pocket, and its not a very deep pocket. Mainly tho what I'm talking about is that OSI servers are huge, 8 way Xeons with 32GB ram, and a good many of them (at least there were it its peak) However most people here cant afford anything near that so we use what we can. Sure RunUO will do just fine with just 1 puter, if its an uber puter, otherwise its still better to have more of them. I have seen many server specs in my time here, and while mine is no where near the fastest or the biggest, I have seen a great many slower older machines than mine running servers (like a 500 MHz P3) I plan on getting a new puter, but its going to be next year as I am so broke I can't pay attention.
__________________
The Den of KillerBeeZ...Kender's Komments, uncensored commentary from the Kender. Plus anything else the Kender might have in his pouches.
|
|
|
|