-- 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 = "Phase Shot",
	display_name = "相位射击",
	type = {"chronomancy/temporal-archery", 1},
	require = temporal_req1,
	points = 5,
	paradox = 3,
	cooldown = 3,
	no_energy = "fake",
	range = 10,
	tactical = { ATTACK = {TEMPORAL = 2} },
	on_pre_use = function(self, t, silent) if not self:hasArcheryWeapon() then if not silent then game.logPlayer(self, "You require a bow or sling for this talent.") end return false end return true end,
	requires_target = true,
	action = function(self, t)
		local tg = {type="bolt"}
		local targets = self:archeryAcquireTargets(tg)
		if not targets then return end
		self:archeryShoot(targets, t, nil, {mult=self:combatTalentWeaponDamage(t, 1.1, 1.9) * getParadoxModifier(self, pm), damtype=DamageType.TEMPORAL, apr=1000})
		return true
	end,
	info = function(self, t)
		local weapon = 100 * (self:combatTalentWeaponDamage(t, 1.1, 1.9) * getParadoxModifier(self, pm))
		return ([[你射出一枚在相位空间外的子弹，这使它可以忽视敌方护甲。此次射击会对目标造成 %d%% 时空武器伤害。
		受紊乱值影响，伤害有额外加成。]]):
		format(damDesc(self, DamageType.TEMPORAL, weapon))
	end
}

newTalent{
	name = "Unerring Shot",
	display_name = "必中射击",
	type = {"chronomancy/temporal-archery", 2},
	require = temporal_req2,
	points = 5,
	paradox = 5,
	cooldown = 8,
	no_energy = "fake",
	range = 10,
	tactical = { ATTACK = {PHYSICAL = 2} },
	on_pre_use = function(self, t, silent) if not self:hasArcheryWeapon() then if not silent then game.logPlayer(self, "You require a bow or sling for this talent.") end return false end return true end,
	requires_target = true,
	action = function(self, t)
		local tg = {type="bolt"}
		local targets = self:archeryAcquireTargets(tg)
		if not targets then return end
		self:setEffect(self.EFF_ATTACK, 1, {power=100})
		self:archeryShoot(targets, t, nil, {mult=self:combatTalentWeaponDamage(t, 1.1, 2.1) * getParadoxModifier(self, pm)})
		return true
	end,
	info = function(self, t)
		local weapon = 100 * (self:combatTalentWeaponDamage(t, 1.1, 1.9) * getParadoxModifier(self, pm))
		return ([[你集中注意力射出极精准的一箭，造成 %d%% 武器伤害。接下来的一次攻击因时空延续保持攻击加成。
		伤害受紊乱值影响有额外加成。]])
		:format(weapon)
	end,
}

newTalent{
	name = "Perfect Aim",
	display_name = "完美瞄准",
	type = {"chronomancy/temporal-archery", 3},
	require = temporal_req3,
	mode = "sustained",
	points = 5,
	sustain_paradox = 225,
	cooldown = 10,
	tactical = { BUFF = 2 },
	no_energy = true,
	getPower = function(self, t) return 10 + (self:combatTalentSpellDamage(t, 10, 40)) end,
	activate = function(self, t)
		local power = t.getPower(self, t)
		return {
		ccp = self:addTemporaryValue("combat_critical_power", power),
		pid = self:addTemporaryValue("combat_physcrit", power / 2),
		sid = self:addTemporaryValue("combat_spellcrit", power / 2),
		}
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("combat_critical_power", p.ccp)
		self:removeTemporaryValue("combat_physcrit", p.pid)
		self:removeTemporaryValue("combat_spellcrit", p.sid)
		return true
	end,
	info = function(self, t)
		local power = t.getPower(self, t)
		return ([[集中你的注意力瞄准，增加你的暴击加成 %d%% 并提高你的物理和法术暴击率 %d%% 。
		受你魔法影响效果有额外加成。]]):format(power, power / 2)
	end,
}

newTalent{
	name = "Quick Shot",
	display_name = "快速射击",
	type = {"chronomancy/temporal-archery", 4},
	require = temporal_req4,
	points = 5,
	paradox = 10,
	cooldown = function(self, t) return 15 - 2 * self:getTalentLevelRaw(t) end,
	no_energy = true,
	range = 10,
	tactical = { ATTACK = {PHYSICAL = 2} },
	on_pre_use = function(self, t, silent) if not self:hasArcheryWeapon() then if not silent then game.logPlayer(self, "You require a bow or sling for this talent.") end return false end return true end,
	requires_target = true,
	action = function(self, t)
		local old = self.energy.value
		local targets = self:archeryAcquireTargets()
		if not targets then return end
		self:archeryShoot(targets, t, nil, {mult=self:combatTalentWeaponDamage(t, 1, 1.5) * getParadoxModifier(self, pm)})
		self.energy.value = old
		return true
	end,
	info = function(self, t)
		local weapon = 100 * (self:combatTalentWeaponDamage(t, 1, 1.5) * getParadoxModifier(self, pm))
		return ([[你暂停时间给你足够的时间射出一支箭，造成 %d%% 伤害。
		伤害受紊乱值加成，另外技能等级提高可以降低冷却时间。]]):format(weapon)
	end,
}
