70 struct Entity *owner_entity =
78 int32_t path_axis_or_input_lock_bits;
79 int32_t path_axis_or_jump_motion_bits;
88 movement_velocity.
x = path_axis_or_input_lock_bits;
93 path_axis_or_jump_motion_bits = owner_entity->
path_target.
z -
z;
94 movement_velocity.
z = path_axis_or_jump_motion_bits;
96 if (owner_entity->
flags &
ENTITY_FLAG_RUN_REQUEST && (uint32_t)path_axis_or_input_lock_bits + 0x200u <= 0x400u && (uint32_t)path_axis_or_jump_motion_bits + 0x200u <= 0x400u)
102 if (current_facing == facing_target)
106 movement_velocity.
x = -(
Math_SinQ14(blended_facing) >> 2);
111 movement_velocity.
x = -(
Math_SinQ14(facing_target) >> 2);
117 path_axis_or_input_lock_bits = movement_velocity.
x;
118 path_axis_or_jump_motion_bits = movement_velocity.
z;
121 movement_velocity.
y = 0;
125 path_axis_or_jump_motion_bits = 0;
126 path_axis_or_input_lock_bits = 0;
127 __builtin_memset(&movement_velocity, 0, 0xc);
134 .
x = -(path_axis_or_input_lock_bits),
136 .z = -(path_axis_or_jump_motion_bits)};
138 int64_t direction_x_squared_wide = (int64_t)movement_velocity.
x * movement_velocity.
x;
139 int64_t direction_y_squared_wide = (int64_t)movement_velocity.
y * movement_velocity.
y;
142 int64_t direction_z_squared_wide = (int64_t)movement_velocity.
z * movement_velocity.
z;
144 path_axis_or_input_lock_bits =
Math_SqrtFP12((int32_t)(((uint64_t)direction_z_squared_wide + (uint64_t)direction_x_squared_wide + (uint64_t)direction_y_squared_wide) >> 12));
145 path_axis_or_jump_motion_bits = 0;
147 if (path_axis_or_input_lock_bits)
149 path_axis_or_jump_motion_bits = path_axis_or_input_lock_bits;
151 int32_t reciprocal_direction_length = INT64_C(4294967296) / path_axis_or_jump_motion_bits;
152 int64_t normalized_x_product_wide = (int64_t)reciprocal_direction_length * movement_velocity.
x;
154 inout_velocity.
x = ((int32_t)((uint64_t)normalized_x_product_wide >> 12)) >> 8;
156 int64_t normalized_y_product_wide = (int64_t)reciprocal_direction_length * movement_velocity.
y;
158 inout_velocity.
y = ((int32_t)((uint64_t)normalized_y_product_wide >> 12)) >> 8;
160 int64_t normalized_z_product_wide = (int64_t)reciprocal_direction_length * movement_velocity.
z;
162 path_axis_or_input_lock_bits = ((int32_t)((uint64_t)normalized_z_product_wide >> 12)) >> 8;
163 inout_velocity.
z = path_axis_or_input_lock_bits;
166 __builtin_memset(&inout_velocity, 0, 0xc);
168 moving_actor = actor;
171 __builtin_memset(&inout_velocity, 0, 0xc);
193 __builtin_memset(&movement_velocity, 0, 0xc);
205 __builtin_memset(&movement_velocity, 0, 0xc);
236 if (current_level_id < LEVEL_BONUS_FIRST || current_level_id >=
LEVEL_AFTER_BONUS)
238 uint32_t flags_1 = owner_entity->
flags;
241 owner_entity->
flags = flags_1;
250 int32_t player_index;
267 __builtin_memset(&movement_velocity, 0, 0xc);
270 __builtin_memset(&movement_velocity, 0, 0xc);
273 inout_velocity = movement_velocity;
279 if (input_lock_ticks)
288 int32_t param_max_speed_1;
291 param_max_speed_1 = 0;
297 speed_z = param_max_speed_1;
302 speed_z = param_max_speed_1;
308 if (path_axis_or_jump_motion_bits)
317 param_max_speed_1 = 0;
329 if (param_max_speed_1)
338 if (param_max_speed_2_1)
339 param_max_speed_2_1 =
340 ((int64_t)descent_horizontal_distance * 4096) / param_max_speed_2_1;
342 path_axis_or_jump_motion_bits = param_max_speed_2_1;
345 int32_t saved_descent_travel_time = path_axis_or_jump_motion_bits;
347 if (param_max_speed_1_1)
349 param_max_speed_1_1 =
350 ((int64_t)speed_z * 4096) / param_max_speed_1_1;
351 path_axis_or_jump_motion_bits = saved_descent_travel_time;
354 if (path_axis_or_jump_motion_bits < param_max_speed_1_1)
356 if (!param_max_speed_1_1)
360 path_axis_or_jump_motion_bits = param_max_speed_1_1;
362 ((int64_t)descent_horizontal_distance * 4096) / path_axis_or_jump_motion_bits;
365 else if (!path_axis_or_jump_motion_bits)
370 path_axis_or_jump_motion_bits = saved_descent_travel_time;
372 ((int64_t)speed_z * 4096) / path_axis_or_jump_motion_bits;
381 if (path_axis_or_jump_motion_bits)
385 param_max_speed_1 = 0;
397 if (param_max_speed_1)
404 if (param_max_speed_2)
406 ((int64_t)ascent_horizontal_distance * 4096) / param_max_speed_2;
408 path_axis_or_jump_motion_bits = param_max_speed_2;
411 int32_t saved_ascent_travel_time = path_axis_or_jump_motion_bits;
413 if (param_max_speed_0)
416 ((int64_t)speed_z * 4096) / param_max_speed_0;
417 path_axis_or_jump_motion_bits = saved_ascent_travel_time;
420 if (path_axis_or_jump_motion_bits < param_max_speed_0)
422 if (!param_max_speed_0)
426 path_axis_or_jump_motion_bits = param_max_speed_0;
428 ((int64_t)ascent_horizontal_distance * 4096) / path_axis_or_jump_motion_bits;
431 else if (!path_axis_or_jump_motion_bits)
435 path_axis_or_jump_motion_bits = saved_ascent_travel_time;
437 ((int64_t)speed_z * 4096) / path_axis_or_jump_motion_bits;
448 int32_t ground_jump_velocity;
450 if (jump_phase_ticks >= 0)
457 if (!jump_phase_ticks)
461 if (ground_jump_velocity)
468 moving_actor->
velocity.
y = ground_jump_velocity;
492 if ((uint8_t)jump_phase_ticks == 0xff)
496 if (ground_jump_velocity)
503 moving_actor->
velocity.
y = ground_jump_velocity;
513 else if (jump_phase_ticks <= 0)
517 if (jump_grace_ticks)
529 moving_actor->
velocity.
y = cached_jump_velocity;
543 if ((int8_t)(jump_phase_ticks - 1) < -60)
561 if (jump_phase_ticks == 1)