-- RegularSkillCalc Control Script, Lua v5.2
-- Skill Configuration (Result, Time) - Can be modified to adjust for own needs

-- SkillID refers to Index of skill in \Data\Skills\SkillList.txt
-- BuffID refers to \Data\BuffEffectManager.cfg

-- Character Classes
CLASS_WIZARD                                          = 0
CLASS_KNIGHT                                          = 1
CLASS_ELF                                             = 2
CLASS_GLADIATOR                                       = 3
CLASS_DARKLORD                                        = 4
CLASS_SUMMONER                                        = 5
CLASS_RAGEFIGHTER                                     = 6
CLASS_GROWLANCER                                      = 7

-- SkillID: 26, Heal - (Fairy Elf, Muse Elf, High Elf)
function ElfHeal(Class, Index, TargetIndex, Energy)
	local SkillEffect = 0
	
	if (Index ~= TargetIndex) then
		if (Class == CLASS_WIZARD) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_KNIGHT) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_ELF) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_GLADIATOR) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_DARKLORD) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_SUMMONER) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_RAGEFIGHTER) then
			SkillEffect = Energy / 5 + 5
		elseif (Class == CLASS_GROWLANCER) then
			SkillEffect = Energy / 5 + 5
		end
	elseif (Index == TargetIndex) then
		SkillEffect = Energy / 5 + 5
	end
	
	return SkillEffect
end


-- SkillID: 234, Recovery - (Fairy Elf, Muse Elf, High Elf)
function ElfShieldRecovery(Energy, PlayerLevel)
 local SkillEffect = Energy / 4 + PlayerLevel
 
 return SkillEffect
end

-- SkillID: 64, Increase Critical Damage - (Dark Lord, Lord Emperor)
function DarkLordCriticalDamage(Command, Energy)
	local SkillEffect = Command / 25 + Energy / 30
	local SkillTime = Energy / 10 + 60
	
	return SkillEffect, SkillTime
end

-- SkillID: 217, Damage Reflection - (Summoner, Bloody Summoner, Dimension Master)
function SummonerDamageReflect(Energy)
	local Reflect = 30 + (Energy / 42)
	local Time = 30 + (Energy / 25)
	
	if (Reflect > 25) then
		Reflect = 25
	end
	
	return Reflect, Time
end

-- SkillID: 218, Berserker - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserker(Energy)
	local SkillEffectUP = Energy / 850
	local SkillEffectDOWN = Energy / 850
	local SkillTime = Energy / 20 + 30
	
	return SkillEffectUP, SkillEffectDOWN, SkillTime
end

-- SkillID: 218, BuffID: 81, 150, 151, 152 - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserkerAttackDamage(Strength, Dexterity)
	local AttackMin = (Strength+Dexterity) / 7
	local AttackMax = (Strength+Dexterity) / 4
	
	return AttackMin, AttackMax
end

-- SkillID: 221, Weakness - MvP - (Summoner, Bloody Summoner, Dimension Master)
function SummonerWeakness_Monster(Energy, Curse, MonsterLevel)
	local SkillSuccessRate = Energy / 50 + Curse / 6 + 32
	local SkillEffect = Energy / 58 + 4
	local SkillTime = Energy / 100 + 4 - MonsterLevel / 20
	
	return SkillSuccessRate, SkillEffect, SkillTime
end

-- SkillID: 221, Weakness - PvP - (Summoner, Bloody Summoner, Dimension Master)
function SummonerWeakness_PvP(Energy, Curse, PlayerLevel, TargetLevel)
	local SkillSuccessRate =  Energy / 50 + Curse / 6 + 17
	local SkillEffect = Energy / 93 + 3
	local SkillTime = Energy / 300 + (PlayerLevel - TargetLevel) / 150 + 5
	
	return SkillSuccessRate, SkillEffect, SkillTime
end

-- SkillID: 222, Innovation - MvP - (Summoner, Bloody Summoner, Dimension Master)
function SummonerInnovation_Monster(Energy, Curse, MonsterLevel)
	local SkillSuccessRate = Energy / 50 + Curse / 6 + 32
	local SkillEffect = Energy / 90 + 20
	local SkillTime = Energy / 100 + 4 - MonsterLevel / 20
	
	return SkillSuccessRate, SkillEffect, SkillTime
end

-- SkillID: 222, Innovation - PvP - (Summoner, Bloody Summoner, Dimension Master)
function SummonerInnovation_PvP(Energy, Curse, PlayerLevel, TargetLevel)
	local SkillSuccessRate =  Energy / 50 + Curse / 6 + 17
	local SkillEffect = Energy / 110 + 12
	local SkillTime = Energy / 300 + (PlayerLevel - TargetLevel) / 150 + 5
	
	return SkillSuccessRate, SkillEffect, SkillTime
end

