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

Npc Library Development Thread.

tarjei

Necronian Engineer
Joined
May 25, 2008
Messages
505
Reaction score
126
Location
Poland
Hello I decided to release this lib, as soon its done, but I still have few I issues I want to overcome first before I release it.
I desided to make it like modules. Meaning -> xml loads data about quests and npc dialogs from separeted modules in questmodules folder.

PHP:
<questmodules>
	<quest name = "Lumberjacking" file="sample.xml"> </quest>
	<npc name = "AldoLumberjacking" file ="annie.xml"/></npc>
</questmodules>

Yes I know it will be a little spread around data folder, but we get Npc script more cleand, and nice flexibility.
Code below basicly is quest structure, notice that you need JUST 1 storage for each mission (all actions in mission are set with bits)
PHP:
<quest = "Bawfuria quests">
	<mission name = "Mission1", storage = 5003>
		<flag name = "Get Task">
			<rewards>
					{exp = 30000},
					{item = 
						{id = 13985, amount = 20}
					},
					{rewardsContainer = 1987}				
			</rewards>
			<requirements>
				{item = {id = 5901, amount = 35}},
				{flags = {'|self||FLAG_GET_FIRST_TASK|'}}			
			</requirements>
			<state> You just get your first task, go do your task!! </state>
		</flag>
		<flag name = "Receive reward">
			<rewards>
					{exp = 30000},
					{item = 
						{id = 13985, amount = 20}
					},
					{rewardsContainer = 1987}				
			</rewards>
			<requirements>
				{item = {id = 5901, amount = 35}},
				{flags = {
					'|Other Defined Quest Name||Mission2||Beat the boss|' -- This is sample dir to flag that is needed to get this defined flag.
					
					}
				}			
			</requirements>
			<state> This is this flag questlog state.</state>
		</flag>
	</mission>
</quest>

But this is not all. This library will include npc dialogs handling.
Here is some sample.
PHP:
   <questline>
   <node keywords = 'quest;task' response = 'Some npc message'>
			<requirement condition='getPlayerLevel(cid) < 10' ></requirement> 
			<callback>
					function(cid, message, keywords, parameters, node)
						print('Callback called when player said node keyword :D PARSER NICE!')
					end
			</callback>
			<setflag mission='Lumberjacking' flag='flag name' > </setflag>
			--Child Keyword
			<node keywords = 'yes; sure' response = 'Ok then I will give you this task'>
				some free tedst
				<setflag mission = 'Lumberjacking' flag='flag name' > </setflag>
			</node>	
	</node>
	<node keywords ='quest;task' response = 'Would you like to take this quest?' >
		<requirement condition='getPlayerLevel(cid) |GREATER| 10' ></requirement> 
			<callback>
					function(cid, message, keywords, parameters, node)
						print('Second parser output.')
					end
			</callback>
		<node keywords = 'yes; sure' response = 'Hmm so you are level bigger than ten'>
				<setflag mission = 'Lumberjacking' flag='flag name' > </setflag> 
				<node keywords ='accepted' response ='You said hidden keyword' >
				</node>
		<node keywords = 'no; nope' response = 'Go away then.'>
		</node>	
	</node>
	</questline>
Requirements in nodes maybe set line condition in lua (just except > sign). It allows to build more slightly dialog trees without using talkstate handling.
Which was annoying for me personaly. The same thing is with storage values, isnt it boring for you when you want to make something you have to watch out for storage key and values and so on. Now even if you want to make action script and check a mission state, all you have to do (of course also you ahve to define quest)
Code:
local quest = QuestHandler:getQuest("Bawfuria quests")
local mission = QuestHandler:getMission("Mission1")

if mission:hasFlag("Get Task") then
    print("ok you can do action")
    
end

The last thing the library provides, is questlog handler (some alpha verison I released already)
Basicly each flag defined in quest is equal to mission state, so when you get some flag in mission, your state is changing, now I made its changing your mission states depening on what flags player received without any ingeration in current quests.xml.

HTML:
...
<state> This is this flag questlog state.</state>
...

- - - Updated - - -

A litle more about this library structure.
Mob%20brain.png


What is Quest its a set of specific Missions.

Each Mission require us to make some actions in it. and thats what Flags are - definition of actions, requirements, and rewards we need to make in each mission.

Sometimes we require some other actions (and from other mission or even quest) to be done before we can do (set) other flag.
I made a parser that looks for those specific flags depending on definition in xml.

<requirements>
{item = {id = 5901, amount = 35}},
{flags = {
'|Other Defined Quest Name||Mission2||Beat the boss|' -- This is sample dir to flag that is needed to get this defined flag.

}
}
</requirements>
|Other Defined Quest Name| --Quest name
|Mission2| --in which mission
|Beat the boss| -- flag name

