Changes

Try fixing the condition of opening torpedo (see the comments)
Line 272: Line 272:  
end
 
end
   −
function ShipCapabilities:_is_midget_submarine(equipment)
+
function ShipCapabilities:_is_wg(equipment)
return equipment:type() == 22
+
return equipment:type() == 37
 
end
 
end
   −
function ShipCapabilities:_is_wg(equipment)
+
function ShipCapabilities:_opening_torpedo_conditon(ship)
return equipment:type() == 37
+
    if not ship then
 +
        ship = self._ship
 +
    end
 +
   
 +
    local has_special_equipment = false
 +
    for i = 1, ship:slot_length() or 0 do
 +
        local equipment, size = ship:slot(i)
 +
        if equipment:id() == 41 or equipment:id() == 541 then
 +
            has_special_equipment = true
 +
        end
 +
    end
 +
    -- copied from Vita ver
 +
    -- Kouhyouteki and Abyssal Cuttelfish Torpedo,
 +
    -- but not midget submarines, are treated solely.
 +
    -- It seems that Abyssal Ambush Torpedo and High-speed Abyssal Torpedo mod.2
 +
    -- cannot perform opening torpedo.
 +
   
 +
    if ship:type() == 13 or ship:type() == 14 then
 +
        if ship._id > 1500 then
 +
            return string.find(ship._suffix, "[Ff]lagshp|[Ee]lite") ~= nil
 +
            -- copied from Vita ver
 +
        else
 +
            local level = ship:level()
 +
            return has_special_equipment or (level and level >= 10)
 +
        end
 +
    else
 +
        return has_special_equipment
 +
    end
 
end
 
end
   Line 583: Line 610:  
-- Basic attack power for opening torpedo, including fleet torpedo.
 
-- Basic attack power for opening torpedo, including fleet torpedo.
 
function ShipCapabilities:opening_torpedo(fleet_torpedo)
 
function ShipCapabilities:opening_torpedo(fleet_torpedo)
local torpedo = self._ship:torpedo_leveled()
+
    return _opening_torpedo_conditon(self._ship) and closing_torpedo(fleet_torpedo)
local opening_torpedo = self._ship:opening_torpedo()
+
    -- With the new implementation we can remove _opening_torpedo attribute
if (opening_torpedo ~= true) and (opening_torpedo == false or not torpedo or torpedo <= 0) then
  −
return false
  −
end
  −
if self:_is_submarine() then
  −
local level = self._ship:level()
  −
if level and level >= 10 then
  −
opening_torpedo = true
  −
end
  −
end
  −
for i = 1, self._ship:slots_length() or 0 do
  −
local equipment, size = self._ship:slot(i)
  −
if equipment then
  −
if self:_is_midget_submarine(equipment) then
  −
opening_torpedo = true
  −
end
  −
local equipment_torpedo = equipment:torpedo_leveled()
  −
if equipment_torpedo and torpedo then
  −
torpedo = torpedo + equipment_torpedo
  −
end
  −
end
  −
end
  −
if opening_torpedo then
  −
return 5 + (fleet_torpedo or 0) + (torpedo or 0)
  −
end
  −
return false
   
end
 
end
  
Anonymous user