Tom.xml
<?xml version="1.0" encoding="UTF-8"?> <npc name="Tom" script="data/npc/scripts/Rookgaard/Tom.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="144" head="113" body="115" legs="115" feet="115" addons="0"/> <parameters> <parameter key="message_greet" value="Hey there, |PLAYERNAME|. I'm Tom the tanner. If you have fresh corpses, leather or paws, trade with me."/> <parameter key="message_farewell" value="Good bye."/> <parameter key="message_walkaway" value="D'oh?"/> <parameter key="message_idletimeout" value="D'oh?"/> <parameter key="message_sendtrade" value="Sure, check what I buy."/> <parameter key="module_shop" value="1"/> <parameter key="shop_sellable" value="bear paw,5896,10;dead rabbit,3119,2;dead rat,2813,2;dead wolf,2826,5;minotaur leather,5878,12;dead spider,2848,3;wolf paw,5897,7;"/> <parameter key="module_keywords" value="1" /> <parameter key="keywords" value="Oracle;Seymour;Cipfried;Tom;tanner;corpse;monster;sewer;troll;orc;Amber;Rookgaard;main;mainland;Obi;Dixi;Lily;Al Dee;wares;job;merchants;Lee'Delle;weapon;shield;Willie;Billy;Norma;" /> <parameter key="keyword_reply1" value="It's in the academy, just above {Seymour}. Go there once you are level 8 to leave this place." /> <parameter key="keyword_reply2" value="He sticks his nose too much in books." /> <parameter key="keyword_reply3" value="I'm not what you'd call a 'believer'." /> <parameter key="keyword_reply4" value="Yep." /> <parameter key="keyword_reply5" value="That's my job. It can be dirty at times but it provides enough income for my living." /> <parameter key="keyword_reply6" value="I'm buying fresh {corpses} of rats, rabbits and wolves. I don't buy half-decayed ones. If you have any for sale, {trade} with me." /> <parameter key="keyword_reply7" value="Good monsters to start with are rats. They live in the {sewers} under the village of {Rookgaard}." /> <parameter key="keyword_reply8" value="The nearest sewer entrance is just to the right of this building." /> <parameter key="keyword_reply9" value="Troll leather stinks. Can't use it." /> <parameter key="keyword_reply10" value="I don't buy orcs. Their skin is too scratchy." /> <parameter key="keyword_reply11" value="Now that's an interesting woman." /> <parameter key="keyword_reply12" value="This island has its own problems, but all in all it's a decent place to live." /> <parameter key="keyword_reply13" value="You can go there once you are level 8 and have talked to the {oracle}." /> <parameter key="keyword_reply14" value="You can go there once you are level 8 and have talked to the {oracle}." /> <parameter key="keyword_reply15" value="He is such a hypocrite." /> <parameter key="keyword_reply16" value="She buys my fine leather clothes." /> <parameter key="keyword_reply17" value="She always comes and preaches about how one should not wear animal skin." /> <parameter key="keyword_reply18" value="He's an apple polisher." /> <parameter key="keyword_reply19" value="I'm buying fresh {corpses} of rats, rabbits and wolves. I don't buy half-decayed ones. If you have any for sale, {trade} with me." /> <parameter key="keyword_reply20" value="I'm the local {tanner}. I buy fresh animal {corpses}, tan them, and convert them into fine leather clothes which I then sell to {merchants}." /> <parameter key="keyword_reply21" value="{Dixi} and {Lee'Delle} sell my leather clothes in their shops." /> <parameter key="keyword_reply22" value="Her nose is a little high in the air, I think. She never shakes my hand." /> <parameter key="keyword_reply23" value="Nope, sorry, don't sell that. Ask {Obi} or {Lee'Delle}." /> <parameter key="keyword_reply24" value="Nope, sorry, don't sell that. Ask {Dixi} or {Lee'Delle}." /> <parameter key="keyword_reply25" value="I kinda like him. At least he says what he thinks." /> <parameter key="keyword_reply26" value="He's a better cook than his cousin {Willie}, actually." /> <parameter key="keyword_reply27" value="I like her beer." /> </parameters> </npc>
Tom.lua
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState,price = {},0 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) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg,'human') then selfSay('Are you crazy?!', cid) npcHandler:releaseFocus(cid) end return true end function thinkCallback() talk = math.random(1,200) if talk == 1 then doCreatureSay(getNpcCid(), "Oh yeah, I'm also interested in wolf paws and bear paws.", TALKTYPE_YELL) elseif talk == 2 then doCreatureSay(getNpcCid(), "Also buying minotaur leather.", TALKTYPE_YELL) elseif talk == 3 then doCreatureSay(getNpcCid(), "Buying fresh corpses of rats, rabbits and wolves.", TALKTYPE_YELL) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())