Changes

no edit summary
Line 17: Line 17:  
-- Calculate shelling hit (normal and critical) rate.
 
-- Calculate shelling hit (normal and critical) rate.
 
-- ship and target can be Ship, EnemyShip, ShipCapabilities, etc.
 
-- ship and target can be Ship, EnemyShip, ShipCapabilities, etc.
-- [[Category:Todo]]: ignoring equipment, type and fuel modifiers.
+
-- [[Category:Todo]]:
 +
-- * ignoring equipment, type and fuel modifiers
 +
-- * also use _fields instead of getter functions? then any record will do for ship and target
 
function Combat2.hit_rate(ship, target, context)
 
function Combat2.hit_rate(ship, target, context)
 
      
 
      
Line 30: Line 32:  
     local luck = ship:luck() or 0
 
     local luck = ship:luck() or 0
 
     local accuracy = ship:accuracy() or 0
 
     local accuracy = ship:accuracy() or 0
 +
    local fit = ship._fit or 0
 +
    local as_modifier = ship._as_modifier or 1
 +
    local ap_modifier = ship._ap_modifier or 1
 
     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 = floor((90 + 2 * sqrt(level) + sqrt(1.5 * luck) + accuracy) * morale * formation)
+
     local accuracy_value = floor(((90 + 2 * sqrt(level) + sqrt(1.5 * luck) + accuracy) * morale * formation + fit) * as_modifier * ap_modifier)
    
     local evasion = target:evasion() or 0
 
     local evasion = target:evasion() or 0
cssedit, gkautomate
6,926

edits