Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- config
- local modalId = 1007
- local choice = {}
- local recipes = {
- [1] = {name = "Raw Leather", subname = "lizard leather", count = 1, storage = 40010, level = 20, tries = 2, id = 22539,
- needed = {
- [1] = {name = "lizard leathers", id = 5876, count = 2}
- }
- },
- [2] = {name = "Raw Leather", subname = "minotaur leather", count = 1, storage = 40010, level = 10, tries = 1, id = 22539,
- needed = {
- [1] = {name = "minotaur leathers", id = 5878, count = 2}
- }
- },
- [3] = {name = "Raw Leather", subname = "red dragon leather", count = 1, storage = 40010, level = 20, tries = 3, id = 22539,
- needed = {
- [1] = {name = "red dragon leathers", id = 5948, count = 2}
- }
- },
- [4] = {name = "Raw Leather", subname = "green dragon leather", count = 1, storage = 40010, level = 20, tries = 2, id = 22539,
- needed = {
- [1] = {name = "green dragon leathers", id = 5877, count = 2}
- }
- },
- [5] = {name = "Raw Leather", subname = "crocodile leather", count = 1, storage = 40010, level = 10, tries = 1, id = 22539,
- needed = {
- [1] = {name = "pieces of crocodile leather", id = 11196, count = 4}
- }
- },
- [6] = {name = "Raw Leather", subname = "orc leather", count = 1, storage = 40010, level = 10, tries = 1, id = 22539,
- needed = {
- [1] = {name = "orc leathers", id = 12435, count = 4}
- }
- },
- [7] = {name = "Raw Leather", subname = "silky fur", count = 1, storage = 40010, level = 30, tries = 1, id = 22539,
- needed = {
- [1] = {name = "silky fur", id = 11209, count = 1}
- }
- },
- [8] = {name = "Raw Leather", subname = "black wool", count = 1, storage = 40010, level = 30, tries = 1, id = 22539,
- needed = {
- [1] = {name = "black wool", id = 12404, count = 1}
- }
- },
- [9] = {name = "Raw Leather", subname = "striped fur", count = 1, storage = 40010, level = 30, tries = 1, id = 22539,
- needed = {
- [1] = {name = "striped fur", id = 11210, count = 1}
- }
- },
- [10] = {name = "Raw Leather", subname = "war wolf fur", count = 2, storage = 40010, level = 40, tries = 2, id = 22539,
- needed = {
- [1] = {name = "war wolf fur", id = 11235, count = 1}
- }
- },
- [11] = {name = "Raw Leather", subname = "winter wolf fur", count = 2, storage = 40010, level = 40, tries = 1, id = 22539,
- needed = {
- [1] = {name = "winter wolf fur", id = 11212, count = 1}
- }
- },
- [12] = {name = "Raw Leather", subname = "wool", count = 2, storage = 40010, level = 40, tries = 1, id = 22539,
- needed = {
- [1] = {name = "wool", id = 11236, count = 1}
- }
- },
- [13] = {name = "Raw Leather", subname = "badger fur", count = 2, storage = 40010, level = 40, tries = 2, id = 22539,
- needed = {
- [1] = {name = "badger fur", id = 11216, count = 1}
- }
- },
- [14] = {name = "Raw Leather", subname = "werewolf fur", count = 2, storage = 40010, level = 40, tries = 4, id = 22539,
- needed = {
- [1] = {name = "werewolf fur", id = 11234, count = 1}
- }
- },
- [15] = {name = "Raw Leather", subname = "thick fur", count = 4, storage = 40010, level = 60, tries = 2, id = 22539,
- needed = {
- [1] = {name = "thick fur", id = 11224, count = 1}
- }
- },
- [16] = {name = "Raw Leather", subname = "frost giant pelt", count = 4, storage = 40010, level = 60, tries = 2, id = 22539,
- needed = {
- [1] = {name = "frost giant pelt", id = 10575, count = 1}
- }
- },
- [17] = {name = "Raw Leather", subname = "white deer skin", count = 4, storage = 40010, level = 80, tries = 3, id = 22539,
- needed = {
- [1] = {name = "white deer skin", id = 13534, count = 1}
- }
- },
- [18] = {name = "Raw Leather", subname = "frazzle skin", count = 4, storage = 40010, level = 80, tries = 4, id = 22539,
- needed = {
- [1] = {name = "frazzle skin", id = 22533, count = 1}
- }
- },
- }
- local training = {
- [40010] = "Basic Tanning",
- }
- function Player:hasReq(recipe)
- for i = 1, #recipe.needed do
- if self:getItemCount(recipe.needed[i].id) < recipe.needed[i].count then
- return false
- end
- end
- return true
- end
- function Player:sendPeltWindow()
- local window = ModalWindow(modalId, "Tanning", "Expand the item you want to produce to view the requirements.\nYou are trained in the following skills:\n")
- local choices = 0
- local temp = 0
- for key,value in pairs(training) do
- if self:getStorageValue(key) >= 10 then
- temp = temp + 1
- window:setMessage(window:getMessage() .. training[key] .. " (" .. self:getCSkill(training[key]) .. ")\n")
- end
- end
- if temp == 0 then
- window:setMessage(window:getMessage() .. "No skill training.\n")
- end
- for i = 1, #recipes do
- if recipes[i].subname then
- if recipes[i].count > 1 then
- window:addChoice(i, recipes[i].count .. " " .. recipes[i]["name"] .. " (" .. recipes[i].subname .. ")")
- else
- window:addChoice(i, recipes[i]["name"] .. " (" .. recipes[i].subname .. ")")
- end
- else
- if recipes[i].count > 1 then
- window:addChoice(i, recipes[i].count .. " " .. recipes[i]["name"])
- else
- window:addChoice(i, recipes[i]["name"])
- end
- end
- choices = choices + 1
- end
- if choices > 0 then
- window:addButton(1, "Expand")
- window:setDefaultEnterButton(1)
- end
- window:addButton(2, "Exit")
- window:setDefaultEscapeButton(2)
- window:sendToPlayer(self)
- return true
- end
- function Player:sendPRecipeWindow(product)
- local window = ModalWindow(modalId + 1, product["name"], "To produce this item, you need:\n")
- for i = 1, #product.needed do
- window:setMessage(window:getMessage() .. product.needed[i].count .. " " .. product.needed[i].name .. " (" .. self:getItemCount(product.needed[i].id) .. ")\n")
- end
- if product.storage then
- local lev = self:getCSkill(training[product.storage])
- window:setMessage(window:getMessage() .. training[product.storage] .. " " .. product.level .. " (" .. lev .. ")\n")
- end
- for j = 1, #product.needed do
- if self:getItemCount(product.needed[j].id) < product.needed[j].count or (product.storage and self:getCSkill(training[product.storage]) < product.level) then
- return window:addButton(2, "Back"), window:setDefaultEscapeButton(2), window:setDefaultEnterButton(2), window:sendToPlayer(self)
- end
- end
- window:addButton(1, "Make It!")
- window:setDefaultEnterButton(1)
- window:addButton(2, "Back")
- window:setDefaultEscapeButton(2)
- window:sendToPlayer(self)
- return true
- end
- function Player:peltWindowChoice(windowId, buttonId, choiceId)
- local p = self:getGuid()
- if windowId == modalId then
- if buttonId == 1 then
- choice[p] = choiceId
- self:sendPRecipeWindow(recipes[choiceId])
- return true
- else
- choice[p] = nil
- return false
- end
- end
- return false
- end
- function Player:pRecipeWindowChoice(windowId, buttonId, choiceId)
- local p = self:getGuid()
- if windowId == modalId + 1 then
- if buttonId == 1 then
- for i = 1, #recipes[choice[p]].needed do
- self:removeItem(recipes[choice[p]].needed[i].id, recipes[choice[p]].needed[i].count)
- end
- local rand = math.random(1,100000)
- local extra = false
- local chance = (cSkills[training[recipes[choice[p]].storage]].bonus * self:getCSkill(training[recipes[choice[p]].storage])) * 100
- if rand < chance * 1000 then
- extra = true
- end
- if extra then
- self:addItem(recipes[choice[p]].id, recipes[choice[p]].count + 2)
- self:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have produced " .. recipes[choice[p]].count + 2 .. " " .. recipes[choice[p]].name .. " instead of the usual " .. recipes[choice[p]].count .. "!")
- else
- self:addItem(recipes[choice[p]].id, recipes[choice[p]].count)
- self:sendTextMessage(MESSAGE_INFO_DESCR, "You have produced " .. recipes[choice[p]].count .. " " .. recipes[choice[p]].name .. "!")
- end
- self:addCSkillTries(training[recipes[choice[p]].storage], recipes[choice[p]].tries)
- return self:hasReq(recipes[choice[p]]) and self:sendPRecipeWindow(recipes[choice[p]]) or self:sendPeltWindow()
- elseif buttonId == 2 then
- self:sendPeltWindow()
- end
- return false
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement