-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org

newTalent{
	name = "Rampage",
	display_name = "暴走",
	type = {"cursed/rampage", 1},
	require = cursed_str_req1,
	points = 5,
	tactical = { ATTACK = { PHYSICAL = 3 } },
	cooldown = function(self, t)
		local tReflexes = self:getTalentFromId(self.T_REFLEXES)
		if tReflexes then
			return tReflexes.getCooldown(self, tReflexes)
		else
			return 150
		end
	end,
	hate = 0.5,
	action = function(self, t, hateLoss)
		local critical = 0
		local damage = 0
		local speed = 0
		local attack = 0
		local evasion = 0

		local hateMultiplier = getHateMultiplier(self, 0.1, 1.0, true)

		critical = t.getCritical(self, t) * hateMultiplier
		if not hateLoss then
			hateLoss = t.getHateLoss(self, t)
		end

		local duration = 5
		local tBrutality = self:getTalentFromId(self.T_BRUTALITY)
		if tBrutality then
			duration = tBrutality.getDuration(self, tBrutality)
			damage = tBrutality.getDamage(self, tBrutality) * hateMultiplier
		end

		local tReflexes = self:getTalentFromId(self.T_REFLEXES)
		if tReflexes then
			speed = tReflexes.getSpeed(self, tReflexes) * hateMultiplier
		end

		local tInstincts = self:getTalentFromId(self.T_INSTINCTS)
		if tInstincts then
			attack = tInstincts.getAttack(self, tInstincts) * hateMultiplier
			evasion = tInstincts.getEvasion(self, tInstincts) * hateMultiplier
		end

		self:setEffect(self.EFF_RAMPAGE, duration, { critical = critical, damage = damage, speed = speed, attack = attack, evasion = evasion, hateLoss = hateLoss })

		return true
	end,
	getHateLoss = function(self, t) return 0.75 - 0.05 * self:getTalentLevelRaw(t) end,
	getCritical = function(self, t) return 10 + 8 * self:getTalentLevel(t) end,
	onTakeHit = function(t, self, fractionDamage)
		if fractionDamage < 0.08 then return false end
		if self:hasEffect(self.EFF_RAMPAGE) then return false end
		if rng.percent(3) then
			t.action(self, t, 0)
			return true
		end
	end,
	info = function(self, t)
		local duration = 5
		local tBrutality = self:getTalentFromId(self.T_BRUTALITY)
		if tBrutality then
			duration = tBrutality.getDuration(self, tBrutality)
		end
		local hateLoss = t.getHateLoss(self, t)
		local critical = t.getCritical(self, t)
		return ([[你进入暴走状态 %d 回合,摧毁在你路径上的所有东西。同时也有较小几率在你被击中时自动激活。
		每回合消耗 %0.2f 仇恨值，提高%d%% （0怒气）～ %d%% （10+怒气）暴击率。
		当装备被诅咒的武器时，怒气技能效果有额外加成。]]):format(duration, hateLoss, critical * 0.3, critical * 1.0)
	end,
}

newTalent{
	name = "Brutality",
	display_name = "无情",
	type = {"cursed/rampage", 2},
	mode = "passive",
	require = cursed_str_req2,
	points = 5,
	on_learn = function(self, t)
	end,
	on_unlearn = function(self, t)
	end,
	getDuration = function(self, t) return 4 + math.floor(1 * self:getTalentLevel(t)) end,
	getDamage = function(self, t) return 10 * self:getTalentLevel(t) end,
	info = function(self, t)
		local duration = t.getDuration(self, t)
		local damage = t.getDamage(self, t)
		return ([[使你的暴走更加无情。
		暴走持续 %d 回合，增加 %d%% （0仇恨）～  %d%% （10+仇恨）物理伤害。
		当装备被诅咒的武器时，仇恨技能效果有额外加成。]]):format(duration, damage * 0.1, damage * 1.0)
	end,
}

newTalent{
	name = "Reflexes",
	display_name = "条件反射",
	type = {"cursed/rampage", 3},
	require = cursed_str_req3,
	points = 5,
	mode = "passive",
	on_learn = function(self, t)
	end,
	on_unlearn = function(self, t)
	end,
	getCooldown = function(self, t) return 150 - math.floor(10 * self:getTalentLevelRaw(t)) end,
	getSpeed = function(self, t) return 10 * self:getTalentLevel(t) end,
	info = function(self, t)
		local cooldown = t.getCooldown(self, t)
		local speed = t.getSpeed(self, t)
		return ([[你的暴走更加频繁。
		暴走冷却时间为 %d 回合，增加 %d%% （0仇恨）～ %d%% （10+仇恨）速度。
		当装备被诅咒的武器时，仇恨技能效果有额外加成。]]):format(cooldown, speed * 0.1, speed * 1.0)
	end,
}

newTalent{
	name = "Instincts",
	display_name = "本能",
	type = {"cursed/rampage", 4},
	mode = "passive",
	require = cursed_str_req4,
	points = 5,
	on_learn = function(self, t)
	end,
	on_unlearn = function(self, t)
	end,
	getAttack = function(self, t) return 20 + 10 * self:getTalentLevel(t) end,
	getEvasion = function(self, t) return 6 * self:getTalentLevel(t) end,
	info = function(self, t)
		local attack = t.getAttack(self, t)
		local evasion = t.getEvasion(self, t)
		return ([[你的暴走增加本能行为。
		增加 %d%% （0仇恨）～ %d%% （10+仇恨）攻击，增加 %d%% （0仇恨）～ %d%% （10+仇恨）闪避。
		当装备被诅咒的武器时，仇恨技能效果有额外加成。]]):format(attack * 0.1, attack * 1.0, evasion * 0.1, evasion * 1.0)
	end,
}
