Advertisement
Guest User

Poisons

a guest
Nov 4th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.65 KB | None | 0 0
  1. -- ToME - Tales of Maj'Eyal
  2. -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
  3. --
  4. -- This program is free software: you can redistribute it and/or modify
  5. -- it under the terms of the GNU General Public License as published by
  6. -- the Free Software Foundation, either version 3 of the License, or
  7. -- (at your option) any later version.
  8. --
  9. -- This program is distributed in the hope that it will be useful,
  10. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. -- GNU General Public License for more details.
  13. --
  14. -- You should have received a copy of the GNU General Public License
  15. -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. --
  17. -- Nicolas Casalini "DarkGod"
  18.  
  19. local _M = loadPrevious(...)
  20.  
  21. local function cancelPoisons(self)
  22.     local todel = {}
  23.     for tid, p in pairs(self.sustain_talents) do
  24.         local t = self:getTalentFromId(tid)
  25.         if t.type[1] == "cunning/poisons-effects" then
  26.             todel[#todel+1] = tid
  27.         end
  28.     end
  29.     while #todel > 1 do self:forceUseTalent(rng.tableRemove(todel), {ignore_energy=true}) end
  30. end
  31.  
  32. newTalent{
  33.     name = "Deadly Poison", short_name = "D_POISON",
  34.     type = {"cunning/poisons", 1},
  35.     require = cuns_req1,
  36.     mode = "sustained",
  37.     points = 5,
  38.     cooldown = 10,
  39.     no_break_stealth = true,
  40.     tactical = { BUFF = 2 },
  41.     getDuration = function(self, t) return math.floor(self:combatTalentScale(t, 4, 7)) end,
  42.     getChance = function(self,t) return 20 + self:getTalentLevel(t) * 5 end,
  43.     getDamage = function(self, t) return 8 + self:combatTalentStatDamage(t, "cun", 10, 60) * 0.4 end,
  44.     callbackOnMeleeAttack = function(self, t, target, hitted, crit, weapon, damtype, mult, dam)
  45.         if target and target:canBe("poison") and rng.percent(t.getChance(self,t)) then
  46.             if self.vile_poisons and next(self.vile_poisons) then
  47.                 local tid = rng.table(table.keys(self.vile_poisons))
  48.                 if tid then
  49.                     local t = self:getTalentFromId(tid)
  50.                     t.proc2(self, t, target, weapon)
  51.                 end
  52.             else
  53.                 target:setEffect(target.EFF_POISONED, t.getDuration(self, t), {src=self, power=t.getDamage(self, t), max_power=t.getDamage(self, t) * 4, apply_power=self:combatAttack()})
  54.             end
  55.         end
  56.     end,
  57.     activate = function(self, t)
  58.         local ret = {
  59.         }
  60.         return ret
  61.     end,
  62.     deactivate = function(self, t, p)
  63.         return true
  64.     end,
  65.     info = function(self, t)
  66.         return ([[Learn how to coat your melee weapons, throwing knives, sling and bow ammo with poison, giving your attacks a %d%% chance to poison the target for %d nature damage per turn for %d turns. Every application of the poison stacks, up to a maximum of %d nature damage per turn.
  67.         The damage scales with your Cunning.]]):
  68.         format(t.getChance(self,t), damDesc(self, DamageType.NATURE, t.getDamage(self, t)), t.getDuration(self, t), damDesc(self, DamageType.NATURE, t.getDamage(self, t)*4))
  69.     end,
  70. }
  71.  
  72. Talents.talents_def.T_EMPOWER_POISONS.hide = true
  73.  
  74. Talents.talents_def.T_TOXIC_DEATH.getChance = function(self, t) return self:combatTalentScale(t, 10, 30) end
  75. Talents.talents_def.T_TOXIC_DEATH.radius = function(self, t) return math.floor(self:combatTalentScale(t, 2, 4)) end
  76. Talents.talents_def.T_TOXIC_DEATH.type = {"cunning/poisons", 2}
  77. Talents.talents_def.T_TOXIC_DEATH.require = cuns_req2
  78. Talents.talents_def.T_TOXIC_DEATH.callbackOnMeleeAttack = function(self, t, target, hitted, crit, weapon, damtype, mult, dam)
  79.    
  80.         if target and rng.percent(t.getChance(self,t)) then
  81.             local poisons = {}
  82.             for k, v in pairs(target.tmp) do
  83.                 local e = target.tempeffect_def[k]
  84.                 if e.subtype.poison and v.src and v.src == self then
  85.                     poisons[k] = target:copyEffect(k)
  86.                 end
  87.             end
  88.            
  89.             local tg = {type="ball", range = 10, radius=1, selffire = false, friendlyfire = false, talent=t}
  90.             self:project(tg, target.x, target.y, function(tx, ty)
  91.                 local target2 = game.level.map(tx, ty, Map.ACTOR)
  92.                 if not target2 or target2 == self then return end
  93.                 for eff, p in pairs(poisons) do
  94.                     target2:setEffect(eff, p.dur, table.clone(p))
  95.                 end
  96.             end)
  97.         end
  98. end
  99. Talents.talents_def.T_TOXIC_DEATH.on_kill = function(self, t, target)
  100.         local poisons = {}
  101.         for k, v in pairs(target.tmp) do
  102.             local e = target.tempeffect_def[k]
  103.             if e.subtype.poison and v.src and v.src == self then
  104.                 poisons[k] = target:copyEffect(k)
  105.             end
  106.         end
  107.  
  108.         local tg = {type="ball", range = 10, radius=self:getTalentRadius(t), selffire = false, friendlyfire = false, talent=t}
  109.         self:project(tg, target.x, target.y, function(tx, ty)
  110.             local target2 = game.level.map(tx, ty, Map.ACTOR)
  111.             if not target2 or target2 == self then return end
  112.             for eff, p in pairs(poisons) do
  113.                 target2:setEffect(eff, p.dur, table.clone(p))
  114.             end
  115.         end)
  116.     end
  117. Talents.talents_def.T_TOXIC_DEATH.info = function(self, t)
  118.         chance = t.getChance(self,t)
  119.         rad = self:getTalentRadius(t)
  120.         return ([[Your melee attacks have a %d%% chance to spray envenomed blood from your enemy, spreading their poisons to adjacent enemies.
  121.     Killing a creature instead gives a %d%% chance for poisons to spread to foes in a radius of %d.]]):
  122.         format(chance, 20 + self:getTalentLevelRaw(t) * 8, rad)
  123. end
  124.  
  125. Talents.talents_def.T_VILE_POISONS.type = {"cunning/poisons", 3}
  126. Talents.talents_def.T_VILE_POISONS.require = cuns_req3
  127. Talents.talents_def.T_VILE_POISONS.on_learn = function(self, t)
  128.         local lev = self:getTalentLevelRaw(t)
  129.         if lev == 1 then
  130.             self.vile_poisons = {}
  131.             self:learnTalent(self.T_NUMBING_POISON, true, nil, {no_unlearn=true})
  132.         elseif lev == 2 then
  133.             self:learnTalent(self.T_INSIDIOUS_POISON, true, nil, {no_unlearn=true})
  134.         elseif lev == 3 then
  135.             self:learnTalent(self.T_CRIPPLING_POISON, true, nil, {no_unlearn=true})
  136.         elseif lev == 4 then
  137.             self:learnTalent(self.T_LEECHING_POISON, true, nil, {no_unlearn=true})
  138.         elseif lev == 5 then
  139.             self:learnTalent(self.T_VOLATILE_POISON, true, nil, {no_unlearn=true})
  140.         end
  141.     end
  142. Talents.talents_def.T_VILE_POISONS.on_unlearn = function(self, t)
  143.         local lev = self:getTalentLevelRaw(t)
  144.         if lev == 0 then
  145.             self:unlearnTalent(self.T_NUMBING_POISON)
  146.             self.vile_poisons = nil
  147.         elseif lev == 1 then
  148.             self:unlearnTalent(self.T_INSIDIOUS_POISON)
  149.         elseif lev == 2 then
  150.             self:unlearnTalent(self.T_CRIPPLING_POISON)
  151.         elseif lev == 3 then
  152.             self:unlearnTalent(self.T_LEECHING_POISON)
  153.         elseif lev == 4 then
  154.             self:unlearnTalent(self.T_VOLATILE_POISON)
  155.         end
  156.     end
  157. Talents.talents_def.T_VILE_POISONS.info = function(self, t)
  158.     return ([[Learn how to enhance your Deadly Poison with new effects, causing it's standard poison to be replaced with a new effect. Each level, you will learn a new kind of poison:
  159.     Level 1: Numbing Poison
  160.     Level 2: Insidious Poison
  161.     Level 3: Crippling Poison
  162.     Level 4: Leeching Poison
  163.     Level 5: Volatile Poison
  164. New poisons can also be learned from special teachers in the world.
  165. Also increases the effectiveness of your poisons by %d%%. (The effect varies for each poison.)
  166. Coating your weapons in poisons does not break stealth.
  167. You may only have two poisons active at once, and the one which is applied is randomly determined.]]):
  168. format(self:getTalentLevel(t) * 20)
  169.     end
  170.  
  171. Talents.talents_def.T_NUMBING_POISON.proc = function(self, t, target)
  172. end
  173. Talents.talents_def.T_NUMBING_POISON.proc2 = function(self, t, target)
  174.     local dam = self:callTalent(self.T_D_POISON, "getDamage")
  175.     local dur = self:callTalent(self.T_D_POISON, "getDuration")
  176.     target:setEffect(target.EFF_NUMBING_POISON, dur, {src=self, power=dam, reduce=t.getEffect(self, t), max_power=dam*2})
  177. end
  178. Talents.talents_def.T_NUMBING_POISON.info = function(self, t)
  179.     return ([[Enhances your Deadly Poison with a numbing agent, causing it to reduce the damage dealt by enemies by %d%%.]]):
  180.     format(t.getEffect(self, t))
  181. end
  182.  
  183. Talents.talents_def.T_INSIDIOUS_POISON.proc = function(self, t, target)
  184. end
  185. Talents.talents_def.T_INSIDIOUS_POISON.proc2 = function(self, t, target)
  186.     local dam = self:callTalent(self.T_D_POISON, "getDamage")
  187.     local dur = self:callTalent(self.T_D_POISON, "getDuration")
  188.     target:setEffect(target.EFF_INSIDIOUS_POISON, dur, {src=self, power=dam, heal_factor=t.getEffect(self, t), max_power=dam*2})
  189. end
  190. Talents.talents_def.T_INSIDIOUS_POISON.info = function(self, t)
  191.     return ([[Enhances your Deadly Poison with an insidious agent, causing it to reduce the healing taken by enemies by %d%%.]]):
  192.     format(t.getEffect(self, t))
  193. end
  194.  
  195. Talents.talents_def.T_CRIPPLING_POISON.proc = function(self, t, target)
  196. end
  197. Talents.talents_def.T_CRIPPLING_POISON.proc2 = function(self, t, target)
  198.     local dam = self:callTalent(self.T_D_POISON, "getDamage")
  199.     local dur = self:callTalent(self.T_D_POISON, "getDuration")
  200.     target:setEffect(target.EFF_CRIPPLING_POISON, dur, {src=self, power=dam, fail=t.getEffect(self, t), max_power=dam*2})
  201. end
  202. Talents.talents_def.T_CRIPPLING_POISON.info = function(self, t)
  203.     return ([[Enhances your Deadly Poison with a crippling agent, giving enemies a %d%% chance on using a talent to fail and lose a turn.]]):
  204.     format(t.getEffect(self, t))
  205. end
  206.  
  207. newTalent{
  208.     name = "Leeching Poison",
  209.     type = {"cunning/poisons-effects", 1},
  210.     points = 1,
  211.     mode = "sustained",
  212.     cooldown = 10,
  213.     no_break_stealth = true,
  214.     no_energy = true,
  215.     tactical = { BUFF = 2 },
  216.     no_unlearn_last = true,
  217.     getEffect = function(self, t) return self:combatTalentLimit(self:getTalentLevel(self.T_VILE_POISONS), 150, 50, 100) end, -- Limit effect to < 50%
  218.     proc2 = function(self, t, target)
  219.         local dam = self:callTalent(self.T_D_POISON, "getDamage")
  220.         local dur = self:callTalent(self.T_D_POISON, "getDuration")
  221.         target:setEffect(target.EFF_LEECHING_POISON, dur, {src=self, power=dam, heal=t.getEffect(self, t), max_power=dam*2})
  222.     end,
  223.     activate = function(self, t)
  224.         cancelPoisons(self)
  225.         self.vile_poisons = self.vile_poisons or {}
  226.         self.vile_poisons[t.id] = true
  227.         return {}
  228.     end,
  229.     deactivate = function(self, t, p)
  230.         self.vile_poisons[t.id] = nil
  231.         return true
  232.     end,
  233.     info = function(self, t)
  234.     return ([[Enhances your Deadly Poison with a leeching agent, causing the poison to heal you for %d%% of the damage dealt.]]):
  235.     format(t.getEffect(self, t))
  236.     end,
  237. }
  238.  
  239. newTalent{
  240.     name = "Volatile Poison",
  241.     type = {"cunning/poisons-effects", 1},
  242.     points = 1,
  243.     mode = "sustained",
  244.     cooldown = 10,
  245.     no_break_stealth = true,
  246.     no_energy = true,
  247.     tactical = { BUFF = 2 },
  248.     no_unlearn_last = true,
  249.     proc2 = function(self, t, target)
  250.         local dam = self:callTalent(self.T_D_POISON, "getDamage")
  251.         local dur = self:callTalent(self.T_D_POISON, "getDuration")
  252.         target:setEffect(target.EFF_VOLATILE_POISON, dur, {src=self, power=dam, max_power=dam*2})
  253.     end,
  254.     activate = function(self, t)
  255.         cancelPoisons(self)
  256.         self.vile_poisons = self.vile_poisons or {}
  257.         self.vile_poisons[t.id] = true
  258.         return {}
  259.     end,
  260.     deactivate = function(self, t, p)
  261.         self.vile_poisons[t.id] = nil
  262.         return true
  263.     end,
  264.     info = function(self, t)
  265.     return ([[Enhances your Deadly Poison with a volatile agent, causing the poison to also damage adjacent enemies.]]):
  266.     format()
  267.     end,
  268. }
  269.  
  270. local temp = Talents.talents_types_def["cunning/poisons"].talents[1]
  271. Talents.talents_types_def["cunning/poisons"].talents[1] = Talents.talents_types_def["cunning/poisons"].talents[3]
  272. Talents.talents_types_def["cunning/poisons"].talents[3] = temp
  273.  
  274. local temp2 = Talents.talents_types_def["cunning/poisons"].talents[5]
  275. Talents.talents_types_def["cunning/poisons"].talents[5] = Talents.talents_types_def["cunning/poisons"].talents[1]
  276. Talents.talents_types_def["cunning/poisons"].talents[1] = temp2
  277.  
  278. local temp3 = Talents.talents_types_def["cunning/poisons"].talents[2]
  279. Talents.talents_types_def["cunning/poisons"].talents[2] = Talents.talents_types_def["cunning/poisons"].talents[4]
  280. Talents.talents_types_def["cunning/poisons"].talents[4] = temp3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement