Here is a second release of mine.
This will create a choice for the player in a RPG-style which allow him to choose between 3 talent-trees.
Depending on the choosed tree, the player will receive some bonus. Also, every levelup getting bonus.
Enjoy
Code:
quest specialization_intro begin state start begin -- Upon player login when login begin -- Check if the player has already received the letter if pc.getqf("specialization_intro_done") == 0 then -- Send the letter to the player send_letter("Specialization - Talk to the Guardian") end end end end quest specialization_bonus begin state start begin -- Interaction with the NPC to choose specialization when 11000.chat."Choose Specialization" or 11002.chat."Choose Specialization" or 11004.chat."Choose Specialization" begin if pc.getqf("specialization_chosen") == 0 then local job = pc.get_job() local specialization_choices = { [0] = { -- Warrior {"Barbarian", "A brutal warrior with great physical strength. Bonus: Vitality and Strength."}, {"Guardian", "A solid warrior protecting others. Bonus: Vitality and Defense."}, {"Balance", "A warrior who maintains a good balance between strength and defense."} }, [1] = { -- Ninja {"Assassin", "An expert in quick and stealthy attacks. Bonus: Dexterity and Strength."}, {"Shadow Master", "An agile ninja with great precision. Bonus: Dexterity and Precision."}, {"Balance", "A ninja who maintains a good balance between agility and strength."} }, [3] = { -- Shaman {"Earth Shaman", "A shaman who uses earth magic to strengthen vitality. Bonus: Intelligence and Vitality."}, {"Water Shaman", "A shaman who uses water magic to increase mana. Bonus: Intelligence and Mana."}, {"Balance", "A shaman who maintains a good balance between magic and vitality."} }, [2] = { -- Sura {"War Sura", "A powerful sura specialized in physical attacks. Bonus: Strength and Magic."}, {"Magic Sura", "A sura who uses powerful spells to deal damage. Bonus: Strength and Magic."}, {"Balance", "A sura who maintains a good balance between strength and magic."} } } while true do if specialization_choices[job] then local choices = specialization_choices[job] local choice = select(choices[1][1], choices[2][1], choices[3][1], "Return") if choice == 4 then -- If "Return" is chosen, cancel the process say("Choice canceled.") return elseif choice then local selected_choice = choices[choice] local description = selected_choice[2] -- Display the description and ask for confirmation say("You have chosen: " .. selected_choice[1] .. ".") say(description) local confirm = select("Confirm", "Return") if confirm == 1 then -- Save the choice and exit the loop pc.setqf("temp_specialization_choice", choice) pc.setqf("temp_specialization_description", description) break else -- Return to the initial selection say("Returning to the initial choice.") end else say("Choice canceled.") return end else say("You cannot choose a specialization.") return end end -- Confirm the specialization choice if pc.getqf("temp_specialization_choice") then local choice = pc.getqf("temp_specialization_choice") local description = pc.getqf("temp_specialization_description") -- Save the chosen specialization local job = pc.get_job() local specialization_choices = { [0] = { -- Warrior "Barbarian", "Guardian", "Balance" }, [1] = { -- Ninja "Assassin", "Shadow Master", "Balance" }, [3] = { -- Shaman "Earth Shaman", "Water Shaman", "Balance" }, [2] = { -- Sura "War Sura", "Magic Sura", "Balance" } } local selected_specialization = specialization_choices[job][choice] -- Save and confirm the choice pc.setqf("specialization_chosen", 1) pc.setqf("specialization", choice) pc.setqf("specialization_name", selected_specialization) say("You have confirmed your specialization choice: " .. selected_specialization .. ".") say(description) -- Save the chosen specialization to apply the bonuses pc.setqf("specialization_intro_done", 1) pc.setqf("temp_specialization_choice", nil) pc.setqf("temp_specialization_description", nil) end else say("You have already chosen a specialization.") end end end state apply_bonus begin -- Apply bonuses when leveling up when levelup begin if pc.getqf("specialization_chosen") == 1 then local job = pc.get_job() local spec = pc.getqf("specialization") local specialization_bonus = { [0] = { -- Warrior [1] = {ht = 2, st = 2}, -- Barbarian [2] = {ht = 3, st = 1}, -- Guardian [3] = {ht = 1, st = 1, dx = 1} -- Balance }, [1] = { -- Ninja [1] = {dx = 3, st = 1}, -- Assassin [2] = {dx = 2, st = 2}, -- Shadow Master [3] = {dx = 2, st = 1, iq = 1} -- Balance }, [3] = { -- Shaman [1] = {iq = 3, ht = 1}, -- Earth Shaman [2] = {iq = 2, ht = 2}, -- Water Shaman [3] = {iq = 2, ht = 1, dx = 1} -- Balance }, [2] = { -- Sura [1] = {st = 2, iq = 1}, -- War Sura [2] = {st = 1, iq = 2}, -- Magic Sura [3] = {st = 2, iq = 1, dx = 1} -- Balance } } if specialization_bonus[job] and specialization_bonus[job][spec] then -- Apply the bonuses local bonuses = specialization_bonus[job][spec] for stat, value in pairs(bonuses) do if stat == "ht" then pc.set_ht(pc.get_ht() + value) elseif stat == "iq" then pc.set_iq(pc.get_iq() + value) elseif stat == "st" then pc.set_st(pc.get_st() + value) elseif stat == "dx" then pc.set_dx(pc.get_dx() + value) end end end end end end end