-- 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 = "Blood Spray",
	display_name = "鲜血喷射",
	type = {"corruption/blood", 1},
	require = corrs_req1,
	points = 5,
	cooldown = 7,
	vim = 24,
	tactical = { ATTACKAREA = {BLIGHT = 2} },
	range = 0,
	radius = function(self, t)
		return math.ceil(3 + self:getTalentLevel(t))
	end,
	direct_hit = true,
	requires_target = true,
	target = function(self, t)
		return {type="cone", range=self:getTalentRange(t), radius=self:getTalentRadius(t), talent=t}
	end,
	action = function(self, t)
		local tg = self:getTalentTarget(t)
		local x, y = self:getTarget(tg)
		if not x or not y then return nil end
		self:project(tg, x, y, DamageType.CORRUPTED_BLOOD, {
			dam = self:spellCrit(self:combatTalentSpellDamage(t, 10, 190)),
			disease_chance = 20 + self:getTalentLevel(t) * 10,
			disease_dam = self:spellCrit(self:combatTalentSpellDamage(t, 10, 220)) / 6,
			disease_power = self:combatTalentSpellDamage(t, 10, 20),
			dur = 6,
		})
		game.level.map:particleEmitter(self.x, self.y, tg.radius, "breath_blood", {radius=tg.radius, tx=x-self.x, ty=y-self.y})
		game:playSoundNear(self, "talents/slime")
		return true
	end,
	info = function(self, t)
		return ([[你从自身射出堕落之血，对前方 %d 格半径锥形范围敌人造成 %0.2f 枯萎伤害。
		每个受影响的单位有 %d%% 概率感染1种随机疾病，在6回合内受到 %0.2f 枯萎伤害。
		受魔法影响，伤害有额外加成。]]):format(self:getTalentRadius(t), damDesc(self, DamageType.BLIGHT, self:combatTalentSpellDamage(t, 10, 190)), 20 + self:getTalentLevel(t) * 10, damDesc(self, DamageType.BLIGHT, self:combatTalentSpellDamage(t, 10, 220)))
	end,
}

newTalent{
	name = "Blood Grasp",
	display_name = "鲜血支配",
	type = {"corruption/blood", 2},
	require = corrs_req2,
	points = 5,
	cooldown = 5,
	vim = 20,
	range = 10,
	proj_speed = 20,
	tactical = { ATTACK = {BLIGHT = 2}, HEAL = 2 },
	requires_target = true,
	target = function(self, t)
		return {type="bolt", range=self:getTalentRange(t), talent=t, display={particle="bolt_blood"}}
	end,
	action = function(self, t)
		local tg = self:getTalentTarget(t)
		local x, y = self:getTarget(tg)
		if not x or not y then return nil end
		self:projectile(tg, x, y, DamageType.DRAINLIFE, {dam=self:spellCrit(self:combatTalentSpellDamage(t, 10, 290)), healfactor=0.5}, {type="blood"})
		game:playSoundNear(self, "talents/slime")
		return true
	end,
	info = function(self, t)
		return ([[释放一个堕落之血球造成 %0.2f 枯萎伤害并恢复你一半伤害值的生命。
		受魔法影响，伤害有额外加成。]]):format(damDesc(self, DamageType.BLIGHT, self:combatTalentSpellDamage(t, 10, 290)))
	end,
}

newTalent{
	name = "Blood Boil",
	display_name = "鲜血沸腾",
	type = {"corruption/blood", 3},
	require = corrs_req3,
	points = 5,
	cooldown = 12,
	vim = 30,
	tactical = { ATTACKAREA = {BLIGHT = 2}, DISABLE = 2 },
	range = 0,
	radius = function(self, t)
		return 2 + self:getTalentLevelRaw(t)
	end,
	requires_target = true,
	target = function(self, t)
		return {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t), selffire=false, talent=t}
	end,
	action = function(self, t)
		local tg = self:getTalentTarget(t)
		local grids = self:project(tg, self.x, self.y, DamageType.BLOOD_BOIL, self:spellCrit(self:combatTalentSpellDamage(t, 28, 190)))
		game.level.map:particleEmitter(self.x, self.y, tg.radius, "ball_blood", {radius=tg.radius})
		game:playSoundNear(self, "talents/slime")
		return true
	end,
	info = function(self, t)
		return ([[使你周围 %d 格半径范围内的敌人鲜血沸腾，造成 %0.2f 枯萎伤害并减少20%%速度。
		受魔法影响，伤害有额外加成。]]):format(self:getTalentRadius(t), damDesc(self, DamageType.BLIGHT, self:combatTalentSpellDamage(t, 28, 190)))
	end,
}

newTalent{
	name = "Blood Fury",
	display_name = "鲜血狂怒",
	type = {"corruption/blood", 4},
	mode = "sustained",
	require = corrs_req4,
	points = 5,
	sustain_vim = 60,
	cooldown = 30,
	tactical = { BUFF = 2 },
	on_crit = function(self, t)
		self:setEffect(self.EFF_BLOOD_FURY, 5, {power=self:combatTalentSpellDamage(t, 10, 30)})
	end,
	activate = function(self, t)
		game:playSoundNear(self, "talents/slime")
		local ret = {
			per = self:addTemporaryValue("combat_spellcrit", self:combatTalentSpellDamage(t, 10, 14)),
		}
		return ret
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("combat_spellcrit", p.per)
		return true
	end,
	info = function(self, t)
		return ([[专注于你带来的腐蚀，提高你 %d%%法术暴击率。
		每当你的法术打出暴击时，你进入嗜血状态5回合，增加你 %d%%枯萎和酸性伤害。
		受魔法影响，伤害有额外加成。]]):
		format(self:combatTalentSpellDamage(t, 10, 14), self:combatTalentSpellDamage(t, 10, 30))
	end,
}
