Jump to content

Repeatable Hunting Quest


KuninoSagiri

Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

This quest requires you to hunt a certain enemy near your level for a certain amount of time, bring the "Animal Heart" item they obtain from killing them back to Yang-Shin once they have a sufficient amount and then allows them to play a gamble for Potion Herbs. The quest levels up and depending on level you can gamble for more rewards, or complete the quest in a shorter period of time.

quest rep_herb_farming begin
	state start begin
		when login with pc.get_level() > 29 and pc.getqf("herb_farming_points") < 1 begin
			send_letter("REP - The cold-blooded Dinner")
		end
		
		when button or info begin
			say_title("Repeatable Quest: The cold-blooded Dinner")
			say("")
			say("Yang-Shin is in trouble, he could need your")
			say("help! - Pay him a visit and maybe he will")
			say("reward you for your troubles!")
			say("")
		end
		
		when 20019.chat."The cold-blooded Dinner" begin
			if pc.getqf("herb_farming_points") < 1 then
				pc.setqf("herblevel",1)
			end
			if pc.get_level() < 30 then
				say_title(mob_name(20019))
				say("")
				say("You are not experienced enough to help me.")
				say("Thanks for your courage but you can not do")
				say("anything for me.")
				say("")
				say_reward("You need to be at least Level 30 or above.")
				say("")
			else
				say_title(mob_name(20019))
				say("")
				say("Please choose an option:")
				say("")
				local t = select("Information about Rep-Quest", "Start Rep-Quest", "Display Quest-Level", "Information about Quest-Levels")
				if opt == 1 then
					say_title(mob_name(20019))
					say("")
					say("Hello, I need your help.")
					say("Our family is well known for our hunting skills.")
					say("However, a severe desease has rendered most of us")
					say("incapable of going on a hunt - it is too risky.")
					say("Would you mind tracking down some enemies for us?")
					say("Bring us their hearts so can hopefully regain")
					say("our health soon. I will reward you with the")
					say("herbs some of our family members started to")
					say("gather as a replacement.")
					say("")
					say_reward("Do you want to help him?")
					say_reward("Activate the quest in the quest menu!")
					say("")
				elseif opt == 2 then
					if get_time() < pc.getqf("timelimit") then
						say_title("Rep-Quest: The cold-blooded Dinner")
						say("")
						say("You can only accomplish this quest")
						say("once in every "..ts_herbtime[pc.getqf("end_state")][pc.getqf("herblevel")].." hours.")
						say("")
						say("Time left: "..pc.getqf("timelimit")-get_time().." seconds.")
						say("")
					else
						local grade = math.floor(pc.get_level()/10)
						local plv = grade-2
						local num_min = 1+(plv-1)*5
						local num_max = 5+(plv-1)*5
						local num = number(num_min,num_max)
						pc.setqf("target_vnum",herb_q_init_v(num))
						pc.setqf("target_amount",herb_q_init_a(pc.getqf("herblevel"),num))
						pc.remove_item(70022,pc.count_item(70022))
						set_state(hunt)
					end
				elseif opt == 3 then
					say_title("Quest-Level:")
					say("")
					say("Your current quest level: "..rep_q_level[pc.getqf("herblevel")]..".")
					say("")
					say("Your current quest points: "..pc.getqf("herb_farming_points").." Points.")
					say("")
				elseif opt == 4 then
					say_title("The Quest Level")
					say("")
					say("In permanent quests you can gain new levels")
					say("by doing these quests more often.")
					say("Every quest yields points and you need")
					say("a certain amount of points to increase")
					say("the level for this quest.")
					say("The higher the quest level, the better")
					say("the reward you get each time you do it.")
					say("")
					say_white("N Level: 0-499 Points")
					say_white("M Level: 500-2499 Points")
					say_white("G Level: 2500-9999 Points")
					say_white("P Level: 10000+ Points")
					say("")
				end
			end
		end
	end
	
	state hunt begin
		when letter begin
			send_letter("Rep-Quest: The cold-blooded Dinner")
		end
		
		when button or info begin
			say_title("Rep-Quest: The cold-blooded Dinner")
			say("")
			say("Thank you so much. May the hunting god")
			say("bless you on your journey.")
			say("")
			say("You can find animal hearts by killing some")
			say(""..mob_name(pc.getqf("target_vnum"))..".")
			say("")
			say_item_vnum(70022)
			say("")
			say_reward("You require "..pc.getqf("target_amount").." animal hearts.")
			say("")
		end
		
		when 20019.chat."Abort the Rep-Quest" begin
			say_title("Yang-Shin:")
			say("")
			say("What, you say you can not do it?")
			say("")
			say_reward("Be aware! If you abort the quest you will")
			say_reward("have to wait 6 hours to try again!")
			say("")
			local abort = select("I will keep on it.", "No, I can't do it.")
			if abort == 2 then
				pc.setqf("end_state",3)
				pc.setqf("timelimit",ts_herbtime[pc.getqf("end_state")][pc.getqf("herblevel")]*60*60+get_time())
				set_state(start)
			end
		end
		
		when kill begin
			if npc.get_race() == pc.getqf("target_vnum") then
				pc.give_item2(70022,1)
				if pc.count_item(70022) == pc.getqf("target_amount") then
					set_state(reward)
				end
			end
		end
	end
	
	state reward begin
		when letter begin
			send_letter("You have all Animal Hearts")
		end
		
		when button or info begin
			say_title("Rep-Quest: The cold-blooded Dinner")
			say("")
			say("You've collected all Animal Hearts!")
			say("You should go back to the Yang-Shin")
			say("and claim your reward!")
			say("")
		end
		
		when 20019.chat."I found all Animal Hearts" begin
			local i = 1
			local q = pc.getqf("herblevel")
			local chance = 80
			local offer
			say_title(mob_name(20019))
			say("")
			say("Wow! That was extraordinary work!")
			say("Thank you for these hearts.")
			say("")
			say("Now to your reward...")
			say("")
			wait()
			say_title("System:")
			say("")
			say("Please choose a herb by typing the alocated number:")
			say("")
			say("1 = Peach Bloom")
			say("2 = Thristle")
			say("3 = Plumbago")
			say("4 = Grinderlia")
			say("5 = Jamul")
			say("6 = Ganoderma")
			say("7 = Lippia")
			say("8 = Sundew")
			say("")
			local herbnum = tonumber(input())
			if tonumber(herbnum) == nil or herbnum == 0 or herbnum > 8  then
				say_title("System:")
				say("")
				say("Please enter a valid number.")
				say("")
				return
			end
			if herbnum > 0 and herbnum < 9 then
				pc.remove_item(70022,pc.count_item(70022))
				while true do
					if i < 8 then
						if q < 4 then
							offer = 10*q+5*(q-1)+5*(i-1)
						else
							offer = 10*q+10*(i-1)
						end
						say_title("Yang-Shin:")
						say("")
						say("Alright, I offer you "..offer.." "..item_name(50720+herbnum)..".")
						say("Do you accept?")
						local answer = select("Yes!","No, I want more!")
						if answer == 1 then
							say_title(mob_name(20019))
							say("")
							say("Alright, here's your reward!")
							say("")
							say_reward("You've received "..offer.." "..item_name(50720+herbnum)..".")
							pc.give_item2(50720+herbnum,offer)
							pc.setqf("end_state",1)
							pc.setqf("timelimit",ts_herbtime[pc.getqf("end_state")][q]*60*60+get_time())
							pc.setqf("herb_farming_points",pc.getqf("herb_farming_points")+offer)
							local a = pc.getqf("herb_farming_points")
							if a >= 500 and a <= 2499 and pc.getqf("herblevel") < 2 or pc.getqf("herblevel") > 2 then
								pc.setqf("herblevel",2)
								syschat("You've ranked up your questlevel to level 2!")
							end
							if a >= 2500 and a <= 9999 and pc.getqf("herblevel") < 3 or pc.getqf("herblevel") > 3 then
								pc.setqf("herblevel",3)
								syschat("You've ranked up your questlevel to level 3!")
							end
							if a >= 10000 and pc.getqf("herblevel") < 4 then
								pc.setqf("herblevel",4)
								syschat("You've ranked up your questlevel to level 4!")
							end
							set_state(start)
							break
						elseif answer == 2 then
							local dice = number(1,100)
							if dice <= chance then
								chance = chance-20
								if i == 1 or i == 2 then
									i = i+1
								elseif i == 3 then
									i = i+2
								elseif i == 5 then
									i = i+3
								end
							else
								say_title(mob_name(20019))
								say("")
								say("So you want to be greedy?")
								say("")
								say("Then go! As a lession I wont give")
								say("you anything!")
								say("")
								say_reward("You gained no herbs for this quest.")
								say("")
								pc.setqf("end_state",2)
								pc.setqf("timelimit",ts_herbtime[pc.getqf("end_state")][pc.getqf("herblevel")]*60*60+get_time())
								set_state(start)
								break
							end
						end
					else
						say_title(mob_name(20019))
						say("")
						say("Alright, here's your reward!")
						say("That's all I got so here, take it!")
						say("")
						say_reward("You've received "..offer.." "..item_name(50720+herbnum)..".")
						pc.give_item2(50720+herbnum,offer)
						pc.setqf("end_state",1)
						pc.setqf("timelimit",ts_herbtime[pc.getqf("end_state")][pc.getqf("herblevel")]*60*60+get_time())
						pc.setqf("herb_farming_points",pc.getqf("herb_farming_points")+offer)
						local a = pc.getqf("herb_farming_points")
						if a >= 500 and a <= 2499 and pc.getqf("herblevel") < 2 or pc.getqf("herblevel") > 2 then
							pc.setqf("herblevel",2)
							syschat("You've ranked up your questlevel to level 2!")
						end
						if a >= 2500 and a <= 9999 and pc.getqf("herblevel") < 3 or pc.getqf("herblevel") > 3 then
							pc.setqf("herblevel",3)
							syschat("You've ranked up your questlevel to level 3!")
						end
						if a >= 10000 and pc.getqf("herblevel") < 4 then
							pc.setqf("herblevel",4)
							syschat("You've ranked up your questlevel to level 4!")
						end
						notice_all(""..pc.get_name().." is a brilliant merchant and traded his animal hearts for "..offer.." "..say_item_vnum(50720+herbnum)..".")
						set_state(start)
						break
					end
				end
			end
		end
	end
