• 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.

[Voting] New Quest NPC system

What do you think about this system?

  • It's awesome!!

    Votes: 9 47.4%
  • It sux!

    Votes: 5 26.3%
  • It's good but needs to be improved (Explain)

    Votes: 5 26.3%

  • Total voters
    19

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Reaction score
38
Location
Sweden
I'm currently working on a new NPC system that I'm maybe going to release. I want you to share your suggestions about it and maybe tell me how I can improve it.

Here is an example of how a NPC script might look like:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()						npcHandler:onThink()						end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

function creatureSayCallback(cid, type, msg)
quest = {
	["mission"] = {
		reuqire = {
			vocation = {id = 1, promotion = 1, error = "You\'re not a master sorcerer."},
			level = {value = 400, error = "You need to be level 400."},
			storage = {id = 3000, value = 1, get = "equal_or_higher"} 
		}
		do = {
			sendMsg = {"Okay", "Do you want a mission?"}, -- Send multiple messages.
			setState = 1
		}
	["yes"] = {
		if talk_state == 1 then
		do = {
			sendMsg = {"Too bad, I don\'t have any. lol"}
			if yes == yes then
				doSendMagicEffect(getCreaturePosition(cid), 2) -- You can also add own functions that doesn't exsist on the npc system.
			end
			setState = 0
		}
		else
			npcHandler:say("What \"yes\"? I didn\'t even ask anything.", cid)
		end
	}
}

setQuestNpc(cid, msg, quest, talk_state)
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

All variables are optional and it's easy for you to add new ones too. :)

You can see how you can add your own keywords, inside every keyword it can be two tables, "require" and "do". Everything inside the table "require" is required to do everything inside the table "do".
 
Require, not reuqire.
It's not system, it's module.
I think it sucks ;d
 
@up, hmm, maybe it should work only with functions instead of tables.. The construction is maybe too messy :p
 
Back
Top