local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local t = {}
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
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
if msgcontains(msg, 'hello') or msgcontains(msg, 'hi') then
npcHandler:say(msgcontains(msg, 'sam') and 'Hi '..getCreatureName(cid)..'. Can I do something for you? I trade with weapons and armor.' or 'Welcome to my shop, adventurer '..getCreatureName(cid)..'! I trade with weapons and armor.', cid)
t[cid] = nil
npcHandler:addFocus(cid)
else
return false
end
elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
npcHandler:say('Good bye and come again, '..getCreatureName(cid)..'.', cid)
npcHandler:releaseFocus(cid)
t[cid] = nil
elseif msgcontains(msg, 'backpack') then
if getPlayerStorageValue(cid, 289) == -1 then
npcHandler:say('What? Are you telling me you found my old adventurer\'s backpack that I lost years ago??', cid)
t[cid] = 1
else
npcHandler:say('Yes, you brought back my old backpack. Thank you again.', cid)
t[cid] = nil
end
elseif t[cid] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 3960, 1) then
npcHandler:say('Thank you very much! This brings back good old memories! Please, as a reward, travel to Kazordoon and ask my old friend Kroox to provide you a special dwarven armor. ...', cid)
npcHandler:say('I will mail him about you immediately. Just tell him, his old buddy Sam is sending you.', cid)
setPlayerStorageValue(cid, 289, 1)
else
npcHandler:say('No, you don\'t have my old backpack. What a pity.', cid)
end
t[cid] = nil
elseif msgcontains(msg, 'no') then
npcHandler:say('What a pity.', cid)
t[cid] = nil
end
end
return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye and come again.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
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
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
if msgcontains(msg, 'hello') or msgcontains(msg, 'hi') or msgcontains(msg, 'hiho') then
npcHandler:say('Welcome to Kroox Quality Armor, '..getCreatureName(cid)..'!', cid)
npcHandler:addFocus(cid)
else
return false
end
elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
npcHandler:say('Good bye. Come back soon.', cid)
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, 'sam') and msgcontains(msg, 'sen') and getPlayerStorageValue(cid, 289) == 1 then
setPlayerStorageValue(cid, 289, 2)
npcHandler:say('Oh, so its you, he wrote me about? Sadly I have no dwarven armor in stock. But I give you the permission to retrive one from the mines. ...', cid)
npcHandler:say('The problem is, some giant spiders made the tunnels where the storage is their new home. Good luck.', cid)
end
return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye. Come back soon.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1225 then
if getPlayerStorageValue(cid, 289) == 2 then
doTransformItem(item.uid, 1226)
doTeleportThing(cid, toPosition, true)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'The door seems to be sealed against unwanted intruders.')
end
return true
end
end
local chance = 1000 -- 1% * rateLoot
local t, r = {
{ {x=32876, y=31707, z=2}, {x=32985, y=31807, z=6} },
{ {x=32886, y=31727, z=8}, {x=32993, y=31806, z=9} },
{ {x=32891, y=31751, z=7}, {x=32990, y=31796, z=7} },
{ {x=32905, y=31797, z=7}, {x=32978, y=31804, z=7} },
{ {x=32951, y=31714, z=7}, {x=32987, y=31750, z=7} },
{ {x=32972, y=31704, z=7}, {x=32987, y=31713, z=7} },
{ {x=32889, y=31749, z=7}, {x=32893, y=31753, z=7} },
{ {x=32908, y=31749, z=7}, {x=32912, y=31750, z=7} },
{ {x=32929, y=31749, z=7}, {x=32933, y=31750, z=7} },
{ {x=32889, y=31770, z=7}, {x=32890, y=31774, z=7} },
{ {x=32889, y=31793, z=7}, {x=32893, y=31797, z=7} },
{ {x=32903, y=31802, z=7}, {x=32907, y=31806, z=7} },
{ {x=32937, y=31805, z=7}, {x=32941, y=31806, z=7} },
{ {x=32974, y=31805, z=7}, {x=32978, y=31806, z=7} }
}, getConfigValue('rateLoot')
function onDeath(cid, corpse)
if math.random(100000) <= chance * r and isInArray({cid, nil}, getCreatureMaster(cid)) then
local p = getThingPos(cid)
for i = 1, #t do
if isInRange(p, t[i][1], t[i][2]) then
doAddContainerItem(corpse.uid, 3960)
break
end
end
end
return true
end
-
<event type="death" name="bp" event="script" value="bp.lua"/>
-
<script>
<event name="bp"/>
</script>