end

And this needs to be added to the questlib.lua to make it work.

rep_q_level = {"Normal", "Master", "Grandmaster", "Perfect Master"}

ts_herbtime = {
    {24,20,16,12},
    {12,10,8,6},
    {6,6,6,6},
}

function herb_q_inf()
    return
    {    --         | Level 30-40 List | Level 40-50 List   | Level 50-60 List       | Level 60-70 List       | Level 70-80 List       | Level 80-90 List       | Level 90-99 List       |
        ["vnum"] = {534,591,636,702,704,732,776,906,902,1001,1031,1101,1103,1301,2034,1106,1107,2064,2203,2204,2203,2204,2303,2304,2305,1131,1136,2314,2315,2401,2412,2403,2404,2411,2413},
        ["Normal"] = {3,2,10,15,10,15,15,10,20,30,10,15,10,10,10,15,10,20,20,20,30,30,20,15,10,15,20,40,25,20,20,15,10,20,10},
        ["Master"] = {5,3,15,20,15,25,20,15,30,50,15,25,15,15,15,25,20,30,30,30,50,50,30,20,15,25,30,60,40,35,40,30,20,40,20},
        ["Grandmaster"] = {8,5,20,30,20,35,30,20,40,70,20,35,20,20,20,40,30,40,40,40,70,70,40,35,30,35,40,80,60,50,60,50,30,60,30},
        ["Perfect_Master"] = {12,8,30,45,30,50,45,30,60,100,30,50,30,35,40,60,50,60,60,60,100,100,60,50,45,50,55,125,90,75,80,75,50,80,45},
    }
end

function herb_q_init_v(num)
    local info = herb_q_inf()
    local vnum = info.vnum[num]
    return vnum
end

function herb_q_init_a(qlv,num)
    local info = herb_q_inf()
    local qlv = pc.getqf("herblevel")
    local amount

    if qlv == 1 then
        amount = info.Normal[num]
    elseif qlv == 2 then
        amount = info.Master[num]
    elseif qlv == 3 then
        amount = info.Grandmaster[num]
    elseif qlv == 4 then
        amount = info.Perfect_Master[num]
    end

    return amount
end

I wrote this quest a long time ago when I just started LUA so please bear with my lack of LUA skills back then so the code might be somewhat unoptimized.

  • Metin2 Dev 3
  • Think 1
  • Love 6
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Leveling up the quest:

 

- Allows you to repeat the quest in shorter intervals

- Requires more monsters per quest

- Wields greater rewards

 

The user gets a mail once that informs him that the quest is available at Yang-Shin, then he can complete and repeat it at his leisure - using the "Start Rep-Quest" command on the Yang-Shin NPC

Link to comment
Share on other sites

Announcements



×
×
  • 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.