Difference between revisions of "Module:Stab bonus"

From CrawlWiki
Jump to: navigation, search
(Module to generate bonus table for Stabbing)
 
m (Undo revision 75038 by Hordes (talk))
 
(6 intermediate revisions by 4 users not shown)
Line 14: Line 14:
 
local function stab_bonus(skill, weapon)
 
local function stab_bonus(skill, weapon)
 
   local bonuses = {}
 
   local bonuses = {}
   for _, tier in ipairs({1, 2, 4, 6}) do
+
   for _, tier in ipairs({1, 4,}) do
 
     table.insert(bonuses, stab_weapon(skill, weapon, tier))
 
     table.insert(bonuses, stab_weapon(skill, weapon, tier))
 
   end
 
   end
Line 24: Line 24:
 
|-
 
|-
 
! rowspan=2 | Stealth/Weapon skill average
 
! rowspan=2 | Stealth/Weapon skill average
! colspan=4 | Short Blades
+
! colspan=2 | Short Blades
! colspan=4 | Others
+
! colspan=2 | Others
 +
|-
 +
! High-Tier
 +
! Low-Tier
 +
! High-Tier
 +
! Low-Tier
 
|-
 
|-
! Tier 1
 
! Tier 2
 
! Tier 3
 
! Tier 4
 
! Tier 1
 
! Tier 2
 
! Tier 3
 
! Tier 4
 
 
]=]
 
]=]
 
   for i = 1, 27 do
 
   for i = 1, 27 do

Latest revision as of 06:33, 22 September 2023

Documentation for this module may be created at Module:Stab bonus/doc

local p = {}

-- This function is based on player_stab_weapon_bonus in attack.cc
local function stab_weapon(skill, weapon, tier)
  local damage = 1
  if weapon ~= "Others" then
    damage = damage * (1 + skill / (tier * 10))
  end

  damage = damage*(1 + skill / (tier*12))
  return 100*(damage-1)
end

local function stab_bonus(skill, weapon)
  local bonuses = {}
  for _, tier in ipairs({1, 4,}) do
    table.insert(bonuses, stab_weapon(skill, weapon, tier))
  end
  return bonuses
end

function p.stab_table(frame)
  local ret = [=[{| class="prettytable" style="border:none; margin:0; padding:0;"
|-
! rowspan=2 | Stealth/Weapon skill average
! colspan=2 | Short Blades
! colspan=2 | Others
|-
! High-Tier
! Low-Tier
! High-Tier
! Low-Tier
|-
]=]
  for i = 1, 27 do
    ret = ret .. ("| %d\n"):format(i)
    for _, bonus in ipairs(stab_bonus(i, "Short Blades")) do
      ret = ret .. ("| %+.1f%%\n"):format(bonus)
    end
    for _, bonus in ipairs(stab_bonus(i, "Others")) do
      ret = ret .. ("| %+.1f%%\n"):format(bonus)
    end
    ret = ret .. "|-\n"
  end
  ret = ret .. "|}\n"
  return ret
end

return p