Add support for specifying maximum distance to target on setting target

Fix set_target parameters beeing inconsistent for different mapgens
This commit is contained in:
sapier 2014-08-24 15:00:46 +02:00
parent 064db78a33
commit f88282adee
4 changed files with 24 additions and 16 deletions

View File

@ -430,15 +430,17 @@ function mgen_flee.set_acceleration(entity,accel,speedup,pos)
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- name: set_target(entity,target) -- name: set_target(entity, target, follow_speedup, max_distance)
-- --
--! @brief set target for movgen --! @brief set target for movgen
--! @memberof mgen_flee --! @memberof mgen_flee
-- --
--! @param entity mob to apply to --! @param entity mob to apply to
--! @param target to set --! @param target to set
--! @param follow_speedup --unused here
--! @param max_distance --unused here
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function mgen_flee.set_target(entity,target) function mgen_flee.set_target(entity, target, follow_speedup, max_distance)
mobf_assert_backtrace(entity ~= nil) mobf_assert_backtrace(entity ~= nil)
mobf_assert_backtrace(target ~= nil) mobf_assert_backtrace(target ~= nil)
entity.dynamic_data.movement.target = target entity.dynamic_data.movement.target = target

View File

@ -607,16 +607,19 @@ function mgen_follow.set_acceleration(entity,accel,speedup,pos)
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- name: set_target(entity,target) -- name: set_target(entity, target, follow_speedup, max_distance)
-- --
--! @brief set target for movgen --! @brief set target for movgen
--! @memberof mgen_follow --! @memberof mgen_follow
-- --
--! @param entity mob to apply to --! @param entity mob to apply to
--! @param target to set --! @param target to set
--! @param follow_speedup --unused here
--! @param max_distance maximum distance to target to be tried to reach
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function mgen_follow.set_target(entity,target) function mgen_follow.set_target(entity,target, follow_speedup, max_distance)
entity.dynamic_data.movement.target = target entity.dynamic_data.movement.target = target
entity.dynamic_data.movement.max_distance = max_distance
return true return true
end end

View File

@ -140,13 +140,15 @@ function mgen_jordan4ibanez.init_dynamic_data(entity,now)
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- name: set_target(entity,target) -- name: set_target(entity, target, follow_speedup, max_distance)
-- --
--! @brief set target for movgen --! @brief set target for movgen
--! @memberof mgen_jordan4ibanez --! @memberof mgen_jordan4ibanez
-- --
--! @param entity mob to apply to --! @param entity mob to apply to --unused here
--! @param target to set --! @param target to set --unused here
--! @param follow_speedup --unused here
--! @param max_distance --unused here
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function mgen_jordan4ibanez.set_target(entity,target) function mgen_jordan4ibanez.set_target(entity,target)
return false return false

View File

@ -270,7 +270,7 @@ function p_mov_gen.set_end_of_path_handler(entity,handler)
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- name: set_target(entity,target) -- name: set_target(entity, target, follow_speedup, max_distance)
-- --
--! @brief set target for movgen --! @brief set target for movgen
--! @memberof p_mov_gen --! @memberof p_mov_gen
@ -279,8 +279,9 @@ end
--! @param entity mob to apply to --! @param entity mob to apply to
--! @param target to set --! @param target to set
--! @param follow_speedup use follow speedup to reach target --! @param follow_speedup use follow speedup to reach target
--! @param max_distance --unused here
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function p_mov_gen.set_target(entity, target, follow_speedup) function p_mov_gen.set_target(entity, target, follow_speedup, max_distance)
mobf_assert_backtrace(target ~= nil) mobf_assert_backtrace(target ~= nil)
local current_pos = entity.getbasepos(entity) local current_pos = entity.getbasepos(entity)
@ -333,7 +334,7 @@ function p_mov_gen.set_target(entity, target, follow_speedup)
mobf_assert_backtrace(#entity.dynamic_data.p_movement.path > 1) mobf_assert_backtrace(#entity.dynamic_data.p_movement.path > 1)
entity.dynamic_data.movement.target = entity.dynamic_data.movement.target =
entity.dynamic_data.p_movement.path[2] entity.dynamic_data.p_movement.path[2]
entity.dynamic_data.movement.follow_speedup = true entity.dynamic_data.movement.follow_speedup = follow_speedup
return true return true
end end
@ -347,7 +348,7 @@ function p_mov_gen.set_target(entity, target, follow_speedup)
table.insert(entity.dynamic_data.p_movement.path,targetpos) table.insert(entity.dynamic_data.p_movement.path,targetpos)
entity.dynamic_data.movement.target = entity.dynamic_data.movement.target =
entity.dynamic_data.p_movement.path[1] entity.dynamic_data.p_movement.path[1]
entity.dynamic_data.movement.follow_speedup = true entity.dynamic_data.movement.follow_speedup = follow_speedup
return true return true
end end