Monster movement as FTE's sv_move.c has it, with gravity along -z: a step that
climbs stairs and slopes and refuses ledges, flying and swimming that rise or sink
toward the enemy, turning toward ideal_yaw, and the choice of a new direction toward
a goal when the way ahead is blocked.
{server, moved?} = QuakeServer.Steps.move_step(server, monster, {dx, dy, 0.0}, true)
{server, moved?} =
QuakeServer.Steps.move_step(server, monster, move, true,
on_trace: &QuakeServer.Builtins.put_trace/2
)Steps are QuakeServer.Physics.step_size/1 high. Angles are brought into 0 up to 360
as FTE's anglemod does, in steps of 360/65536 degrees.
Summary
Functions
Whether entity stands with every corner of its box over ground: all four corners
just below the box in solid world, or a point trace down from each corner landing no
more than a step below the trace from the middle, which must land within two steps.
The box's top corner is sized from the world hull the entity's size chooses.
Turn entity's yaw toward its ideal_yaw by at most its yaw_speed.
Move entity by move if it can go there, returning {server, moved?}.
Step entity distance toward its goalentity, as the movetogoal builtin does:
nothing unless it is :onground, :fly or :swim; nothing when it has an enemy and
the goal's box is within distance of its own; otherwise one time in four, or when
the step along ideal_yaw fails, a new direction toward the goal.
Set entity's ideal_yaw to yaw, turn toward it, and step distance along it.
The step is taken back when the entity is still more than 45 degrees from facing
yaw. Relinks the entity either way. Returns {server, moved?}, moved? true
whenever the step was possible.
Types
@type on_trace() :: (QuakeServer.Server.t(), Cauldron3D.Hull.Trace.t() -> QuakeServer.Server.t())
Functions
@spec bottom?(QuakeServer.Server.t(), non_neg_integer()) :: boolean()
Whether entity stands with every corner of its box over ground: all four corners
just below the box in solid world, or a point trace down from each corner landing no
more than a step below the trace from the middle, which must land within two steps.
The box's top corner is sized from the world hull the entity's size chooses.
@spec change_yaw(QuakeServer.Server.t(), non_neg_integer()) :: QuakeServer.Server.t()
Turn entity's yaw toward its ideal_yaw by at most its yaw_speed.
@spec move_step( QuakeServer.Server.t(), non_neg_integer(), Cauldron3D.Vec.t(), boolean(), keyword() ) :: {QuakeServer.Server.t(), boolean()}
Move entity by move if it can go there, returning {server, moved?}.
An entity flagged :fly or :swim first tries the move raised or lowered 8 units
toward its enemy's height (lowered when more than 40 above it, raised when less than
30), then the plain move; a swimmer whose move would end outside water, slime, lava
or sky tries the next attempt. Anything else is pushed down from a step above the
wished position, from the position itself when that start is inside something, and
fails when it would walk off a ledge or leave a corner dangling, unless it is already
:partialground, when it moves (falling, with :onground cleared, if nothing is
below). Landing clears :partialground and sets groundentity.
relink? links the entity and touches triggers after a move. Options:
:enemy?— whether flying and swimming look at the enemy (defaulttrue); whenfalseonly one attempt is made unless a swimmer would leave the water:on_trace—fun(server, trace)called with every trace made, returning the server
@spec move_to_goal(QuakeServer.Server.t(), non_neg_integer(), number()) :: QuakeServer.Server.t()
Step entity distance toward its goalentity, as the movetogoal builtin does:
nothing unless it is :onground, :fly or :swim; nothing when it has an enemy and
the goal's box is within distance of its own; otherwise one time in four, or when
the step along ideal_yaw fails, a new direction toward the goal.
@spec step_direction(QuakeServer.Server.t(), non_neg_integer(), number(), number()) :: {QuakeServer.Server.t(), boolean()}
Set entity's ideal_yaw to yaw, turn toward it, and step distance along it.
The step is taken back when the entity is still more than 45 degrees from facing
yaw. Relinks the entity either way. Returns {server, moved?}, moved? true
whenever the step was possible.