Line 235: |
Line 235: |
| function ShipCapabilities:_is_depth_charge(equipment) | | function ShipCapabilities:_is_depth_charge(equipment) |
| return equipment:type() == 15 | | return equipment:type() == 15 |
| + | end |
| + | |
| + | function ShipCapabilities:_is_type_3_shell(equipment) |
| + | return equipment:type() == 18 |
| end | | end |
| | | |
Line 245: |
Line 249: |
| end | | end |
| | | |
− | -- Basic attack power for shelling and carrier shelling. | + | function ShipCapabilities:_is_wg(equipment) |
− | function ShipCapabilities:day_battle() | + | return equipment:type() == 37 |
| + | end |
| + | |
| + | function ShipCapabilities:_anti_installation() |
| + | local type_3_shells, wgs = 0, 0 |
| + | for i = 1, self._ship:slots_length() or 0 do |
| + | local equipment, size = self._ship:slot(i) |
| + | if equipment then |
| + | if self:_is_type_3_shell(equipment) then |
| + | type_3_shells = type_3_shells + 1 |
| + | elseif self:_is_wg(equipment) then |
| + | wgs = wgs + 1 |
| + | end |
| + | end |
| + | end |
| + | return { type_3_shell_equiped = type_3_shells > 0, wg_equiped = wgs > 0 } |
| + | end |
| + | |
| + | -- Basic attack power for shelling and carrier shelling, including anti-installation modifiers. |
| + | function ShipCapabilities:day_battle(vs_installation) |
| if not self:_is_submarine() then | | if not self:_is_submarine() then |
| local firepower = self._ship:firepower_leveled() | | local firepower = self._ship:firepower_leveled() |
Line 264: |
Line 287: |
| end | | end |
| end | | end |
− | return 1, 5 + firepower | + | local anti_installation_modifier = 1 |
| + | if vs_installation then |
| + | local anti_installation = self:_anti_installation() |
| + | anti_installation_modifier = anti_installation.type_3_shell_equiped and 2.5 or 1 |
| + | firepower = firepower + (anti_installation.wg_equiped and 75 or 0) |
| + | end |
| + | return 1, (5 + firepower) * anti_installation_modifier |
| end | | end |
| else | | else |
Line 295: |
Line 324: |
| end | | end |
| if has_planes then | | if has_planes then |
| + | if vs_installation then |
| + | if bombing > 0 then |
| + | return false |
| + | end |
| + | torpedo = 0 |
| + | end |
| return is_installation and 3 or 2, 55 + math.floor(1.5 * (firepower + torpedo + math.floor(1.3 * bombing))) | | return is_installation and 3 or 2, 55 + math.floor(1.5 * (firepower + torpedo + math.floor(1.3 * bombing))) |
| end | | end |
Line 339: |
Line 374: |
| ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo | | ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo |
| | | |
− | -- Detect possible day time special attack modifiers (post-cap). | + | -- Detect possible day time special attack modifiers. |
| function ShipCapabilities:artillery_spotting() | | function ShipCapabilities:artillery_spotting() |
| local total_space = self._ship:total_space() | | local total_space = self._ship:total_space() |
Line 390: |
Line 425: |
| | | |
| -- Basic attack power for night battle carrier shelling. | | -- Basic attack power for night battle carrier shelling. |
− | -- Or basic attack power for night battle attack * detected night special attack modifier (pre-cap). | + | -- Or basic attack power for night battle attack, including night special attack and anti-installation modifiers. |
− | function ShipCapabilities:night_battle() | + | function ShipCapabilities:night_battle(vs_installation) |
| 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, firepower, torpedo = 0, 0, 0, false, self._ship:firepower_leveled(), self._ship:torpedo_leveled() |
| if not firepower or not torpedo then | | if not firepower or not torpedo then |
Line 421: |
Line 456: |
| end | | end |
| end | | end |
| + | end |
| + | local anti_installation_modifier = 1 |
| + | if vs_installation then |
| + | torpedo = 0 |
| + | local anti_installation = self:_anti_installation() |
| + | anti_installation_modifier = anti_installation.type_3_shell_equiped and 2.5 or 1 |
| + | firepower = firepower + (anti_installation.wg_equiped and 75 or 0) |
| end | | end |
| if self:_is_carrier() then | | if self:_is_carrier() then |
Line 431: |
Line 473: |
| return 7, (firepower + torpedo) * 1.5 | | return 7, (firepower + torpedo) * 1.5 |
| elseif main_guns >= 3 and firepower > 0 then | | elseif main_guns >= 3 and firepower > 0 then |
− | return 4, (firepower + torpedo) * 2 | + | return 4, (firepower + torpedo) * 2 * anti_installation_modifier |
| elseif main_guns >= 2 and secondary_guns >= 1 and firepower > 0 then | | elseif main_guns >= 2 and secondary_guns >= 1 and firepower > 0 then |
− | return 5, (firepower + torpedo) * 1.75 | + | return 5, (firepower + torpedo) * 1.75 * anti_installation_modifier |
| elseif main_guns >= 1 and torpedoes == 1 and firepower > 0 and torpedo > 0 then | | elseif main_guns >= 1 and torpedoes == 1 and firepower > 0 and torpedo > 0 then |
| return 6, (firepower + torpedo) * 1.3 | | return 6, (firepower + torpedo) * 1.3 |
| elseif main_guns + secondary_guns >= 2 and firepower > 0 then | | elseif main_guns + secondary_guns >= 2 and firepower > 0 then |
− | return 3, (firepower + torpedo) * 1.2 | + | return 3, (firepower + torpedo) * 1.2 * anti_installation_modifier |
| elseif torpedoes > 0 and torpedo > 0 then | | elseif torpedoes > 0 and torpedo > 0 then |
| return 2, firepower + torpedo | | return 2, firepower + torpedo |
| elseif firepower > 0 then | | elseif firepower > 0 then |
− | return 1, firepower + torpedo | + | return 1, (firepower + torpedo) * anti_installation_modifier |
| else | | else |
| return false | | return false |