-- // ============================================================
-- // == X12 MUONLINE SERVER EMULATOR
-- // == www.muemu.tech
-- // == (C) 2021 MUEMU
-- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- // == File is a part of MUEMU MuOnline Server files.
-- // ============================================================
-- CalcCharacter Control Script, Lua v5.2
-- Character Calculations Configuration - Can be modified to adjust for own needs
-- Character Classes
CLASS_WIZARD                                          = 0	-- Fairy Elf, Muse Elf, High Elf
CLASS_KNIGHT                                          = 1	-- Dark Wizard, Soul Master, Grand Master
CLASS_ELF                                             = 2	-- Dark Knight, Blade Knight, Blade Master
CLASS_GLADIATOR                                       = 3	-- Magic Gladiator, Duel Master
CLASS_DARKLORD                                        = 4	-- Dark Lord, Lord Emperor
CLASS_SUMMONER                                        = 5	-- Summoner, Bloody Summoner, Dimension Master
CLASS_RAGEFIGHTER                                     = 6	-- Rage Fighter, Fist Master
CLASS_GROWLANCER				      = 7	-- Grow Lancer, Mirage Lancer

-- Character Elemental Damage - PvP and MvP - Dark Wizard, Soul Master, Grand Master)
function WizardElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Energy / 9)
	MaxDamage = ItemMaxDamage + (Energy / 6)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Dark Knight, Blade Knight, Blade Master)
function KnightElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Strength / 6)
	MaxDamage = ItemMaxDamage + (Strength / 4)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Fairy Elf, Muse Elf, High Elf)
function ElfElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Dexterity / 8) + (Strength / 14)
	MaxDamage = ItemMaxDamage + (Dexterity / 4) + (Strength / 8)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Magic Gladiator, Duel Master)
function GladiatorElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Strength / 10) + (Energy / 14)
	MaxDamage = ItemMaxDamage + (Strength / 6) + (Energy / 8)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Dark Lord, Lord Emperor)
function LordElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Strength / 10) + (Energy / 14)
	MaxDamage = ItemMaxDamage + (Strength / 6) + (Energy / 10)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Summoner, Bloody Summoner, Dimension Master)
function SummonerElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Energy / 10)
	MaxDamage = ItemMaxDamage + (Energy / 6)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Rage Fighter, Fist Master)
function RageFighterElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Strength / 10) + (Vitality / 20)
	MaxDamage = ItemMaxDamage + (Strength / 6) + (Vitality / 15)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Damage - PvP and MvP - (Grow Lancer, Mirage Lancer)
function GrowLancerElementalDamageCalc(Strength, Dexterity, Vitality, Energy, ItemMinDamage, ItemMaxDamage)
	local MinDamage = 0
	local MaxDamage = 0
	
	MinDamage = ItemMinDamage + (Strength / 4) + (Dexterity / 1)
	MaxDamage = ItemMaxDamage + (Strength / 4) + (Dexterity / 1)
	
	return MinDamage, MaxDamage
end

-- Character Elemental Defense - General
function ElementalDefenseCalc(Class, Dexterity)
	local Defense = 0
	
	if(Class == CLASS_WIZARD) then
		Defense = Dexterity / 4
	elseif(Class == CLASS_KNIGHT) then
		Defense = Dexterity / 3
	elseif(Class == CLASS_ELF) then
		Defense = Dexterity / 10
	elseif(Class == CLASS_GLADIATOR) then
		Defense = Dexterity / 5
	elseif(Class == CLASS_DARKLORD) then
		Defense = Dexterity / 7
	elseif(Class == CLASS_SUMMONER) then
		Defense = Dexterity / 3
	elseif(Class == CLASS_RAGEFIGHTER) then
		Defense = Dexterity / 8
	elseif(Class == CLASS_GROWLANCER) then
		Defense = Dexterity / 7
	end
	
	return Defense
end
		
-- BuffID: 174, 175, 176, 177, 178 - (Fire, Frost, Tornado, Bind, Darkness)
function ElementalDebuffGetDuration(ID, CharacterLevel)
	local Duration = 0
	
	if (ID == 174) then
		Duration = CharacterLevel / 4 + 20
	elseif (ID == 175) then
		Duration = CharacterLevel / 4 + 20
	elseif (ID == 176) then
		Duration = CharacterLevel / 4 + 20
	elseif (ID == 177) then
		Duration = CharacterLevel / 4 + 20
	elseif (ID == 178) then
		Duration = CharacterLevel / 4 + 20
	end
	
	return Duration
end

-- SkillID: X, Bastion - (IGC_BuffEffectManager.xml -> Index: 238)
function BastionBuffCalcSuccessAndTime(CharacterLevel)
	local SuccessRate = 50
	local Duration = 25
	
	return SuccessRate, Duration
end	
	
-- SkillID: X, Hemorrhage - (IGC_BuffEffectManager.xml -> Index: 239)
function BleedingBuffCalcSuccessAndTime(CharacterLevel)
	local SuccessRate = 30
	local Duration = CharacterLevel / 4 + 20
	
	return SuccessRate, Duration
end

-- SkillID: X, Paralysis - (IGC_BuffEffectManager.xml -> Index: 240)
function ParalyzingBuffCalcSuccess(CharacterLevel)
	local SuccessRate = 10
	
	return SuccessRate
end

-- SkillID: X, Bondage - (IGC_BuffEffectManager.xml -> Index: 241)
function BindingBuffCalcSuccess(CharacterLevel)
	local SuccessRate = 5
	
	return SuccessRate
end

-- SkillID: X, Blindness - (IGC_BuffEffectManager.xml -> Index: 242)
function BlindingBuffCalcSuccessAndTime(CharacterLevel)
	local SuccessRate = 30
	local Duration = CharacterLevel / 4 + 20
	
	return SuccessRate, Duration
end	

-- SkillID: X, Punish 
function PunishBuffCalcSuccess(CharacterLevel)
	local SuccessRate = 30
	local PunishMaxDamage = 250000
	
	return SuccessRate, PunishMaxDamage
end
											   