Skip to content
Snippets Groups Projects
Commit 6091cfb2 authored by DarkGod's avatar DarkGod
Browse files

Disengage autoselects the farther spot you can jump to in a straight line from the target

parent afd6293d
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,9 @@ function _M:targetDisplayTooltip(dx, dy, force, nb_keyframes)
-- Move target around
if self.old_tmx ~= tmx or self.old_tmy ~= tmy then
self.target.target.x, self.target.target.y = tmx, tmy
if not (self.target_mode and self.target_no_move_tooltip) then
self.target.target.x, self.target.target.y = tmx, tmy
end
end
self.old_tmx, self.old_tmy = tmx, tmy
end
......@@ -132,6 +134,10 @@ function _M:targetMode(v, msg, co, typ)
self.target:setActive(true, typ)
self.target_style = "lock"
self.target_warning = true
self.target_no_move_tooltip = true
if type(typ) == "table" and typ.no_move_tooltip then
self.target_no_move_tooltip = true
end
if type(typ) == "table" and typ.talent then
self.target_warning = typ.talent.name
elseif type(typ) == "table" and typ.__name then
......@@ -146,16 +152,20 @@ function _M:targetMode(v, msg, co, typ)
self.key:setCurrent()
local do_scan = true
if self.target_no_star_scan
or (
self.target.target.entity and
self.level.map.seens(self.target.target.entity.x, self.target.target.entity.y) and
self.player ~= self.target.target.entity
) then
if type(typ) == "table" and typ.no_start_scan then
do_scan = false
else
if self.target_no_start_scan
or (
self.target.target.entity and
self.level.map.seens(self.target.target.entity.x, self.target.target.entity.y) and
self.player ~= self.target.target.entity
) then
if type(typ) == "table" and typ.first_target ~= "friend" and self.player:reactionToward(self.target.target.entity) >= 0 then
else
do_scan = false
if type(typ) == "table" and typ.first_target ~= "friend" and self.target.target and self.target.target.entity and self.player:reactionToward(self.target.target.entity) >= 0 then
else
do_scan = false
end
end
end
if do_scan then
......@@ -272,12 +282,12 @@ function _M:targetGetForPlayer(typ)
if self.target.forced then return unpack(self.target.forced) end
if coroutine.running() and typ then
local msg
self.target_no_star_scan = nil
self.target_no_start_scan = nil
if type(typ) == "string" then msg, typ = typ, nil
elseif type(typ) == "table" then
if typ.default_target then
self.target.target.entity = typ.default_target
self.target_no_star_scan = true
self.target_no_start_scan = true
end
msg = typ.msg
end
......
......@@ -86,7 +86,31 @@ newTalent{
local dx, dy
if self.player then -- player targeting
local tg2 = {type="beam", source_actor=self, selffire=false, range=move_dist, talent=t}
local l = target:lineFOV(self.x, self.y)
l:set_corner_block()
local lx, ly, is_corner_blocked = l:step(true)
local possible_x, possible_y = lx, ly
local pass_self = false
-- Check for terrain and friendly actors
while lx and ly and not is_corner_blocked and core.fov.distance(self.x, self.y, lx, ly) <= move_dist do
local actor = game.level.map(lx, ly, engine.Map.ACTOR)
if actor == self then
pass_self = true
elseif pass_self and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then
-- possible_x, possible_y = lx, ly
break
end
possible_x, possible_y = lx, ly
lx, ly = l:step(true)
end
if pass_self then
game.target.target.entity = nil
game.target.target.x = possible_x
game.target.target.y = possible_y
end
local tg2 = {type="beam", source_actor=self, selffire=false, range=move_dist, talent=t, no_start_scan=true, no_move_tooltip=true}
tg2.display_line_step = function(self, d) -- highlight permissible grids for the player
local t_range = core.fov.distance(self.target_type.start_x, self.target_type.start_y, d.lx, d.ly)
if t_range >= 1 and t_range <= tg2.range and not d.block and check_dest(d.lx, d.ly) then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment