help with Combat.lua and checkHit() required
Posted: Fri Oct 05, 2012 12:46 am
I'm working on Combat.lua and the checkHit function:
I can't figure out what "factor" and "p" do as they are not referenced in the function itself. Lots of calls to this function however send in values for factor and sometimes p.
DG?
Code: Select all
--New, simpler checkHit that relies on rescaleCombatStats() being used elsewhere
function _M:checkHit(atk, def, min, max, factor, p)
if atk < 0 then atk = 0 end
if def < 0 then def = 0 end
local min = min or 0
local max = max or 100
if game.player:hasQuest("tutorial-combat-stats") then
min = 0
max = 100
end --ensures predictable combat for the tutorial
print("checkHit", atk, def)
local hit = math.ceil(50 + 2.5 * (atk - def))
hit = util.bound(hit, min, max)
print("=> chance to hit", hit)
return rng.percent(hit), hit
end
DG?