Jump to content

Recommended Posts

Have you tried google?

First link: you just need to add one more variable for each skill

----------------------------------
--  Regenbogenstein der nach dem lesen verschwindet
----------------------------------
quest regenbogen begin
    state start begin
            when 50512.use  begin
                
                say_title("Regenbogenstein")
                say("Beachte, dass der Regenbogenstein nach dem Lesen verschwindet.")
                say("Das Ausnutzen des Bugs ist verboten!")
                say("Du möchtest also deine Skills auf")
                say("Perfekter-Meister setzen?")
                
                if pc.job ==0 then
                say("Wähle deine Lehre aus")
                
                local s=select("Körper","Mental")
                
                if s==1 then
                --Körper
                pc.set_skill_group(1)
                pc.set_skill_level(1 ,59)
                pc.set_skill_level(2 ,59)
                pc.set_skill_level(3 ,59)
                pc.set_skill_level(4 ,59)
                pc.set_skill_level(5 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                if s==2 then
                --Mentalo
                pc.set_skill_group(2)
                pc.set_skill_level(16 ,59)
                pc.set_skill_level(17 ,59)
                pc.set_skill_level(18 ,59)
                pc.set_skill_level(19 ,59)
                pc.set_skill_level(20 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                elseif pc.job ==1 then
                say("Wähle deine Lehre aus")
                
                local s=select("Nahkampf","Bogen")
                
                if s==1 then
                --Nahkampf
                pc.set_skill_group(3)
                pc.set_skill_level(31 ,59)
                pc.set_skill_level(32 ,59)
                pc.set_skill_level(33 ,59)
                pc.set_skill_level(34 ,59)
                pc.set_skill_level(35 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                if s==2 then
                --Fernkampf
                pc.set_skill_group(4)
                pc.set_skill_level(46 ,59)
                pc.set_skill_level(47 ,59)
                pc.set_skill_level(48 ,59)
                pc.set_skill_level(49 ,59)
                pc.set_skill_level(50 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                elseif pc.job ==2 then
                say("Wähle deine Lehre aus")
                local s=select("Magie","Waffe")
                
                if s==1 then
                --Magie
                pc.set_skill_group(5)
                pc.set_skill_level(76 ,59)
                pc.set_skill_level(77 ,59)
                pc.set_skill_level(78 ,59)
                pc.set_skill_level(79 ,59)
                pc.set_skill_level(80 ,59)
                pc.set_skill_level(81, 59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                if s==2 then
                --Waffe
                pc.set_skill_group(6)
                pc.set_skill_level(61 ,59)
                pc.set_skill_level(62 ,59)
                pc.set_skill_level(63 ,59)
                pc.set_skill_level(64 ,59)
                pc.set_skill_level(65 ,59)
                pc.set_skill_level(66 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                elseif pc.job ==3 then
                say("Wähle deine Lehre aus")
                local s=select("Heil","Drachen")
                
                if s==1 then
                --Heil
                pc.set_skill_group(7)
                pc.set_skill_level(106 ,59)
                pc.set_skill_level(107 ,59)
                pc.set_skill_level(108 ,59)
                pc.set_skill_level(109 ,59)
                pc.set_skill_level(110 ,59)
                pc.set_skill_level(111 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
                item.remove (50512 ,1)
                
                if s==2 then
                --Drachen
                pc.set_skill_group(8)
                pc.set_skill_level(91 ,59)
                pc.set_skill_level(92 ,59)
                pc.set_skill_level(93 ,59)
                pc.set_skill_level(94 ,59)
                pc.set_skill_level(95 ,59)
                pc.set_skill_level(96 ,59)
                say("Deine Skills sind auf Perfekter Meister")
                end
        item.remove (50512 ,1)
            end
        end
    end
end

 

Edited by CantSt0p
Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-154968
Share on other sites

5 minutes ago, CantSt0p said:

Hai provato google?

Primo collegamento: devi solo aggiungere un'altra variabile per ogni abilità




                
                
                 
                
                
                
                 
                     
                 
                
                 
                     
                 
                
                 
                
                
                
                 
                     
                 
                
                 
                     
                 
                
                 
                
                
                 
                      
                 
                
                 
                      
                 
                
                 
                
                
                 
                      
                 
                
                 
                      
                 
            
        
    

 

I have already found this and more, I was hoping there would be a quest with skill level control.
And with the ability to choose one skill, not all of them

Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-154969
Share on other sites

  • Honorable Member
--[[
    Returns:
        An array containing 2 subarrays:
        - The first subarray, vnum_list, contains the vnums of the skills;
        - The second subarray, name_list, contains the names of the skills;

    Needs: https://metin2.dev/topic/29230-syreldars-useful-globals
]]
BuildSkillList = function(job, group, min_level, max_level)
    local vnum_list = {};
    local name_list = {};

    if (not job) then
        job = pc.get_job();
    end -- if

    if (not group or group == 0) then
        group = DOCTRINE_1;
    end -- if
    
    if (not min_level) then
        min_level = BASE_SKILL_LEVEL;
    end -- if
    
    if (not max_level) then
        max_level = PERFECT_MASTER_SKILL_LEVEL;
    end -- if

    local skill_level = 0;
    local skill_list = ACTIVE_SKILL_LIST[job][group];

    for _, skill_vnum in ipairs(skill_list) do
        skill_level = pc.get_skill_level(skill_vnum);
        if (skill_level >= min_level and skill_level <= max_level) then
            table.insert(vnum_list, skill_vnum);
            table.insert(name_list, SKILL_NAME_TABLE[skill_vnum]);
        end -- if
    end -- for

    return {vnum_list, name_list};
end -- function

 

Edited by Syreldar
  • Love 2

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-154970
Share on other sites

define SOUL_STONE 40004

quest update_skill_g2p begin
	state start begin
		when SOUL_STONE.use begin
			MIN_LVL_SKILL = 30
			MAX_LVL_SKILL = 40
			if pc.get_skill_group() != 0 then
				local skill_list = special.active_skill_list[pc.job+1][pc.get_skill_group()]
				local ret_vnum_list, ret_name_list = {}, {}

				table.foreach(skill_list,
				function(i, skill_vnum)
				local skill_level = pc.get_skill_level(skill_vnum)
				if skill_level >= MIN_LVL_SKILL and skill_level < MAX_LVL_SKILL then
					table.insert(ret_vnum_list, skill_vnum)
					local name = locale.GM_SKILL_NAME_DICT[skill_vnum]
					if name == nil then 
						name = skill_vnum 
					end
						table.insert(ret_name_list, name)
					end
				end)
				if table.getn(ret_name_list) != 0 then 
					table.insert(ret_name_list, "Close")
					say_title("Upgrade skill G to P")
					say()
					say("Disappear after use")
					local sel = select_table(ret_name_list)
					if sel != table.getn(ret_name_list) then
						pc.set_skill_level(ret_vnum_list[sel], MAX_LVL_SKILL)
						pc.remove_item(item.vnum)
					end
				end
			end
		end
	end
end

 

  • Metin2 Dev 1
Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-154975
Share on other sites

On 2/3/2023 at 7:33 PM, caanmasu said:
define SOUL_STONE 40004

quest update_skill_g2p begin
	state start begin
		when SOUL_STONE.use begin
			MIN_LVL_SKILL = 30
			MAX_LVL_SKILL = 40
			if pc.get_skill_group() != 0 then
				local skill_list = special.active_skill_list[pc.job+1][pc.get_skill_group()]
				local ret_vnum_list, ret_name_list = {}, {}

				table.foreach(skill_list,
				function(i, skill_vnum)
				local skill_level = pc.get_skill_level(skill_vnum)
				if skill_level >= MIN_LVL_SKILL and skill_level < MAX_LVL_SKILL then
					table.insert(ret_vnum_list, skill_vnum)
					local name = locale.GM_SKILL_NAME_DICT[skill_vnum]
					if name == nil then 
						name = skill_vnum 
					end
						table.insert(ret_name_list, name)
					end
				end)
				if table.getn(ret_name_list) != 0 then 
					table.insert(ret_name_list, "Close")
					say_title("Upgrade skill G to P")
					say()
					say("Disappear after use")
					local sel = select_table(ret_name_list)
					if sel != table.getn(ret_name_list) then
						pc.set_skill_level(ret_vnum_list[sel], MAX_LVL_SKILL)
						pc.remove_item(item.vnum)
					end
				end
			end
		end
	end
end

 

I thank you, that was what I was looking for.

 

Thanks to all for the help

Edited by Nuzzo
  • Good 1
Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-155005
Share on other sites

  • 1 year later...
On 2/3/2023 at 5:51 PM, Syreldar said:
--[[
    Returns:
        An array containing 2 subarrays:
        - The first subarray, vnum_list, contains the vnums of the skills;
        - The second subarray, name_list, contains the names of the skills;

    Needs: https://metin2.dev/topic/29230-syreldars-useful-globals
]]
BuildSkillList = function(job, group, min_level, max_level)
    local vnum_list = {};
    local name_list = {};

    if (not job) then
        job = pc.get_job();
    end -- if

    if (not group or group == 0) then
        group = DOCTRINE_1;
    end -- if
    
    if (not min_level) then
        min_level = BASE_SKILL_LEVEL;
    end -- if
    
    if (not max_level) then
        max_level = PERFECT_MASTER_SKILL_LEVEL;
    end -- if

    local skill_level = 0;
    local skill_list = ACTIVE_SKILL_LIST[job][group];

    for _, skill_vnum in ipairs(skill_list) do
        skill_level = pc.get_skill_level(skill_vnum);
        if (skill_level >= min_level and skill_level <= max_level) then
            table.insert(vnum_list, skill_vnum);
            table.insert(name_list, SKILL_NAME_TABLE[skill_vnum]);
        end -- if
    end -- for

    return {vnum_list, name_list};
end -- function

 

For anyone who was also looking for a quick and dirty solution:

I installed the quest functions mentioned by Syreldar, but there were a few problems for me: some quest functions had different names and also the skill_names table did not exist. I created a new quest function with the correct names (was not necessary, but made debugging easier for me. You can also rework the BuildSKillList function by Syrelda).

My rainbow stone check if a skill is in between a min and max skill level and then sets it to lvl 30 (grandmaster). Thanks a lot for the functions @ Syreldar!

So here is  my implementation with some insights on what to do:

rainbow_stone.quest

Spoiler
quest skill_upgrade begin
    state start begin
        when 50512.use begin
            -- Title and introductory messages
            say_title("Rainbow Stone")
            say("The stone will vanish after usage.")
            say("So you want to upgrade your master skills")
            say("to grandmaster?")
            wait()
            
            say_title("Skill selection")

            -- Retrieve job and group
            local job = pc.get_job()
            local group = pc.get_skill_group()

            -- Define the level range for skill selection
            local min_level = 20 -- skill M
            local max_level = 29 -- skill M10

            -- Call BuildSkillList3 to fetch skills within the specified range
            local skill_data = BuildSkillList3(job, group, min_level, max_level)
            local skill_vnums = skill_data[1] -- Skill Vnums
            local skill_names = skill_data[2] -- Skill Names

            -- Check if any skills are found
            if table.getn(skill_vnums) == 0 then
                say("There are no skills with the rank Master.")
                return
            end

            -- Append "Cancel" option at the end of skill_names
            table.insert(skill_names, "Cancel")

            -- Build options manually for select function
            local choice = select(skill_names[1], skill_names[2], skill_names[3], skill_names[4], skill_names[5], skill_names[6])

            -- Check if the user chose "Cancel" (which is the last option)
            if choice == table.getn(skill_names) then
                say("Skill upgrade canceled.")
                return
            end

            -- Get the selected skill VNUM
            local selected_vnum = skill_vnums[choice]
            local current_level = pc.get_skill_level(selected_vnum)

            -- Check if the skill can be upgraded
            if current_level >= min_level and current_level <= max_level then
                pc.set_skill_level(selected_vnum, 30)
                say("The skill " .. skill_names[choice] .. " was upgraded to Grandmaster.")
                say("If not visible: relog")
                item.remove(50512, 1)  -- Remove the item after usage
            else
                say("This skill can not be upgraded further.") -- not required, as this scenario will not happen
            end

            -- Final message
            say("Enjoy your new skill upgrade!")
        end
    end
end

 

add in questlib.lua

Spoiler
special.active_skill_list = {
    {
        { 1, 2, 3, 4, 5},
        { 16, 17, 18, 19, 20},
    },
    {
        {31, 32, 33, 34, 35},
        {46, 47, 48, 49, 50},
    },
    {
        {61, 62, 63, 64, 65, 66},
        {76, 77, 78, 79, 80, 81},
    },
    {
        {91, 92, 93, 94, 95, 96},
        {106, 107, 108, 109, 110, 111},
    },
}

special.skill_name_list = {
    [1] = "3-WegeSchnitt",
    [2] = "Schwertwirbel",
    [3] = "Kampfrausch",
    [4] = "AuraDesSchwertes",
    [5] = "Sausen",
    [16] = "Durchschlag",
    [17] = "HeftigesSchlagen",
    [18] = "Stampfer",
    [19] = "StarkerKörper",
    [20] = "Schwertschlag",
    [31] = "Hinterhalt",
    [32] = "Blitzangriff",
    [33] = "Degenwirbel",
    [34] = "Tarnung",
    [35] = "Giftwolke",
    [46] = "WiederholterSchuss",
    [47] = "Pfeilregen",
    [48] = "FeuerPfeil",
    [49] = "Federschreiten",
    [50] = "GiftPfeil",
    [61] = "Fingerschlag",
    [62] = "Drachenwirbel",
    [63] = "VerzauberteKlinge",
    [64] = "Furcht",
    [65] = "VerzauberteRüstung",
    [66] = "ZauberAufheben",
    [76] = "DunklerSchlag",
    [77] = "Flammenschlag",
    [78] = "GDF",
    [79] = "DunklerSchutz",
    [80] = "Geisterschlag",
    [81] = "DunklerStein",
    [91] = "FliegenderTalisman",
    [92] = "Drachenschießen",
    [93] = "Drachengebrüll",
    [94] = "Segen",
    [95] = "Reflektieren",
    [96] = "HilfedesDrachens",
    [106] = "Blitzwurf",
    [107] = "BlitzHeraufbeschwören",
    [108] = "Blitzkralle",
    [109] = "Kurieren",
    [110] = "Schnelligkeit",
    [111] = "Angriff+",
}

BuildSkillList3 = function(job, group, min_level, max_level)
    local vnum_list = {};
    local name_list = {};

    if (not job) then
        job = pc.get_job();
    end -- if

    if (not group or group == 0) then
        group = DOCTRINE_1;
    end -- if
    
    if (not min_level) then
        min_level = BASE_SKILL_LEVEL;
    end -- if
	
    if (not max_level) then
        max_level = PERFECT_MASTER_SKILL_LEVEL;
    end -- if
	
    local skill_level = 0;
    local skill_list = special.active_skill_list[job+1][group];
	-- Check if skill_list is valid
	
    for _, skill_vnum in ipairs(skill_list) do
        skill_level = pc.get_skill_level(skill_vnum);	
        if (skill_level >= min_level and skill_level <= max_level) then
            table.insert(vnum_list, skill_vnum);
            table.insert(name_list, special.skill_name_list[skill_vnum]);
        end -- if
    end -- for
	
    return {vnum_list, name_list};
end -- function

 

This solution is not smooth or idea, but works. Please check, if special.active_skill_list already exists.

Add the function in quest_functions

Spoiler

BuildSkillList3



Add the quest in locale_list.txt

Spoiler

rainbow_stone.quest

Edited by im4x8061
Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-168889
Share on other sites

  • Honorable Member
6 hours ago, im4x8061 said:

For anyone who was also looking for a quick and dirty solution:

I installed the quest functions mentioned by Syreldar, but there were a few problems for me: some quest functions had different names and also the skill_names table did not exist. I created a new quest function with the correct names (was not necessary, but made debugging easier for me. You can also rework the BuildSKillList function by Syrelda).

My rainbow stone check if a skill is in between a min and max skill level and then sets it to lvl 30 (grandmaster). Thanks a lot for the functions @ Syreldar!

So here is  my implementation with some insights on what to do:

rainbow_stone.quest

  Reveal hidden contents
quest skill_upgrade begin
    state start begin
        when 50512.use begin
            -- Title and introductory messages
            say_title("Rainbow Stone")
            say("The stone will vanish after usage.")
            say("So you want to upgrade your master skills")
            say("to grandmaster?")
            wait()
            
            say_title("Skill selection")

            -- Retrieve job and group
            local job = pc.get_job()
            local group = pc.get_skill_group()

            -- Define the level range for skill selection
            local min_level = 20 -- skill M
            local max_level = 29 -- skill M10

            -- Call BuildSkillList3 to fetch skills within the specified range
            local skill_data = BuildSkillList3(job, group, min_level, max_level)
            local skill_vnums = skill_data[1] -- Skill Vnums
            local skill_names = skill_data[2] -- Skill Names

            -- Check if any skills are found
            if table.getn(skill_vnums) == 0 then
                say("There are no skills with the rank Master.")
                return
            end

            -- Append "Cancel" option at the end of skill_names
            table.insert(skill_names, "Cancel")

            -- Build options manually for select function
            local choice = select(skill_names[1], skill_names[2], skill_names[3], skill_names[4], skill_names[5], skill_names[6])

            -- Check if the user chose "Cancel" (which is the last option)
            if choice == table.getn(skill_names) then
                say("Skill upgrade canceled.")
                return
            end

            -- Get the selected skill VNUM
            local selected_vnum = skill_vnums[choice]
            local current_level = pc.get_skill_level(selected_vnum)

            -- Check if the skill can be upgraded
            if current_level >= min_level and current_level <= max_level then
                pc.set_skill_level(selected_vnum, 30)
                say("The skill " .. skill_names[choice] .. " was upgraded to Grandmaster.")
                say("If not visible: relog")
                item.remove(50512, 1)  -- Remove the item after usage
            else
                say("This skill can not be upgraded further.") -- not required, as this scenario will not happen
            end

            -- Final message
            say("Enjoy your new skill upgrade!")
        end
    end
end

 

add in questlib.lua

  Reveal hidden contents
special.active_skill_list = {
    {
        { 1, 2, 3, 4, 5},
        { 16, 17, 18, 19, 20},
    },
    {
        {31, 32, 33, 34, 35},
        {46, 47, 48, 49, 50},
    },
    {
        {61, 62, 63, 64, 65, 66},
        {76, 77, 78, 79, 80, 81},
    },
    {
        {91, 92, 93, 94, 95, 96},
        {106, 107, 108, 109, 110, 111},
    },
}

special.skill_name_list = {
    [1] = "3-WegeSchnitt",
    [2] = "Schwertwirbel",
    [3] = "Kampfrausch",
    [4] = "AuraDesSchwertes",
    [5] = "Sausen",
    [16] = "Durchschlag",
    [17] = "HeftigesSchlagen",
    [18] = "Stampfer",
    [19] = "StarkerKörper",
    [20] = "Schwertschlag",
    [31] = "Hinterhalt",
    [32] = "Blitzangriff",
    [33] = "Degenwirbel",
    [34] = "Tarnung",
    [35] = "Giftwolke",
    [46] = "WiederholterSchuss",
    [47] = "Pfeilregen",
    [48] = "FeuerPfeil",
    [49] = "Federschreiten",
    [50] = "GiftPfeil",
    [61] = "Fingerschlag",
    [62] = "Drachenwirbel",
    [63] = "VerzauberteKlinge",
    [64] = "Furcht",
    [65] = "VerzauberteRüstung",
    [66] = "ZauberAufheben",
    [76] = "DunklerSchlag",
    [77] = "Flammenschlag",
    [78] = "GDF",
    [79] = "DunklerSchutz",
    [80] = "Geisterschlag",
    [81] = "DunklerStein",
    [91] = "FliegenderTalisman",
    [92] = "Drachenschießen",
    [93] = "Drachengebrüll",
    [94] = "Segen",
    [95] = "Reflektieren",
    [96] = "HilfedesDrachens",
    [106] = "Blitzwurf",
    [107] = "BlitzHeraufbeschwören",
    [108] = "Blitzkralle",
    [109] = "Kurieren",
    [110] = "Schnelligkeit",
    [111] = "Angriff+",
}

BuildSkillList3 = function(job, group, min_level, max_level)
    local vnum_list = {};
    local name_list = {};

    if (not job) then
        job = pc.get_job();
    end -- if

    if (not group or group == 0) then
        group = DOCTRINE_1;
    end -- if
    
    if (not min_level) then
        min_level = BASE_SKILL_LEVEL;
    end -- if
	
    if (not max_level) then
        max_level = PERFECT_MASTER_SKILL_LEVEL;
    end -- if
	
    local skill_level = 0;
    local skill_list = special.active_skill_list[job+1][group];
	-- Check if skill_list is valid
	
    for _, skill_vnum in ipairs(skill_list) do
        skill_level = pc.get_skill_level(skill_vnum);	
        if (skill_level >= min_level and skill_level <= max_level) then
            table.insert(vnum_list, skill_vnum);
            table.insert(name_list, special.skill_name_list[skill_vnum]);
        end -- if
    end -- for
	
    return {vnum_list, name_list};
end -- function

 

This solution is not smooth or idea, but works. Please check, if special.active_skill_list already exists.

Add the function in quest_functions

  Reveal hidden contents

BuildSkillList3



Add the quest in locale_list.txt

  Reveal hidden contents

rainbow_stone.quest

Please, next time at least take the time to read.

I explicitly wrote in the function's definition that it needs the globals from my other topic, I even linked it.

And, if you are using it, then I sincerely hope you did not just blindly copy that one func I wrote in here one year ago instead of using the whole functions file I linked (hence using the func's latest updated version).

..cause that's the only possible explanation as of why you could've had any issues in making it work. I changed globals' definitions several times in the span of one year in order to improve the file's structure.

So that was.. pretty useless. Whatever you were trying to do there.

Edited by Syreldar

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-168890
Share on other sites

3 hours ago, Syreldar said:

Please, next time at least take the time to read.

I explicitly wrote in the function's definition that it needs the globals from my other topic, I even linked it.

And, if you are using it, then I sincerely hope you did not just blindly copy that one func I wrote in here one year ago instead of using the whole functions file I linked (hence using the func's latest updated version).

..cause that's the only possible explanation as of why you could've had any issues in making it work. I changed globals' definitions several times in the span of one year in order to improve the file's structure.

So that was.. pretty useless. Whatever you were trying to do there.

Hmm.. I read that and thereforeI copied all the stuff from your other topic. It took me quite some time to find out, that stuff was missing. I searched the topic and did not find anything.

I guess, that this one is still my fault, but if I messed it up, maybe someone else did too. So what ever you say: it was not useless, thanks.

Edited by im4x8061
Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-168893
Share on other sites

  • 4 weeks later...
On 1/2/2025 at 2:07 AM, im4x8061 said:

For anyone who was also looking for a quick and dirty solution:

I installed the quest functions mentioned by Syreldar, but there were a few problems for me: some quest functions had different names and also the skill_names table did not exist. I created a new quest function with the correct names (was not necessary, but made debugging easier for me. You can also rework the BuildSKillList function by Syrelda).

My rainbow stone check if a skill is in between a min and max skill level and then sets it to lvl 30 (grandmaster). Thanks a lot for the functions @ Syreldar!

So here is  my implementation with some insights on what to do:

rainbow_stone.quest

  Hide contents
quest skill_upgrade begin
    state start begin
        when 50512.use begin
            -- Title and introductory messages
            say_title("Rainbow Stone")
            say("The stone will vanish after usage.")
            say("So you want to upgrade your master skills")
            say("to grandmaster?")
            wait()
            
            say_title("Skill selection")

            -- Retrieve job and group
            local job = pc.get_job()
            local group = pc.get_skill_group()

            -- Define the level range for skill selection
            local min_level = 20 -- skill M
            local max_level = 29 -- skill M10

            -- Call BuildSkillList3 to fetch skills within the specified range
            local skill_data = BuildSkillList3(job, group, min_level, max_level)
            local skill_vnums = skill_data[1] -- Skill Vnums
            local skill_names = skill_data[2] -- Skill Names

            -- Check if any skills are found
            if table.getn(skill_vnums) == 0 then
                say("There are no skills with the rank Master.")
                return
            end

            -- Append "Cancel" option at the end of skill_names
            table.insert(skill_names, "Cancel")

            -- Build options manually for select function
            local choice = select(skill_names[1], skill_names[2], skill_names[3], skill_names[4], skill_names[5], skill_names[6])

            -- Check if the user chose "Cancel" (which is the last option)
            if choice == table.getn(skill_names) then
                say("Skill upgrade canceled.")
                return
            end

            -- Get the selected skill VNUM
            local selected_vnum = skill_vnums[choice]
            local current_level = pc.get_skill_level(selected_vnum)

            -- Check if the skill can be upgraded
            if current_level >= min_level and current_level <= max_level then
                pc.set_skill_level(selected_vnum, 30)
                say("The skill " .. skill_names[choice] .. " was upgraded to Grandmaster.")
                say("If not visible: relog")
                item.remove(50512, 1)  -- Remove the item after usage
            else
                say("This skill can not be upgraded further.") -- not required, as this scenario will not happen
            end

            -- Final message
            say("Enjoy your new skill upgrade!")
        end
    end
end

 

add in questlib.lua

  Hide contents
special.active_skill_list = {
    {
        { 1, 2, 3, 4, 5},
        { 16, 17, 18, 19, 20},
    },
    {
        {31, 32, 33, 34, 35},
        {46, 47, 48, 49, 50},
    },
    {
        {61, 62, 63, 64, 65, 66},
        {76, 77, 78, 79, 80, 81},
    },
    {
        {91, 92, 93, 94, 95, 96},
        {106, 107, 108, 109, 110, 111},
    },
}

special.skill_name_list = {
    [1] = "3-WegeSchnitt",
    [2] = "Schwertwirbel",
    [3] = "Kampfrausch",
    [4] = "AuraDesSchwertes",
    [5] = "Sausen",
    [16] = "Durchschlag",
    [17] = "HeftigesSchlagen",
    [18] = "Stampfer",
    [19] = "StarkerKörper",
    [20] = "Schwertschlag",
    [31] = "Hinterhalt",
    [32] = "Blitzangriff",
    [33] = "Degenwirbel",
    [34] = "Tarnung",
    [35] = "Giftwolke",
    [46] = "WiederholterSchuss",
    [47] = "Pfeilregen",
    [48] = "FeuerPfeil",
    [49] = "Federschreiten",
    [50] = "GiftPfeil",
    [61] = "Fingerschlag",
    [62] = "Drachenwirbel",
    [63] = "VerzauberteKlinge",
    [64] = "Furcht",
    [65] = "VerzauberteRüstung",
    [66] = "ZauberAufheben",
    [76] = "DunklerSchlag",
    [77] = "Flammenschlag",
    [78] = "GDF",
    [79] = "DunklerSchutz",
    [80] = "Geisterschlag",
    [81] = "DunklerStein",
    [91] = "FliegenderTalisman",
    [92] = "Drachenschießen",
    [93] = "Drachengebrüll",
    [94] = "Segen",
    [95] = "Reflektieren",
    [96] = "HilfedesDrachens",
    [106] = "Blitzwurf",
    [107] = "BlitzHeraufbeschwören",
    [108] = "Blitzkralle",
    [109] = "Kurieren",
    [110] = "Schnelligkeit",
    [111] = "Angriff+",
}

BuildSkillList3 = function(job, group, min_level, max_level)
    local vnum_list = {};
    local name_list = {};

    if (not job) then
        job = pc.get_job();
    end -- if

    if (not group or group == 0) then
        group = DOCTRINE_1;
    end -- if
    
    if (not min_level) then
        min_level = BASE_SKILL_LEVEL;
    end -- if
	
    if (not max_level) then
        max_level = PERFECT_MASTER_SKILL_LEVEL;
    end -- if
	
    local skill_level = 0;
    local skill_list = special.active_skill_list[job+1][group];
	-- Check if skill_list is valid
	
    for _, skill_vnum in ipairs(skill_list) do
        skill_level = pc.get_skill_level(skill_vnum);	
        if (skill_level >= min_level and skill_level <= max_level) then
            table.insert(vnum_list, skill_vnum);
            table.insert(name_list, special.skill_name_list[skill_vnum]);
        end -- if
    end -- for
	
    return {vnum_list, name_list};
end -- function

 

This solution is not smooth or idea, but works. Please check, if special.active_skill_list already exists.

Add the function in quest_functions

  Hide contents

BuildSkillList3



Add the quest in locale_list.txt

  Hide contents

rainbow_stone.quest

i would suggest putting the code in the (questlib.lua step) in like rainbow.lua and use Dofile in questlib.lua .. easier , Faster and cleaner

Link to comment
https://metin2.dev/topic/30307-rainbow-stone/#findComment-169231
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.