ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Mon Mar 01, 2021 8:26 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Jun 30, 2016 7:29 pm 

Joined: Tue May 14, 2013 3:45 pm
Posts: 888
I'm working on some archer tweaks, and duplicated Intuitive Shots while shuffling trees around. I'm trying to replicate the cancellation of attacks from it proccing, but I can't seem to get it to work. Also, Intuitive Shots itself doesn't seem to be cancelling attacks when it procs. Not sure if it's a main game bug or just me breaking stuff. Code below:

   name = "Intuitive Shots", short_name = "INTUITIVE_SHOTS_RAZ",
   type = {"technique/reflexes_raz", 2},
   mode = "sustained",
   points = 5,
   cooldown = 10,
   sustain_stamina = 30,
   no_energy = true,
   require = techs_dex_req2,
   tactical = { BUFF = 2 },
   getChance = function(self, t) return math.floor(self:combatTalentLimit(t, 50, 5, 40)) end,
   getDamage = function(self, t) return self:combatTalentWeaponDamage(t, 0.4, 0.9) end,
   -- called by _M:attackTarget in mod.class.interface.Combat.lua
   proc = function(self, t, target)
      local weapon, ammo = self:hasArcheryWeapon()
      if not weapon then return end
      if self.turn_procs.intuitive_shots and self.turn_procs.intuitive_shots ~= target then return end
      if self.turn_procs.intuitive_shots == target then return true end
      local targets = self:archeryAcquireTargets(nil, {one_shot=true, x=target.x, y=target.y}) --Ammo check done here
      if not targets then return end
      self.turn_procs.intuitive_shots = target
      local xatk, ret = 1e6, true
      --Precheck hit chance so a miss doesn't stop the melee attack
      if not self:checkHit(self:combatAttackRanged(weapon, ammo), target:combatDefenseRanged()) or target:checkEvasion(self) then
         xatk, ret = -1e6, false
      game.logSeen(self, "%s %s the attack!",, ret and "intercepts" or "fails to intercept")
      self:archeryShoot(targets, t, nil, {atk = xatk, mult=self:combatTalentWeaponDamage(t, 0.4, 0.9)})
      return ret
   on_pre_use = function(self, t, silent) return archerPreUse(self, t, silent) end,
   activate = function(self, t)
      return {}
   deactivate = function(self, t, p)
      return true
   info = function(self, t)
      local chance = t.getChance(self,t)
      local dam = t.getDamage(self,t)*100
      return ([[Activating this talent enhances your reflexes to incredible levels.  Each time you are attacked in melee, you have a %d%% chance get a defensive shot off in time to intercept the attack, fully disrupting it (including extra blows from certain talents) and dealing %d%% archery damage.
      This cannot damage the same target more than once per turn.]])
      :format(chance, dam)

class:bindHook("Combat:attackTarget", function(self, data)
   data.mult = data.mult or 1
   local speed, hit, damtype, mult, target = data.speed, data.hit, data.damtype, data.mult,
   local sound, sound_miss

   if target:isTalentActive(target.T_INTUITIVE_SHOTS_RAZ) and rng.percent(target:callTalent(target.T_INTUITIVE_SHOTS_RAZ, "getChance")) then
      local ret = target:callTalent(target.T_INTUITIVE_SHOTS_RAZ, "proc", self)
      if ret then return false end
   data.speed, data.hit, data.damtype, data.mult = speed, hit, damtype, mult
   return data

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group