Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Date: 20.10.2017
- Quest Name: LockPicking.lua
- Author: Dominik Michalski
- Version: 1.0.0
- ]]--
- quest lockpicking begin
- -- send target and talk about this system with npc
- state start begin
- when login or levelup or enter with pc.level >= 90 begin
- set_state (box_inform)
- end
- end
- state box_inform begin
- when letter begin
- send_letter("Spróchniałe Skrzynie")
- local v = find_npc_by_vnum (20131)
- if v != 0 then
- target.vid ("__TARGET__",v,"Idź do Poszukiwacza")
- end
- end
- when button or info begin
- say_cegla(" Oferta:")
- say("")
- say("Poszukiwacz z Twojej wioski ma dla Ciebie ofertę.")
- say("Udaj się do niego, aby dowiedzieć się więcej.")
- say("")
- end
- when __TARGET__.target.click or 20131.chat."Spróchniałe Skrzynie" begin
- target.delete("__TARGET__")
- say_title(mob_name(20131))
- say("")
- say("Witaj Poszukiwaczu Przygód!")
- say("Ja też jestem Poszukiwaczem! Szukam skarbów ")
- say("ukrytych w zakamarkach starych skrzyń.")
- say("")
- say("Chcesz dowiedzieć się coś o Spróchniałych Skrzyniach? ")
- say("Na nowo odkrytych mapach widzieliśmy dużo tych skrzyń.")
- say("Wyglądem przypominają szkatułki Władców, lecz skrywają ")
- say("cenniejsze nagrody.")
- say("")
- say("Możesz użyć specjalnego Klucza, aby zapewnić sobie ")
- say("100% pewności przy otwieraniu zamków.")
- say("Jeśli nie posiadasz klucza, wystarczy,")
- say("że klikniesz na szkatułkę.")
- say_item_vnum(51040, "Magiczny Klucz", "Dzięki temu przedmiotowi możesz otworzyć każdą napotkaną szkatułkę.")
- say("")
- pc.give_item2(51040,1)
- pc.set_skill_level(lockpicking.settings()['skillVnum'], lockpicking.getSkillLevel()+1)
- clear_letter()
- set_state(main_part)
- end
- end
- -- main part of this system
- state main_part begin
- function settings()
- return {
- ['skillVnum'] = 133,
- ['maxLevel'] = 40,
- ['readDelay'] = 2, -- in hours
- ['boxNPCVnum'] = 20130,
- ['missionNPCVnum'] = 20131,
- ['skillBookVnum'] = 51033,
- ['specialItemVnum'] = 51040,
- ['bookReadChance'] = 40, -- percentage
- ['defaultChance'] = 20, -- percentage
- ['defaultCount'] = 1,
- ['keyAllowUse'] = 10,
- -- choose lang for texts in mission
- ['choosenLang'] = "pl",
- ['translation'] = {
- ['pl'] = {
- ['chat_skill_max_level'] = "Posiadasz już maksymalny poziom tej umiejętności.",
- ['chat_dont_have_item'] = "Nie posiadasz odpowiedniej księgi, aby rozwinąć tę umiejętność.",
- ['chat_training_success'] = "Pomyślnie zakończyłeś trening!",
- ['chat_upgraded_to_master'] = "Rozwinąłeś umiejętność na poziom Mistrzowski.",
- ['chat_training_failed'] = "Trening zakończony niepowodzeniem. Spróbuj ponownie później.",
- ['chat_cant_read_by_time'] = "Nie możesz jeszcze czytać tej książki. Spróbuj ponownie za %d minut.",
- ['chat_opening_success'] = "Brawo! Udało Ci się otworzyć skrzynię!",
- ['chat_opening_failed'] = "Nie udało Ci się otworzyć tej skrzyni.",
- ['chat_cannot_open_box'] = "Nie możesz otworzyć tej skrzyni, odbierz pierwsze misje od poszukiwacza.",
- ['chat_inform_about_count_of_opened'] = "Do tej pory napotkałeś %d skrzyń.",
- },
- ['eng'] = {
- ['chat_skill_max_level'] = "You have maxium level of this skill.",
- ['chat_dont_have_item'] = "You don't have proper book to upgrade this skill.",
- ['chat_training_success'] = "You have successfully finished training!",
- ['chat_upgraded_to_master'] = "You have upgraded skill to the Master level.",
- ['chat_training_failed'] = "Training failed. Please try again later.",
- ['chat_cant_read_by_time'] = "You can't read this book now. Try again in %d minutes.",
- ['chat_opening_success'] = "Congratulations! You was able to open this box!",
- ['chat_opening_failed'] = "You didn't be able to open this box.",
- ['chat_cannot_open_box'] = "You can't open this box, go to Researcher and get mission before you do it again.",
- ['chat_inform_about_count_of_opened'] = "You already fount the %d boxes!",
- },
- },
- }
- end
- function getSkillLevel()
- return tonumber(pc.get_skill_level(lockpicking.settings()['skillVnum']))
- end
- function learnByBook()
- -- check if player have item(just for sure)
- if pc.count_item(lockpicking.settings()['skillBookVnum']) < 1 then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_dont_have_item'])
- return
- end
- -- check if player can read the book(time limit)
- if pc.getqf("nextRead") >= get_time() and not pc.is_skill_book_no_delay() then
- chat(string.format(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_cant_read_by_time'], math.floor((pc.getqf("nextRead") - get_time())/60) ))
- return
- end
- -- check if player have max level of skillVnum
- if lockpicking.getSkillLevel() >= lockpicking.settings()['maxLevel'] then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_skill_max_level'])
- return
- end
- local readChance
- if pc.is_skill_book_always_read() then
- readChance = 0
- else
- readChance = number(1, 100)
- end
- pc.remove_item(lockpicking.settings()['skillBookVnum'], 1)
- if pc.getqf("nextRead") >= get_time() then
- pc.remove_skill_book_no_delay()
- end
- pc.remove_skill_book_always_read()
- pc.setqf("nextRead", get_time() + ( (lockpicking.settings()['readDelay']) * 3600 ))
- if readChance <= lockpicking.settings()['bookReadChance'] then
- pc.set_skill_level(lockpicking.settings()['skillVnum'], lockpicking.getSkillLevel()+1)
- -- other info when player advances to the max level
- if lockpicking.getSkillLevel() == lockpicking.settings()['maxLevel'] then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_training_success'])
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_upgraded_to_master'])
- else
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_training_success'])
- end
- else
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_training_failed'])
- end
- end
- function getCount(level)
- if level >= 1 and level < 10 then
- return tonumber(lockpicking.settings()['defaultCount'])
- elseif level >= 10 and level < 20 then
- return tonumber(lockpicking.settings()['defaultCount'] + number(0, 2))
- elseif level >= 20 and level < 30 then
- return tonumber(lockpicking.settings()['defaultCount'] + number(1, 3))
- elseif level >= 30 and level < 40 then
- return tonumber(lockpicking.settings()['defaultCount'] + number(1, 4))
- elseif level >= lockpicking.settings()['maxLevel'] then
- return tonumber(lockpicking.settings()['defaultCount'] + number(2, 4))
- else
- return 0
- end
- end
- function getChance(level)
- if level == 1 then
- return tonumber(lockpicking.settings()['defaultChance'])
- elseif level > 1 then
- return tonumber(lockpicking.settings()['defaultChance'] + level)
- else
- return -1
- end
- end
- function get_reward_from_box()
- local reward_table = {
- {['vnum'] = 30096, ['count'] = 3, ['chance'] = 100}, -- one of these records must have value 100
- {['vnum'] = 71001, ['count'] = 1, ['chance'] = 20},
- {['vnum'] = 71094, ['count'] = 1, ['chance'] = 20},
- {['vnum'] = 71084, ['count'] = 15, ['chance'] = 70},
- {['vnum'] = 71085, ['count'] = 15, ['chance'] = 60},
- {['vnum'] = 71084, ['count'] = 20, ['chance'] = 50},
- {['vnum'] = 71085, ['count'] = 20, ['chance'] = 50},
- {['vnum'] = 71084, ['count'] = 10, ['chance'] = 90},
- {['vnum'] = 71085, ['count'] = 10, ['chance'] = 90},
- {['vnum'] = 71107, ['count'] = 1, ['chance'] = 45},
- {['vnum'] = 71153, ['count'] = 1, ['chance'] = 5},
- {['vnum'] = 71044, ['count'] = 3, ['chance'] = 45},
- {['vnum'] = 71045, ['count'] = 3, ['chance'] = 45},
- {['vnum'] = 71027, ['count'] = 2, ['chance'] = 35},
- {['vnum'] = 71028, ['count'] = 2, ['chance'] = 35},
- {['vnum'] = 71029, ['count'] = 2, ['chance'] = 50},
- {['vnum'] = 71030, ['count'] = 2, ['chance'] = 50},
- {['vnum'] = 71032, ['count'] = 1, ['chance'] = 35},
- {['vnum'] = 71034, ['count'] = 3, ['chance'] = 60},
- {['vnum'] = 71080, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 71081, ['count'] = 1, ['chance'] = 30},
- {['vnum'] = 71082, ['count'] = 1, ['chance'] = 20},
- {['vnum'] = 70004, ['count'] = 1, ['chance'] = 15},
- {['vnum'] = 30096, ['count'] = 5, ['chance'] = 75},
- {['vnum'] = 70102, ['count'] = 3, ['chance'] = 60},
- {['vnum'] = 25040, ['count'] = 1, ['chance'] = 45},
- {['vnum'] = 50002, ['count'] = 1, ['chance'] = 75},
- {['vnum'] = 50006, ['count'] = 1, ['chance'] = 60},
- {['vnum'] = 50007, ['count'] = 1, ['chance'] = 70},
- {['vnum'] = 50008, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 50009, ['count'] = 1, ['chance'] = 50},
- {['vnum'] = 50012, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 50013, ['count'] = 1, ['chance'] = 45},
- {['vnum'] = 50034, ['count'] = 3, ['chance'] = 60},
- {['vnum'] = 50216, ['count'] = 1, ['chance'] = 60},
- {['vnum'] = 71210, ['count'] = 2, ['chance'] = 90},
- {['vnum'] = 51503, ['count'] = 3, ['chance'] = 70},
- {['vnum'] = 51504, ['count'] = 1, ['chance'] = 50},
- {['vnum'] = 71016, ['count'] = 1, ['chance'] = 45},
- {['vnum'] = 71018, ['count'] = 5, ['chance'] = 60},
- {['vnum'] = 71019, ['count'] = 5, ['chance'] = 60},
- {['vnum'] = 71019, ['count'] = 5, ['chance'] = 60},
- {['vnum'] = 71020, ['count'] = 5, ['chance'] = 60},
- {['vnum'] = 50157, ['count'] = 1, ['chance'] = 45},
- {['vnum'] = 77004, ['count'] = 1, ['chance'] = 65},
- {['vnum'] = 77005, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 80022, ['count'] = 1, ['chance'] = 30},
- {['vnum'] = 80021, ['count'] = 1, ['chance'] = 25},
- {['vnum'] = 30500, ['count'] = 5, ['chance'] = 60},
- {['vnum'] = 30501, ['count'] = 4, ['chance'] = 60},
- {['vnum'] = 30502, ['count'] = 3, ['chance'] = 60},
- {['vnum'] = 30503, ['count'] = 2, ['chance'] = 60},
- {['vnum'] = 30504, ['count'] = 1, ['chance'] = 60},
- {['vnum'] = 80010, ['count'] = 1, ['chance'] = 100},
- {['vnum'] = 80011, ['count'] = 1, ['chance'] = 50},
- {['vnum'] = 80012, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 80013, ['count'] = 1, ['chance'] = 30},
- {['vnum'] = 80018, ['count'] = 1, ['chance'] = 20},
- {['vnum'] = 80017, ['count'] = 1, ['chance'] = 15},
- {['vnum'] = 80014, ['count'] = 1, ['chance'] = 15},
- {['vnum'] = 72725, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 72729, ['count'] = 1, ['chance'] = 40},
- {['vnum'] = 72726, ['count'] = 1, ['chance'] = 25},
- {['vnum'] = 72730, ['count'] = 1, ['chance'] = 25},
- {['vnum'] = 72703, ['count'] = 1, ['chance'] = 5},
- {['vnum'] = 72704, ['count'] = 1, ['chance'] = 5},
- {['vnum'] = 72705, ['count'] = 1, ['chance'] = 5},
- {['vnum'] = 72706, ['count'] = 1, ['chance'] = 5},
- {['vnum'] = 71050, ['count'] = 1, ['chance'] = 50},
- {['vnum'] = 50107, ['count'] = 5, ['chance'] = 50}
- }
- local itemChance = number(1, 100)
- local itemVnum = 0
- local itemCount = 0
- repeat
- local idx = number(1, table.getn(reward_table))
- if itemChance <= reward_table[idx]['chance'] then
- itemVnum = reward_table[idx]['vnum']
- itemCount = reward_table[idx]['count']
- end
- until (itemVnum != 0 and itemCount != 0)
- return {itemVnum, itemCount}
- end
- function openBox(byKey)
- local chance
- if byKey == true then
- chance = 100
- else
- chance = lockpicking.getChance(lockpicking.getSkillLevel())
- end
- if chance == -1 then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_cannot_open_box'])
- return
- end
- npc.purge() -- remove NPC from map
- if number(1, 100) <= chance then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_opening_success'])
- for i = 1, lockpicking.getCount(lockpicking.getSkillLevel()) do
- local rewardTable = lockpicking.get_reward_from_box()
- pc.give_item2(rewardTable[1], rewardTable[2])
- end
- else
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_opening_failed'])
- end
- end
- function increaseOpenedCount()
- if lockpicking.getSkillLevel() < 1 then
- return
- end
- local opened = pc.getqf("openedBoxes")
- pc.setqf("openedBoxes", opened + 1)
- chat(string.format(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_inform_about_count_of_opened'], opened+1))
- end
- when 51033.use begin
- lockpicking.learnByBook()
- end
- -- click on box npc
- when 20130.click begin
- lockpicking.increaseOpenedCount()
- lockpicking.openBox(false)
- end
- -- user Special Item to open Box
- when 20130.take with item.vnum == 51040 begin
- lockpicking.increaseOpenedCount()
- if lockpicking.getSkillLevel() < 1 then
- chat(lockpicking.settings()['translation'][lockpicking.settings()['choosenLang']]['chat_cannot_open_box'])
- return
- end
- -- set flag, that item was first used
- if item.get_socket(1) != 1 then
- item.set_socket(1, 1)
- item.set_socket(0, lockpicking.settings()['keyAllowUse']) -- set the count for using key
- end
- if item.get_socket(0) > 0 then
- item.set_socket(0, item.get_socket(0) - 1)
- if item.get_socket(0) == 0 then
- item.remove()
- end
- lockpicking.openBox(true)
- end
- end
- -- talk with quest NPC
- when 20131.chat."Kim jesteś?" begin
- say_title(mob_name(20131))
- say("")
- say("Witaj Poszukiwaczu Przygód!")
- say("Ja też jestem Poszukiwaczem! Szukam skarbów ")
- say("ukrytych w zakamarkach starych skrzyń.")
- say("")
- say("Po osiągnięciu 90 poziomu będę potrzebował ")
- say("Twojej pomocy. Na nowo odkrytych mapach ")
- say("widzieliśmy wiele starych, drogocennych skrzyń!")
- say("")
- end
- when 20131.chat."Spróchniałe Skrzynie" begin
- say_title(mob_name(20131))
- say("")
- say("Witaj Poszukiwaczu Przygód!")
- say("Chcesz dowiedzieć się coś o Spróchniałych Skrzyniach? ")
- say("Na nowo odkrytych mapach widzieliśmy dużo tych skrzyń.")
- say("Wyglądem przypominają szkatułki Władców, lecz skrywają ")
- say("cenniejsze nagrody.")
- say("")
- say("Po osiągnięciu 90 poziomu będę potrzebował ")
- say("Twojej pomocy. Na nowo odkrytych mapach ")
- say("widzieliśmy wiele starych, drogocennych skrzyń!")
- say("")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement