102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference | GitLab repository
Loading...
Searching...
No Matches
movement_commands.c
Go to the documentation of this file.
1/* Recovered game implementation; original addresses identify provenance. */
11#include "pcdogs/math/types.h"
14#include "pcdogs/script/enums.h"
17#include <math.h>
18#include <stdarg.h>
19#include <string.h>
20
21// Original pcdogs.exe: 0x40fe60
22// Decodes a move selector and its selector-dependent distance payload, resolves group targets, and traces the current entity's path. A zero best-distance bound becomes INT_MAX; failure branches and success stores the attachment selector.
23void Script_OpMoveToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
24{
25 /* The native ECX push only reserves a stack slot. */
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);
30
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]);
35
36 int16_t target_selector = (uint32_t)*operand_cursor << 8;
37
38 target_selector |= operand_cursor[1];
39
40 int16_t resolved_selector = target_selector;
41
42 if (resolved_selector < (int16_t)SCRIPT_ENTITY_GROUP_NEXT || resolved_selector > (int16_t)SCRIPT_ENTITY_GROUP_RANDOM || resolved_selector == (int16_t)0x8003)
43 {
44 *instruction_pointer = (&operand_cursor[6]);
45
46 int32_t move_param = (uint32_t)(operand_cursor[2]) << 24;
47
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;
52 }
53 else
54 {
55 best_path_distance = INT32_MAX;
56 *instruction_pointer = (&operand_cursor[6]);
57 }
58
59 if (resolved_selector == SCRIPT_ENTITY_NO_TARGET)
60 return;
61
62 struct Entity *script_entity = g_scriptCurrentEntity;
63 struct Level_Data *current_level = pkg_resource_current_level_data;
64
65 if (resolved_selector == (int16_t)SCRIPT_ENTITY_CURRENT)
66 {
67 target_selector = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)script_entity - (char *)current_level->entity_array)) >> 38);
68 resolved_selector = target_selector + (int16_t)(target_selector >> 0x1f) + 1;
69 }
70 else if (resolved_selector == (int16_t)SCRIPT_ENTITY_EXECUTING)
71 {
72 target_selector = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)current_level->entity_array)) >> 38);
73 resolved_selector = target_selector + (target_selector >> 0x1f) + 1;
74 }
75
76 if (resolved_selector == (int16_t)SCRIPT_ENTITY_CURRENT)
77 {
78 int32_t resolved_entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)script_entity - (char *)current_level->entity_array)) >> 38);
79
80 resolved_selector = (uint16_t)resolved_entity_index_quotient + (int16_t)(resolved_entity_index_quotient >> 0x1f) + 1;
81 }
82 else if (resolved_selector == (int16_t)SCRIPT_ENTITY_GROUP_NEXT)
83 {
84 uint32_t flags = script_entity->flags;
85
87 {
88 uint8_t bonus_respawn_mode_1 = script_entity->bonus_respawn_mode;
89 uint8_t next_group_index = script_entity->active_flag + 1;
90
91 script_entity->active_flag = next_group_index;
92
93 if (next_group_index >= bonus_respawn_mode_1)
94 script_entity->active_flag = 0;
95 }
96
98 }
99 else if (resolved_selector == (int16_t)SCRIPT_ENTITY_GROUP_PREVIOUS)
100 {
101 uint32_t flags_1 = script_entity->flags;
102
104 {
105 flags_1 |= (uint8_t)(ENTITY_FLAG_GROUP_REVERSE);
106 script_entity->flags = flags_1;
107
108 if (!(((uint32_t)flags_1 >> 8 & 0xff) & (ENTITY_FLAG_GROUP_RANDOM >> 8)))
109 {
110 uint8_t previous_group_or_wrap_count = script_entity->active_flag;
111
112 script_entity->active_flag = previous_group_or_wrap_count - 1;
113
114 if (!previous_group_or_wrap_count)
115 {
116 previous_group_or_wrap_count = script_entity->bonus_respawn_mode;
117 script_entity->active_flag = previous_group_or_wrap_count;
118
119 if (previous_group_or_wrap_count)
120 script_entity->active_flag = previous_group_or_wrap_count - 1;
121 }
122 }
123 }
124
125 uint32_t flags_2 = script_entity->flags;
126
128 script_entity->flags = flags_2;
129 }
130 else if (resolved_selector == (int16_t)SCRIPT_ENTITY_GROUP_RANDOM)
131 {
132 int32_t random_group_flags = script_entity->flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_BIT_9);
133
134 random_group_flags |= ENTITY_FLAG_GROUP_RANDOM;
135 script_entity->flags = random_group_flags;
136
137 uint8_t bonus_respawn_mode = script_entity->bonus_respawn_mode;
138
139 if (bonus_respawn_mode > 1)
140 {
141 uint8_t i;
142 uint32_t range;
143
144 for (i = Math_GenerateRandom((uint32_t)bonus_respawn_mode);
145 i == script_entity->active_flag; i = Math_GenerateRandom(range))
146 {
147 range = (uint8_t)(script_entity->bonus_respawn_mode);
148 }
149
150 script_entity->active_flag = i;
151 }
152 }
153
154 if (!best_path_distance)
155 best_path_distance = INT32_MAX;
156
157 int16_t traced_target_selector = Actor_TracePath(script_entity, (int32_t)resolved_selector, INT32_MAX,
158 best_path_distance, 0);
159
160 if (!traced_target_selector)
161 {
162 *instruction_pointer = (&operand_cursor[fail_target_delta]);
163
164 return;
165 }
166
167 script_entity->attach_offset_x = traced_target_selector;
168}
169
170// Original pcdogs.exe: 0x410070
171// Decodes a walk selector, animation identifier, and maximum path distance, then traces with the walk flag. Failure branches, and both outcomes store the animation identifier.
172void Script_OpWalkToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
173{
174 /* The native ECX push only reserves a stack slot. */
175 uint32_t fail_target_delta = 0;
176 int16_t target_selector = 0;
177 uint8_t *operand_cursor = (*script_cursor_inout + 2);
178
179 *script_cursor_inout = (operand_cursor);
180
181 int16_t attach_value = 0;
182
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]);
189
190 int16_t resolved_target_selector = target_selector;
191
192 attach_value = (uint32_t)(operand_cursor[2]) << 8;
193 attach_value |= operand_cursor[3];
194 *script_cursor_inout = (&operand_cursor[8]);
195
196 int32_t distance_hi_value = (uint32_t)(operand_cursor[4]) << 24;
197
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];
201
202 if (resolved_target_selector == (int16_t)SCRIPT_ENTITY_EXECUTING)
203 {
204 int32_t entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)pkg_resource_current_level_data->entity_array)) >> 38);
205
206 resolved_target_selector = (uint16_t)entity_index_quotient + (int32_t)((uint32_t)entity_index_quotient >> 0x1f) + 1;
207 }
208
209 struct Entity *script_current_entity_1 = g_scriptCurrentEntity;
210 uint32_t flags_1 = script_current_entity_1->flags;
211
212 script_current_entity_1->path_best_distance = 0;
213
214 int32_t cleared_movement_flags = flags_1 & (uint32_t)~(ENTITY_FLAG_WALK_REQUEST | ENTITY_FLAG_RUN_REQUEST);
215
216 script_current_entity_1->flags = cleared_movement_flags;
217
218 int32_t group_movement_flags = cleared_movement_flags;
219
220 if (resolved_target_selector == (int16_t)SCRIPT_ENTITY_CURRENT)
221 {
222 script_current_entity_1->default_anim_state = attach_value;
223
224 return;
225 }
226
227 if (resolved_target_selector == (int16_t)SCRIPT_ENTITY_GROUP_NEXT)
228 {
229 if (group_movement_flags & (ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_BIT_9))
230 {
231 // contact_tangent_4 low byte cycles against high byte for special target selectors.
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;
234
235 script_current_entity_1->active_flag = next_group_index;
236
237 if (!group_index_in_range)
238 script_current_entity_1->active_flag = 0;
239 }
240
241 script_current_entity_1->flags = group_movement_flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_RANDOM | ENTITY_FLAG_GROUP_BIT_9);
242 }
243 else if (resolved_target_selector == (int16_t)SCRIPT_ENTITY_GROUP_PREVIOUS)
244 {
246 {
247 group_movement_flags |= (uint8_t)(ENTITY_FLAG_GROUP_REVERSE);
248 script_current_entity_1->flags = group_movement_flags;
249
250 if (!(((uint32_t)group_movement_flags >> 8 & 0xff) & (ENTITY_FLAG_GROUP_RANDOM >> 8)))
251 {
252 uint8_t previous_group_or_wrap_count = script_current_entity_1->active_flag;
253
254 script_current_entity_1->active_flag = previous_group_or_wrap_count - 1;
255
256 if (!previous_group_or_wrap_count)
257 {
258 previous_group_or_wrap_count = script_current_entity_1->bonus_respawn_mode;
259 script_current_entity_1->active_flag = previous_group_or_wrap_count;
260
261 if (previous_group_or_wrap_count)
262 script_current_entity_1->active_flag = previous_group_or_wrap_count - 1;
263 }
264 }
265 }
266
267 uint32_t flags = script_current_entity_1->flags;
268
270 script_current_entity_1->flags = flags;
271 }
272 else if (resolved_target_selector == (int16_t)SCRIPT_ENTITY_GROUP_RANDOM && (group_movement_flags & (ENTITY_FLAG_GROUP_RANDOM | ENTITY_FLAG_GROUP_BIT_9)) != ENTITY_FLAG_GROUP_RANDOM)
273 {
274 int32_t random_group_flags = group_movement_flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_BIT_9);
275
276 random_group_flags |= ENTITY_FLAG_GROUP_RANDOM;
277 script_current_entity_1->flags = random_group_flags;
278
279 uint8_t bonus_respawn_mode = script_current_entity_1->bonus_respawn_mode;
280
281 if (bonus_respawn_mode > 1)
282 {
283 uint8_t i;
284 uint32_t range;
285
286 for (i = Math_GenerateRandom((uint32_t)bonus_respawn_mode);
287 i == script_current_entity_1->active_flag; i = Math_GenerateRandom(range))
288 {
289 range = (uint8_t)(script_current_entity_1->bonus_respawn_mode);
290 }
291
292 script_current_entity_1->active_flag = i;
293 }
294 }
295
296 script_current_entity_1->flags |= ENTITY_FLAG_WALK_REQUEST;
297
298 if (!Actor_TracePath(script_current_entity_1, (int32_t)resolved_target_selector,
299 distance_hi_value, INT32_MAX, 0x20))
300 {
301 *script_cursor_inout = (&operand_cursor[fail_target_delta]);
302 // Store attach-value operand into attach_offset.x high word after failed path branch.
303 script_current_entity_1->default_anim_state = attach_value;
304
305 return;
306 }
307
308 if (resolved_target_selector != (int16_t)SCRIPT_ENTITY_GROUP_NEXT && resolved_target_selector != (int16_t)SCRIPT_ENTITY_GROUP_PREVIOUS && resolved_target_selector != (int16_t)SCRIPT_ENTITY_GROUP_RANDOM)
309 script_current_entity_1->path_best_distance = 0;
310
311 script_current_entity_1->default_anim_state = attach_value;
312}
313
314// Original pcdogs.exe: 0x410250
315// Decodes a run selector, animation identifier, and best-distance bound, resolving group targets before tracing. A zero bound becomes INT_MAX, success installs the resume cursor, and both outcomes store the animation identifier.
316void Script_OpRunToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
317{
318 uint32_t success_delta = 0;
319 uint32_t attach_value_word = 0;
320 uint8_t *operand_cursor = (*script_cursor_inout + 2);
321
322 *script_cursor_inout = operand_cursor;
323 success_delta = (uint32_t)(operand_cursor[-2]) << 8;
324 success_delta |= operand_cursor[-1];
325
326 uint8_t *resume_cursor = &operand_cursor[success_delta];
327 int16_t target_selector = 0;
328
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];
333
334 attach_value_word = (uint32_t)(operand_cursor[2]) << 8;
335 attach_value_word |= operand_cursor[3];
336 *script_cursor_inout = &operand_cursor[8];
337
338 int32_t distance_high_word_value = (uint32_t)(operand_cursor[4]) << 24;
339
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];
343
344 int32_t best_path_distance = distance_high_word_value;
345
346 if ((uint16_t)target_selector == SCRIPT_ENTITY_EXECUTING)
347 {
348 int32_t distance_byte_or_entity_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)pkg_resource_current_level_data->entity_array)) >> 38);
349
350 target_selector = (uint16_t)distance_byte_or_entity_quotient + ((uint32_t)distance_byte_or_entity_quotient >> 0x1f) + 1;
351 }
352
353 struct Entity *script_current_entity_1 = g_scriptCurrentEntity;
354 uint32_t flags = script_current_entity_1->flags;
355
356 script_current_entity_1->path_best_distance = 0;
357 flags &= ~(uint32_t)(uint8_t)(ENTITY_FLAG_WALK_REQUEST);
358 flags |= (uint8_t)(ENTITY_FLAG_RUN_REQUEST);
359 script_current_entity_1->flags = flags;
360
361 if ((uint16_t)target_selector == SCRIPT_ENTITY_CURRENT)
362 {
363 struct Math_Vec3I32 *position_ptr = script_current_entity_1->position_ptr;
364
365 // Selector 0x8008 copies component triplet into path_target vector.
366 script_current_entity_1->path_target.x = position_ptr->x;
367 script_current_entity_1->path_target.y = position_ptr->y;
368 script_current_entity_1->path_target.z = position_ptr->z;
369 *script_cursor_inout = resume_cursor;
370 // Store attach-value operand after direct path_target copy path.
371 script_current_entity_1->default_anim_state = (uint16_t)attach_value_word;
372
373 return;
374 }
375
376 uint16_t group_index;
377 uint8_t group_count_bits = script_current_entity_1->bonus_respawn_mode;
378
379 if ((uint8_t)group_count_bits)
380 {
381 if ((uint16_t)target_selector == SCRIPT_ENTITY_GROUP_NEXT)
382 {
383 group_index = (uint8_t)script_current_entity_1->active_flag;
384
385 if ((uint8_t)flags & ENTITY_FLAG_GROUP_REVERSE)
386 {
387 group_index += 1;
388
389 if ((int16_t)group_index >= (uint16_t)(uint8_t)group_count_bits)
390 group_index = 0;
391 }
392
393 target_selector = -1 - (uint16_t)group_index;
395 script_current_entity_1->flags = flags;
396 }
397 else if ((uint16_t)target_selector == SCRIPT_ENTITY_GROUP_PREVIOUS)
398 {
399 group_index = (uint8_t)script_current_entity_1->active_flag;
400
401 if (!((uint8_t)flags & ENTITY_FLAG_GROUP_REVERSE))
402 {
403 flags |= (uint8_t)(ENTITY_FLAG_GROUP_REVERSE);
404 script_current_entity_1->flags = flags;
405
406 if (!(((uint32_t)flags >> 8 & 0xff) & (ENTITY_FLAG_GROUP_RANDOM >> 8)))
407 {
408 int16_t prior_group_index = (uint16_t)group_index;
409
410 group_index -= 1;
411
412 if (!prior_group_index)
413 {
414 group_index = (uint16_t)(uint8_t)group_count_bits;
415
416 if ((uint16_t)group_index)
417 group_index -= 1;
418 }
419 }
420 }
421
422 uint32_t flags_1 = script_current_entity_1->flags;
423
424 target_selector = -1 - (uint16_t)group_index;
426 script_current_entity_1->flags = flags_1;
427 }
428 else if ((uint16_t)target_selector == SCRIPT_ENTITY_GROUP_RANDOM)
429 {
430 group_index = (uint8_t)script_current_entity_1->active_flag;
431
432 if (!(((uint32_t)flags >> 8 & 0xff) & (ENTITY_FLAG_GROUP_RANDOM >> 8)))
433 {
434 int32_t random_group_flags = flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_BIT_9);
435
436 random_group_flags |= ENTITY_FLAG_GROUP_RANDOM;
437 script_current_entity_1->flags = random_group_flags;
438
439 if ((uint8_t)group_count_bits > 1)
440 {
441 uint8_t i;
442 uint32_t range;
443
444 for (i = Math_GenerateRandom((uint32_t)(uint8_t)group_count_bits);
445 i == (uint8_t)script_current_entity_1->active_flag; i = Math_GenerateRandom(range))
446 {
447 range = (uint8_t)(script_current_entity_1->bonus_respawn_mode);
448 }
449
450 group_index = (uint16_t)i;
451 }
452 }
453
454 target_selector = -1 - (uint16_t)group_index;
455 }
456 }
457
458 if (!best_path_distance)
459 best_path_distance = INT32_MAX;
460
461 if (!Actor_TracePath(script_current_entity_1, (int32_t)target_selector, INT32_MAX,
462 best_path_distance, 0x40))
463 {
464 // Clear best-distance scratch after trace failure before returning.
465 script_current_entity_1->path_best_distance = 0;
466 script_current_entity_1->default_anim_state = (uint16_t)attach_value_word;
467
468 return;
469 }
470
471 *script_cursor_inout = resume_cursor;
472 // Store attach-value operand after successful run-to-target trace.
473 script_current_entity_1->default_anim_state = (uint16_t)attach_value_word;
474}
475
476// Original pcdogs.exe: 0x410440
477// Decodes a facing target, rotation parameter, and animation identifier, clears movement mode state, and branches if the facing update fails.
478void Script_OpRotateActor(struct Entity *entity, uint8_t **script_cursor_inout)
479{
480 (void)entity;
481 uint32_t fail_delta = 0;
482 int16_t target_selector = 0;
483 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
484
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];
492
493 int32_t rotation_param = (uint32_t)(operand_cursor[2]) << 24;
494
495 rotation_param |= (uint32_t)(operand_cursor[3]) << 16;
496 rotation_param |= (uint32_t)(operand_cursor[4]) << 8;
497 rotation_param |= operand_cursor[5];
498
499 int16_t attach_value = 0;
500
501 *script_cursor_inout = &operand_cursor[8];
502 attach_value = (uint32_t)(operand_cursor[6]) << 8;
503 attach_value |= operand_cursor[7];
504
505 struct Entity *script_entity = g_scriptCurrentEntity;
506 uint32_t flags = script_entity->flags;
507
508 script_entity->path_best_distance = 0;
509 script_entity->flags = flags & (uint32_t)~(ENTITY_FLAG_WALK_REQUEST | ENTITY_FLAG_RUN_REQUEST);
510 script_entity->default_anim_state = attach_value;
511
512 if (!Actor_SetFacingTarget(script_entity, (int32_t)target_selector,
513 rotation_param))
514 *script_cursor_inout = &operand_cursor[fail_delta];
515}
516
517// Original pcdogs.exe: 0x4104d0
518// Resolves movement and facing selectors, resets path state, and snaps or moves the current entity using the decoded parameters.
519void Script_OpMoveToTargetWithCamera(struct Entity *entity, uint8_t **script_cursor_inout)
520{
521 int16_t move_target_selector_raw = 0;
522 int16_t facing_selector_raw = 0;
523 uint8_t *operand_cursor = (*script_cursor_inout + 2);
524
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];
529
530 int16_t move_target_selector = move_target_selector_raw;
531
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];
535
536 int16_t facing_selector = facing_selector_raw;
537 int32_t move_param = (uint32_t)(operand_cursor[2]) << 24;
538
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];
543
544 int32_t movement_parameter_high_word_value = (uint32_t)(operand_cursor[6]) << 24;
545
546 movement_parameter_high_word_value |= (uint32_t)(operand_cursor[7]) << 16;
547 movement_parameter_high_word_value |= (uint32_t)(operand_cursor[8]) << 8;
548
549 struct Level_Data *current_level = pkg_resource_current_level_data;
550
551 movement_parameter_high_word_value |= operand_cursor[9];
552
553 int32_t movement_parameter = movement_parameter_high_word_value;
554
555 if ((uint16_t)move_target_selector == SCRIPT_ENTITY_EXECUTING)
556 {
557 int32_t movement_byte_or_entity_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)current_level->entity_array)) >> 38);
558
559 move_target_selector = (uint16_t)movement_byte_or_entity_quotient + (movement_byte_or_entity_quotient >> 0x1f) + 1;
560 }
561
562 if ((uint16_t)facing_selector == SCRIPT_ENTITY_EXECUTING)
563 {
564 int32_t movement_byte_or_entity_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)current_level->entity_array)) >> 38);
565
566 facing_selector = (uint16_t)movement_byte_or_entity_quotient + (movement_byte_or_entity_quotient >> 0x1f) + 1;
567 }
568
569 struct Entity *script_current_entity_1 = g_scriptCurrentEntity;
570
571 if ((uint16_t)move_target_selector == SCRIPT_ENTITY_GROUP_NEXT)
572 {
573 uint32_t flags = script_current_entity_1->flags;
574
576 {
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;
579
580 script_current_entity_1->active_flag = next_group_index;
581
582 if (!group_index_in_range)
583 script_current_entity_1->active_flag = 0;
584 }
585
586 script_current_entity_1->flags = flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_RANDOM | ENTITY_FLAG_GROUP_BIT_9);
587 }
588 else if ((uint16_t)move_target_selector == SCRIPT_ENTITY_GROUP_PREVIOUS)
589 {
590 uint32_t flags_1 = script_current_entity_1->flags;
591
593 {
594 flags_1 |= ENTITY_FLAG_GROUP_REVERSE;
595 script_current_entity_1->flags = flags_1;
596
597 if (!(((uint32_t)flags_1 >> 8 & 0xff) & (ENTITY_FLAG_GROUP_RANDOM >> 8)))
598 {
599 uint8_t previous_group_or_wrap_count = script_current_entity_1->active_flag;
600
601 script_current_entity_1->active_flag = previous_group_or_wrap_count - 1;
602
603 if (!previous_group_or_wrap_count)
604 {
605 previous_group_or_wrap_count = script_current_entity_1->bonus_respawn_mode;
606 script_current_entity_1->active_flag = previous_group_or_wrap_count;
607
608 if (previous_group_or_wrap_count)
609 script_current_entity_1->active_flag = previous_group_or_wrap_count - 1;
610 }
611 }
612 }
613
614 uint32_t flags_2 = script_current_entity_1->flags;
615
617 script_current_entity_1->flags = flags_2;
618 }
619 else if ((uint16_t)move_target_selector == SCRIPT_ENTITY_GROUP_RANDOM)
620 {
621 uint8_t bonus_respawn_mode = script_current_entity_1->bonus_respawn_mode;
622 int32_t random_group_flags = script_current_entity_1->flags & (uint32_t)~(ENTITY_FLAG_GROUP_REVERSE | ENTITY_FLAG_GROUP_BIT_9);
623
624 random_group_flags |= ENTITY_FLAG_GROUP_RANDOM;
625 script_current_entity_1->flags = random_group_flags;
626
627 if (bonus_respawn_mode > 1)
628 {
629 uint8_t i;
630 uint32_t range;
631
632 for (i = Math_GenerateRandom((uint32_t)bonus_respawn_mode);
633 i == script_current_entity_1->active_flag; i = Math_GenerateRandom(range))
634 {
635 range = (uint8_t)(script_current_entity_1->bonus_respawn_mode);
636 }
637
638 script_current_entity_1->active_flag = i;
639 }
640 }
641
642 uint32_t flags_3 = script_current_entity_1->flags;
643
644 script_current_entity_1->path_best_distance = 0; // Clear best-distance scratch before trace/copy path.
645 script_current_entity_1->flags = flags_3 & (uint32_t)~(ENTITY_FLAG_WALK_REQUEST | ENTITY_FLAG_RUN_REQUEST);
646
647 if ((uint16_t)move_target_selector != SCRIPT_ENTITY_CURRENT)
648 {
649 Actor_TracePath(script_current_entity_1, (int32_t)move_target_selector, INT32_MAX,
651 script_current_entity_1->path_best_distance = 0;
652 }
653 else
654 {
655 struct Math_Vec3I32 *position_ptr = script_current_entity_1->position_ptr;
656
657 // Selector 0x8008 copies component triplet into path_target vector.
658 script_current_entity_1->path_target.x = position_ptr->x;
659 script_current_entity_1->path_target.y = position_ptr->y;
660 script_current_entity_1->path_target.z = position_ptr->z;
661 }
662
663 Actor_ResetVelocityAndMoveToTarget(script_current_entity_1, facing_selector,
664 move_param, movement_parameter);
665}
666
667// Original pcdogs.exe: 0x4107c0
668// Resolves an entity selector, traces toward it, and stores the resulting attachment selector or branches on failure. Selector 0x7fff skips the trace.
669void Script_OpPathfindToEntity(struct Entity *entity, uint8_t **script_cursor_inout)
670{
671 uint32_t fail_target_delta = 0;
672 int16_t entity_selector = 0;
673 uint8_t *operand_cursor = (*script_cursor_inout + 2);
674
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];
681
682 int16_t entity_selector_1 = entity_selector;
683
684 if (entity_selector_1 == SCRIPT_ENTITY_NO_TARGET)
685 return;
686
687 struct Entity *script_current_entity_1 = g_scriptCurrentEntity;
688 struct Entity *selector_entity;
689
690 if ((uint16_t)entity_selector_1 == SCRIPT_ENTITY_CURRENT || (uint16_t)entity_selector_1 == SCRIPT_ENTITY_EXECUTING)
691 {
692 if ((uint16_t)entity_selector_1 == SCRIPT_ENTITY_CURRENT)
693 {
694 selector_entity = script_current_entity_1;
695 }
696 else
697 {
698 selector_entity = entity;
699 }
700
701 int32_t entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)selector_entity - (char *)pkg_resource_current_level_data->entity_array)) >> 38);
702
703 entity_selector_1 = (uint16_t)entity_index_quotient + ((uint32_t)entity_index_quotient >> 0x1f) + 1;
704 }
705
706 int32_t saved_collision_push_xz = script_current_entity_1->param_10C;
707
708 script_current_entity_1->flags |= ENTITY_FLAG_FACING_REQUEST;
709
710 // TraceActorPath: Find path to target room, set flag 0x8 during pathfind
711 int16_t traced_entity_selector = Actor_TracePath(script_current_entity_1, (int32_t)entity_selector_1, INT32_MAX,
712 saved_collision_push_xz, ACTOR_TRACE_VIEW_CONE);
713
714 if (!traced_entity_selector)
715 {
716 // Path failed: jump to offset (conditional branch on pathfind failure)
717 *script_cursor_inout = &operand_cursor[fail_target_delta];
718
719 return;
720 }
721
722 // On success, attach_offset.x low word receives traced actor selector.
723 script_current_entity_1->attach_offset_x = traced_entity_selector;
724}
725
726// Original pcdogs.exe: 0x410860
727// Temporarily installs the selected entity's trace properties, performs the path test, and branches on failure. Saved attachment, phase, step, property, and path-result fields are restored afterward.
728void Script_OpTraceActorPath(struct Entity *entity, uint8_t **script_cursor_inout)
729{
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;
735
736 if (source != (int16_t)SCRIPT_ENTITY_NO_TRACE_SOURCE)
737 property = (uint32_t)operands[6] << 24 | (uint32_t)operands[7] << 16 | (uint32_t)operands[8] << 8 | operands[9];
738
739 *script_cursor_inout = operands + 10;
740
741 struct Entity *current = g_scriptCurrentEntity;
742 struct Entity *entities = pkg_resource_current_level_data->entity_array;
743
744 if (source == (int16_t)SCRIPT_ENTITY_CURRENT)
745 source = (int16_t)(((int32_t)((uintptr_t)current - (uintptr_t)entities)) / (int32_t)sizeof(struct Entity) + 1);
746 else if (source == (int16_t)SCRIPT_ENTITY_EXECUTING)
747 source = (int16_t)(((int32_t)((uintptr_t)entity - (uintptr_t)entities)) / (int32_t)sizeof(struct Entity) + 1);
748
749 if (target == (int16_t)SCRIPT_ENTITY_CURRENT)
750 target = (int16_t)(((int32_t)((uintptr_t)current - (uintptr_t)entities)) / (int32_t)sizeof(struct Entity) + 1);
751 else if (target == (int16_t)SCRIPT_ENTITY_EXECUTING)
752 target = (int16_t)(((int32_t)((uintptr_t)entity - (uintptr_t)entities)) / (int32_t)sizeof(struct Entity) + 1);
753
754 struct Entity *trace_entity = NULL;
755 int16_t saved_attach = 0;
756 int32_t saved_phase = 0, saved_step = 0, saved_property = 0;
757 struct Math_Vec3I32 saved_result;
758
759 if (source != (int16_t)SCRIPT_ENTITY_NO_TRACE_SOURCE)
760 {
761 if (source == (int16_t)SCRIPT_ENTITY_CURRENT)
762 trace_entity = current;
763 else
764 {
765 if (!source)
766 {
767 source = current->attach_offset_x;
768
769 if (source <= 0)
770 {
771 *script_cursor_inout = failure_cursor;
772
773 return;
774 }
775 }
776
777 trace_entity = &entities[(int32_t)source - 1];
778 }
779
780 saved_attach = trace_entity->attach_offset_x;
781 saved_phase = trace_entity->target_offset_phase;
782 saved_step = trace_entity->target_offset_step;
783 saved_property = trace_entity->param_108;
784 saved_result = trace_entity->path_result;
785
786 if (!target)
787 {
788 trace_entity->attach_offset_x = current->attach_offset_x;
789 trace_entity->path_result = current->path_result;
790 }
791
792 Entity_SetActorProperty(trace_entity, PROP_PARAM_108, property);
793 trace_entity->target_offset_phase = 0;
794 }
795
796 if (!Actor_TracePath(trace_entity, target, INT32_MAX, INT32_MAX, (ACTOR_TRACE_VIEW_CONE | ACTOR_TRACE_SKIP_ACTOR_OCCLUSION)))
797 *script_cursor_inout = failure_cursor;
798
799 if (trace_entity)
800 {
801 trace_entity->attach_offset_x = saved_attach;
802 trace_entity->target_offset_step = saved_step;
803 trace_entity->path_result = saved_result;
804 trace_entity->param_108 = saved_property;
805 trace_entity->target_offset_phase = saved_phase;
806 }
807}
808
809// Original pcdogs.exe: 0x410ac0
810// Decodes a navigation command and target selector, resolves the current entity index, and queues the command. Opcode 0x67 only updates the level's current entity index; other selector names remain descriptive rather than recovered enum names.
811void Script_OpAddNavigationCommand(struct Entity *entity, uint8_t **script_cursor_inout)
812{
813 (void)entity;
814 uint8_t *operand_cursor = (*script_cursor_inout + 1);
815
816 *script_cursor_inout = (operand_cursor);
817
818 char nav_opcode = operand_cursor[-1];
819 int32_t duration_or_range;
820 int16_t resolved_selector;
821
822 if (nav_opcode != SCRIPT_NAV_SELECT_CURRENT_ENTITY)
823 {
824 int16_t target_selector = 0;
825
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]);
830
831 int32_t duration_or_range_high_word_value = (uint32_t)(operand_cursor[2]) << 24;
832
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;
838 }
839 else
840 {
841 *script_cursor_inout = (&operand_cursor[6]);
842 }
843
844 struct Entity *script_entity = g_scriptCurrentEntity;
845
846 if (nav_opcode == SCRIPT_NAV_SELECT_CURRENT_ENTITY)
847 {
848 struct Level_Data *current_level = pkg_resource_current_level_data;
849 int32_t selected_entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)script_entity - (char *)current_level->entity_array)) >> 38);
850
851 current_level->current_entity_index =
852 (uint16_t)selected_entity_index_quotient + (int16_t)(selected_entity_index_quotient >> 0x1f);
853
854 return;
855 }
856
857 if (resolved_selector >= 0)
858 {
859 if (!resolved_selector)
860 resolved_selector = script_entity->attach_offset_x;
861
862 if (resolved_selector <= 0)
863 return;
864 }
865
866 if (!duration_or_range)
867 duration_or_range = INT32_MAX;
868
869 int32_t command_entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)script_entity - (char *)pkg_resource_current_level_data->entity_array)) >> 38);
870
871 Navigation_AddCommand((uint8_t)nav_opcode,
872 (uint16_t)command_entity_index_quotient + (int16_t)(command_entity_index_quotient >> 0x1f) + 1, resolved_selector, duration_or_range,
873 script_entity->position_ptr);
874}
875
876// Original pcdogs.exe: 0x410ba0
877// Performs a decoded path test and branches on failure, restoring the current entity's path-result vector afterward. Opcode 0xff consumes the operands without tracing.
878void Script_OpTestPathTrace(struct Entity *entity, uint8_t **script_cursor_inout)
879{
880 (void)entity;
881 uint32_t fail_target_delta = 0;
882 int32_t best_path_distance = 0;
883 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
884 int16_t trace_flags = NAVIGATION_COMMAND_DEFAULT_SELECTOR;
885
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];
890
891 uint8_t trace_opcode = *(uint8_t *)operand_cursor;
892
893 if (trace_opcode == SCRIPT_TRACE_SKIP || trace_opcode == SCRIPT_TRACE_DEFAULT_FLAGS_FIRST || trace_opcode == SCRIPT_TRACE_DEFAULT_FLAGS_SECOND)
894 *script_cursor_inout = &operand_cursor[7];
895 else
896 {
897 int16_t trace_flags_1 = 0;
898
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;
903
904 if (trace_opcode < SCRIPT_TRACE_DEFAULT_FLAGS_FIRST || (trace_opcode >= SCRIPT_TRACE_DISTANCE_RANGE_FIRST && trace_opcode < SCRIPT_TRACE_DISTANCE_RANGE_END))
905 {
906 *script_cursor_inout = &operand_cursor[7];
907
908 int32_t distance = (uint32_t)(operand_cursor[3]) << 24;
909
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;
914 }
915 else
916 *script_cursor_inout = &operand_cursor[7];
917 }
918
919 if (trace_opcode == SCRIPT_TRACE_SKIP)
920 return;
921
922 struct Entity *script_entity = g_scriptCurrentEntity;
923 // Save current path result vector; this opcode probes without keeping trace output.
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;
927
928 if (!Actor_TracePath(script_entity, (uint32_t)trace_opcode - SCRIPT_TRACE_SELECTOR_BIAS, INT32_MAX,
929 best_path_distance, (int32_t)trace_flags))
930 *script_cursor_inout = &operand_cursor[fail_target_delta];
931
932 script_entity->path_result = (struct Math_Vec3I32){
933 // Restore current path result vector after test trace.
934 .x = saved_path_result_x,
935 .y = saved_path_result_y,
936 .z = saved_path_result_z};
937}
938
939// Original pcdogs.exe: 0x410eb0
940// Runs a nested bytecode block with another current script entity and restores the previous global entity afterward. The original entity remains the handler argument, and nested opcode dispatch is unchecked.
941void Script_OpRunWithActor(struct Entity *entity, uint8_t **script_cursor_inout)
942{
943 uint32_t block_end_delta = 0;
944 int16_t actor_selector = 0;
945 uint8_t *operand_cursor = (*script_cursor_inout + 2);
946
947 *script_cursor_inout = (operand_cursor);
948 block_end_delta = (uint32_t)(operand_cursor[-2]) << 8;
949 block_end_delta |= operand_cursor[-1];
950
951 // rel16 block length gives nested script block end cursor.
952 uint8_t *block_end = &operand_cursor[block_end_delta];
953
954 *script_cursor_inout = (&operand_cursor[2]);
955
956 struct Level_Data *current_level = pkg_resource_current_level_data;
957
958 actor_selector = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
959 actor_selector |= operand_cursor[1];
960
961 int16_t resolved_actor_selector = actor_selector;
962
963 if ((uint16_t)resolved_actor_selector == SCRIPT_ENTITY_CURRENT)
964 {
965 int32_t entity_index_quotient = (int32_t)(((int64_t)ENTITY_INDEX_RECIPROCAL * ((char *)entity - (char *)current_level->entity_array)) >> 38);
966
967 resolved_actor_selector = (uint16_t)entity_index_quotient + (int16_t)(entity_index_quotient >> 0x1f) + 1;
968 }
969
970 if (!resolved_actor_selector)
971 {
972 // Selector 0 falls back to actor attach_offset.x low word.
973 resolved_actor_selector = entity->attach_offset_x;
974
975 if (resolved_actor_selector <= 0)
976 {
977 *script_cursor_inout = (block_end);
978
979 return;
980 }
981 }
982
983 struct Entity *target_entity =
984 &current_level->entity_array[(int32_t)resolved_actor_selector - 1];
985
986 if (target_entity != entity)
987 {
988 if (target_entity->flags_high_byte & (ENTITY_FLAG_RESTORE_DEFAULTS >> 8))
989 {
990 *script_cursor_inout = (block_end);
991
992 return;
993 }
994
995 Entity_EnsureCameraActorActive(target_entity);
996 Entity_UpdateVisibilityAndSpawn(target_entity, entity);
997 }
998
999 struct Entity *script_entity = g_scriptCurrentEntity;
1000
1001 g_scriptCurrentEntity = target_entity;
1002
1003 uint8_t *nested_cursor = *script_cursor_inout;
1004
1005 do
1006 {
1007 enum ScriptActorOpcode nested_opcode = SCRIPT_OP_NULL;
1008
1009 *script_cursor_inout = (&nested_cursor[1]);
1010 nested_opcode = (uint8_t)(*(uint8_t *)nested_cursor);
1011 Script_ActorOpcodeDispatchTable[nested_opcode](entity, script_cursor_inout);
1012 nested_cursor = *script_cursor_inout;
1013
1014 if (!nested_cursor)
1015 break;
1016 } while (nested_cursor != block_end);
1017
1018 g_scriptCurrentEntity = script_entity;
1019}
1020
1021// Original pcdogs.exe: 0x410fc0
1022// Activates the camera actor for a positive entity selector or traces a nonpositive selector to choose one. The caller entity's path-result vector is restored after tracing.
1023void Script_OpEnsureCameraActive(struct Entity *entity, uint8_t **script_cursor_inout)
1024{
1025 int16_t actor_selector = 0;
1026 uint8_t *operand_cursor = (*script_cursor_inout + 2);
1027
1028 *script_cursor_inout = (operand_cursor);
1029 actor_selector = (uint32_t)(operand_cursor[-2]) << 8;
1030 actor_selector |= operand_cursor[-1];
1031
1032 if (actor_selector > 0)
1033 {
1035 &pkg_resource_current_level_data->entity_array[(int32_t)actor_selector - 1]);
1036
1037 return;
1038 }
1039
1040 int32_t saved_path_result_x = entity->path_result.x;
1041 int32_t saved_path_result_y = entity->path_result.y;
1042 int32_t saved_path_result_z = entity->path_result.z;
1043 int16_t traced_actor_selector =
1044 Actor_TracePath(entity, (int32_t)actor_selector, INT32_MAX, INT32_MAX, ACTOR_TRACE_MATCH_ACTIVATION);
1045
1046 entity->path_result = (struct Math_Vec3I32){
1047 // Restore actor path result vector after camera-active trace probe.
1048 .x = saved_path_result_x,
1049 .y = saved_path_result_y,
1050 .z = saved_path_result_z};
1051
1052 if (traced_actor_selector > 0)
1054 &pkg_resource_current_level_data->entity_array[(int32_t)traced_actor_selector - 1]);
1055}
#define ACTOR_TRACE_VIEW_CONE
Definition constants.h:73
#define ACTOR_TRACE_SKIP_ACTOR_OCCLUSION
Definition constants.h:76
#define ACTOR_TRACE_USE_TARGET_POSITION
Definition constants.h:74
#define ACTOR_TRACE_MATCH_ACTIVATION
Definition constants.h:79
@ PROP_PARAM_108
Definition enums.h:19
bool Actor_SetFacingTarget(struct Entity *entity, int32_t target_selector, int32_t angle_degrees_q12)
Definition movement.c:34
int32_t Actor_TracePath(struct Entity *entity, int32_t target_selector, int32_t max_path_distance, int32_t best_path_distance, int32_t trace_flags)
void Actor_ResetVelocityAndMoveToTarget(struct Entity *entity, int16_t facing_selector, int32_t facing_angle_degrees_q12, int32_t duration_q12)
Definition movement.c:124
#define ENTITY_FLAG_GROUP_BIT_9
Definition constants.h:16
#define ENTITY_INDEX_RECIPROCAL
Definition constants.h:33
#define ENTITY_FLAG_FACING_REQUEST
Definition constants.h:10
#define ENTITY_FLAG_WALK_REQUEST
Definition constants.h:12
#define ENTITY_FLAG_GROUP_REVERSE
Definition constants.h:14
#define ENTITY_FLAG_RESTORE_DEFAULTS
Definition constants.h:18
#define ENTITY_FLAG_RUN_REQUEST
Definition constants.h:13
#define ENTITY_FLAG_GROUP_RANDOM
Definition constants.h:15
BOOL Entity_UpdateVisibilityAndSpawn(struct Entity *entity, struct Entity *reactivation_requester_or_null)
Definition lifecycle.c:452
void Entity_SetActorProperty(struct Entity *entity, enum Actor_PropID prop_id, int32_t value)
Definition lifecycle.c:63
void Entity_EnsureCameraActorActive(struct Entity *entity)
Definition lifecycle.c:787
uint32_t Math_GenerateRandom(uint32_t range)
void Script_OpRotateActor(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpTestPathTrace(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpEnsureCameraActive(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpMoveToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpTraceActorPath(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpRunWithActor(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpAddNavigationCommand(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpRunToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpWalkToTarget(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpMoveToTargetWithCamera(struct Entity *entity, uint8_t **script_cursor_inout)
void Script_OpPathfindToEntity(struct Entity *entity, uint8_t **script_cursor_inout)
#define NAVIGATION_COMMAND_DEFAULT_SELECTOR
Definition constants.h:11
void Navigation_AddCommand(uint8_t command_type, int16_t target_selector_a, int16_t target_selector_b, int32_t speed, struct Math_Vec3I32 const *position)
Definition commands.c:42
#define pkg_resource_current_level_data
Definition globals.h:117
@ SCRIPT_ENTITY_GROUP_RANDOM
Definition constants.h:38
@ SCRIPT_ENTITY_NO_TARGET
Definition constants.h:40
@ SCRIPT_ENTITY_CURRENT
Definition constants.h:36
@ SCRIPT_ENTITY_GROUP_PREVIOUS
Definition constants.h:35
@ SCRIPT_ENTITY_GROUP_NEXT
Definition constants.h:34
@ SCRIPT_ENTITY_NO_TRACE_SOURCE
Definition constants.h:37
@ SCRIPT_ENTITY_EXECUTING
Definition constants.h:39
#define SCRIPT_TRACE_SELECTOR_BIAS
Definition constants.h:98
@ SCRIPT_TRACE_DEFAULT_FLAGS_FIRST
Definition constants.h:91
@ SCRIPT_NAV_SELECT_CURRENT_ENTITY
Definition constants.h:90
@ SCRIPT_TRACE_DISTANCE_RANGE_FIRST
Definition constants.h:93
@ SCRIPT_TRACE_DISTANCE_RANGE_END
Definition constants.h:94
@ SCRIPT_TRACE_DEFAULT_FLAGS_SECOND
Definition constants.h:92
@ SCRIPT_TRACE_SKIP
Definition constants.h:95
ScriptActorOpcode
Definition enums.h:149
@ SCRIPT_OP_NULL
Definition enums.h:152
#define Script_ActorOpcodeDispatchTable
Definition globals.h:20
#define g_scriptCurrentEntity
Definition globals.h:32
Definition types.h:22
int32_t param_10C
Definition types.h:100
uint32_t flags
Definition types.h:25
uint8_t bonus_respawn_mode
Definition types.h:39
int16_t attach_offset_x
Definition types.h:42
struct Math_Vec3I32 path_target
Definition types.h:113
uint8_t flags_high_byte
Definition types.h:30
struct Math_Vec3I32 * position_ptr
Definition types.h:78
int32_t param_108
Definition types.h:99
struct Math_Vec3I32 path_result
Definition types.h:114
int32_t target_offset_step
Definition types.h:117
int32_t target_offset_phase
Definition types.h:116
int16_t default_anim_state
Definition types.h:43
int32_t path_best_distance
Definition types.h:112
uint8_t active_flag
Definition types.h:38
int16_t current_entity_index
Definition types.h:43
struct Entity * entity_array
Definition types.h:45
int32_t y
Definition types.h:471
int32_t x
Definition types.h:470
int32_t z
Definition types.h:472