Page 1 of 1

help with Combat.lua and checkHit() required

Posted: Fri Oct 05, 2012 12:46 am
by jenx
I'm working on Combat.lua and the checkHit function:

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
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?

Re: help with Combat.lua and checkHit() required

Posted: Fri Oct 05, 2012 1:38 am
by aardvark
It doesn't look like they do anything. Probably vestigial from an earlier version of the function.

Re: help with Combat.lua and checkHit() required

Posted: Fri Oct 05, 2012 6:42 am
by darkgod
yup indeed

Re: help with Combat.lua and checkHit() required

Posted: Fri Oct 05, 2012 11:37 am
by jenx
Ok