Skip to content
Snippets Groups Projects
Commit 94b6e52d authored by dg's avatar dg
Browse files

disperce magic

git-svn-id: http://svn.net-core.org/repos/t-engine4@268 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1e8daf6e
No related branches found
No related tags found
No related merge requests found
......@@ -302,3 +302,8 @@ function rng.table(t)
local id = rng.range(1, #t)
return t[id], id
end
function rng.tableRemove(t)
local id = rng.range(1, #t)
return table.remove(t, id)
end
......@@ -44,6 +44,8 @@ function _M:init(t, no_default)
self.fatigue = 0
self.spell_cooldown_reduction = 0
self.unused_stats = self.unused_stats or 0
self.unused_talents = self.unused_talents or 0
self.unused_talents_types = self.unused_talents_types or 0
......@@ -331,6 +333,14 @@ function _M:postUseTalent(ab, ret)
return true
end
--- Starts a talent cooldown; overloaded from the default to handle talent cooldown reduction
-- @param t the talent to cooldown
function _M:startTalentCooldown(t)
if not t.cooldown then return end
self.talents_cd[t.id] = math.ceil(t.cooldown * (1 - self.spell_cooldown_reduction or 0))
self.changed = true
end
--- How much experience is this actor worth
-- @param target to whom is the exp rewarded
-- @return the experience rewarded
......
newTalent{
name = "Recharge",
type = {"spell/meta",1},
require = spells_req1,
points = 5,
mana = 80,
cooldown = 30,
action = function(self, t)
return true
end,
info = function(self, t)
return ([[Recharges a magic item.
The power increases with the Magic stat]]):format(util.bound((self:combatSpellpower(25) * self:getTalentLevel(t)) / 100, 0.1, 0.4))
end,
}
newTalent{
name = "Disperse Magic",
type = {"spell/meta",2},
require = spells_req2,
points = 5,
mana = 40,
cooldown = 7,
action = function(self, t)
local target = self
if self:getTalentLevel(t) >= 3 then
local tx, ty = self:getTarget{type="hit", range=self:getTalentRange(t)}
if game.level.map(tx, ty, Map.ACTOR) then
target = game.level.map(tx, ty, Map.ACTOR)
end
end
local effs = {}
-- Go through all spell effects
for eff_id, p in pairs(target.tmp) do
effs[#effs+1] = {"effect", eff_id}
end
-- Go through all sustained spells
for tid, act in pairs(target.sustain_talents) do
if act then
effs[#effs+1] = {"talent", tid}
end
end
for i = 1, math.floor(self:getTalentLevel(t)) do
if #effs == 0 then break end
local eff = rng.tableRemove(effs)
if eff[1] == "effect" then
target:removeEffect(eff[2])
else
local old = target.energy.value
target:useTalent(eff[2])
-- Prevent using energy
target.energy.value = old
end
end
return true
end,
info = function(self, t)
return ([[Removes up to %d magical effects (both good or bad) from the target.
At level 3 it can be targetted.
]]):format(self:getTalentLevel(t))
end,
}
newTalent{
name = "Quicken Spells",
type = {"spell/meta",3},
require = spells_req3,
points = 5,
mode = "sustained",
sustain_mana = 150,
cooldown = 30,
tactical = {
BUFF = 10,
},
activate = function(self, t)
local power = util.bound(self:getTalentLevel(t) / 15, 0.05, 0.3)
return {
cd = self:addTemporaryValue("spell_cooldown_reduction", power),
}
end,
deactivate = function(self, t, p)
self:removeTemporaryValue("spell_cooldown_reduction", p.cd)
return true
end,
info = function(self, t)
return ([[Reduces the cooldown of all spells by %d%%.
The reduction increases with the Magic stat]]):format(util.bound(self:getTalentLevel(t) / 15, 0.05, 0.3) * 100)
end,
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment