Skip to content
Snippets Groups Projects
mindstar-mastery.lua 8.71 KiB
Newer Older
dg's avatar
dg committed
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
dg's avatar
dg committed
--
-- 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

function get_mindstar_power_mult(self, div)
	local main, off = self:hasPsiblades(true, true)
	if not main or not off then return 1 end

	local mult = 1 + (main.combat.dam + off.combat.dam) * 0.8 / (div or 40)
dg's avatar
dg committed
newTalent{
	name = "Psiblades",
	type = {"wild-gift/mindstar-mastery", 1},
	require = gifts_req1,
	points = 5,
	mode = "sustained",
	sustain_equilibrium = 18,
	cooldown = 6,
dg's avatar
dg committed
	tactical = { BUFF = 4 },
	getPowermult = function(self,t,level) return 1.076 + 0.324*(level or self:getTalentLevel(t))^.5 end, --I5
dg's avatar
dg committed
	getStatmult = function(self,t,level) return 1.076 + 0.324*(level or self:getTalentLevel(t))^.5 end, --I5
	getAPRmult = function(self,t,level) return 0.65 + 0.51*(level or self:getTalentLevel(t))^.5 end, -- I5
	getDamage = function(self, t) return self:getTalentLevel(t) * 10 end,
	getPercentInc = function(self, t) return math.sqrt(self:getTalentLevel(t) / 5) / 2 end,
dg's avatar
dg committed
	activate = function(self, t)
		local r = {
			tmpid = self:addTemporaryValue("psiblades_active", self:getTalentLevel(t)),
		}

dg's avatar
dg committed
		for i, o in ipairs(self:getInven("MAINHAND") or {}) do self:onTakeoff(o, true) self:onWear(o, true) end
		for i, o in ipairs(self:getInven("OFFHAND") or {}) do self:onTakeoff(o, true) self:onWear(o, true) end
dg's avatar
dg committed
		self:updateModdableTile()

		return r
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("psiblades_active", p.tmpid)

		for i, o in ipairs(self:getInven("MAINHAND") or {}) do self:onTakeoff(o, true) self:checkMindstar(o) self:onWear(o, true) end
		for i, o in ipairs(self:getInven("OFFHAND") or {}) do self:onTakeoff(o, true) self:checkMindstar(o) self:onWear(o, true) end
dg's avatar
dg committed
		self:updateModdableTile()

		return true
	end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		local inc = t.getPercentInc(self, t)
dg's avatar
dg committed
		return ([[Channel your mental power through your wielded mindstars, generating psionic blades sprouting from the mindstars.
		Mindstar psiblades have their damage modifiers (how much damage they gain from stats) multiplied by %0.2f, their armour penetration by %0.2f and mindpower, willpower and cunning by %0.2f.
		Also increases Physical Power by %d and increases weapon damage by %d%% when using mindstars.]]):
		format(t.getStatmult(self, t), t.getAPRmult(self, t), t.getPowermult(self, t), damage, 100 * inc) --I5
dg's avatar
dg committed
	end,
}

newTalent{
	name = "Thorn Grab",
	type = {"wild-gift/mindstar-mastery", 2},
	require = gifts_req2,
	points = 5,
	no_energy = true,
	range = 1,
	tactical = { ATTACK = 2, DISABLE = 2 },
	on_pre_use = function(self, t, silent) if not self:hasPsiblades(true, false) then if not silent then game.logPlayer(self, "You require a psiblade in your mainhand to use this talent.") end return false end return true end,
dg's avatar
dg committed
	speedPenalty = function(self, t) return self:combatTalentLimit(t, 1, 0.18, 0.23) end,
	action = function(self, t)
		local tg = {type="hit", range=self:getTalentRange(t)}
		local x, y, target = self:getTarget(tg)
		if not x or not y or not target then return nil end
		if core.fov.distance(self.x, self.y, x, y) > 1 then return nil end
dg's avatar
dg committed
		target:setEffect(target.EFF_THORN_GRAB, 10, {src=self, speed = t.speedPenalty(self, t), dam=self:mindCrit(self:combatTalentMindDamage(t, 15, 250) / 10 * get_mindstar_power_mult(self))})
dg's avatar
dg committed
		return true
dg's avatar
dg committed
	end,		
dg's avatar
dg committed
	info = function(self, t)
dg's avatar
dg committed
		return ([[You touch the target with your psiblade, bringing the forces of nature to bear on your foe.
		Thorny vines will grab the target, slowing it by %d%% and dealing %0.2f nature damage each turn for 10 turns.
dg's avatar
dg committed
		Damage will increase with your Mindpower and Mindstar power (requires two mindstars, multiplier %2.f).]]):
dg's avatar
dg committed
		format(100*t.speedPenalty(self,t), damDesc(self, DamageType.NATURE, self:combatTalentMindDamage(t, 15, 250) / 10 * get_mindstar_power_mult(self)), get_mindstar_power_mult(self))
dg's avatar
dg committed
	end,
}

