Jump to content
  • We need you!

    You must register to discover all the features of our community!

[Quest] Alchemy with a daily limit


Recommended Posts

Posted (edited)

Hi, my first publication in this forum. Quest with daily limit and level interval for drop cor draconis in alchemi. I think it will be useful to someone. I also write commissioned quests :)

https://github.com/Alerinos/M2-Quest-Alchemy

Quest is compatible with Marty files.

Edited by Alerin (see edit history)
  • Love 3
Link to post
  • Developer
Posted (edited)

Good job, glad to see someone post in this section every now and then.

 

Let me help you with something:

 

	-- Customizable
	function count(level)
		local ranges = {
			{["min"] = 110, ["count"] = 20},
			{["min"] = 100, ["count"] = 18},
			{["min"] = 90, ["count"] = 16},
			{["min"] = 80, ["count"] = 14},
			{["min"] = 70, ["count"] = 12},
			{["min"] = 60, ["count"] = 10},
			{["min"] = 50, ["count"] = 8},
			{["min"] = 40, ["count"] = 6},
			{["min"] = 30, ["count"] = 4},
		};
		
		for _, range in ipairs(ranges) do
			if (level >= range["min"]) then
				return range["count"];
			end -- if
		end -- for
		
		return 0;
	end -- function
	
	-- Dynamic
	function count(level)
		local ranges = {30, 40, 50, 60, 70, 80, 90, 100, 110, INSERT_MAX_LEVEL_HERE};
		local multiplier = pc.ispremium() and 1.5 or 1;
		
		for index = 1, table.getn(ranges) do
			if (level >= range[index] and level < range[index+1]) then
				return (2 + 2 * index) * multiplier;
			end -- if
		end -- for
		
		return 0;
	end -- function

One more thing I can tell you is that if the argument you're going to pass to the function is always the player's level, there is no point in making it an argument in the first place, you can just call pc.get_level() instead, save it in a var if you prefer.

Edited by Syreldar (see edit history)
  • Love 1

? Premium Lua Developer ?

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying those who help them.

-Syreldar

Link to post
Posted (edited)

Thank you for opinion. You can do it nicely in an array, but I made editing the version for the less experienced easier. I also try to avoid unnecessary loops. Lua is the fastest scripting language but implementation in metin is scary.

Edited by Alerin (see edit history)
Link to post
  • Developer
21 minutes ago, Alerin said:

Thank you for opinion. You can do it nicely in an array, but I made editing the version for the less experienced easier. I also try to avoid unnecessary loops. Lua is the fastest scripting language but implementation in metin is scary.

Don't be scared using loops by any means, they work fine and fast.

? Premium Lua Developer ?

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying those who help them.

-Syreldar

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

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.