Line 1: |
Line 1: |
| + | local format = require("Module:Core").format |
| local BaseData = require("Module:BaseData") | | local BaseData = require("Module:BaseData") |
− | local Formatting = require('Module:Formatting') | + | local Formatting = require("Module:Formatting") |
− | | + | |
− | local format = require('Module:Utils').format
| |
− | | |
| local ShipCapabilities = BaseData{ | | local ShipCapabilities = BaseData{ |
− | -- _anti_air_cut_in_types = {
| |
− | -- {
| |
− | -- name = "Akizuki (HA HA R)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "High-angle Gun", "Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Akizuki (HA AAR)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Akizuki (HA HA)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "High-angle Gun"}
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Type 3 AAR",
| |
− | -- equipment = {"Large Caliber Main Gun", "Type 3 Shell", "Anti-Aircraft Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HAFD HAFD AAR",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Type 3",
| |
− | -- equipment = {"Large Caliber Main Gun", "Type 3 Shell", "Anti-Aircraft Fire Director"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HA AAFD AAR",
| |
− | -- equipment = {"High-angle Gun", "Anti-Aircraft Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HAFD AAR",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HA AAFD",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Maya Kai Ni (HA CD AAR)",
| |
− | -- ship = {"Maya/Kai Ni"},
| |
− | -- equipment = {"High-angle Gun", "25mm Triple Autocannon Mount Concentrated Deployment", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Maya Kai Ni (HA CD)",
| |
− | -- ship = {"Maya/Kai Ni"},
| |
− | -- equipment = {"High-angle Gun", "25mm Triple Autocannon Mount Concentrated Deployment"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "CD AAMG AAR",
| |
− | -- equipment = {"25mm Triple Autocannon Mount Concentrated Deployment", "Anti-Air Machine Gun", "Anti-Air Radar"}
| |
− | -- },
| |
− | -- },
| |
| _attack_template = "${mode} (${attack_power})", | | _attack_template = "${mode} (${attack_power})", |
| _day_battle_modes = { | | _day_battle_modes = { |
Line 85: |
Line 29: |
| [7] = "Cut-in: Torpedo", | | [7] = "Cut-in: Torpedo", |
| [8] = "Bombing", | | [8] = "Bombing", |
| + | [9] = "Cut-in: Carrier", |
| }, | | }, |
| _night_battle_attack_counts = { | | _night_battle_attack_counts = { |
Line 92: |
Line 37: |
| }, | | }, |
| _asw_attack_modes = { | | _asw_attack_modes = { |
| + | opening = "Opening", |
| day = "Day", | | day = "Day", |
| night = "Night", | | night = "Night", |
| }, | | }, |
| } | | } |
− | | + | |
| function ShipCapabilities:create(data) | | function ShipCapabilities:create(data) |
| if data.ship then | | if data.ship then |
Line 106: |
Line 52: |
| return data | | return data |
| end | | end |
| + | |
| + | local Self = ShipCapabilities |
| | | |
− | --function ShipCapabilities:anti_air_cut_in()
| + | function Self:_find_equipment(fn) |
− | --local result = false | + | for i = 1, self._ship:slots_length() or 0 do |
− | --base_name = self._ship:base_name()
| + | local equipment, size = self._ship:slot(i) |
− | --if base_name == "Akizuki" then
| + | if equipment and fn(equipment, size) then |
− | -- result = self:akizuki_anti_air_cut_in()
| + | return equipment |
− | --elseif base_name == "Maya" and self._ship:suffix() == "Kai Ni" then
| + | end |
− | -- result = self:maya_kai_ni_anti_air_cut_in()
| + | end |
| + | return false |
| + | end |
| | | |
| + | function Self:_fold_equipment(result, fn) |
| + | for i = 1, self._ship:slots_length() or 0 do |
| + | local equipment, size = self._ship:slot(i) |
| + | if equipment then |
| + | result = fn(equipment, result) |
| + | end |
| + | end |
| + | return result |
| + | end |
| + | |
| function ShipCapabilities:_is_asw_surface_ship(ship) | | function ShipCapabilities:_is_asw_surface_ship(ship) |
| if not ship then | | if not ship then |
Line 122: |
Line 82: |
| local asw_leveled = ship:asw_leveled() | | local asw_leveled = ship:asw_leveled() |
| return (asw_leveled == nil or asw_leveled > 0) | | return (asw_leveled == nil or asw_leveled > 0) |
− | and ship_type ~= 7 | + | and not self:_is_carrier(ship) |
| --[[ | | --[[ |
| ship_type == 2 | | ship_type == 2 |
Line 130: |
Line 90: |
| --]] | | --]] |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_asw_aviation_ship(ship) | | function ShipCapabilities:_is_asw_aviation_ship(ship) |
| if not ship then | | if not ship then |
Line 142: |
Line 102: |
| or ship_type == 17 | | or ship_type == 17 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_aviation_ship(ship) | | function ShipCapabilities:_is_aviation_ship(ship) |
| if not ship then | | if not ship then |
Line 157: |
Line 117: |
| or ship_type == 18 | | or ship_type == 18 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_light_carrier(ship) | | function ShipCapabilities:_is_light_carrier(ship) |
| if not ship then | | if not ship then |
Line 164: |
Line 124: |
| return ship:type() == 7 | | return ship:type() == 7 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_carrier(ship) | | function ShipCapabilities:_is_carrier(ship) |
| if not ship then | | if not ship then |
Line 174: |
Line 134: |
| or ship_type == 18 | | or ship_type == 18 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_submarine(ship) | | function ShipCapabilities:_is_submarine(ship) |
| if not ship then | | if not ship then |
Line 184: |
Line 144: |
| end | | end |
| | | |
| + | -- Automatically make units with 0 speed installations |
| + | -- todo: the effect of type 3 shell |
| function ShipCapabilities:_is_installation(ship) | | function ShipCapabilities:_is_installation(ship) |
| if not ship then | | if not ship then |
| ship = self._ship | | ship = self._ship |
| end | | end |
− | return ship:is_installation() | + | return ship:speed() == 0 and not ship:is_pillbox() |
| end | | end |
| | | |
| + | -- The logic is copied from Kan Colle Kai |
| + | -- Automatically make most of enemy carriers night bombing |
| + | -- _night_bombing is now used to disable night bombing caused by firepower and torpedo, and not related to night ASW |
| + | function ShipCapabilities:_is_night_bombing(ship) |
| + | if not ship then |
| + | ship = self._ship |
| + | end |
| + | return ship:night_bombing() ~= false |
| + | and self:_is_carrier(ship) |
| + | and (ship:firepower() or 0) + (ship:torpedo() or 0) > 0 |
| + | end |
| + | |
| function ShipCapabilities:_is_main_gun(equipment) | | function ShipCapabilities:_is_main_gun(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 198: |
Line 172: |
| or equipment_type == 38 | | or equipment_type == 38 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_secondary_gun(equipment) | | function ShipCapabilities:_is_secondary_gun(equipment) |
| return equipment:type() == 4 | | return equipment:type() == 4 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_torpedo(equipment) | | function ShipCapabilities:_is_torpedo(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 208: |
Line 182: |
| or equipment_type == 32 | | or equipment_type == 32 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_bomber(equipment) | | function ShipCapabilities:_is_bomber(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 215: |
Line 189: |
| or equipment_type == 11 | | or equipment_type == 11 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_air_power_plane(equipment) | | function ShipCapabilities:_is_air_power_plane(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 222: |
Line 196: |
| or equipment_type == 8 | | or equipment_type == 8 |
| or equipment_type == 11 | | or equipment_type == 11 |
| + | or equipment_type == 47 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_torpedo_bomber(equipment) | | function ShipCapabilities:_is_torpedo_bomber(equipment) |
| return equipment:type() == 8 | | return equipment:type() == 8 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_reconnaissance_seaplane(equipment) | | function ShipCapabilities:_is_reconnaissance_seaplane(equipment) |
| return equipment:type() == 10 | | return equipment:type() == 10 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_seaplane(equipment) | | function ShipCapabilities:_is_seaplane(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 237: |
Line 212: |
| or equipment_type == 11 | | or equipment_type == 11 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_radar(equipment) | | function ShipCapabilities:_is_radar(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 243: |
Line 218: |
| or equipment_type == 13 | | or equipment_type == 13 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_sonar(equipment) | | function ShipCapabilities:_is_sonar(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
Line 249: |
Line 224: |
| or equipment_type == 40 | | or equipment_type == 40 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_depth_charge(equipment) | | function ShipCapabilities:_is_depth_charge(equipment) |
| return equipment:type() == 15 | | return equipment:type() == 15 |
| end | | end |
− | | + | |
− | -- small main guns', recon sea planes' and radars' asw is invalid | + | -- only following equipments' asw value are counted for attack |
− | function ShipCapabilities:_is_unable_asw_equip(equipment) | + | function ShipCapabilities:_is_damaging_asw_equip(equipment) |
| local equipment_type = equipment:type() | | local equipment_type = equipment:type() |
− | return equipment_type == 1 | + | return equipment_type == 7 |
− | or equipment_type == 10 | + | or equipment_type == 8 |
− | or equipment_type == 12 | + | or equipment_type == 11 |
− | or equipment_type == 13 | + | or equipment_type == 14 |
− | or equipment_type == 93 | + | or equipment_type == 15 |
| + | or equipment_type == 25 |
| + | or equipment_type == 26 |
| + | or equipment_type == 40 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_type_3_shell(equipment) | | function ShipCapabilities:_is_type_3_shell(equipment) |
| return equipment:type() == 18 | | return equipment:type() == 18 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_ap_shell(equipment) | | function ShipCapabilities:_is_ap_shell(equipment) |
| return equipment:type() == 19 | | return equipment:type() == 19 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_midget_submarine(equipment) | | function ShipCapabilities:_is_midget_submarine(equipment) |
| return equipment:type() == 22 | | return equipment:type() == 22 |
| end | | end |
− | | + | |
| function ShipCapabilities:_is_wg(equipment) | | function ShipCapabilities:_is_wg(equipment) |
| return equipment:type() == 37 | | return equipment:type() == 37 |
| end | | end |
| | | |
| + | --- Midget Submarines (type = 22) that trigger opening torpedo |
| + | function Self._is_active_midget_submarine(equipment) |
| + | return equipment:id() == 41 or equipment:id() == 541 |
| + | end |
| + | |
| + | function ShipCapabilities:_is_night_aviation_personnel(equipment) |
| + | return equipment:id() == 258 |
| + | or equipment:id() == 259 |
| + | or equipment:id() == 608 |
| + | end |
| + | |
| function ShipCapabilities:_anti_installation() | | function ShipCapabilities:_anti_installation() |
| local type_3_shells, wgs = 0, 0 | | local type_3_shells, wgs = 0, 0 |
Line 295: |
Line 284: |
| end | | end |
| | | |
| + | -- Single Attack, Single Torpedo and Bombing are actually same |
| + | -- https://github.com/andanteyk/ElectronicObserver/blob/master/ElectronicObserver/Other/Information/kcmemo.md#%E5%A4%9C%E6%88%A6 |
| + | function ShipCapabilities:_single_attack_style(ship) |
| + | if not ship then |
| + | ship = self._ship |
| + | end |
| + | local ship_type = ship:type() |
| + | if ship_type == 13 or ship_type == 14 then |
| + | return 2 |
| + | end |
| + | if ship_type == 7 or ship_type == 11 or ship_type == 18 then |
| + | -- currently hard coding, lack of Graf Zeppelin (Kai) and Saratoga |
| + | -- a flag like _cv_night_shelling might be better? |
| + | local ship_name = ship:name() or "" |
| + | if ship_name:match("Lycoris Princess") or ship_name:match("Abyssal Jellyfish Princess") then |
| + | return 1 |
| + | elseif ship:id() == 1964 then |
| + | return 9 |
| + | else |
| + | return 8 |
| + | end |
| + | end |
| + | for i = 1, ship:slots_length() or 0 do |
| + | local equipment, size = ship:slot(i) |
| + | if equipment then |
| + | if self:_is_main_gun(equipment) or self:_is_secondary_gun(equipment) then |
| + | return 1 |
| + | elseif self:_is_torpedo(equipment) then |
| + | return 2 |
| + | end |
| + | end |
| + | end |
| + | return 1 |
| + | end |
| + | |
| -- Basic attack power for shelling and carrier shelling, including anti-installation modifiers and fleet firepower. | | -- Basic attack power for shelling and carrier shelling, including anti-installation modifiers and fleet firepower. |
| function ShipCapabilities:day_battle(vs_installation, fleet_firepower) | | function ShipCapabilities:day_battle(vs_installation, fleet_firepower) |
Line 302: |
Line 326: |
| return nil | | return nil |
| end | | end |
− | local is_installation = self:_is_installation() | + | --[[ |
− | local shiptype = self._ship:type()
| + | local has_bomber_planes = false |
− | local is_installation_bb = ((shiptype == 8) or (shiptype == 9)) and is_installation | + | for i = 1, self._ship:slots_length() do |
− | if not self:_is_carrier() and not is_installation or is_installation_bb then | + | local equipment, size = self._ship:slot(i) |
| + | if equipment and self:_is_bomber(equipment) and size and size > 0 then |
| + | has_bomber_planes = true |
| + | break |
| + | end |
| + | end |
| + | ]]-- |
| + | local is_installation_bbv = self._ship:speed() == 0 and self._ship:type() == 10 |
| + | if not self:_is_carrier() and not is_installation_bbv then |
| if firepower > 0 then | | if firepower > 0 then |
| for i = 1, self._ship:slots_length() do | | for i = 1, self._ship:slots_length() do |
Line 362: |
Line 394: |
| torpedo = 0 | | torpedo = 0 |
| end | | end |
− | return is_installation and 3 or 2, 55 + math.floor(1.5 * (firepower + torpedo + math.floor(1.3 * bombing))) | + | return is_installation_bbv and 3 or 2, 55 + math.floor(1.5 * (firepower + torpedo + math.floor(1.3 * bombing))) |
| end | | end |
| end | | end |
Line 369: |
Line 401: |
| return false | | return false |
| end | | end |
− | | + | |
| function ShipCapabilities:format_day_battle(mode, attack_power) | | function ShipCapabilities:format_day_battle(mode, attack_power) |
| if mode then | | if mode then |
Line 378: |
Line 410: |
| return "??" | | return "??" |
| end | | end |
− | | + | |
| -- Basic attack power for closing torpedo, including fleet torpedo. | | -- Basic attack power for closing torpedo, including fleet torpedo. |
| function ShipCapabilities:closing_torpedo(fleet_torpedo) | | function ShipCapabilities:closing_torpedo(fleet_torpedo) |
Line 396: |
Line 428: |
| return false | | return false |
| end | | end |
− | | + | |
| function ShipCapabilities:format_torpedo(attack_power) | | function ShipCapabilities:format_torpedo(attack_power) |
| if attack_power then | | if attack_power then |
Line 403: |
Line 435: |
| return "No" | | return "No" |
| end | | end |
− | | + | |
| ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo | | ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo |
− | | + | |
| -- Detect possible day time special attack modifiers. | | -- Detect possible day time special attack modifiers. |
| function ShipCapabilities:artillery_spotting(post_cap_attack_power) | | function ShipCapabilities:artillery_spotting(post_cap_attack_power) |
Line 467: |
Line 499: |
| return false | | return false |
| end | | end |
− | | + | |
| function ShipCapabilities:format_artillery_spotting(modes) | | function ShipCapabilities:format_artillery_spotting(modes) |
| if modes then | | if modes then |
Line 484: |
Line 516: |
| return "No" | | return "No" |
| end | | end |
− | | + | |
| -- Basic attack power for night battle carrier shelling. | | -- Basic attack power for night battle carrier shelling. |
| -- Or basic attack power for night battle attack, including night special attack, anti-installation and contact modifiers. | | -- Or basic attack power for night battle attack, including night special attack, anti-installation and contact modifiers. |
| function ShipCapabilities:night_battle(vs_installation, contact) | | function ShipCapabilities:night_battle(vs_installation, contact) |
− | local main_guns, secondary_guns, torpedoes, has_planes, firepower, torpedo = 0, 0, 0, false, self._ship:firepower_leveled(), self._ship:torpedo_leveled() | + | local main_guns, secondary_guns, torpedoes, has_planes, has_night_aviation_personnel, firepower, torpedo = 0, 0, 0, false, self._ship:night_aviation_personnel(), self._ship:firepower_leveled(), self._ship:torpedo_leveled() |
| if not firepower or not torpedo then | | if not firepower or not torpedo then |
| return nil | | return nil |
| end | | end |
| + | if firepower + torpedo <= 0 then |
| + | return false |
| + | end |
| for i = 1, self._ship:slots_length() or 0 do | | for i = 1, self._ship:slots_length() or 0 do |
| local equipment, size = self._ship:slot(i) | | local equipment, size = self._ship:slot(i) |
Line 509: |
Line 544: |
| equipment_torpedo = 0 | | equipment_torpedo = 0 |
| end | | end |
| + | elseif self:_is_night_aviation_personnel(equipment) then |
| + | has_night_aviation_personnel = true |
| end | | end |
| if equipment_firepower then | | if equipment_firepower then |
Line 521: |
Line 558: |
| firepower = firepower + 5 | | firepower = firepower + 5 |
| end | | end |
− | if self:_is_carrier() then | + | if self._ship:night_bombing() == false then |
− | if has_planes and self._ship:night_bombing() then
| + | -- if night bombing is forbidden |
− | return 8, firepower + torpedo
| |
− | end
| |
| return false | | return false |
| else | | else |
Line 553: |
Line 588: |
| elseif main_guns + secondary_guns >= 2 and firepower > 0 then | | elseif main_guns + secondary_guns >= 2 and firepower > 0 then |
| return 3, ((firepower + torpedo) * anti_installation_modifier + anti_installation_bonus) * 1.2 | | return 3, ((firepower + torpedo) * anti_installation_modifier + anti_installation_bonus) * 1.2 |
− | elseif torpedoes > 0 and torpedo > 0 then | + | -- WIP: just a hack for enemy CVs, no plane checked, only NF + NTB (120%) supported |
− | if vs_installation then
| + | elseif self:_is_carrier(self._ship) and has_night_aviation_personnel then |
− | return false
| + | return 9, ((firepower + torpedo) * anti_installation_modifier + anti_installation_bonus) * 1.2 |
− | else
| + | -- Single Attack, Single Torpedo and Bombing are actually same |
− | return 2, firepower + torpedo
| |
− | end
| |
− | elseif firepower > 0 then | |
− | return 1, (firepower + torpedo) * anti_installation_modifier + anti_installation_bonus
| |
| else | | else |
− | return false | + | return self:_single_attack_style(), (firepower + torpedo) * anti_installation_modifier + anti_installation_bonus |
| end | | end |
| end | | end |
| end | | end |
− | | + | |
| function ShipCapabilities:format_night_battle(mode, attack_power) | | function ShipCapabilities:format_night_battle(mode, attack_power) |
| if mode then | | if mode then |
Line 580: |
Line 611: |
| return "Unknown" | | return "Unknown" |
| end | | end |
− | | + | |
− | -- 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()
| + | fleet_torpedo = fleet_torpedo or 0 |
− | local opening_torpedo = self._ship:opening_torpedo() | + | local torpedo = self._ship:torpedo_leveled() |
− | if (opening_torpedo ~= true) and (opening_torpedo == false or not torpedo or torpedo <= 0) then
| + | if self._ship:opening_torpedo() == false or not torpedo or torpedo <= 0 then |
| return false | | return false |
| end | | end |
− | if self:_is_submarine() then | + | local is_enemy = not self._ship._hp_max |
− | local level = self._ship:level()
| + | local is_enemy_submarine = is_enemy and self:_is_submarine() |
− | if level and level >= 10 then
| + | local is_player_submarine = not is_enemy and self:_is_submarine() |
− | opening_torpedo = true
| + | if |
− | end
| + | self._ship:opening_torpedo() == true or |
− | end
| + | not is_enemy_submarine and self:_find_equipment(Self._is_active_midget_submarine) or |
− | for i = 1, self._ship:slots_length() or 0 do
| + | is_player_submarine and self._ship:level() and self._ship:level() >= 10 or |
− | local equipment, size = self._ship:slot(i)
| + | is_enemy_submarine and self._ship:suffix() and (self._ship:suffix():match("Elite") or self._ship:suffix():match("Flagship")) |
− | if equipment then
| + | then |
− | if self:_is_midget_submarine(equipment) then
| + | torpedo = self:_fold_equipment(torpedo, function(equipment, torpedo) |
− | opening_torpedo = true
| + | return torpedo + (equipment:torpedo_leveled() or 0) |
− | end
| + | end) |
− | local equipment_torpedo = equipment:torpedo_leveled()
| + | return 5 + fleet_torpedo + torpedo |
− | if equipment_torpedo and torpedo then
| + | end |
− | torpedo = torpedo + equipment_torpedo
| + | return false |
− | end
| |
− | end
| |
− | end
| |
− | if opening_torpedo then
| |
− | return 5 + (fleet_torpedo or 0) + (torpedo or 0)
| |
− | end
| |
− | return false
| |
| end | | end |
− | | + | |
| ShipCapabilities.format_opening_torpedo = ShipCapabilities.format_torpedo | | ShipCapabilities.format_opening_torpedo = ShipCapabilities.format_torpedo |
− | | + | |
| -- Basic attack power for ASW attack * sonar w/ depth charge modifier (pre-cap). | | -- Basic attack power for ASW attack * sonar w/ depth charge modifier (pre-cap). |
| function ShipCapabilities:asw_attack() | | function ShipCapabilities:asw_attack() |
| local base_asw | | local base_asw |
− | local asw_override, day, night = self._ship:asw_attack(), true, true | + | local asw_override, opening, day, night = self._ship:asw_attack(), false, true, true |
| if asw_override == false then | | if asw_override == false then |
| return false | | return false |
Line 624: |
Line 648: |
| elseif self:_is_asw_aviation_ship() then | | elseif self:_is_asw_aviation_ship() then |
| base_asw = 8 | | base_asw = 8 |
− | if not self._ship:night_bombing() or self._ship:asw_leveled() == 0 then | + | if not self:_is_night_bombing() or self._ship:asw_leveled() == 0 then |
| night = false | | night = false |
| end | | end |
Line 630: |
Line 654: |
| return false | | return false |
| end | | end |
| + | if self._ship._opening_asw then |
| + | opening = true |
| + | end |
| local asw_leveled = self._ship:asw_leveled() | | local asw_leveled = self._ship:asw_leveled() |
| local ship_asw, equipment_asw, depth_charge, sonar, bomber = (asw_leveled or 0), 0, false, false, false | | local ship_asw, equipment_asw, depth_charge, sonar, bomber = (asw_leveled or 0), 0, false, false, false |
Line 644: |
Line 671: |
| end | | end |
| -- some equipments' asw value is invalid | | -- some equipments' asw value is invalid |
− | if not self:_is_unable_asw_equip(equipment) then | + | if self:_is_damaging_asw_equip(equipment) then |
| equipment_asw = equipment_asw + (equipment:asw_leveled() or 0) | | equipment_asw = equipment_asw + (equipment:asw_leveled() or 0) |
| end | | end |
Line 657: |
Line 684: |
| depth_charge_sonar_boost = 1.15 | | depth_charge_sonar_boost = 1.15 |
| end | | end |
− | return depth_charge_sonar_boost * (base_asw + 1.5 * equipment_asw + 2 * math.sqrt(ship_asw)), day, night, not asw_leveled | + | return depth_charge_sonar_boost * (base_asw + 1.5 * equipment_asw + 2 * math.sqrt(ship_asw)), opening, day, night, not asw_leveled |
| end | | end |
− | | + | |
− | function ShipCapabilities:format_asw_attack(attack_power, day, night, uncertain) | + | function ShipCapabilities:format_asw_attack(attack_power, opening, day, night, uncertain) |
| if attack_power then | | if attack_power then |
| attack_power = math.floor(attack_power) | | attack_power = math.floor(attack_power) |
| local phases = {} | | local phases = {} |
| + | if opening then |
| + | table.insert(phases, self._asw_attack_modes.opening) |
| + | end |
| if day then | | if day then |
| table.insert(phases, self._asw_attack_modes.day) | | table.insert(phases, self._asw_attack_modes.day) |
Line 680: |
Line 710: |
| return "No" | | return "No" |
| end | | end |
− | | + | |
| -- Basic attack power for opening airstrike (returns an array with attack values per each bomber). | | -- Basic attack power for opening airstrike (returns an array with attack values per each bomber). |
| function ShipCapabilities:opening_airstrike() | | function ShipCapabilities:opening_airstrike() |
− | if not self:_is_aviation_ship() then
| |
− | return false
| |
− | end
| |
| local airstrikes = {} | | local airstrikes = {} |
| for i = 1, self._ship:slots_length() or 0 do | | for i = 1, self._ship:slots_length() or 0 do |
Line 703: |
Line 730: |
| return false | | return false |
| end | | end |
− | | + | |
| function ShipCapabilities:format_opening_airstrike(attacks) | | function ShipCapabilities:format_opening_airstrike(attacks) |
| if attacks then | | if attacks then |
Line 714: |
Line 741: |
| return "No" | | return "No" |
| end | | end |
− | | + | |
| return ShipCapabilities | | return ShipCapabilities |