newTalent{
	name = "Leaves Tide",
	type = {"wild-gift/mindstar-mastery", 3},
	require = gifts_req3,
	points = 5,
	equilibrium = 20,
	cooldown = 25,
	tactical = { ATTACK = 2, DEFEND=3 },
	getDamage = function(self, t) return 5 + self:combatTalentMindDamage(t, 5, 35) * get_mindstar_power_mult(self) end,
	getChance = function(self, t) return util.bound(10 + self:combatTalentMindDamage(t, 3, 25), 10, 40) * get_mindstar_power_mult(self, 90) end,
	on_pre_use = function(self, t, silent) if not self:hasPsiblades(true, true) then if not silent then game.logPlayer(self, "You require two psiblades in your hands to use this talent.") end return false end return true end,
dg's avatar
dg committed
	action = function(self, t)
		-- Add a lasting map effect
		game.level.map:addEffect(self,
			self.x, self.y, 7,
			DamageType.LEAVES, {dam=self:mindCrit(t.getDamage(self, t)), chance=t.getChance(self, t)},
			3,
			5, nil,
			{type="leavestide", only_one=true},
			function(e)
				e.x = e.src.x
				e.y = e.src.y
				return true
			end,
			true
		)
		game:playSoundNear(self, "talents/icestorm")
dg's avatar
dg committed
		return true
	end,
	info = function(self, t)
		local dam = t.getDamage(self, t)
		local c = t.getChance(self, t)
dg's avatar
dg committed
		return ([[Smash your psiblades into the ground, creating a tide of crystallized leaves circling you in a radius of 3 for 7 turns.
		All foes hit by the leaves will start bleeding for %0.2f per turn (cumulative).
		All allies hit will be covered in leaves, granting them %d%% chance to completely avoid any damaging attack.
dg's avatar
dg committed
		Damage and avoidance will increase with your Mindpower and Mindstar power (requires two mindstars, multiplier %2.f).]]):
		format(dam, c, get_mindstar_power_mult(self))
dg's avatar
dg committed
	end,
}

newTalent{
	name = "Nature's Equilibrium",
	type = {"wild-gift/mindstar-mastery", 4},
	require = gifts_req4,
	points = 5,
	equilibrium = 5,
	cooldown = 15,
	range = 1,
	tactical = { ATTACK = 1, HEAL = 1, EQUILIBRIUM = 1 },
dg's avatar
dg committed
	direct_hit = true,
	requires_target = true,
	on_pre_use = function(self, t, silent) if not self:hasPsiblades(true, true) then if not silent then game.logPlayer(self, "You require two psiblades in your hands to use this talent.") end return false end return true end,
	getMaxDamage = function(self, t) return 50 + self:combatTalentMindDamage(t, 5, 250) * get_mindstar_power_mult(self) end,
dg's avatar
dg committed
	action = function(self, t)
		local main, off = self:hasPsiblades(true, true)

		local tg = {type="hit", range=self:getTalentRange(t)}
		local x, y, target = self:getTarget(tg)
		if not x or not y or not target then return nil end
		if core.fov.distance(self.x, self.y, x, y) > 1 then return nil end

		local ol = target.life
		local speed, hit = self:attackTargetWith(target, main.combat, nil, self:combatTalentWeaponDamage(t, 2.5, 4))
		local dam = util.bound(ol - target.life, 0, t.getMaxDamage(self, t))

		while hit do -- breakable if
			local tg = {default_target=self, type="hit", nowarning=true, range=1, first_target="friend"}
			local x, y, target = self:getTarget(tg)
			if not x or not y or not target then break end
			if core.fov.distance(self.x, self.y, x, y) > 1 then break end

			target:attr("allow_on_heal", 1)
DarkGod's avatar
DarkGod committed
			target:heal(dam, t)
			target:attr("allow_on_heal", -1)
			target:incEquilibrium(-dam / 10)
			if core.shader.active(4) then
DarkGod's avatar
DarkGod committed
				self:addParticles(Particles.new("shader_shield_temp", 1, {toback=true ,size_factor=1.5, y=-0.3, img="healgreen", life=25}, {type="healing", time_factor=2000, beamsCount=20, noup=2.0}))
				self:addParticles(Particles.new("shader_shield_temp", 1, {toback=false,size_factor=1.5, y=-0.3, img="healgreen", life=25}, {type="healing", time_factor=2000, beamsCount=20, noup=1.0}))
dg's avatar
dg committed
		game:playSoundNear(self, "talents/spell_generic2")
		return true
	end,
	info = function(self, t)
		return ([[You hit a foe with your mainhand psiblade doing %d%% weapon damage, channeling all the damage done through your offhand psiblade with which you touch a friendly creature to heal it.
dg's avatar
dg committed
		The maximum heal possible is %d. Equilibrium of the healed target will also decrease by 10%% of the heal power.
dg's avatar
dg committed
		Max heal will increase with your Mindpower and Mindstar power (requires two mindstars, multiplier %2.f).]]):
		format(self:combatTalentWeaponDamage(t, 2.5, 4) * 100, t.getMaxDamage(self, t), get_mindstar_power_mult(self))
dg's avatar
dg committed
	end,
}