Jump to content

Recommended Posts

Hi, I would need a quest that start when you kill mobs, and based on your level, drop different item.

But i don't know if something like this may cause too much lag and should be better doing it ina  different way

This is an example of what i would need to do:

quest test_drop begin
	state start begin
		when kill with not npc.is_pc() begin
			-- not sure how to do this part, if mob is 10 level > or < than pc_leven then return
				return
				
			else
				local drop math.random(1, 10000)
				local items1 = {101, 102, 103, 104, 105, 106} 
				local items2 = {201, 202, 203, 204, 205, 206} 
				local items3 = {301, 302, 303, 304, 305, 306} 
				local items4 = {401, 402, 43, 404, 405, 406} 
				local items5 = {501, 502, 503, 504, 505, 506} 
				if drop <= 100 then
					if pc.get_level() > 19 and pc.get_level() < 40 then
						game.drop_item_with_ownership(items1[number(1, table.getn(items1))])
					elseif pc.get_level() > 39 and pc.get_level() < 60 then
						game.drop_item_with_ownership(items2[number(1, table.getn(items2))])
					elseif pc.get_level() > 59 and pc.get_level() < 80 then
						game.drop_item_with_ownership(items3[number(1, table.getn(items3))])
					elseif pc.get_level() > 79 and pc.get_level() < 99 then
						game.drop_item_with_ownership(items4[number(1, table.getn(items4))])
					elseif pc.get_level() > 99 then
						game.drop_item_with_ownership(items5[number(1, table.getn(items5))])
				else
					return
				end
			end
		end
	end
end

 

Link to comment
https://metin2.dev/topic/22112-help-drop-item-from-quest-bad-idea/
Share on other sites

  • Forum Moderator

I don't like so much Lua, but i did something fast, i hope that's what you wanted.
Replace npc.get_level() with npc.get_level0() if you use marty source.

quest common_drop_quest begin
	state start begin

		function CanDrop(pc_level, npc_level, isPC)
			local DIFF_LEVEL_CONST = 10
			return not isPC and math.abs(pc_level - npc_level) <= DIFF_LEVEL_CONST
		end

		function GetSettings()
			local PLAYER_MAX_LEVEL_CONST = 105
			return
			{
				{ 20, 40, {27001, 27001, 27001, 27001, 27001, 27001} }, -- from 20 to 39
				{ 40, 60, {27002, 27002, 27002, 27002, 27002, 27002} }, -- from 40 to 59
				{ 60, 80, {27003, 27003, 27003, 27003, 27003, 27003} }, -- from 60 to 79
				{ 80, 100, {27004, 27004, 27004, 27004, 27004, 27004} }, -- from 80 to 99
				{ 100, PLAYER_MAX_LEVEL_CONST + 1, {27005, 27005, 27005, 27005, 27005, 27005} }, -- from 100 to PLAYER_MAX_LEVEL_CONST
			}
		end

		when kill with common_drop_quest.CanDrop(pc.get_level(), npc.get_level(), npc.is_pc()) begin
			local common_drop_table = common_drop_quest.GetSettings()

			for i = 1, table.getn(common_drop_table) do
				local dropLevelMin, dropLevelMax, dropItemTable = unpack(common_drop_table[i])
				local dropItemVnum = dropItemTable[number(1, table.getn(dropItemTable))]

				if pc.get_level() >= dropLevelMin and pc.get_level() < dropLevelMax then
					if number(1, 10000) <= 100 then
						game.drop_item_with_ownership(dropItemVnum)
						break
					end
				end
			end
		end
	end
end

 

  • Love 5
  • 2 years later...
  • Honorable Member

Making a mob_drop_item in lua is not only possible, but also very convenient and way more manageable than the .txt counterpart: you can basically do whatever you want with it, like apply drop eventflags to increase/decrease drops at will.

 

The only downside is that systems such as the info_drop will stop working, since they work by string parsing the .txt.

 

"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

I have this problem with "normal" common_drop_item

SYSERR: May 31 01:05:27 :: CreateDropItem: CreateDropItem 30 ~ 60 50333(2400)

SYSERR: May 31 01:05:27 :: CreateDropItem: CreateDropItem 30 ~ 60 50334(2400)

SYSERR: May 31 01:05:27 :: CreateDropItem: CreateDropItem 30 ~ 60 50335(2400)

SYSERR: May 31 01:05:27 :: CreateDropItem: CreateDropItem 30 ~ 60 50336(2400)

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.