• 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] Haroun

Kjeld

Avid OTLand fan
Joined
Oct 17, 2007
Messages
47
Reaction score
11
Location
255.255.255.0
Here's Haroun, except he doesn't trades any items, e.g. fire swords for magic sulphur.

haroun.lua

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureSay(cid, type, msg) 							npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos) 				npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature) 							npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id) 							npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature) 							npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature) 						npcHandler:onCreatureChangeOutfit(creature) end
function onThink() 									npcHandler:onThink() end
-- OTServ event handling functions end

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

-- ITEMS HE BUYS! --
-- Rings: --
shopModule:addSellableItem({'sell sword ring'}, 2207, 100, 'Sword Ring')
shopModule:addSellableItem({'sell club ring'}, 2209, 100, 'Club Ring')
shopModule:addSellableItem({'sell axe ring'}, 2208, 100, 'Axe Ring')
shopModule:addSellableItem({'sell power ring'}, 2166, 50, 'Power Ring')
shopModule:addSellableItem({'sell stealth ring'}, 2165, 200, 'Stealth Ring')
-- Amulets: --
shopModule:addSellableItem({'sell stone skin amulet'}, 2197, 500, 'Stone Skin Amulet')
shopModule:addSellableItem({'sell elven amulet'}, 2198, 100, 'Elven Amulet')
shopModule:addSellableItem({'sell bronze amulet'}, 2172, 50, 'Bronze Amulet')
shopModule:addSellableItem({'sell garlic necklace'}, 2199, 50, 'Garlic Necklace')
-- Wands: -- 
shopModule:addSellableItem({'magic light wand', 'magic lightwand'}, 2162, 35, 'Magic Lightwand')
shopModule:addSellableItem({'wand of vortex'}, 2190, 100, 'Wand of Vortex')
shopModule:addSellableItem({'wand of dragonbreath'}, 2191, 200, 'Wand of Dragonbreath')
shopModule:addSellableItem({'wand of plague'}, 2188, 1000, 'Wand of Plague')
shopModule:addSellableItem({'wand of cosmic energy'}, 2189, 2000, 'Wand of Cosmic Energy')
shopModule:addSellableItem({'wand of inferno'}, 2187, 3000, 'Wand of Inferno')
-- Special Items: --
shopModule:addSellableItem({'orb'}, 2176, 750, 'Orb')
shopModule:addSellableItem({'mind stone'}, 2178, 100, 'Mind Stone')
shopModule:addSellableItem({'life crystal'}, 2177, 50, 'Life Crystal')

-- ITEMS HE SELLS! --
shopModule:addBuyableItem({'buy sword ring'}, 2207, 500, 'Sword Ring')
shopModule:addBuyableItem({'buy club ring'}, 2209, 500, 'Club Ring')
shopModule:addBuyableItem({'buy axe ring'}, 2208, 500, 'Axe Ring')
shopModule:addBuyableItem({'buy power ring'}, 2166, 100, 'Power Ring')
shopModule:addBuyableItem({'buy stealth ring'}, 2165, 5000, 'Stealth Ring')
-- Amulets: --
shopModule:addBuyableItem({'buy stone skin amulet'}, 	2197, 5000, 	10,	'Stone Skin Amulet')
shopModule:addBuyableItem({'buy elven amulet'}, 	2198, 500,	50,	'Elven Amulet')
shopModule:addBuyableItem({'buy bronze amulet'}, 	2172, 100,	200, 	'Bronze Amulet')
shopModule:addBuyableItem({'buy garlic necklace'}, 	2199, 100,	150,	'Garlic Necklace')



-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

Haroun.xml

Code:
<?xml version="1.0"?>

<npc name="Haroun" script="data/npc/scripts/haroun.lua" access="3" lookdir="2" autowalk="25">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type=80" head="20" body="30" legs="40" feet="50"/>

	<parameters>
		<parameter key="module_shop" value="1" />
		<parameter key="message_greet" value="Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?" />
		<parameter key="message_farewell" value="Farewell, human." />		
		<parameter key="message_buy" value="Do you want to purchase |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold?" />
		<parameter key="message_sell" value="Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold?" />
		<parameter key="message_decline" value="Well, obviously not." />		
		<parameter key="message_onbuy" value="It'll serve you well!" />
		<parameter key="message_onsell" value="Thank you human." />
		<parameter key="message_walkaway" value="Farewell, human." />
		
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="job" />
		<parameter key="keyword_reply1" value="I'm an old djinn, I buy several items, and sell a few myself." />

	</parameters>


</npc>

Kjeld~

I've noticed one bug, its not really a bug, but it doesn't sells you a SSA with 5 shots, but a SSA with one charge.
 
Last edited:
And work on Forgotten?

This command: shopModule:addSellableItem ??

Cya.

Code:
23:48 Alibert [2]: hi
23:48 Haroun: Be greeted, human Alibert. How can a humble djinn be of service?
23:48 Alibert [2]: sell sword ring
23:48 Haroun: Do you want to sell 1 Sword Ring for 100 gold?
23:48 Alibert [2]: yes
23:48 Haroun: Thank you human.
23:48 Alibert [2]: bye
23:48 Haroun: Farewell, human.

Tested and works.

I noticed a small bug in it, and i'll show what I mean:

Code:
23:46 You see a stone skin amulet that has 1 charge left.
It weighs 7.60 oz.
ItemID: [2197].
Position: [X: 349] [Y: 95] [Z: 7].
23:46 You see a bronze amulet that has 1 charge left.
It weighs 5.00 oz.
ItemID: [2172].
Position: [X: 350] [Y: 95] [Z: 7].
23:46 You see an elven amulet that has 1 charge left.
It weighs 2.70 oz.
ItemID: [2198].
Position: [X: 351] [Y: 95] [Z: 7].

It sells amulets with one charge, I tried fixing it, but it still doesn't works.

Help is apreciated!

Kjeld~
 
Last edited:
Cool npc;)

I like the
<parameters>
<parameter key="module_shop" value="1" />
<parameter key="message_greet" value="Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?" />
<parameter key="message_farewell" value="Farewell, human." />
<parameter key="message_buy" value="Do you want to purchase |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold?" />
<parameter key="message_sell" value="Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold?" />
<parameter key="message_decline" value="Well, obviously not." />
<parameter key="message_onbuy" value="It'll serve you well!" />
<parameter key="message_onsell" value="Thank you human." />
<parameter key="message_walkaway" value="Farewell, human." />

<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="job" />
<parameter key="keyword_reply1" value="I'm an old djinn, I buy several items, and sell a few myself." />

</parameters>
 
Haha, thanks a lot :p

I'm now working on a furniture npc, might release it when its done.

Kjeld~
 
Back
Top