but it can lack quest, or quest and mission like:
flags = {
'|Mission2||Beat the boss|' -- This is sample dir to flag that is needed to get this defined flag.

}
flags = {
'|Beat the boss|' -- This is sample dir to flag that is needed to get this defined flag.

}
It all depends on how far our wanted flag is located from current quest.


So all potential quest creator would have to handle is distibuating flags properly.

- - - Updated - - -

Decided to place some documentation I made before release it. I hope here I wont lose it >.< xD

Ultimate Npc/Quest Library Documentation.

XML Tags
questline -> informs that we are parsing npc dialogs (mostly its for handle quest actions)
-node it holds parameters : keywords (for npc replies) response - "Npc reply"
-
HTML:
<setflag  flag='|Scott Quest||Mission1||Get Task|' > </setflag>
(flag has to have format |QUESTNAME||MISSIONNAME||FLAGNAME|)

-Requirements
HTML:
		<requirement condition='getPlayerLevel(cid) |GREATER| 10' >
			{condition = something},
			{error = {
				 response = "Oww this response wastaken but you prolly dont pass requirements. Refuse "
			}
		</requirement>

condition in tag parameter is checked before message is proceed. Purpose of that behavior is for get proper node with same keywords
condition in "lua" array is after message is procced - it can hold requirements about items needed and so on.
error -> Npc reply after this second condition was not passed.

-Callbacks
<callback>
function(cid, message, keywords, parameters, node)
doPlayerPopupFYI(cid, "List of rewards:\n\n1 - Small Sapphire and a Gold Ingot\n2 - 3 Gold Ingots\n3 - Chain Armor\n4 - Kadabra Stick (agressive, for mages)\n5 - Abra Stick (supportive, for mages)\n6 - Giant Fist (C/R weapon, Atk/Def: 23/19, for warriors)\n7 - Silver Dagger (C/R weapon, Atk/Def: 23(+4 holy)/5, for rangers)\n\n Say [reward], then number of the reward to obtain it.")
end
</callback>

If we want more complicated action to be taken after some node is procced, we can always use this tag to achive that,
Its is always give with parameters show above (from npc system.)


--Building Quests Data

HTML:
<quest name = "Scott Quest">
--Quest name
HTML:
<mission name = "Mission1" storage = 5012>
Mission name and its storage(the only definition)

Flag name (the more intuitional they are the more easy its handling it later.)
<
HTML:
flag name = "Get Task">
			<state> Scott asked you to kill some earth diggers and somethign else too, </state> If player has set this flag, questlog will be set with this message for this quest.
		</flag>
		<flag name = "Task1_Reward">
			<requirements> This server to check if player can be set with this flag. (check items, other flags)
				{item = {id = 12807, amount = 20}},
				{item = {id = 11186, amount = 10}},
				{flags = {
					 '|Get Task|'					
					}
				}			
			</requirements>
			<state>You succesfully passed first Scott task, maybe its good time to take next one? </state>
		</flag>

--Conditional Quest States.
HTML:
		<flag name = "Vocation Killing" >
			<state condition = "getPlayerVocation(cid) == 1" > You have to kill mobs 1</state>
			<state condition = "getPlayerVocation(cid) == 2" > You have to kill mobs 2</state>
			<state condition = "getPlayerVocation(cid) == 3" > You have to kill some mobs 3</state>
		</flag>

I comeacross that making more complicated quests is harder using this lib. Thats why I implemented something I called
conditional quest states.
Basicly it works like if condition shown in tag paremeter is passed, then message in questlog is shown. (Notice I have still same value after calculation flags)

-conditional requirements.
HTML:
			<requirements condition = " getPlayerVocation(cid) == 1">
				{item = {id = 11097, amount = 3}},
				{item = {id = 12777, amount = 20}},
				{flags = {
					 '|Vocation Killing|'					
					}
				}			
			</requirements>
			<requirements condition = " getPlayerVocation(cid) == 2">
				{item = {id = 2677, amount = 160}},
				{flags = {
					 '|Vocation Killing|'					
					}
				}				
			</requirements>

works preety the same as conditional mission state above.
 

Attachments

Last edited:
lol, now i understand what you where saying at msn, great dude ! this is amazing, i will read it again like 2 more times to understand it better so i can talk with you on msn :D
 
Sure I will keep it updated, beacosue im still changing things, and I want it all bo be in one place XD
But this requires updating in npcsystem and so on, and my is kinda deprecated I quess.
Anyways Im still developing it XD
 
Maybe state tgis is for otclient? ;)

Awesome dude, everytime i speak to you you're excited about this or you AI ;) good job
 
Back
Top