• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC [Enhanced NPC System] 0.01ALPHA Released

jeybi

New Member
Joined
Oct 6, 2008
Messages
39
Reaction score
1
Development thread: http://otland.net/f163/enhanced-npc-system-141709/

As promised, here’s the alpha version. THIS IS NOT READY FOR A PRODUCTION SERVER. I’m not exactly done with the documentation (loads of orthography horrors, english = not my mother language) but for advanced users I think its documented enough. I'll be out for a month or so but in my spare time I’ll keep working on it. Expect bugs and maybe even crashes, not every part of the code is tested.

Code:
How to use
1. Create a new folder 'mckazinpc' in '\data\npc\lib\'
2. Download [ATTACH]10694[/ATTACH] extract and copy all the files to the new folder
3. Read the documentation of the files (each file has its own documentation, soon it will be in fancy html)
4. For now, you will have to put this line at the top of every npc Lua file that uses this library:
require(getDataDir() .. 'npc/lib/mckazinpc/ai')
5. See how your server crashes when you haven't even opened it
6. Profit

That's it, remember this is only a LUA library and nothing more, no source changes, no crazy stuff.

PS: I know the documentation is kind of harsh now, but it will be soon improved and easily viewed in a HTML site.

PS2: Remember to report any bugs if you are supporting this, I won't be around here for a few weeks so, patience.
 

Attachments

Last edited:
WORKING Example:
Lua:
require(getDataDir() .. 'npc/lib/mckazinpc/ai')

local Npc = AI.SocialNpc:New()

Npc.VisionRadius = 5
Npc.HearRadius = 5

Npc.LookAtFocus = false

-- All of these properties have their own default values, just messing around
Npc.GreetKeywords = {"hi", "sup"}
Npc.FarewellKeywords = {"bb", "cYa"}
Npc.MaxIdleTime = 50000
Npc.ResponseDelay = 1000
Npc.TalkCaseSensitive = true
Npc.PlayerNameToken = 'DUDE'


Npc.GreetReply = "Hello |DUDE|, I'm a test npc"
Npc.FarewellReply = "Bye |DUDE|"

Npc.Conversation = {
	{["ass%"]= function(talk, match)
		talk:Say("You called me an " .. match)
		talk:Say("You must die")
		
		local m = talk:Listen()
		
		talk:End("And now you called me a " .. m .. "! Bye |DUDE|")
	end},
	
	{["job|occupation"] = "My job is to be a !failure"},
	{["mission|quest"] = "I have no missions for you son"},
	{["heal"] = {
		{[function(talk) 
			return getCreatureHealth(talk.player) < 200 
		end] = function(talk)
			doCreatureAddHealth(talk.player, 200)
			return "You have been healed!"
		end},
		{[true] = "Sorry ur not wounded enought!"}
	}}
}

Npc:Register()

I'll be adding a newbie guide in the next hours, or maybe tomorrow Idk.
 
Last edited:
i ai.lua :
dofile(getDataDir() .. 'npc/lib/mckazinpc/ai_containers.lua')

and you write

1. Create a new folder 'ainpcsystem' in '\data\npc\lib\'

:p
--- edit
so, now :)
02:44 Andy [210]: hi
02:44 Jeybi: Hello Andy, I'm a test npc
02:44 Andy [210]: bb
02:44 Jeybi: Bye Andy
02:44 Andy [210]: hi
02:44 Jeybi: Hello Andy, I'm a test npc
02:44 Andy [210]: ass
02:44 Jeybi: You called me an ass
02:44 Jeybi: You must die
02:44 Andy [210]: javol
02:44 Jeybi: And now you called me a javol! Bye Andy
02:44 Andy [210]: job
02:44 Andy [210]: hi
02:44 Jeybi: Hello Andy, I'm a test npc
02:44 Andy [210]: job
02:44 Jeybi: My job is to be a !failure
02:44 Andy [210]: quest blabla
02:44 Jeybi: I have no missions for you son
02:45 Andy [210]: blab heal
02:45 Jeybi: Sorry ur not wounded enought!

^_^
 
Last edited:
@up
thx for the bug report, hope you try to make something more complex with the library
 
@upup
yes i will
I think that attract more people if you give more examples, better advertising
and do not give up your job!! :)
 
@andypsylon
yea, the problem is im on vacations (sort of) so i cant really give more examples (at least for a few weeks). Will appreciate if you publish your tests in this post!
 
Back
Top