[b34] rush not triggering traps
Posted: Tue Oct 11, 2011 2:19 pm
When NPC ends his Rush maneuver on a tile with trap, the trap does not get triggered. For sure its the case for rogue-set traps.
Everything about ToME
https://forums.te4.org/
Code: Select all
if not forced and moved and ox and oy and (ox ~= self.x or oy ~= self.y) and self:knowTalent(self.T_LIGHT_OF_FOOT) then
self:incStamina(self:getTalentLevelRaw(self.T_LIGHT_OF_FOOT) * 0.2)
Code: Select all
function _M:move(x, y, force)
local moved = false
local ox, oy = self.x, self.y
if force or self:enoughEnergy() then
-- Confused ?
if not force and self:attr("confused") then
if rng.percent(self:attr("confused")) then
x, y = self.x + rng.range(-1, 1), self.y + rng.range(-1, 1)
end
end
-- Encased in ice, attack the ice
if not force and self:attr("encased_in_ice") then
self:attackTarget(self)
moved = true
-- Should we prob travel through walls ?
elseif not force and self:attr("prob_travel") and game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move", self) then
moved = self:probabilityTravel(x, y, self:attr("prob_travel"))
-- Never move but tries to attack ? ok
elseif not force and self:attr("never_move") then
-- A bit weird, but this simple asks the collision code to detect an attack
if not game.level.map:checkAllEntities(x, y, "block_move", self, true) then
game.logPlayer(self, "You are unable to move!")
end
else
moved = engine.Actor.move(self, x, y, force)
end
if not force and moved and (self.x ~= ox or self.y ~= oy) and not self.did_energy then
self:useEnergy(game.energy_to_act * self:combatMovementSpeed())
end
end
self.did_energy = nil
-- Try to detect traps
if self:knowTalent(self.T_TRAP_DETECTION) then
local power = self:getTalentLevel(self.T_TRAP_DETECTION) * self:getCun(25, true)
local grids = core.fov.circle_grids(self.x, self.y, 1, true)
for x, yy in pairs(grids) do for y, _ in pairs(yy) do
local trap = game.level.map(x, y, Map.TRAP)
if trap and not trap:knownBy(self) and self:checkHit(power, trap.detect_power) then
trap:setKnown(self, true)
game.level.map:updateMap(x, y)
game.logPlayer(self, "You have found a trap (%s)!", trap:getName())
end
end end
end
if moved and self:knowTalent(self.T_CURSED_TOUCH) then
local t = self:getTalentFromId(self.T_CURSED_TOUCH)
t.curseFloor(self, t, x, y)
end
if moved and self:isTalentActive(self.T_BODY_OF_STONE) then
self:forceUseTalent(self.T_BODY_OF_STONE, {ignore_energy=true})
end
if not forced and moved and ox and oy and (ox ~= self.x or oy ~= self.y) and self:knowTalent(self.T_LIGHT_OF_FOOT) then
self:incStamina(self:getTalentLevelRaw(self.T_LIGHT_OF_FOOT) * 0.2)
end
if moved and not force and ox and oy and (ox ~= self.x or oy ~= self.y) and config.settings.tome.smooth_move > 0 then
local blur = 0
if game.level.data.zero_gravity then blur = 2 end
if self:attr("lightning_speed") or self:attr("step_up") or self:attr("wild_speed") then blur = 3 end
self:setMoveAnim(ox, oy, config.settings.tome.smooth_move, blur)
end
return moved
end