Jump to content

Mean/skill simulator ingame


Recommended Posts

  • Active Member

Hi


Demostration: https://metin2.download/video/3lPDNkFwv4KaL4T2u9ClI0xfmfD0oZ0U/.mp4

 

Important: Do these tests without people in the game.


Inputs:

You must enter the average and the desired skill. The cycle ends when a greater or equal average or skill has been found.
If you just want to find average, enter the value of your average, and an unlikely skill value.
If you just want to find skill, enter the value of your skill, and an average improbable value.

Example:

I just want to find 60 on average:
Average input: 60
Skill input: 100

I just want to find 28 skill:
Average input: 100
Skill input: 28

I want to find 60 average or 28 skill:
Average input: 60
Skill input: 28




Implementation:
 

questlua_global.cpp

1. 
Add anywhere:
 

	ALUA(_skill_mean) //return success, skill, mean, switches
	{
		if( !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3)) //skill, mean, switches
			return 0;
		
		int skill_need = lua_tonumber(L, 1);
		int mean_need = lua_tonumber(L, 2);
		int count = lua_tonumber(L, 3);
		
		int switches = 0;
		int new_skill = 0;
		int new_mean = 0;
		
		for (int i = 0; i < count; i++)
		{
			int iSkillBonus = MINMAX(-30, (int) (gauss_random(0, 5) + 0.5f), 30);
			int iNormalHitBonus = 0;
			if (abs(iSkillBonus) <= 20)
				iNormalHitBonus = -2 * iSkillBonus + abs(number(-8, 8) + number(-8, 8)) + number(1, 4);
			else
				iNormalHitBonus = -2 * iSkillBonus + number(1, 5);
			switches = i+1;
			new_skill = iSkillBonus;
			new_mean = iNormalHitBonus;
			if (iSkillBonus >= skill_need || iNormalHitBonus >= mean_need)
			{
				lua_pushboolean(L, true);
				lua_pushnumber(L, new_skill);
				lua_pushnumber(L, new_mean);
				lua_pushnumber(L, switches);
				return 4;
			}
		}
		lua_pushboolean(L, false);
		lua_pushnumber(L, new_skill);
		lua_pushnumber(L, new_mean);
		lua_pushnumber(L, switches);
		return 4;
	}

2. Above of:

			{	NULL,	NULL	}

Add:

			{	"get_skill_mean", 				_skill_mean					},


meanskill_simulator.quest

quest meanskill_simulator begin
	state start begin
		when letter with pc.is_gm() begin
			send_letter("Mean Skill simulator")
		end
		
		when button or info begin
			meanskill_simulator.dialog()
			while true do
				if select("Again", "Close") == 2 then
					return
				end
				meanskill_simulator.dialog()
			end
		end
		
		function dialog()
			local max_switches = 1000000
			say("Mean:")
			local mean = tonumber(input())
			say("Skill:")
			local skill = tonumber(input())
			local success, new_skill, new_mean, switches = get_skill_mean(skill, mean, max_switches)
			if success then
				say(" Success: ")
			else
				say("Fail: ")
			end
			say("Mean: "..new_mean)
			say("Skill: "..new_skill)
			say("Switches: "..numtomoney(switches))
		end
	end
end

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Metin2 Dev 1
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.