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

Vim correctly refunds when killing foes with a Vim using talent in all cases

git-svn-id: http://svn.net-core.org/repos/t-engine4@4514 51575b47-30f0-44d4-a5cc-537603b46e54
parent ab99a18b
No related branches found
No related tags found
No related merge requests found
......@@ -75,12 +75,12 @@ function _M:takeHit(value, src, death_note)
end
--- Called when died
function _M:die(src)
function _M:die(src, death_note)
if game.level:hasEntity(self) then game.level:removeEntity(self) end
self.dead = true
self.changed = true
self:check("on_die", src)
self:check("on_die", src, death_note)
end
--- Actor is being attacked!
......
......@@ -1434,10 +1434,10 @@ function _M:resolveSource()
end
end
function _M:die(src)
function _M:die(src, death_note)
if self.dead then self:disappear(src) self:deleteFromMap(game.level.map) return true end
engine.interface.ActorLife.die(self, src)
engine.interface.ActorLife.die(self, src, death_note)
-- Gives the killer some exp for the kill
local killer = nil
......@@ -1628,7 +1628,12 @@ function _M:die(src)
-- Increase vim
if src and src.knowTalent and src:knowTalent(src.T_VIM_POOL) then src:incVim(1 + src:getWil() / 10) end
if src and src.attr and src:attr("vim_on_death") and not self:attr("undead") then src:incVim(src:attr("vim_on_death")) end
if src and src.last_vim_turn and src.last_vim_turn >= game.turn - 30 then src:incVim(src.last_vim_spent) src.last_vim_turn = nil end
if src and death_note and death_note.source_talent and death_note.source_talent.vim and src.last_vim_turn ~= game.turn then
src.last_vim_turn = game.turn
game:onTickEnd(function() -- Do it on tick end to make sure Vim is spent by the talent code before being refunded
src:incVim(death_note.source_talent.vim)
end)
end
if src and ((src.resolveSource and src:resolveSource().player) or src.player) then
-- Achievements
......@@ -2428,12 +2433,6 @@ function _M:preUseTalent(ab, silent, fake)
end
end
-- Log vim usage for free vim on kill
if not fake and ab.vim then
self.last_vim_turn = game.turn
self.last_vim_spent = ab.vim
end
return true
end
......
......@@ -180,7 +180,7 @@ function _M:onTakeHit(value, src)
return value
end
function _M:die(src)
function _M:die(src, death_note)
if self.dead then self:disappear(src) self:deleteFromMap(game.level.map) return true end
if src and Faction:get(self.faction) and Faction:get(self.faction).hostile_on_attack then
......@@ -255,7 +255,7 @@ function _M:die(src)
-- Ok the player managed to kill a boss dont bother him with tutorial anymore
if self.rank >= 3.5 and not profile.mod.allow_build.tutorial_done then game:setAllowedBuild("tutorial_done") end
return mod.class.Actor.die(self, src)
return mod.class.Actor.die(self, src, death_note)
end
function _M:tooltip(x, y, seen_by)
......
......@@ -171,8 +171,9 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
print("[PROJECTOR] final dam", dam)
local source_talent = src.__projecting_for and src.__projecting_for.project_type and (src.__projecting_for.project_type.talent_id or src.__projecting_for.project_type.talent) and src.getTalentFromId and src:getTalentFromId(src.__projecting_for.project_type.talent or src.__projecting_for.project_type.talent_id)
local dead
dead, dam = target:takeHit(dam, src, {damtype=type})
dead, dam = target:takeHit(dam, src, {damtype=type, source_talent=source_talent})
-- Log damage for later
if not DamageType:get(type).hideMessage then
......@@ -206,8 +207,8 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
game.logSeen(target, "%s is healed by the %s%s#LAST# damage!", target.name:capitalize(), DamageType:get(type).text_color or "#aaaaaa#", DamageType:get(type).name)
end
if dam > 0 and src.__projecting_for and src.__projecting_for.project_type and (src.__projecting_for.project_type.talent_id or src.__projecting_for.project_type.talent) and src.getTalentFromId then
local t = src:getTalentFromId(src.__projecting_for.project_type.talent or src.__projecting_for.project_type.talent_id)
if dam > 0 and source_talent then
local t = source_talent
if src:attr("spellshock_on_damage") and target:checkHit(src:combatSpellpower(), target:combatPhysicalResist(), 0, 95, 15) and not target:hasEffect(target.EFF_SPELLSHOCKED) then
target:crossTierEffect(target.EFF_SPELLSHOCKED, src:combatSpellpower())
......
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