Changes

no edit summary
Line 18: Line 18:  
end
 
end
   −
-- Shelling hit rate.
+
function Combat2.accuracy_value(ship, target, context)
-- ship and target can be Ship, EnemyShip, ShipCapabilities, or a plain table.
  −
-- [[Category:Todo]]: detection based on _equipment, fuel modifier.
  −
function Combat2.hit_rate(ship, target, context)
  −
 
   
     ship = ship and ship.ship or ship
 
     ship = ship and ship.ship or ship
 
     target = target and target.ship or target
 
     target = target and target.ship or target
Line 29: Line 25:  
         return
 
         return
 
     end
 
     end
   
     local level = ship._level or 1
 
     local level = ship._level or 1
 
     local luck = ship._luck or 0
 
     local luck = ship._luck or 0
Line 38: Line 33:  
     local morale = morale_modifier(ship._morale)
 
     local morale = morale_modifier(ship._morale)
 
     local formation = context._formation or ship._formation or 1
 
     local formation = context._formation or ship._formation or 1
 +
    local accuracy_value_1 = (90 + 2 * sqrt(level) + sqrt(1.5 * luck) + accuracy) * morale * formation
 +
    local accuracy_value_2 = accuracy_value_1 + fit
 +
    local accuracy_value_3 = accuracy_value_2 * as_modifier * ap_modifier
 +
    return accuracy_value_1, accuracy_value_2, accuracy_value_3
 +
end
 +
 +
-- Shelling hit rate.
 +
-- ship and target can be Ship, EnemyShip, ShipCapabilities, or a plain table.
 +
-- [[Category:Todo]]: detection based on _equipment, fuel modifier.
 +
function Combat2.hit_rate(ship, target, context)
 +
 +
    ship = ship and ship.ship or ship
 +
    target = target and target.ship or target
 +
    context = context or {}
 +
    if not ship or not target then
 +
        return
 +
    end
   −
     local accuracy_value = floor(((90 + 2 * sqrt(level) + sqrt(1.5 * luck) + accuracy) * morale * formation + fit) * as_modifier * ap_modifier)
+
     local _, _, accuracy_value = Combat2.accuracy_value(ship, target, context)
    
     local evasion = target._evasion or 0
 
     local evasion = target._evasion or 0
Line 85: Line 97:  
     }
 
     }
 
     local target = Ship("Destroyer Ro-Class")
 
     local target = Ship("Destroyer Ro-Class")
     mw.log(Combat2.hit_rate(ship, target))
+
    mw.log(Combat2.accuracy_value(ship, target))
 +
     mw.log(Combat2.hit_rate(ship, target), "")
 
     mw.log(Combat2.critical_hit_rate(ship, target))
 
     mw.log(Combat2.critical_hit_rate(ship, target))
 
end
 
end
    
return Combat2
 
return Combat2
cssedit, gkautomate
7,064

edits