26 uint8_t **instruction_pointer = script_cursor_inout;
27 int32_t best_path_distance;
28 uint32_t fail_target_delta = 0;
29 uint8_t *operand_cursor = (*instruction_pointer + 2);
31 *instruction_pointer = (operand_cursor);
32 fail_target_delta = (uint32_t)(operand_cursor[-2]) << 8;
33 fail_target_delta |= operand_cursor[-1];
34 *instruction_pointer = (&operand_cursor[2]);
36 int16_t target_selector = (uint32_t)*operand_cursor << 8;
38 target_selector |= operand_cursor[1];
40 int16_t resolved_selector = target_selector;
44 *instruction_pointer = (&operand_cursor[6]);
46 int32_t move_param = (uint32_t)(operand_cursor[2]) << 24;
48 move_param |= (uint32_t)(operand_cursor[4]) << 8;
49 move_param |= (uint32_t)(operand_cursor[3]) << 16;
50 move_param |= operand_cursor[5];
51 best_path_distance = move_param;
55 best_path_distance = INT32_MAX;
56 *instruction_pointer = (&operand_cursor[6]);
68 resolved_selector = target_selector + (int16_t)(target_selector >> 0x1f) + 1;
73 resolved_selector = target_selector + (target_selector >> 0x1f) + 1;
80 resolved_selector = (uint16_t)resolved_entity_index_quotient + (int16_t)(resolved_entity_index_quotient >> 0x1f) + 1;
84 uint32_t flags = script_entity->
flags;
89 uint8_t next_group_index = script_entity->
active_flag + 1;
93 if (next_group_index >= bonus_respawn_mode_1)
101 uint32_t flags_1 = script_entity->
flags;
106 script_entity->
flags = flags_1;
110 uint8_t previous_group_or_wrap_count = script_entity->
active_flag;
112 script_entity->
active_flag = previous_group_or_wrap_count - 1;
114 if (!previous_group_or_wrap_count)
117 script_entity->
active_flag = previous_group_or_wrap_count;
119 if (previous_group_or_wrap_count)
120 script_entity->
active_flag = previous_group_or_wrap_count - 1;
125 uint32_t flags_2 = script_entity->
flags;
128 script_entity->
flags = flags_2;
135 script_entity->
flags = random_group_flags;
139 if (bonus_respawn_mode > 1)
154 if (!best_path_distance)
155 best_path_distance = INT32_MAX;
157 int16_t traced_target_selector =
Actor_TracePath(script_entity, (int32_t)resolved_selector, INT32_MAX,
158 best_path_distance, 0);
160 if (!traced_target_selector)
162 *instruction_pointer = (&operand_cursor[fail_target_delta]);
175 uint32_t fail_target_delta = 0;
176 int16_t target_selector = 0;
177 uint8_t *operand_cursor = (*script_cursor_inout + 2);
179 *script_cursor_inout = (operand_cursor);
181 int16_t attach_value = 0;
183 fail_target_delta = (uint32_t)(operand_cursor[-2]) << 8;
184 fail_target_delta |= operand_cursor[-1];
185 *script_cursor_inout = (&operand_cursor[2]);
186 target_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
187 target_selector |= operand_cursor[1];
188 *script_cursor_inout = (&operand_cursor[4]);
190 int16_t resolved_target_selector = target_selector;
192 attach_value = (uint32_t)(operand_cursor[2]) << 8;
193 attach_value |= operand_cursor[3];
194 *script_cursor_inout = (&operand_cursor[8]);
196 int32_t distance_hi_value = (uint32_t)(operand_cursor[4]) << 24;
198 distance_hi_value |= (uint32_t)(operand_cursor[6]) << 8;
199 distance_hi_value |= (uint32_t)(operand_cursor[5]) << 16;
200 distance_hi_value |= operand_cursor[7];
206 resolved_target_selector = (uint16_t)entity_index_quotient + (int32_t)((uint32_t)entity_index_quotient >> 0x1f) + 1;
210 uint32_t flags_1 = script_current_entity_1->
flags;
216 script_current_entity_1->
flags = cleared_movement_flags;
218 int32_t group_movement_flags = cleared_movement_flags;
232 uint8_t next_group_index = script_current_entity_1->
active_flag + 1;
233 bool group_index_in_range = next_group_index < script_current_entity_1->
bonus_respawn_mode;
235 script_current_entity_1->
active_flag = next_group_index;
237 if (!group_index_in_range)
248 script_current_entity_1->
flags = group_movement_flags;
252 uint8_t previous_group_or_wrap_count = script_current_entity_1->
active_flag;
254 script_current_entity_1->
active_flag = previous_group_or_wrap_count - 1;
256 if (!previous_group_or_wrap_count)
259 script_current_entity_1->
active_flag = previous_group_or_wrap_count;
261 if (previous_group_or_wrap_count)
262 script_current_entity_1->
active_flag = previous_group_or_wrap_count - 1;
267 uint32_t
flags = script_current_entity_1->
flags;
277 script_current_entity_1->
flags = random_group_flags;
298 if (!
Actor_TracePath(script_current_entity_1, (int32_t)resolved_target_selector,
299 distance_hi_value, INT32_MAX, 0x20))
301 *script_cursor_inout = (&operand_cursor[fail_target_delta]);
318 uint32_t success_delta = 0;
319 uint32_t attach_value_word = 0;
320 uint8_t *operand_cursor = (*script_cursor_inout + 2);
322 *script_cursor_inout = operand_cursor;
323 success_delta = (uint32_t)(operand_cursor[-2]) << 8;
324 success_delta |= operand_cursor[-1];
326 uint8_t *resume_cursor = &operand_cursor[success_delta];
327 int16_t target_selector = 0;
329 *script_cursor_inout = &operand_cursor[2];
330 target_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
331 target_selector |= operand_cursor[1];
332 *script_cursor_inout = &operand_cursor[4];
334 attach_value_word = (uint32_t)(operand_cursor[2]) << 8;
335 attach_value_word |= operand_cursor[3];
336 *script_cursor_inout = &operand_cursor[8];
338 int32_t distance_high_word_value = (uint32_t)(operand_cursor[4]) << 24;
340 distance_high_word_value |= (uint32_t)(operand_cursor[5]) << 16;
341 distance_high_word_value |= (uint32_t)(operand_cursor[6]) << 8;
342 distance_high_word_value |= operand_cursor[7];
344 int32_t best_path_distance = distance_high_word_value;
350 target_selector = (uint16_t)distance_byte_or_entity_quotient + ((uint32_t)distance_byte_or_entity_quotient >> 0x1f) + 1;
354 uint32_t
flags = script_current_entity_1->
flags;
369 *script_cursor_inout = resume_cursor;
376 uint16_t group_index;
379 if ((uint8_t)group_count_bits)
383 group_index = (uint8_t)script_current_entity_1->
active_flag;
389 if ((int16_t)group_index >= (uint16_t)(uint8_t)group_count_bits)
393 target_selector = -1 - (uint16_t)group_index;
395 script_current_entity_1->
flags = flags;
399 group_index = (uint8_t)script_current_entity_1->
active_flag;
404 script_current_entity_1->
flags = flags;
408 int16_t prior_group_index = (uint16_t)group_index;
412 if (!prior_group_index)
414 group_index = (uint16_t)(uint8_t)group_count_bits;
416 if ((uint16_t)group_index)
422 uint32_t flags_1 = script_current_entity_1->
flags;
424 target_selector = -1 - (uint16_t)group_index;
426 script_current_entity_1->
flags = flags_1;
430 group_index = (uint8_t)script_current_entity_1->
active_flag;
437 script_current_entity_1->
flags = random_group_flags;
439 if ((uint8_t)group_count_bits > 1)
450 group_index = (uint16_t)i;
454 target_selector = -1 - (uint16_t)group_index;
458 if (!best_path_distance)
459 best_path_distance = INT32_MAX;
461 if (!
Actor_TracePath(script_current_entity_1, (int32_t)target_selector, INT32_MAX,
462 best_path_distance, 0x40))
471 *script_cursor_inout = resume_cursor;
481 uint32_t fail_delta = 0;
482 int16_t target_selector = 0;
483 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
485 *script_cursor_inout = operand_cursor;
486 fail_delta = (uint32_t)(operand_cursor[-2]) << 8;
487 fail_delta |= operand_cursor[-1];
488 *script_cursor_inout = &operand_cursor[2];
489 target_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
490 target_selector |= operand_cursor[1];
491 *script_cursor_inout = &operand_cursor[6];
493 int32_t rotation_param = (uint32_t)(operand_cursor[2]) << 24;
495 rotation_param |= (uint32_t)(operand_cursor[3]) << 16;
496 rotation_param |= (uint32_t)(operand_cursor[4]) << 8;
497 rotation_param |= operand_cursor[5];
499 int16_t attach_value = 0;
501 *script_cursor_inout = &operand_cursor[8];
502 attach_value = (uint32_t)(operand_cursor[6]) << 8;
503 attach_value |= operand_cursor[7];
514 *script_cursor_inout = &operand_cursor[fail_delta];
521 int16_t move_target_selector_raw = 0;
522 int16_t facing_selector_raw = 0;
523 uint8_t *operand_cursor = (*script_cursor_inout + 2);
525 *script_cursor_inout = operand_cursor;
526 move_target_selector_raw = (uint32_t)(operand_cursor[-2]) << 8;
527 move_target_selector_raw |= operand_cursor[-1];
528 *script_cursor_inout = &operand_cursor[2];
530 int16_t move_target_selector = move_target_selector_raw;
532 facing_selector_raw = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
533 facing_selector_raw |= operand_cursor[1];
534 *script_cursor_inout = &operand_cursor[6];
536 int16_t facing_selector = facing_selector_raw;
537 int32_t move_param = (uint32_t)(operand_cursor[2]) << 24;
539 move_param |= (uint32_t)(operand_cursor[3]) << 16;
540 move_param |= (uint32_t)(operand_cursor[4]) << 8;
541 move_param |= operand_cursor[5];
542 *script_cursor_inout = &operand_cursor[0xa];
544 int32_t movement_parameter_high_word_value = (uint32_t)(operand_cursor[6]) << 24;
546 movement_parameter_high_word_value |= (uint32_t)(operand_cursor[7]) << 16;
547 movement_parameter_high_word_value |= (uint32_t)(operand_cursor[8]) << 8;
551 movement_parameter_high_word_value |= operand_cursor[9];
553 int32_t movement_parameter = movement_parameter_high_word_value;
559 move_target_selector = (uint16_t)movement_byte_or_entity_quotient + (movement_byte_or_entity_quotient >> 0x1f) + 1;
566 facing_selector = (uint16_t)movement_byte_or_entity_quotient + (movement_byte_or_entity_quotient >> 0x1f) + 1;
573 uint32_t
flags = script_current_entity_1->
flags;
577 uint8_t next_group_index = script_current_entity_1->
active_flag + 1;
578 bool group_index_in_range = next_group_index < script_current_entity_1->
bonus_respawn_mode;
580 script_current_entity_1->
active_flag = next_group_index;
582 if (!group_index_in_range)
590 uint32_t flags_1 = script_current_entity_1->
flags;
595 script_current_entity_1->
flags = flags_1;
599 uint8_t previous_group_or_wrap_count = script_current_entity_1->
active_flag;
601 script_current_entity_1->
active_flag = previous_group_or_wrap_count - 1;
603 if (!previous_group_or_wrap_count)
606 script_current_entity_1->
active_flag = previous_group_or_wrap_count;
608 if (previous_group_or_wrap_count)
609 script_current_entity_1->
active_flag = previous_group_or_wrap_count - 1;
614 uint32_t flags_2 = script_current_entity_1->
flags;
617 script_current_entity_1->
flags = flags_2;
625 script_current_entity_1->
flags = random_group_flags;
642 uint32_t flags_3 = script_current_entity_1->
flags;
649 Actor_TracePath(script_current_entity_1, (int32_t)move_target_selector, INT32_MAX,
664 move_param, movement_parameter);
671 uint32_t fail_target_delta = 0;
672 int16_t entity_selector = 0;
673 uint8_t *operand_cursor = (*script_cursor_inout + 2);
675 *script_cursor_inout = operand_cursor;
676 fail_target_delta = (uint32_t)(operand_cursor[-2]) << 8;
677 fail_target_delta |= operand_cursor[-1];
678 *script_cursor_inout = &operand_cursor[2];
679 entity_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
680 entity_selector |= operand_cursor[1];
682 int16_t entity_selector_1 = entity_selector;
688 struct Entity *selector_entity;
694 selector_entity = script_current_entity_1;
698 selector_entity = entity;
703 entity_selector_1 = (uint16_t)entity_index_quotient + ((uint32_t)entity_index_quotient >> 0x1f) + 1;
706 int32_t saved_collision_push_xz = script_current_entity_1->
param_10C;
711 int16_t traced_entity_selector =
Actor_TracePath(script_current_entity_1, (int32_t)entity_selector_1, INT32_MAX,
714 if (!traced_entity_selector)
717 *script_cursor_inout = &operand_cursor[fail_target_delta];
730 uint8_t *operands = *script_cursor_inout;
731 uint8_t *failure_cursor = operands + 2 + ((uint32_t)operands[0] << 8 | operands[1]);
732 int16_t source = (uint16_t)operands[2] << 8 | operands[3];
733 int16_t target = (uint16_t)operands[4] << 8 | operands[5];
734 uint32_t
property = 0;
737 property = (uint32_t)operands[6] << 24 | (uint32_t)operands[7] << 16 | (uint32_t)operands[8] << 8 | operands[9];
739 *script_cursor_inout = operands + 10;
745 source = (int16_t)(((int32_t)((uintptr_t)current - (uintptr_t)entities)) / (int32_t)
sizeof(
struct Entity) + 1);
747 source = (int16_t)(((int32_t)((uintptr_t)entity - (uintptr_t)entities)) / (int32_t)
sizeof(
struct Entity) + 1);
750 target = (int16_t)(((int32_t)((uintptr_t)current - (uintptr_t)entities)) / (int32_t)
sizeof(
struct Entity) + 1);
752 target = (int16_t)(((int32_t)((uintptr_t)entity - (uintptr_t)entities)) / (int32_t)
sizeof(
struct Entity) + 1);
754 struct Entity *trace_entity = NULL;
755 int16_t saved_attach = 0;
756 int32_t saved_phase = 0, saved_step = 0, saved_property = 0;
762 trace_entity = current;
771 *script_cursor_inout = failure_cursor;
777 trace_entity = &entities[(int32_t)source - 1];
783 saved_property = trace_entity->
param_108;
797 *script_cursor_inout = failure_cursor;
804 trace_entity->
param_108 = saved_property;
814 uint8_t *operand_cursor = (*script_cursor_inout + 1);
816 *script_cursor_inout = (operand_cursor);
818 char nav_opcode = operand_cursor[-1];
819 int32_t duration_or_range;
820 int16_t resolved_selector;
824 int16_t target_selector = 0;
826 *script_cursor_inout = (&operand_cursor[2]);
827 target_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
828 target_selector |= operand_cursor[1];
829 *script_cursor_inout = (&operand_cursor[6]);
831 int32_t duration_or_range_high_word_value = (uint32_t)(operand_cursor[2]) << 24;
833 resolved_selector = target_selector;
834 duration_or_range_high_word_value |= (uint32_t)(operand_cursor[3]) << 16;
835 duration_or_range_high_word_value |= (uint32_t)(operand_cursor[4]) << 8;
836 duration_or_range_high_word_value |= operand_cursor[5];
837 duration_or_range = duration_or_range_high_word_value;
841 *script_cursor_inout = (&operand_cursor[6]);
852 (uint16_t)selected_entity_index_quotient + (int16_t)(selected_entity_index_quotient >> 0x1f);
857 if (resolved_selector >= 0)
859 if (!resolved_selector)
862 if (resolved_selector <= 0)
866 if (!duration_or_range)
867 duration_or_range = INT32_MAX;
872 (uint16_t)command_entity_index_quotient + (int16_t)(command_entity_index_quotient >> 0x1f) + 1, resolved_selector, duration_or_range,
881 uint32_t fail_target_delta = 0;
882 int32_t best_path_distance = 0;
883 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
886 *script_cursor_inout = operand_cursor;
887 fail_target_delta = (uint32_t)(operand_cursor[((int32_t)0xfffffffe)]) << 8;
888 fail_target_delta |= operand_cursor[-1];
889 *script_cursor_inout = &operand_cursor[1];
891 uint8_t trace_opcode = *(uint8_t *)operand_cursor;
894 *script_cursor_inout = &operand_cursor[7];
897 int16_t trace_flags_1 = 0;
899 *script_cursor_inout = &operand_cursor[3];
900 trace_flags_1 = (uint32_t)(operand_cursor[1]) << 8;
901 trace_flags_1 |= operand_cursor[2];
902 trace_flags = trace_flags_1;
906 *script_cursor_inout = &operand_cursor[7];
908 int32_t distance = (uint32_t)(operand_cursor[3]) << 24;
910 distance |= (uint32_t)(operand_cursor[5]) << 8;
911 distance |= (uint32_t)(operand_cursor[4]) << 16;
912 distance |= operand_cursor[6];
913 best_path_distance = distance;
916 *script_cursor_inout = &operand_cursor[7];
924 int32_t saved_path_result_x = script_entity->
path_result.
x;
925 int32_t saved_path_result_y = script_entity->
path_result.
y;
926 int32_t saved_path_result_z = script_entity->
path_result.
z;
929 best_path_distance, (int32_t)trace_flags))
930 *script_cursor_inout = &operand_cursor[fail_target_delta];
934 .
x = saved_path_result_x,
935 .y = saved_path_result_y,
936 .z = saved_path_result_z};
943 uint32_t block_end_delta = 0;
944 int16_t actor_selector = 0;
945 uint8_t *operand_cursor = (*script_cursor_inout + 2);
947 *script_cursor_inout = (operand_cursor);
948 block_end_delta = (uint32_t)(operand_cursor[-2]) << 8;
949 block_end_delta |= operand_cursor[-1];
952 uint8_t *block_end = &operand_cursor[block_end_delta];
954 *script_cursor_inout = (&operand_cursor[2]);
958 actor_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
959 actor_selector |= operand_cursor[1];
961 int16_t resolved_actor_selector = actor_selector;
967 resolved_actor_selector = (uint16_t)entity_index_quotient + (int16_t)(entity_index_quotient >> 0x1f) + 1;
970 if (!resolved_actor_selector)
975 if (resolved_actor_selector <= 0)
977 *script_cursor_inout = (block_end);
983 struct Entity *target_entity =
984 ¤t_level->
entity_array[(int32_t)resolved_actor_selector - 1];
986 if (target_entity != entity)
990 *script_cursor_inout = (block_end);
1003 uint8_t *nested_cursor = *script_cursor_inout;
1009 *script_cursor_inout = (&nested_cursor[1]);
1010 nested_opcode = (uint8_t)(*(uint8_t *)nested_cursor);
1012 nested_cursor = *script_cursor_inout;
1016 }
while (nested_cursor != block_end);
1025 int16_t actor_selector = 0;
1026 uint8_t *operand_cursor = (*script_cursor_inout + 2);
1028 *script_cursor_inout = (operand_cursor);
1029 actor_selector = (uint32_t)(operand_cursor[-2]) << 8;
1030 actor_selector |= operand_cursor[-1];
1032 if (actor_selector > 0)
1043 int16_t traced_actor_selector =
1048 .
x = saved_path_result_x,
1049 .y = saved_path_result_y,
1050 .z = saved_path_result_z};
1052 if (traced_actor_selector > 0)