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

Talents can be auto cast by melee weapon hit

Added one new world artifact


git-svn-id: http://svn.net-core.org/repos/t-engine4@1020 51575b47-30f0-44d4-a5cc-537603b46e54
parent 34532ec3
No related branches found
No related tags found
No related merge requests found
......@@ -97,13 +97,13 @@ function _M:init(t)
end
--- Make the actor use the talent
function _M:useTalent(id, who, force_level)
function _M:useTalent(id, who, force_level, ignore_cd, force_target)
who = who or self
local ab = _M.talents_def[id]
assert(ab, "trying to cast talent "..tostring(id).." but it is not defined")
if ab.mode == "activated" and ab.action then
if self:isTalentCoolingDown(ab) then
if self:isTalentCoolingDown(ab) and not ignore_cd then
game.logPlayer(who, "%s is still on cooldown for %d turns.", ab.name:capitalize(), self.talents_cd[ab.id])
return
end
......@@ -111,19 +111,22 @@ function _M:useTalent(id, who, force_level)
local co = coroutine.create(function()
print("USING", ab, ab.name)
local old_level
local old_target
if force_level then old_level = who.talents[id]; who.talents[id] = force_level end
if force_target then old_target = rawget(who, "getTarget"); who.getTarget = function() return force_target.x, force_target.y, force_target end end
local ret = ab.action(who, ab)
if force_target then who.getTarget = old_target end
if force_level then who.talents[id] = old_level end
if not self:postUseTalent(ab, ret) then return end
-- Everything went ok? then start cooldown if any
self:startTalentCooldown(ab)
if not ignore_cd then self:startTalentCooldown(ab) end
end)
local ok, err = coroutine.resume(co)
if not ok and err then print(debug.traceback(co)) error(err) end
elseif ab.mode == "sustained" and ab.activate and ab.deactivate then
if self:isTalentCoolingDown(ab) then
if self:isTalentCoolingDown(ab) and not ignore_cd then
game.logPlayer(who, "%s is still on cooldown for %d turns.", ab.name:capitalize(), self.talents_cd[ab.id])
return
end
......@@ -147,7 +150,7 @@ function _M:useTalent(id, who, force_level)
if not self:postUseTalent(ab, ret) then return end
-- Everything went ok? then start cooldown if any
self:startTalentCooldown(ab)
if not ignore_cd then self:startTalentCooldown(ab) end
self.sustain_talents[id] = nil
end
end)
......
......@@ -301,7 +301,7 @@ end
-- @return true if the teleport worked
function _M:teleportRandom(x, y, dist, min_dist)
return engine.Actor.teleportRandom(x, y, dist, min_dist)
return engine.Actor.teleportRandom(self, x, y, dist, min_dist)
end
--- Quake a zone
......
......@@ -212,6 +212,13 @@ function _M:getTextualDesc()
desc[#desc+1] = ("Damage on hit(melee): %s."):format(table.concat(rs, ','))
end
if self.combat and self.combat.talent_on_hit then
local rs = {}
for tid, data in pairs(self.combat.talent_on_hit) do
desc[#desc+1] = ("Talent on hit(melee): %d%% chance %s (level %d)."):format(data.chance, self:getTalentFromId(tid).name, data.level)
end
end
if w.ranged_project then
local rs = {}
for typ, dam in pairs(w.ranged_project) do
......
......@@ -252,9 +252,7 @@ function _M:attackTargetWith(target, weapon, damtype, mult)
local old_cd = self:isTalentCoolingDown(self:getTalentFromId(tid))
local old = self.energy.value
self.energy.value = 100000
self.getTarget = function() return target.x, target.y, target end
self:useTalent(tid)
self.getTarget = nil
self:useTalent(tid, nil, nil, nil, target)
self.energy.value = old
-- Do not setup a cooldown
if not old_cd then
......@@ -264,6 +262,18 @@ function _M:attackTargetWith(target, weapon, damtype, mult)
end
end
-- On hit talent
if hitted and not target.dead and weapon.talent_on_hit and next(weapon.talent_on_hit) then
for tid, data in pairs(weapon.talent_on_hit) do
if rng.percent(data.chance) then
local old = self.energy.value
self.energy.value = 100000
self:useTalent(tid, nil, data.level, true, target)
self.energy.value = old
end
end
end
-- Shattering Impact
if hitted and self:attr("shattering_impact") then
local dam = dam * self.shattering_impact
......
......@@ -496,6 +496,32 @@ After Frodo destroyed it, Elrond passed the knowledge to Aragorn the King of Men
},
},
}
newEntity{ base = "BASE_GREATMAUL",
unique = true,
name = "Mithril Hammer of Khaza'dûm", color = colors.LIGHT_RED,
unided_name = "flame scorched mithril hammer",
desc = [[The legendary hammer of the dwarven master smiths of Khaza'dûm. For ages it was used to forge powerful weapons with searing heat until it became of high power by intself.]],
level_range = {38, 50},
rarity = 250,
require = { stat = { str=48 }, },
cost = 650,
material_level = 5,
combat = {
dam = 82,
apr = 7,
physcrit = 4,
dammod = {str=1.2},
talent_on_hit = { [Talents.T_FLAMESHOCK] = {level=3, chance=10} },
},
wielder = {
inc_damage={
[DamageType.PHYSICAL] = 15,
},
melee_project={[DamageType.FIRE] = 30},
},
}
--[=[
newEntity{
unique = true,
......
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