We can add a check in preUseTalent just after checking the resources and before printing the message:
Code: Select all
-- Check for special preuse
if ab.on_preuse and not ab.on_preuse(self, ab) then
return false
end
Code: Select all
on_preuse = function(self, t)
-- Check nearby actors
local grids = core.fov.circle_grids(self.x, self.y, math.floor(10 - self:getTalentLevel(t) * 1.1), true)
for x, yy in pairs(grids) do for y in pairs(yy) do
local actor = game.level.map(x, y, game.level.map.ACTOR)
if actor and actor ~= self and actor:reactionToward(self) < 0 and not rng.percent(self.hide_chance or 0) then
game.logPlayer(self, "You cannot Stealth with nearby foes watching!")
return nil
end
end end
return true
end,