ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Fri May 24, 2019 2:56 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 28, 2015 9:15 pm 

Joined: Tue May 14, 2013 3:45 pm
Posts: 850
I have an ability that's a spin on the usual 'make X random attacks against targets in an area'. Effectively this will fire up to X projectiles against targets in a cone, and if there are more projectiles than targets a target can be hit up to 3 times. However, currently it seems a little buggy and sometimes exceeds the number of projectiles. Is there a better way to write this?

   name = "Fan of Knives",
   type = {"technique/throwing-knives", 2},
   require = techs_dex_req2,
   points = 5,
   tactical = { ATTACKAREA = 3 },
   getDamage = function (self, t) return self:combatTalentWeaponDamage(t, 0.6, 1.2) end,
   getNb = function(self, t) return math.floor(self:combatTalentScale(t, 4, 8)) end,
   range = 0,
   cooldown = 10,
   stamina = 20,
   radius = function(self, t) return math.floor(self:combatTalentScale(t, 3, 7)) end,
   target = function(self, t)
      return {type="cone", range=self:getTalentRange(t), friendlyfire=false, radius=self:getTalentRadius(t)}
   action = function(self, t)
      local tg = self:getTalentTarget(t)
      local x, y = self:getTarget(tg)
      if not x or not y then return end

      local nb = t.getNb(self,t)
      local count = t.getNb(self,t)
      local tgts = {}
      grids = self:project(tg, x, y, function(px, py)
         local target =, py, engine.Map.ACTOR)
         if not target then return end
         tgts[#tgts+1] = target

      while count > 0 do
         if #tgts <= 0 then break end
         for i = 1, math.min(nb, #tgts) do
            local a, id = tgts[i]
            local tg2 = {type="bolt", range=self:getTalentRadius(t), selffire=false, talent=t, display={display='', particle="arrow", particle_args={tile="shockbolt/object/knife_steel"} }}
               self:projectile(tg2, a.x, a.y, function(px, py, tg2, self)
                  local target =, py, engine.Map.ACTOR)
                  if target and target ~= self then
                     local t2 = self:getTalentFromId(self.T_THROWING_KNIVES)
                     self:attackTargetWith(target, t2.getKnives(self, t), nil, t.getDamage(self,t))
                     target.turn_procs.fan_of_knives = 1 + (target.turn_procs.fan_of_knives or 0)
                     if target.turn_procs.fan_of_knives==3 then table.remove(tgts, id) end
               count = count - 1

      return true
   info = function(self, t)
      return ([[Throw up to %d throwing knives at enemies within a radius %d cone, for %d%% damage each. If the number of knives exceeds the number of enemies, a target can be hit up to 3 times.]]):
      format(t.getNb(self,t), self:getTalentRadius(t), t.getDamage(self, t)*100)

PostPosted: Wed Oct 28, 2015 11:47 pm 
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5876
Oh god, yes it can be better.
But I can't write it for you at the moment.

My feedback meter decays into coding. Give me feedback and I make mods.

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

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

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