-- 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 = "Illuminate",
	display_name = "照明术",
	type = {"spell/phantasm",1},
	require = spells_req1,
	random_ego = "utility",
	points = 5,
	mana = 5,
	cooldown = 14,
	range = 0,
	radius = function(self, t) return 5 + self:getTalentLevel(t) end,
	tactical = { DISABLE = function(self, t)
		if self:getTalentLevel(t) >= 3 then
			return 2
		end
		return 0
	end},
	getBlindPower = function(self, t) return 3 + self:getTalentLevel(t) end,
	action = function(self, t)
		local tg = {type="ball", range=self:getTalentRange(t), selffire=true, radius=self:getTalentRadius(t), talent=t}
		self:project(tg, self.x, self.y, DamageType.LITE, 1)
		if self:getTalentLevel(t) >= 3 then
			tg.selffire= false
			self:project(tg, self.x, self.y, DamageType.BLIND, t.getBlindPower(self, t))
		end
		game:playSoundNear(self, "talents/heal")
		return true
	end,
	info = function(self, t)
		local radius = self:getTalentRadius(t)
		return ([[制造一个发光的球体，照亮 %d 格半径范围区域。
		在等级3时，它同时可以致盲看到它的人（施法者除外）。]]):
		format(radius)
	end,
}

newTalent{
	name = "Blur Sight",
	display_name = "模糊视觉",
	type = {"spell/phantasm", 2},
	mode = "sustained",
	require = spells_req2,
	points = 5,
	sustain_mana = 30,
	cooldown = 10,
	tactical = { BUFF = 2 },
	getDefense = function(self, t) return self:combatTalentSpellDamage(t, 4, 30) end,
	activate = function(self, t)
		game:playSoundNear(self, "talents/heal")
		return {
			particle = self:addParticles(Particles.new("phantasm_shield", 1)),
			def = self:addTemporaryValue("combat_def", t.getDefense(self, t)),
		}
	end,
	deactivate = function(self, t, p)
		self:removeParticles(p.particle)
		self:removeTemporaryValue("combat_def", p.def)
		return true
	end,
	info = function(self, t)
		local defence = t.getDefense(self, t)
		return ([[施法者的形象变的模糊不清，增加 %d 点闪避。
		受法术强度影响，闪避有额外加成。]]):
		format(defence)
	end,
}

newTalent{
	name = "Phantasmal Shield",
	display_name = "幻象护盾",
	type = {"spell/phantasm", 3},
	mode = "sustained",
	require = spells_req3,
	points = 5,
	sustain_mana = 60,
	cooldown = 10,
	tactical = { BUFF = 2 },
	getDamage = function(self, t) return self:combatTalentSpellDamage(t, 10, 50) end,
	activate = function(self, t)
		game:playSoundNear(self, "talents/heal")
		return {
			particle = self:addParticles(Particles.new("phantasm_shield", 1)),
			onhit = self:addTemporaryValue("on_melee_hit", {[DamageType.ARCANE]=t.getDamage(self, t)}),
		}
	end,
	deactivate = function(self, t, p)
		self:removeParticles(p.particle)
		self:removeTemporaryValue("on_melee_hit", p.onhit)
		return true
	end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		return ([[施法者被幻象护盾所包围。若你受到近战打击，此护盾会对攻击者造成 %d 点奥术伤害。
		受法术强度影响，伤害有额外加成。]]):
		format(damDesc(self, DamageType.ARCANE, damage))
	end,
}

newTalent{
	name = "Invisibility",
	display_name = "隐匿",
	type = {"spell/phantasm", 4},
	mode = "sustained",
	require = spells_req4,
	points = 5,
	sustain_mana = 150,
	cooldown = 30,
	tactical = { ESCAPE = 2, DEFEND = 2 },
	getInvisibilityPower = function(self, t) return self:combatTalentSpellDamage(t, 10, 50) end,
	activate = function(self, t)
		game:playSoundNear(self, "talents/heal")
		local ret = {
			invisible = self:addTemporaryValue("invisible", t.getInvisibilityPower(self, t)),
			invisible_damage_penalty = self:addTemporaryValue("invisible_damage_penalty", 0.7),
			drain = self:addTemporaryValue("mana_regen", -2),
		}
		self:resetCanSeeCacheOf()
		return ret
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("invisible", p.invisible)
		self:removeTemporaryValue("invisible_damage_penalty", p.invisible_damage_penalty)
		self:removeTemporaryValue("mana_regen", p.drain)
		self:resetCanSeeCacheOf()
		return true
	end,
	info = function(self, t)
		local invisi = t.getInvisibilityPower(self, t)
		return ([[施法者从视线中淡出，额外增加 %d 点隐身等级。
		注意：你你必须取下携带的油灯，否则你仍然会被轻易发现。
		由于你变的不可见，你离开了现实位面。你的所有攻击降低70%%伤害。
		当此技能激活时，它会逐渐消耗你的法力（2法力/回合）。
		受法术强度影响，隐匿强度有额外加成。]]):
		format(invisi)
	end,
}
