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:
parent
064db78a33
commit
f88282adee
@ -430,15 +430,17 @@ function mgen_flee.set_acceleration(entity,accel,speedup,pos)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- name: set_target(entity,target)
|
||||
-- name: set_target(entity, target, follow_speedup, max_distance)
|
||||
--
|
||||
--! @brief set target for movgen
|
||||
--! @memberof mgen_flee
|
||||
--
|
||||
--! @param entity mob to apply to
|
||||
--! @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(target ~= nil)
|
||||
entity.dynamic_data.movement.target = target
|
||||
|
@ -607,16 +607,19 @@ function mgen_follow.set_acceleration(entity,accel,speedup,pos)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- name: set_target(entity,target)
|
||||
-- name: set_target(entity, target, follow_speedup, max_distance)
|
||||
--
|
||||
--! @brief set target for movgen
|
||||
--! @memberof mgen_follow
|
||||
--
|
||||
--! @param entity mob to apply to
|
||||
--! @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.max_distance = max_distance
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Mob Framework Mod by Sapier
|
||||
--
|
||||
--
|
||||
-- You may copy, use, modify or do nearly anything except removing this
|
||||
-- copyright notice.
|
||||
-- copyright notice.
|
||||
-- And of course you are NOT allow to pretend you have written it.
|
||||
--
|
||||
--! @file main_follow.lua
|
||||
@ -14,7 +14,7 @@
|
||||
--! @defgroup mgen_jordan4ibanez MGEN: a velocity based movement generator
|
||||
--! @brief A movement generator creating simple random movement
|
||||
--! @ingroup framework_int
|
||||
--! @{
|
||||
--! @{
|
||||
-- Contact sapier a t gmx net
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@ -61,8 +61,8 @@ function mgen_jordan4ibanez.callback(entity,now)
|
||||
entity.dynamic_data.movement.yaw = 360 * math.random()
|
||||
entity.object:setyaw(entity.dynamic_data.movement.yaw)
|
||||
entity.dynamic_data.movement.turn_timer = 0
|
||||
entity.dynamic_data.movement.direction = {x = math.sin(entity.dynamic_data.movement.yaw)*-1,
|
||||
y = -10,
|
||||
entity.dynamic_data.movement.direction = {x = math.sin(entity.dynamic_data.movement.yaw)*-1,
|
||||
y = -10,
|
||||
z = math.cos(entity.dynamic_data.movement.yaw)}
|
||||
--entity.object:setvelocity({x=entity.dynamic_data.movement.direction.x,y=entity.object:getvelocity().y,z=entity.dynamic_data.movement.direction.z})
|
||||
--entity.object:setacceleration(entity.dynamic_data.movement.direction)
|
||||
@ -140,13 +140,15 @@ function mgen_jordan4ibanez.init_dynamic_data(entity,now)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- name: set_target(entity,target)
|
||||
-- name: set_target(entity, target, follow_speedup, max_distance)
|
||||
--
|
||||
--! @brief set target for movgen
|
||||
--! @memberof mgen_jordan4ibanez
|
||||
--
|
||||
--! @param entity mob to apply to
|
||||
--! @param target to set
|
||||
--! @param entity mob to apply to --unused here
|
||||
--! @param target to set --unused here
|
||||
--! @param follow_speedup --unused here
|
||||
--! @param max_distance --unused here
|
||||
-------------------------------------------------------------------------------
|
||||
function mgen_jordan4ibanez.set_target(entity,target)
|
||||
return false
|
||||
|
@ -270,7 +270,7 @@ function p_mov_gen.set_end_of_path_handler(entity,handler)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- name: set_target(entity,target)
|
||||
-- name: set_target(entity, target, follow_speedup, max_distance)
|
||||
--
|
||||
--! @brief set target for movgen
|
||||
--! @memberof p_mov_gen
|
||||
@ -279,8 +279,9 @@ end
|
||||
--! @param entity mob to apply to
|
||||
--! @param target to set
|
||||
--! @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)
|
||||
|
||||
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)
|
||||
entity.dynamic_data.movement.target =
|
||||
entity.dynamic_data.p_movement.path[2]
|
||||
entity.dynamic_data.movement.follow_speedup = true
|
||||
entity.dynamic_data.movement.follow_speedup = follow_speedup
|
||||
return true
|
||||
end
|
||||
|
||||
@ -347,7 +348,7 @@ function p_mov_gen.set_target(entity, target, follow_speedup)
|
||||
table.insert(entity.dynamic_data.p_movement.path,targetpos)
|
||||
entity.dynamic_data.movement.target =
|
||||
entity.dynamic_data.p_movement.path[1]
|
||||
entity.dynamic_data.movement.follow_speedup = true
|
||||
entity.dynamic_data.movement.follow_speedup = follow_speedup
|
||||
return true
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user