-- SkillID: 265, 564, 566 - Dragon Slasher - SD Reduction - (Rage Fighter, Fist Master)
function DragonSlasher_DecreaseVictimSD(Energy)
	local SuccessRate = 0
	local DecreasePercent = 0
	
	SuccessRate = Energy / 100 + 10
	DecreasePercent = Energy / 30 + 10
	
	if (SuccessRate > 100) then
		SuccessRate = 100
	end
	
	if (DecreasePercent > 100) then
		DecreasePercent = 100
	end
	
	return SuccessRate, DecreasePercent
end

-- SkillID: 18, Defense - (Shields Skill)
function ShieldSkill_DecreaseVictimDamage(InDamage)
 local OutDamage = InDamage / 2
 
 return OutDamage
end

-- SkillID: 272, Circle Shield - (Grow Lancer, Mirage Lancer)
function GrowLancerCircleShield(Strength, Dexterity, Energy)
	local SkillEffect = 10
	local SkillSuccessRate = Strength / 40
	local SkillTime = Energy / 10 + 60

	return SkillEffect, SkillSuccessRate, SkillTime
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: 28, Greater Damage - (Fairy Elf, Muse Elf, High Elf)
function ElfAttack(Class, Index, TargetIndex, Energy)
	local SkillEffect = 0
	local SkillTime = 60
	
	if (Index ~= TargetIndex) then
		if (Class == CLASS_WIZARD) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_KNIGHT) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_ELF) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_GLADIATOR) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_DARKLORD) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_SUMMONER) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_RAGEFIGHTER) then
			SkillEffect = 3 + Energy / 7
		elseif (Class == CLASS_GROWLANCER) then
			SkillEffect = 3 + Energy / 7
		end
	elseif (Index == TargetIndex) then
		SkillEffect = 3 + Energy / 7
	end
	
	return SkillEffect, SkillTime
end

-- SkillID: 27, Greater Defense - (Fairy Elf, Muse Elf, High Elf)
function ElfDefense(Class, Index, TargetIndex, Energy)
	local SkillEffect = 0
	local SkillTime = 60
	
	if (Index ~= TargetIndex) then
		if (Class == CLASS_WIZARD) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_KNIGHT) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_ELF) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_GLADIATOR) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_DARKLORD) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_SUMMONER) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_RAGEFIGHTER) then
			SkillEffect = 2 + Energy / 8
		elseif (Class == CLASS_GROWLANCER) then
			SkillEffect = 2 + Energy / 8
		end
	elseif (Index == TargetIndex) then
		SkillEffect = 2 + Energy / 8
	end
	
	return SkillEffect, SkillTime
end

-- SkillID: 218, Berserker - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserker(Energy)
	local SkillEffectUP = Energy / 300
	local SkillEffectDOWN = Energy / 600
	local SkillTime = Energy / 20 + 30
	
	return SkillEffectUP, SkillEffectDOWN, SkillTime
end

-- SkillID: 218, BuffID: 81, 150, 151, 152 - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserkerAttackDamage(Strength, Dexterity)
	local AttackMin = (Strength+Dexterity) / 140
	local AttackMax = (Strength+Dexterity) / 80
	
	return AttackMin, AttackMax
end

-- SkillID: 218, Berserker - Magic Damage - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserkerMagicDamage(Effect, Energy)
	local MagicMin = (Energy / 34) * Effect / 100
	local MagicMax = (Energy / 16) * Effect / 100
	
	return MagicMin, MagicMax
end

-- SkillID: 218, Berserker - Curse Damage - (Summoner, Bloody Summoner, Dimension Master)
function SummonerBerserkerCurseDamage(Effect, Energy)
	local CurseMin = Effect * (Energy / 27) / 100
	local CurseMax = Effect * ((Energy + 0.015) / 12) / 100
	
	return CurseMin, CurseMax
end

-- SkillID: X, Bastion - (IGC_BuffEffectManager.xml -> Index: 238)
function BastionBuffCalcSuccessAndTime(CharacterLevel)
	local SuccessRate = 20
	local Duration = CharacterLevel / 4 + 20

	if (SuccessRate > 100) then
		SuccessRate = 100
	end
	
	return SuccessRate, Duration
end

-- SkillID: X, Hemorrhage - (IGC_BuffEffectManager.xml -> Index: 239)
function BleedingBuffCalcSuccessAndTime(CharacterLevel)
	local SuccessRate = 10
	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 - (BuffEffectManager.xml -> Index: 241)
function BindingBuffCalcSuccess(CharacterLevel)
	local SuccessRate = 10

	if (SuccessRate > 100) then
		SuccessRate = 100
	end	

	return SuccessRate
end

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

	if (SuccessRate > 100) then
		SuccessRate = 100
	end
	
	return SuccessRate, Duration
end
