Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------- creaturescritps.xml
- <event type="kill" name="Tasks2" script="killtasks2.lua"/>
- ---------------------------------------------- login.lua
- player:registerEvent("Tasks2")
- ---------------------------------------------- killtask2.lua
- local config = {
- ['troll'] = {amount = 50, storage = 18000, startstorage = 6110, startvalue = 1},
- ['rotworm'] = {amount = 100, storage = 18001, startstorage = 6111, startvalue = 1},
- ['tortoise'] = {amount = 200, storage = 18002, startstorage = 6112, startvalue = 1},
- ['cyclops'] = {amount = 100, storage = 18003, startstorage = 6113, startvalue = 1},
- ['amazon'] = {amount = 100, storage = 18004, startstorage = 6114, startvalue = 1},
- ['valkyrie'] = {amount = 100, storage = 18005, startstorage = 6115, startvalue = 1},
- ['tarantula'] = {amount = 150, storage = 18006, startstorage = 6116, startvalue = 1},
- ['scarab'] = {amount = 150, storage = 18007, startstorage = 6117, startvalue = 1},
- ['slime'] = {amount = 50, storage = 18008, startstorage = 6118, startvalue = 1},
- ['ice golem'] = {amount = 50, storage = 18009, startstorage = 6119, startvalue = 1},
- ['mammoth'] = {amount = 50, storage = 18010, startstorage = 6120, startvalue = 1},
- ['fire elemental'] = {amount = 50, storage = 18011, startstorage = 6121, startvalue = 1},
- ['demon skeleton'] = {amount = 100, storage = 18012, startstorage = 6122, startvalue = 1},
- ['crypt shambler'] = {amount = 100, storage = 18013, startstorage = 6123, startvalue = 1},
- ['mummy'] = {amount = 100, storage = 18014, startstorage = 6124, startvalue = 1},
- ['kongra'] = {amount = 100, storage = 18015, startstorage = 6125, startvalue = 1},
- ['wyvern'] = {amount = 100, storage = 18016, startstorage = 6126, startvalue = 1},
- ['orc leader'] = {amount = 100, storage = 18017, startstorage = 6127, startvalue = 1},
- ['ancient scarab'] = {amount = 200, storage = 18018, startstorage = 6128, startvalue = 1},
- ['banshee'] = {amount = 50, storage = 18019, startstorage = 6129, startvalue = 1},
- ['hero'] = {amount = 200, storage = 18020, startstorage = 6130, startvalue = 1},
- ['dragon'] = {amount = 200, storage = 18021, startstorage = 6131, startvalue = 1},
- ['dragon lord'] = {amount = 100, storage = 18022, startstorage = 6132, startvalue = 1},
- ['frost dragon'] = {amount = 200, storage = 18023, startstorage = 6133, startvalue = 1},
- ['warlock'] = {amount = 200, storage = 18024, startstorage = 6134, startvalue = 1},
- ['hydra'] = {amount = 150, storage = 18025, startstorage = 6135, startvalue = 1},
- ['demon'] = {amount = 150, storage = 18026, startstorage = 6136, startvalue = 1},
- ['necromancer'] = {amount = 200, storage = 18027, startstorage = 6137, startvalue = 1},
- ['vampire'] = {amount = 150, storage = 18028, startstorage = 6138, startvalue = 1},
- ['serpent spawn'] = {amount = 200, storage = 18029, startstorage = 6139, startvalue = 1},
- ['thornback tortoise'] = {amount = 200, storage = 18030, startstorage = 6140, startvalue = 1},
- ['plaguesmith'] = {amount = 200, storage = 18031, startstorage = 6141, startvalue = 1},
- ['dark torturer'] = {amount = 200, storage = 18032, startstorage = 6142, startvalue = 1},
- ['nightmare'] = {amount = 300, storage = 18033, startstorage = 6143, startvalue = 1},
- ['ghoul'] = {amount = 10, storage = 18034, startstorage = 6144, startvalue = 1},
- ['bonebeast'] = {amount = 200, storage = 18035, startstorage = 6145, startvalue = 1}
- }
- function onKill(player, target)
- local monster = config[target:getName():lower()]
- if target:isPlayer() or not monster or target:getMaster() then
- return true
- end
- local stor = player:getStorageValue(monster.storage)+1
- if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
- player:setStorageValue(monster.storage, stor)
- player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
- end
- if (stor +1) == monster.amount then
- player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
- player:setStorageValue(monster.storage, stor +1)
- end
- return true
- end
- ---------------------------------------------- Grizzly Adams.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <npc name="Grizzly Adams" script="tasks2.lua" walkinterval="2000" floorchange="0">
- <health now="100" max="100" />
- <look type="144" head="44" body="41" legs="86" feet="48" addons="3" />
- </npc>
- ---------------------------------------------- tasks2.lua
- -- Monster Tasks by Limos
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local xmsg = {}
- 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 storage = 62003
- local monsters = {
- ["Trolls"] = {storage = 6110, mstorage = 18000, amount = 50, exp = 2500, items = {{id = 2152, count = 25}}},
- ["Rotworms"] = {storage = 6111, mstorage = 18001, amount = 100, exp = 8000, items = {{id = 2152, count = 60}}},
- ["Tortoises"] = {storage = 6112, mstorage = 18002, amount = 200, exp = 30000, items = {{id = 2152, count = 70}}},
- ["Cyclops"] = {storage = 6113, mstorage = 18003, amount = 100, exp = 25000, items = {{id = 2160, count = 1}}},
- ["Amazons"] = {storage = 6114, mstorage = 18004, amount = 100, exp = 15000, items = {{id = 2160, count = 1}}},
- ["Valkyries"] = {storage = 6115, mstorage = 18005, amount = 100, exp = 20000, items = {{id = 2160, count = 1}}},
- ["Tarantulas"] = {storage = 6116, mstorage = 18006, amount = 150, exp = 40000, items = {{id = 2160, count = 1}, {id = 2152, count = 60}}},
- ["Scarabs"] = {storage = 6117, mstorage = 18007, amount = 150, exp = 45000, items = {{id = 2160, count = 1}, {id = 2152, count = 50}}},
- ["Slimes"] = {storage = 6118, mstorage = 18008, amount = 50, exp = 12000, items = {{id = 2152, count = 50}}},
- ["Ice Golems"] = {storage = 6119, mstorage = 18009, amount = 50, exp = 30000, items = {{id = 2152, count = 80}}},
- ["Mammoths"] = {storage = 6120, mstorage = 18010, amount = 50, exp = 12000, items = {{id = 2152, count = 70}}},
- ["Fire Elementals"] = {storage = 6121, mstorage = 18011, amount = 50, exp = 25000, items = {{id = 2160, count = 1}}},
- ["Demon Skeletons"] = {storage = 6122, mstorage = 18012, amount = 100, exp = 50000, items = {{id = 2160, count = 2}}},
- ["Crypt Shamblers"] = {storage = 6123, mstorage = 18013, amount = 100, exp = 40000, items = {{id = 2160, count = 1}}},
- ["Mummys"] = {storage = 6124, mstorage = 18014, amount = 100, exp = 35000, items = {{id = 2160, count = 1}}},
- ["Kongras"] = {storage = 6125, mstorage = 18015, amount = 100, exp = 30000, items = {{id = 2160, count = 1}}},
- ["Wyverns"] = {storage = 6126, mstorage = 18016, amount = 100, exp = 120000, items = {{id = 2160, count = 2}}},
- ["Orc Leaders"] = {storage = 6127, mstorage = 18017, amount = 150, exp = 80000, items = {{id = 2160, count = 1}}},
- ["Ancient Scarabs"] = {storage = 6128, mstorage = 18018, amount = 200, exp = 250000, items = {{id = 2160, count = 3}}},
- ["Banshees"] = {storage = 6129, mstorage = 18019, amount = 50, exp = 100000, items = {{id = 2160, count = 3}}},
- ["Heros"] = {storage = 6130, mstorage = 18020, amount = 200, exp = 500000, items = {{id = 2160, count = 4}}},
- ["Dragons"] = {storage = 6131, mstorage = 18021, amount = 200, exp = 300000, items = {{id = 2160, count = 3}}},
- ["Dragon Lords"] = {storage = 6132, mstorage = 18022, amount = 100, exp = 450000, items = {{id = 2160, count = 6}}},
- ["Frost Dragons"] = {storage = 6133, mstorage = 18023, amount = 200, exp = 900000, items = {{id = 2160, count = 9}}},
- ["Warlocks"] = {storage = 6134, mstorage = 18024, amount = 200, exp = 1500000, items = {{id = 2160, count = 15}}},
- ["Hydras"] = {storage = 6135, mstorage = 18025, amount = 150, exp = 700000, items = {{id = 2160, count = 7}}},
- ["Demons"] = {storage = 6136, mstorage = 18026, amount = 150, exp = 2000000, items = {{id = 2160, count = 15}}},
- ["Necromancers"] = {storage = 6137, mstorage = 18027, amount = 200, exp = 250000, items = {{id = 2160, count = 4}}},
- ["Vampires"] = {storage = 6138, mstorage = 18028, amount = 150, exp = 100000, items = {{id = 2160, count = 3}}},
- ["Serpent Spawns"] = {storage = 6139, mstorage = 18029, amount = 200, exp = 1000000, items = {{id = 2160, count = 10}}},
- ["Thornback Tortoises"] = {storage = 6140, mstorage = 18030, amount = 200, exp = 80000, items = {{id = 2160, count = 2}}},
- ["Plaguesmith"] = {storage = 6141, mstorage = 18031, amount = 200, exp = 2300000, items = {{id = 2160, count = 15}}},
- ["Dark Torturer"] = {storage = 6142, mstorage = 18032, amount = 200, exp = 2100000, items = {{id = 2160, count = 15}}},
- ["Nightmare"] = {storage = 6143, mstorage = 18033, amount = 300, exp = 1000000, items = {{id = 2160, count = 12}}},
- ["Ghoul"] = {storage = 6144, mstorage = 18034, amount = 100, exp = 18000, items = {{id = 2160, count = 1}}},
- ["Bonebeast"] = {storage = 6145, mstorage = 18035, amount = 200, exp = 340000, items = {{id = 2160, count = 4}}}
- }
- local function getItemsFromTable(itemtable)
- local text = ""
- for v = 1, #itemtable do
- count, info = itemtable[v].count, ItemType(itemtable[v].id)
- local ret = ", "
- if v == 1 then
- ret = ""
- elseif v == #itemtable then
- ret = " and "
- end
- text = text .. ret
- text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
- end
- return text
- end
- local function Cptl(f, r)
- return f:upper()..r:lower()
- end
- function creatureSayCallback(cid, type, msg)
- local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
- if not npcHandler:isFocused(cid) then
- if msg == "hi" or msg == "hello" then
- npcHandler:addFocus(cid)
- if player:getStorageValue(storage) <= 1 then
- local text, n = "", 0
- for k, x in pairs(monsters) do
- if player:getStorageValue(x.mstorage) < x.amount then
- n = n + 1
- text = text .. ", "
- text = text .. ""..x.amount.." {"..k.."}"
- end
- end
- if n > 1 then
- npcHandler:say("I have several tasks for you to kill monsters. I can show you a [task] with rewards to let you choose the task that you want and you can [cancel] a task if you want. Say [report] if u finished task.", cid)
- npcHandler.topic[cid] = 1
- xmsg[cid] = msg
- elseif n == 1 then
- npcHandler:say("I have one last task for you"..text..".", cid)
- npcHandler.topic[cid] = 1
- else
- npcHandler:say("You already did all tasks, I have nothing for you to do anymore, good job though.", cid)
- end
- elseif player:getStorageValue(storage) > 1 then
- print("tasks.lua")
- print(storage)
- for k, x in pairs(monsters) do
- print(x.storage)
- if player:getStorageValue(storage) == x.storage then
- npcHandler:say("Did you kill? If yes say [report] "..x.amount.." "..k.."? ("..#monsters..")", cid)
- npcHandler.topic[cid] = 2
- xmsg[cid] = k
- end
- end
- end
- else
- return false
- end
- elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
- if player:getStorageValue(monsters[cmsg].storage) == -1 then
- npcHandler:say("Good luck, come back when you killed "..monsters[cmsg].amount.." "..cmsg..".", cid)
- player:setStorageValue(storage, monsters[cmsg].storage)
- player:setStorageValue(monsters[cmsg].storage, 1)
- else
- npcHandler:say("You already did the mission.", cid)
- end
- npcHandler.topic[cid] = 0
- elseif msgcontains(msg, "report") and npcHandler.topic[cid] == 2 then
- local x = monsters[xmsg[cid]]
- if player:getStorageValue(x.mstorage) >= x.amount then
- npcHandler:say("Good job, here is your reward, "..getItemsFromTable(x.items)..".", cid)
- for g = 1, #x.items do
- player:addItem(x.items[g].id, x.items[g].count)
- end
- player:addExperience(x.exp)
- player:setStorageValue(x.storage, 2)
- player:setStorageValue(storage, -1)
- npcHandler.topic[cid] = 3
- else
- npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
- end
- elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
- local text, n = "", 0
- for k, x in pairs(monsters) do
- if player:getStorageValue(x.mstorage) < x.amount then
- n = n + 1
- text = text .. (n == 1 and "" or ", ")
- text = text .. "{"..k.."}"
- end
- end
- if text ~= "" then
- text = "Want to do another task? You can choose "..text.."."
- --npcHandler:say("Want to do another task? You can choose "..text..".", cid)
- player:showTextDialog(2175, text)
- npcHandler.topic[cid] = 1
- else
- npcHandler:say("You already did all tasks.", cid)
- end
- elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
- npcHandler:say("Ok then.", cid)
- npcHandler.topic[cid] = 0
- elseif msgcontains(msg, "cancel") then
- local text, n = "", 0
- for k, x in pairs(monsters) do
- if player:getStorageValue(x.mstorage) < x.amount then
- n = n + 1
- text = text .. (n == 1 and "" or ", ")
- text = text .. "{"..k.."}"
- if player:getStorageValue(x.storage) > 1 then
- player:setStorageValue(x.storage, -1)
- end
- end
- end
- if player:getStorageValue(storage) > 1 then
- npcHandler:say("Alright, let me know if you want to continue an other task, you can still choose", cid)
- local tmp = player:getStorageValue(storage)
- player:setStorageValue(tmp, -1)
- else
- npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose ", cid)
- end
- player:setStorageValue(storage, -1)
- npcHandler.topic[cid] = 1
- elseif msgcontains(msg, "task") then
- local text = "Tasks\n\n"
- for k, x in pairs(monsters) do
- if player:getStorageValue(x.mstorage) < x.amount then
- text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n Rewards:\n "..getItemsFromTable(x.items).."\n "..x.exp.." experience \n\n"
- else
- text = text .. k .." [DONE]\n"
- end
- end
- player:showTextDialog(2175, "" .. text)
- --player:showTextDialog(item:getId(), text)
- npcHandler:say("Here you are.", cid)
- elseif msgcontains(msg, "bye") then
- npcHandler:say("Bye.", cid)
- npcHandler:releaseFocus(cid)
- else
- npcHandler:say("What?", cid)
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement