Page 1 of 1

Lua errors with Throw Bomb talent into magical darkness

Posted: Mon Oct 15, 2012 11:58 pm
by Hachem_Muche
Using Throw Bomb will generate a targetting error if you try to target a spot inside magical darkness. (The explosive damage is not impeded by darkness, however.)

The error appears to be caused by core.fov.calc_circle returning a nil table if the starting point is a darkened grid. This is then returned through

Code: Select all

if typ.ball and typ.ball > 0 then
==>		core.fov.calc_circle(
			stop_radius_x,
			stop_radius_y,
			game.level.map.w,
			game.level.map.h,
			typ.ball,
			function(_, px, py)
				if typ.block_radius and typ:block_radius(px, py) then return true end
			end,
			function(_, px, py)
				-- Deal damage: ball
				addGrid(px, py)
			end,
		nil)
		addGrid(stop_x, stop_y)
in _M:project in ActorProject.lua back to

Code: Select all

	if self:knowTalent(self.T_EXPLOSION_EXPERT) then
			local theorical_nb = ({ 9, 25, 45, 77, 109, 145 })[tg.radius] or 145
			local nb = 0
==>			local grids = self:project(tg, x, y, function(tx, ty) end)
			for px, ys in pairs(grids) do for py, _ in pairs(ys) do nb = nb + 1 end end
			nb = theorical_nb - nb
			if nb > 0 then
				local mult = math.log10(nb) / (6 - math.min(self:getTalentLevelRaw(self.T_EXPLOSION_EXPERT), 5))
				print("Adjusting explosion damage to account for ", nb, " lost tiles => ", mult * 100)
				dam = dam + dam * mult
			end
		end
in explosives.lua

Re: Lua errors with Throw Bomb talent into magical darkness

Posted: Wed Oct 24, 2012 3:20 pm
by darkgod
fixd