• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
m
no edit summary
Line 183: Line 183:  
-- * Ship object with extra fields related to combat.
 
-- * Ship object with extra fields related to combat.
   −
local Ship = {}
+
function Combat.ship(ship, equip, night_attack, spotting)
   −
function Ship:new(ship, equip, night_attack, spotting)
+
local ship = {
 +
_firepower_max = ship._firepower_max or 0,
 +
_torpedo_max = ship._torpedo_max or 0,
 +
_luck = ship._luck or 0,
 +
equipment = equip or {},
 +
equipment_bonus = { firepower = 0, torpedo = 0 },
 +
health = ship.health or Combat.modifier.health.normal,
 +
anti_ground = ship.anti_ground and Combat.modifier.anti_ground or 1,
 +
anti_ground_bonus = ship.wg and Combat.modifier.wg_bonus or 0,
 +
anti_sub = ship.anti_sub or 1,
 +
night_attack = night_attack or 1,
 +
night_attack_x2 = night_attack == Combat.modifier.night_attack.cut_in.torpedo or
 +
  night_attack == Combat.modifier.night_attack.cut_in.mixed,
 +
spotting = spotting or 1,
 +
critical = ship.critical or 1,
 +
ap = ship.ap or 1,
 +
ammo = ship.ammo or 1,
 +
}
   −
self._firepower_max = ship._firepower_max or 0
+
for _, eq in pairs(ship.equipment) do
self._torpedo_max = ship._torpedo_max or 0
  −
self._luck = ship._luck or 0
  −
 
  −
self.equipment = equip or {}
  −
self.equipment_bonus = { firepower = 0, torpedo = 0 }
  −
for _, eq in pairs(self.equipment) do
   
if eq.firepower then
 
if eq.firepower then
self.equipment_bonus.firepower = self.equipment_bonus.firepower + eq.firepower + (eq.k and eq.rank and eq.k * math.sqrt(eq.rank) or 0)
+
ship.equipment_bonus.firepower = ship.equipment_bonus.firepower + eq.firepower + (eq.k and eq.rank and eq.k * math.sqrt(eq.rank) or 0)
 
end
 
end
 
if eq.torpedo then
 
if eq.torpedo then
self.equipment_bonus.torpedo = self.equipment_bonus.torpedo + eq.torpedo + (eq.k and eq.rank and eq.k * math.sqrt(eq.rank) or 0)
+
ship.equipment_bonus.torpedo = ship.equipment_bonus.torpedo + eq.torpedo + (eq.k and eq.rank and eq.k * math.sqrt(eq.rank) or 0)
 
end
 
end
 
end
 
end
self.equipment_bonus.firepower = math.floor(self.equipment_bonus.firepower)
+
ship.equipment_bonus.firepower = math.floor(ship.equipment_bonus.firepower)
self.equipment_bonus.torpedo = math.floor(self.equipment_bonus.torpedo)
+
ship.equipment_bonus.torpedo = math.floor(ship.equipment_bonus.torpedo)
   −
self.health = ship.health or Combat.modifier.health.normal
+
return ship
self.anti_ground = ship.anti_ground and Combat.modifier.anti_ground or 1
  −
self.anti_ground_bonus = ship.wg and Combat.modifier.wg_bonus or 0
  −
self.anti_sub = ship.anti_sub or 1
  −
self.night_attack = night_attack or 1
  −
self.night_attack_x2 = night_attack == Combat.modifier.night_attack.cut_in.torpedo or
  −
  night_attack == Combat.modifier.night_attack.cut_in.mixed
  −
self.spotting = spotting or 1
  −
self.critical = ship.critical or 1
  −
self.ap = ship.ap or 1
  −
self.ammo = ship.ammo or 1
  −
return self
      
end
 
end
Line 317: Line 317:  
function format_damage(ship_, type_code, damage_type_fn, equip_setup, night_attack, spotting)
 
function format_damage(ship_, type_code, damage_type_fn, equip_setup, night_attack, spotting)
 
local combat = Combat:new(night_attack)
 
local combat = Combat:new(night_attack)
local normal_damage = combat:damage(damage_type_fn(combat, Ship:new(ship_, {}, night_attack)))
+
local normal_damage = combat:damage(damage_type_fn(combat,Combat.ship(ship_, {}, night_attack)))
 
local normal_damage_string =
 
local normal_damage_string =
 
normal_damage >= combat.cap
 
normal_damage >= combat.cap
Line 324: Line 324:  
local equip = equipment[type_code][equip_setup]
 
local equip = equipment[type_code][equip_setup]
 
spotting = spotting or 1
 
spotting = spotting or 1
local equip_damage_pre = combat:damage(damage_type_fn(combat, Ship:new(ship_, equip, night_attack)))
+
local equip_damage_pre = combat:damage(damage_type_fn(combat, Combat.ship(ship_, equip, night_attack)))
local equip_damage = combat:damage(damage_type_fn(combat, Ship:new(ship_, equip, night_attack, spotting)))
+
local equip_damage = combat:damage(damage_type_fn(combat, Combat.ship(ship_, equip, night_attack, spotting)))
 
local equip_damage_string =
 
local equip_damage_string =
 
equip_damage_pre >= combat.cap
 
equip_damage_pre >= combat.cap
cssedit, gkautomate
6,928

edits

Navigation menu