Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
map_api.c
Go to the documentation of this file.
1#include "common.h"
2#include "model.h"
3#include "evt.h"
4#include "game_modes.h"
5
7extern s32 LastSafeFloor;
9
10API_CALLABLE(TranslateModel) {
11 Bytecode* args = script->ptrReadPos;
12 s32 modelIndex = evt_get_variable(script, *args++);
13 f32 x;
14 f32 y;
15 f32 z;
16 Model* model;
17
18 modelIndex = get_model_list_index_from_tree_index(modelIndex);
19 x = evt_get_float_variable(script, *args++);
20 y = evt_get_float_variable(script, *args++);
21 z = evt_get_float_variable(script, *args++);
22 model = get_model_from_list_index(modelIndex);
23
24 if (!(model->flags & MODEL_FLAG_HAS_TRANSFORM)) {
25 guTranslateF(model->userTransformMtx, x, y, z);
27 } else {
28 Matrix4f mtx;
29
30 guTranslateF(mtx, x, y, z);
31 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
32 }
33
34 return ApiStatus_DONE2;
35}
36
37API_CALLABLE(RotateModel) {
38 Bytecode* args = script->ptrReadPos;
39 s32 var1 = evt_get_variable(script, *args++);
40 s32 modelListIndex = get_model_list_index_from_tree_index(var1);
41 f32 a = evt_get_float_variable(script, *args++);
42 f32 x = evt_get_float_variable(script, *args++);
43 f32 y = evt_get_float_variable(script, *args++);
44 f32 z = evt_get_float_variable(script, *args++);
45 Model* model = get_model_from_list_index(modelListIndex);
46
47 if (!(model->flags & MODEL_FLAG_HAS_TRANSFORM)) {
48 guRotateF(model->userTransformMtx, a, x, y, z);
50 } else {
51 Matrix4f mtx;
52
53 guRotateF(mtx, a, x, y, z);
54 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
55 }
56
57 return ApiStatus_DONE2;
58}
59
60API_CALLABLE(ScaleModel) {
61 Bytecode* args = script->ptrReadPos;
62 s32 modelIndex = evt_get_variable(script, *args++);
63 f32 x;
64 f32 y;
65 f32 z;
66 Model* model;
67
68 modelIndex = get_model_list_index_from_tree_index(modelIndex);
69 x = evt_get_float_variable(script, *args++);
70 y = evt_get_float_variable(script, *args++);
71 z = evt_get_float_variable(script, *args++);
72 model = get_model_from_list_index(modelIndex);
73
74 if (!(model->flags & MODEL_FLAG_HAS_TRANSFORM)) {
75 guScaleF(model->userTransformMtx, x, y, z);
77 } else {
78 Matrix4f mtx;
79
80 guScaleF(mtx, x, y, z);
81 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
82 }
83
84 return ApiStatus_DONE2;
85}
86
87API_CALLABLE(GetModelIndex) {
88 Bytecode* args = script->ptrReadPos;
89 Bytecode modelID = evt_get_variable(script, *args++);
90 Bytecode index = *args++;
91
93 return ApiStatus_DONE2;
94}
95
96API_CALLABLE(InvalidateModelTransform) {
97 Bytecode* args = script->ptrReadPos;
98 Bytecode modelID = evt_get_variable(script, *args++);
100
101 model->flags &= ~MODEL_FLAG_HAS_TRANSFORM;
102 return ApiStatus_DONE2;
103}
104
105API_CALLABLE(CloneModel) {
106 Bytecode* args = script->ptrReadPos;
107 Bytecode srcModelID = evt_get_variable(script, *args++);
108 Bytecode newModelID = evt_get_variable(script, *args++);
109
110 clone_model(srcModelID, newModelID);
111 return ApiStatus_DONE2;
112}
113
114API_CALLABLE(GetModelCenter) {
115 Bytecode* args = script->ptrReadPos;
116 f32 centerX;
117 f32 centerY;
118 f32 centerZ;
119 f32 sizeX;
120 f32 sizeY;
121 f32 sizeZ;
122
123 get_model_center_and_size(evt_get_variable(script, *args++), &centerX, &centerY, &centerZ, &sizeX, &sizeY,
124 &sizeZ);
125 script->varTable[0] = centerX;
126 script->varTable[1] = centerY;
127 script->varTable[2] = centerZ;
128 return ApiStatus_DONE2;
129}
130
131API_CALLABLE(SetTexPanner) {
132 Bytecode* args = script->ptrReadPos;
133 s32 treeIndex = evt_get_variable(script, *args++);
134 s32 var2 = evt_get_variable(script, *args++);
136
137 set_tex_panner(model, var2);
139 return ApiStatus_DONE2;
140}
141
142API_CALLABLE(SetCustomGfxEnabled) {
143 Bytecode* args = script->ptrReadPos;
144 Bytecode treeIndex = evt_get_variable(script, *args++);
145 Bytecode enable = evt_get_variable(script, *args++);
147
148 if (enable) {
150 } else {
151 model->flags &= ~MODEL_FLAG_USES_CUSTOM_GFX;
152 }
153 return ApiStatus_DONE2;
154}
155
156API_CALLABLE(SetModelCustomGfx) {
157 Bytecode* args = script->ptrReadPos;
158 s32 treeIndex = evt_get_variable(script, *args++);
159 s32 customGfxUnit = evt_get_variable(script, *args++);
160 s32 var3 = evt_get_variable(script, *args++);
161 Model* model;
162
163 treeIndex = get_model_list_index_from_tree_index(treeIndex);
164 model = get_model_from_list_index(treeIndex);
165
166 set_mdl_custom_gfx_set(model, customGfxUnit, var3);
167 if (customGfxUnit != -1) {
169 }
170 return ApiStatus_DONE2;
171}
172
173API_CALLABLE(SetModelTexVariant) {
174 Bytecode* args = script->ptrReadPos;
175 Bytecode modelID = evt_get_variable(script, *args++);
176 Bytecode variation = evt_get_variable(script, *args++);
177 s32 modelIndex = get_model_list_index_from_tree_index(modelID);
178 Model* model = get_model_from_list_index(modelIndex);
179
180 model->textureVariation = variation;
181 return ApiStatus_DONE2;
182}
183
184API_CALLABLE(EnableTexPanning) {
185 Bytecode* args = script->ptrReadPos;
186 s32 modelID = evt_get_variable(script, *args++);
187 s32 flag = evt_get_variable(script, *args++);
188 s32 modelIndex = get_model_list_index_from_tree_index(modelID);
189 Model* model = get_model_from_list_index(modelIndex);
190
191 if (flag) {
193 } else {
194 model->flags &= ~MODEL_FLAG_HAS_TEX_PANNER;
195 }
196 return ApiStatus_DONE2;
197}
198
199API_CALLABLE(EnableModel) {
200 Bytecode* args = script->ptrReadPos;
201 s32 modelIndex = get_model_list_index_from_tree_index(evt_get_variable(script, *args++));
202 Bytecode enabled = evt_get_variable(script, *args++);
203 Model* model = get_model_from_list_index(modelIndex);
204
205 if (enabled) {
206 model->flags &= ~MODEL_FLAG_HIDDEN;
207 } else {
208 model->flags |= MODEL_FLAG_HIDDEN;
209 }
210 return ApiStatus_DONE2;
211}
212
213API_CALLABLE(SetGroupVisibility) {
214 Bytecode* args = script->ptrReadPos;
215 Bytecode groupModelID = evt_get_variable(script, *args++);
216 Bytecode enabled = evt_get_variable(script, *args++);
217
218 mdl_group_set_visibility(groupModelID, MODEL_FLAG_HIDDEN, enabled);
219 return ApiStatus_DONE2;
220}
221
222API_CALLABLE(SetTexPanOffset) {
223 Bytecode* args = script->ptrReadPos;
224 Bytecode texPanner = evt_get_variable(script, *args++);
225 Bytecode tileSelect = evt_get_variable(script, *args++);
226 Bytecode u = evt_get_variable(script, *args++);
227 Bytecode v = evt_get_variable(script, *args++);
228
229 if (tileSelect == 0) {
230 set_main_pan_u(texPanner, u);
231 set_main_pan_v(texPanner, v);
232 } else {
233 set_aux_pan_u(texPanner, u);
234 set_aux_pan_v(texPanner, v);
235 }
236
237 return ApiStatus_DONE2;
238}
239
240API_CALLABLE(SetCustomGfx) {
241 Bytecode* args = script->ptrReadPos;
242 s32 idx = evt_get_variable(script, *args++);
243 Gfx* pre = (Gfx*) evt_get_variable(script, *args++);
244 Gfx* post = (Gfx*) evt_get_variable(script, *args++);
245
246 set_custom_gfx(idx, pre, post);
247 return ApiStatus_DONE2;
248}
249
250API_CALLABLE(SetCustomGfxBuilders) {
251 Bytecode* args = script->ptrReadPos;
252 s32 index = evt_get_variable(script, *args++);
255
256 set_custom_gfx_builders(index, pre, post);
257 return ApiStatus_DONE2;
258}
259
260API_CALLABLE(SetModelFlags) {
261 Bytecode* args = script->ptrReadPos;
262 s32 modelIndex;
263 s32 a1;
264 s32 enable;
265 Model* model;
266
267 modelIndex = evt_get_variable(script, *args++);
268 modelIndex = get_model_list_index_from_tree_index(modelIndex);
269 a1 = *args++;
270 enable = evt_get_variable(script, *args++);
271 model = get_model_from_list_index(modelIndex);
272
273 if (enable) {
274 model->flags |= a1;
275 } else {
276 model->flags &= ~a1;
277 }
278
279 return ApiStatus_DONE2;
280}
281
282void apply_transform_to_children(ApiStatus (*apiFunc)(Evt*, s32), Evt* script) {
283 Evt localEvt;
284 ModelTreeInfo* parentModelInfo;
285 ModelTreeInfo* childModelInfo;
286 s32 parentModelID;
287 s32 originalArg;
288 s32* argsPtr;
289 s32 modelIndex;
290 s32 firstChild;
291 s32 lastChild;
292 s32 i;
293
294 firstChild = -1;
295 parentModelID = evt_get_variable(script, *script->ptrReadPos);
296 modelIndex = (*gCurrentModelTreeNodeInfo)[parentModelID].modelIndex;
297 lastChild = -1;
298
299 if (modelIndex < 0xFF) {
300 firstChild = lastChild = modelIndex;
301 } else {
302 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[parentModelID].treeDepth;
303
304 // check all models with a lowerID in the tree
305 for (i = parentModelID - 1; i >= 0; i--) {
306 childModelInfo = &(*gCurrentModelTreeNodeInfo)[i];
307
308 if (treeDepth < childModelInfo->treeDepth) {
309 s32 childModelIndex = childModelInfo->modelIndex;
310
311 if (childModelIndex < 0xFF) {
312 if (lastChild == -1) {
313 lastChild = childModelIndex;
314 }
315 firstChild = childModelIndex;
316 }
317 } else {
318 // if node is no longer deeper than parent, we've exhausted the children
319 break;
320 }
321 }
322 }
323
324 // copy the input script into a local one we will modify
325 localEvt = *script;
326
327 argsPtr = localEvt.ptrReadPos;
328 originalArg = *argsPtr;
329
330 for (i = firstChild; i <= lastChild; i++) {
331 Model* model = (*gCurrentModels)[i];
332
333 localEvt.ptrReadPos = argsPtr;
334 *argsPtr = model->modelID;
335
336 apiFunc(&localEvt, TRUE);
337 }
338
339 *argsPtr = originalArg;
340}
341
342API_CALLABLE(MakeTransformGroup) {
343 mdl_make_transform_group((u16)evt_get_variable(script, *script->ptrReadPos));
344 return ApiStatus_DONE2;
345}
346
347API_CALLABLE(SetTransformGroupEnabled) {
348 Bytecode* args = script->ptrReadPos;
349 u16 modelID = evt_get_variable(script, *args++);
350 s32 enable = evt_get_variable(script, *args++);
351
352 if (enable) {
353 enable_transform_group(modelID);
354 } else {
356 }
357 return ApiStatus_DONE2;
358}
359
360API_CALLABLE(TranslateGroup) {
361 Bytecode* args = script->ptrReadPos;
362 s32 modelID = evt_get_variable(script, *args++);
363 s32 index = get_transform_group_index(modelID);
364 ModelTransformGroup* transformGroup;
365 Matrix4f mtx;
366 f32 x, y, z;
367
368 if (index == -1) {
370 return ApiStatus_DONE2;
371 }
372
373 x = evt_get_float_variable(script, *args++);
374 y = evt_get_float_variable(script, *args++);
375 z = evt_get_float_variable(script, *args++);
376
377 transformGroup = get_transform_group(index);
378
379 if (transformGroup->flags & TRANSFORM_GROUP_FLAG_HAS_TRANSFORM) {
380 guTranslateF(mtx, x, y, z);
381 guMtxCatF(mtx, transformGroup->userTransformMtx, transformGroup->userTransformMtx);
382 } else {
383 guTranslateF(transformGroup->userTransformMtx, x, y, z);
384 transformGroup->flags |= TRANSFORM_GROUP_FLAG_HAS_TRANSFORM;
385 transformGroup->flags |= TRANSFORM_GROUP_FLAG_MATRIX_DIRTY;
386 }
387
388 return ApiStatus_DONE2;
389}
390
391API_CALLABLE(RotateGroup) {
392 Bytecode* args = script->ptrReadPos;
393 s32 modelID = evt_get_variable(script, *args++);
394 s32 index = get_transform_group_index(modelID);
395 ModelTransformGroup* transformGroup;
396 Matrix4f mtx;
397 f32 a, x, y, z;
398
399 if (index == -1) {
401 return ApiStatus_DONE2;
402 }
403
404 a = evt_get_float_variable(script, *args++);
405 x = evt_get_float_variable(script, *args++);
406 y = evt_get_float_variable(script, *args++);
407 z = evt_get_float_variable(script, *args++);
408
409 transformGroup = get_transform_group(index);
410
411 if (transformGroup->flags & TRANSFORM_GROUP_FLAG_HAS_TRANSFORM) {
412 guRotateF(mtx, a, x, y, z);
413 guMtxCatF(mtx, transformGroup->userTransformMtx, transformGroup->userTransformMtx);
414 } else {
415 guRotateF(transformGroup->userTransformMtx, a, x, y, z);
416 transformGroup->flags |= TRANSFORM_GROUP_FLAG_HAS_TRANSFORM;
417 transformGroup->flags |= TRANSFORM_GROUP_FLAG_MATRIX_DIRTY;
418 }
419
420 return ApiStatus_DONE2;
421}
422
423API_CALLABLE(ScaleGroup) {
424 Bytecode* args = script->ptrReadPos;
425 s32 modelID = evt_get_variable(script, *args++);
426 s32 transformIndex = get_transform_group_index(modelID);
427 ModelTransformGroup* transformGroup;
428 Matrix4f mtx;
429 f32 x, y, z;
430
431 if (transformIndex == -1) {
433 return ApiStatus_DONE2;
434 }
435
436 x = evt_get_float_variable(script, *args++);
437 y = evt_get_float_variable(script, *args++);
438 z = evt_get_float_variable(script, *args++);
439
440 transformGroup = get_transform_group(transformIndex);
441
442 if (transformGroup->flags & TRANSFORM_GROUP_FLAG_HAS_TRANSFORM) {
443 guScaleF(mtx, x, y, z);
444 guMtxCatF(mtx, transformGroup->userTransformMtx, transformGroup->userTransformMtx);
445 } else {
446 guScaleF(transformGroup->userTransformMtx, x, y, z);
447 transformGroup->flags |= TRANSFORM_GROUP_FLAG_HAS_TRANSFORM;
448 transformGroup->flags |= TRANSFORM_GROUP_FLAG_MATRIX_DIRTY;
449 }
450
451 return ApiStatus_DONE2;
452}
453
454API_CALLABLE(GetTransformGroup) {
455 Bytecode* args = script->ptrReadPos;
456 s32 modelID = evt_get_variable(script, *args++);
457 Bytecode var2 = *args++;
458
459 evt_set_variable(script, var2, get_transform_group_index(modelID));
460 return ApiStatus_DONE2;
461}
462
463API_CALLABLE(EnableGroup) {
464 Bytecode* args = script->ptrReadPos;
465 s32 modelID = evt_get_variable(script, *args);
466 s32 index = get_transform_group_index(modelID);
467 s32 flagUnset;
468 ModelTransformGroup* transformGroup;
469
470 if (index == -1) {
472 return ApiStatus_DONE2;
473 }
474
475 args++;
476
477 flagUnset = evt_get_variable(script, *args++);
478 transformGroup = get_transform_group(index);
479
480 for (index = transformGroup->minChildModelIndex; index <= transformGroup->maxChildModelIndex; index++) {
481 Model* model = get_model_from_list_index(index);
482 if (flagUnset) {
483 model->flags &= ~MODEL_FLAG_HIDDEN;
484 } else {
485 model->flags |= MODEL_FLAG_HIDDEN;
486 }
487 }
488
489 return ApiStatus_DONE2;
490}
491
492API_CALLABLE(MakeLocalVertexCopy) {
493 Bytecode* args = script->ptrReadPos;
494 s32 copyIndex = evt_get_variable(script, *args++);
495 u16 modelID = evt_get_variable(script, *args++);
496 s32 isMakingCopy = evt_get_variable(script, *args++);
497
498 mdl_make_local_vertex_copy(copyIndex, modelID, isMakingCopy);
499 return ApiStatus_DONE2;
500}
501
502void modify_collider_family_flags(s32 index, s32 flags, s32 mode) {
503 Collider* collider = &gCollisionData.colliderList[index];
504
505 if (collider->nextSibling >= 0) {
507 }
508
509 if (collider->firstChild >= 0) {
511 }
512
513 switch (mode) {
515 collider->flags |= flags;
516 break;
518 collider->flags &= ~flags;
519 break;
521 collider->flags = flags;
522 break;
524 collider->flags &= ~0xFF;
525 collider->flags |= flags & 0xFF;
526 break;
527
528 }
529}
530
531API_CALLABLE(ModifyColliderFlags) {
532 Bytecode* args = script->ptrReadPos;
533 s32 mode = evt_get_variable(script, *args++);
534 s32 index = evt_get_variable(script, *args++);
535 s32 flags = evt_get_variable(script, *args++);
536 Collider* collider = &gCollisionData.colliderList[index];
537
538 if (collider->firstChild >= 0) {
540 }
541
542 switch (mode) {
544 collider->flags |= flags;
545 break;
547 collider->flags &= ~flags;
548 break;
550 collider->flags = flags;
551 break;
553 collider->flags &= ~0xFF;
554 collider->flags |= flags & 0xFF;
555 break;
556 }
557
558 return ApiStatus_DONE2;
559}
560
561//TODO rename to MonitorLastSafeFloor
562API_CALLABLE(ResetFromLava) {
563 Bytecode* args = script->ptrReadPos;
564 CollisionStatus* collisionStatus = &gCollisionStatus;
565 Collider* collider;
566 LavaReset* lavaReset;
567
568 if (isInitialCall) {
569 lavaReset = gLavaResetList = (LavaReset*)evt_get_variable(script, *args++);
570
571 while (TRUE) {
572 if (lavaReset->colliderID == -1) {
573 break;
574 }
575 collider = &gCollisionData.colliderList[lavaReset->colliderID];
576 if (collider->firstChild >= 0) {
578 }
579 collider->flags |= COLLIDER_FLAG_SAFE_FLOOR;
580 lavaReset++;
581 }
582
583 LastSafeFloor = -1;
584 }
585
586 if (!(collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT)) {
587 collider = &gCollisionData.colliderList[collisionStatus->curFloor];
588 if (collider->flags & COLLIDER_FLAG_SAFE_FLOOR) {
589 LastSafeFloor = collisionStatus->curFloor;
590 return ApiStatus_BLOCK;
591 }
592 }
593
594 return ApiStatus_BLOCK;
595}
596
597s32 get_lava_reset_pos(f32* outX, f32* outY, f32* outZ) {
598 Vec4f *temp_v0;
599 s32 temp_a0;
600 LavaReset* lavaReset = gLavaResetList;
601
602 if (LastSafeFloor == -1) {
604 *outX = temp_v0->x;
605 *outY = temp_v0->y;
606 *outZ = temp_v0->z;
607 return -1;
608 }
609
610 while (TRUE) {
611 if (lavaReset->colliderID == -1) {
612 break;
613 }
614
615 if (lavaReset->colliderID == LastSafeFloor) {
616 *outX = lavaReset->pos.x;
617 *outY = lavaReset->pos.y;
618 *outZ = lavaReset->pos.z;
619 return 1;
620 }
621 lavaReset++;
622 }
623 return 0;
624}
625
626API_CALLABLE(GetColliderCenter) {
627 f32 x, y, z;
628
629 get_collider_center(evt_get_variable(script, *script->ptrReadPos), &x, &y, &z);
630
631 script->varTable[0] = x;
632 script->varTable[1] = y;
633 script->varTable[2] = z;
634
635 return ApiStatus_DONE2;
636}
637
638API_CALLABLE(ParentColliderToModel) {
639 Bytecode* args = script->ptrReadPos;
640 s16 colliderID = evt_get_variable(script, *args++);
641 s32 treeIndex = evt_get_variable(script, *args++);
642
644 update_collider_transform(colliderID);
645 return ApiStatus_DONE2;
646}
647
648API_CALLABLE(UpdateColliderTransform) {
649 update_collider_transform(evt_get_variable(script, *script->ptrReadPos));
650 return ApiStatus_DONE2;
651}
652
653void set_zone_enabled(s32 zoneID, s32 enabled) {
655
656 if (zone->nextSibling >= 0) {
657 set_zone_enabled(zone->nextSibling, enabled);
658 }
659 if (zone->firstChild >= 0) {
660 set_zone_enabled(zone->firstChild, enabled);
661 }
662
663 switch (enabled) {
664 case 0:
666 break;
667 case 1:
668 zone->flags &= ~TEMP_SET_ZONE_ENABLED_FLAG_10000;
669 break;
670 }
671}
672
673API_CALLABLE(SetZoneEnabled) {
674 Bytecode* args = script->ptrReadPos;
675 s32 zoneID = evt_get_variable(script, *args++);
676 s32 enabled = evt_get_variable(script, *args++);
678
679 if (zone->firstChild >= 0) {
680 set_zone_enabled(zone->firstChild, enabled);
681 }
682
683 switch (enabled) {
684 case FALSE:
686 break;
687 case TRUE:
688 zone->flags &= ~TEMP_SET_ZONE_ENABLED_FLAG_10000;
689 break;
690 }
691
692 return ApiStatus_DONE2;
693}
694
695void goto_map(Evt* script, s32 mode) {
696 Bytecode* args = script->ptrReadPos;
697 s16 mapID;
698 s16 areaID;
699 s16 mapTransitionEffect = TRANSITION_STANDARD;
700
701 if (mode == 2) {
702 areaID = evt_get_variable(script, *args++);
703 mapID = evt_get_variable(script, *args++);
704 } else {
705 get_map_IDs_by_name_checked((char*)evt_get_variable(script, *args++), &areaID, &mapID);
706 }
707
708 gGameStatusPtr->areaID = areaID;
709 gGameStatusPtr->mapID = mapID;
710 gGameStatusPtr->entryID = evt_get_variable(script, *args++);
711
712 if (mode == 1) {
713 mapTransitionEffect = evt_get_variable(script, *args++);
714 }
715
716 set_map_transition_effect(mapTransitionEffect);
718}
719
720API_CALLABLE(GotoMap) {
721 goto_map(script, 0);
722 return ApiStatus_DONE1;
723}
724
725API_CALLABLE(GotoMapSpecial) {
726 goto_map(script, 1);
727 return ApiStatus_DONE1;
728}
729
730API_CALLABLE(GotoMapByID) {
731 goto_map(script, 2);
732 return ApiStatus_DONE1;
733}
734
735API_CALLABLE(GetEntryID) {
736 evt_set_variable(script, *script->ptrReadPos, gGameStatusPtr->entryID);
737 return ApiStatus_DONE2;
738}
739
740API_CALLABLE(GetMapID) {
741 evt_set_variable(script, *script->ptrReadPos, gGameStatusPtr->mapID);
742 return ApiStatus_DONE2;
743}
744
745API_CALLABLE(GetLoadType) {
746 evt_set_variable(script, *script->ptrReadPos, gGameStatusPtr->loadType != 0);
747 return ApiStatus_DONE2;
748}
749
750API_CALLABLE(SetRenderMode) {
751 Bytecode* args = script->ptrReadPos;
752 s32 treeIndex = evt_get_variable(script, *args++);
753 s8 renderMode = evt_get_variable(script, *args++);
754
756
757 return ApiStatus_DONE2;
758}
759
760API_CALLABLE(PlaySoundAtModel) {
761 Bytecode* args = script->ptrReadPos;
762 s32 modelID = evt_get_variable(script, *args++);
763 s32 soundID = evt_get_variable(script, *args++);
764 s32 var3 = evt_get_variable(script, *args++);
765 f32 x, y, z;
766 f32 sx, sy, sz;
767
768 get_model_center_and_size(modelID, &x, &y, &z, &sx, &sy, &sz);
769 sfx_play_sound_at_position(soundID, var3, x, y, z);
770
771 return ApiStatus_DONE2;
772}
773
774API_CALLABLE(PlaySoundAtCollider) {
775 Bytecode* args = script->ptrReadPos;
776 s32 colliderID = evt_get_variable(script, *args++);
777 s32 soundID = evt_get_variable(script, *args++);
778 s32 var3 = evt_get_variable(script, *args++);
779 f32 x, y, z;
780
781 get_collider_center(colliderID, &x, &y, &z);
782 sfx_play_sound_at_position(soundID, var3, x, y, z);
783
784 return ApiStatus_DONE2;
785}
Collider * colliderList
Bytecode * ptrReadPos
f32 Matrix4f[4][4]
s8 flags
Definition demo_api.c:15
#define guRotateF
#define sfx_play_sound_at_position
#define guTranslateF
#define guMtxCatF
#define guScaleF
@ TRANSITION_STANDARD
Definition enums.h:2362
@ TRANSFORM_GROUP_FLAG_HAS_TRANSFORM
Definition enums.h:5083
@ TRANSFORM_GROUP_FLAG_MATRIX_DIRTY
Definition enums.h:5084
@ TEMP_SET_ZONE_ENABLED_FLAG_10000
Definition enums.h:5061
@ MODEL_FLAG_HAS_TRANSFORM
Definition enums.h:4367
@ MODEL_FLAG_HIDDEN
Definition enums.h:4358
@ MODEL_FLAG_USES_CUSTOM_GFX
Definition enums.h:4361
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4369
@ MODEL_FLAG_HAS_TEX_PANNER
Definition enums.h:4368
@ COLLIDER_FLAG_SAFE_FLOOR
Definition enums.h:4694
@ MODIFY_COLLIDER_FLAGS_SET_BITS
Definition enums.h:4705
@ MODIFY_COLLIDER_FLAGS_SET_SURFACE
Definition enums.h:4708
@ MODIFY_COLLIDER_FLAGS_SET_VALUE
Definition enums.h:4707
@ MODIFY_COLLIDER_FLAGS_CLEAR_BITS
Definition enums.h:4706
s32 ApiStatus
Definition evt.h:115
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
void clone_model(u16 srcModelID, u16 newModelID)
Definition model.c:3621
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void enable_transform_group(u16 modelID)
Definition model.c:3587
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
void get_map_IDs_by_name_checked(const char *mapName, s16 *areaID, s16 *mapID)
Same as get_map_IDs_by_name, but will panic if the map doesn't exist.
Definition world.c:247
void mdl_group_set_visibility(u16, s32, s32)
Definition model.c:3637
void set_map_transition_effect(ScreenTransition)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
void update_collider_transform(s16 colliderID)
Definition collision.c:391
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
void disable_transform_group(u16 modelID)
Definition model.c:3604
void mdl_make_transform_group(u16 modelID)
Definition model.c:3514
void set_custom_gfx(s32 customGfxIndex, Gfx *pre, Gfx *post)
Definition model.c:3844
s32 get_transform_group_index(s32)
Definition model.c:3418
void get_collider_center(s32 colliderID, f32 *x, f32 *y, f32 *z)
Definition collision.c:497
void set_aux_pan_v(s32 texPannerID, s32 value)
Definition model.c:3828
void set_main_pan_u(s32 texPannerID, s32 value)
Definition model.c:3816
void set_aux_pan_u(s32 texPannerID, s32 value)
Definition model.c:3824
void parent_collider_to_model(s16 colliderID, s16 modelIndex)
Definition collision.c:320
void set_tex_panner(struct Model *model, s32 texPannerID)
Definition model.c:3812
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
void set_main_pan_v(s32 texPannerID, s32 value)
Definition model.c:3820
struct ModelTransformGroup * get_transform_group(s32 index)
Definition model.c:3453
void get_model_center_and_size(u16 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
Definition model.c:3433
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_CHANGE_MAP
Definition game_modes.h:13
s32 get_lava_reset_pos(f32 *outX, f32 *outY, f32 *outZ)
Definition map_api.c:597
void set_zone_enabled(s32 zoneID, s32 enabled)
Definition map_api.c:653
s32 LastSafeFloor
Definition script_list.c:24
void apply_transform_to_children(ApiStatus(*apiFunc)(Evt *, s32), Evt *script)
Definition map_api.c:282
ModelTreeInfoList * gCurrentModelTreeNodeInfo
Definition model.c:107
LavaReset * gLavaResetList
Definition script_list.c:23
void goto_map(Evt *script, s32 mode)
Definition map_api.c:695
void modify_collider_family_flags(s32 index, s32 flags, s32 mode)
Definition map_api.c:502
void mdl_make_local_vertex_copy(s32 arg0, u16 treeIdx, s32)
Definition model.c:4041
void(* ModelCustomGfxBuilderFunc)(s32 index)
Definition model.h:136
s8 renderMode
Definition model.h:72
u8 modelIndex
Definition model.h:113
s8 textureVariation
Definition model.h:75
void set_custom_gfx_builders(s32 customGfxIndex, ModelCustomGfxBuilderFunc pre, ModelCustomGfxBuilderFunc post)
Definition model.c:3849
u16 flags
Definition model.h:60
void set_mdl_custom_gfx_set(Model *, s32, u32)
Definition model.c:3832
Matrix4f userTransformMtx
Definition model.h:86
Matrix4f userTransformMtx
Definition model.h:68
u16 modelID
Definition model.h:61
ModelTreeInfo ModelTreeInfoList[0x200]
Definition model.h:187
Definition model.h:59
ApiStatus SetCustomGfxBuilders(Evt *script, b32 isInitialCall)
ApiStatus EnableGroup(Evt *script, b32 isInitialCall)
Enables or disables the given group.
ApiStatus RotateGroup(Evt *script, b32 isInitialCall)
Rotates the given group's position.
ApiStatus SetGroupVisibility(Evt *script, b32 isInitialCall)
Enables or disables the given group.
ApiStatus SetModelCustomGfx(Evt *script, b32 isInitialCall)
ApiStatus PlaySoundAtModel(Evt *script, b32 isInitialCall)
Plays the given sound at the given model.
ApiStatus SetCustomGfxEnabled(Evt *script, b32 isInitialCall)
ApiStatus GetEntryID(Evt *script, b32 isInitialCall)
Returns the entryID of the Entry that the player entered the map from.
ApiStatus EnableModel(Evt *script, b32 isInitialCall)
Enables or disables the given model.
ApiStatus GotoMap(Evt *script, b32 isInitialCall)
Makes the player go to the given map and at the given entrance.
ApiStatus TranslateModel(Evt *script, b32 isInitialCall)
Translates the given model's position.
ApiStatus SetTransformGroupEnabled(Evt *script, b32 isInitialCall)
ApiStatus GetTransformGroup(Evt *script, b32 isInitialCall)
ApiStatus SetCustomGfx(Evt *script, b32 isInitialCall)
ApiStatus RotateModel(Evt *script, b32 isInitialCall)
Rotates the model the given amount on the selected axis.
ApiStatus GetMapID(Evt *script, b32 isInitialCall)
Returns the mapID of the map the player is currently on.
ApiStatus PlaySoundAtCollider(Evt *script, b32 isInitialCall)
Plays the given sound at the given collider.
ApiStatus SetTexPanOffset(Evt *script, b32 isInitialCall)
Sets offsets for texture panners.
ApiStatus SetModelTexVariant(Evt *script, b32 isInitialCall)
ApiStatus ScaleGroup(Evt *script, b32 isInitialCall)
Scales the given group's position.
ApiStatus SetModelFlags(Evt *script, b32 isInitialCall)
Sets flags for models.
ApiStatus ScaleModel(Evt *script, b32 isInitialCall)
Scales the model the given amount along the selected axis.
ApiStatus GetColliderCenter(Evt *script, b32 isInitialCall)
Returns the center of the given collider.
ApiStatus MakeTransformGroup(Evt *script, b32 isInitialCall)
ApiStatus GetModelCenter(Evt *script, b32 isInitialCall)
Returns the center of the given model.
ApiStatus ResetFromLava(Evt *script, b32 isInitialCall)
ApiStatus SetZoneEnabled(Evt *script, b32 isInitialCall)
Enables or disables the given zone.
ApiStatus TranslateGroup(Evt *script, b32 isInitialCall)
Translates the given group's position.
ApiStatus UpdateColliderTransform(Evt *script, b32 isInitialCall)
Applies transformation from parent model.
ApiStatus EnableTexPanning(Evt *script, b32 isInitialCall)
Enables or disables texture panning on the given model.
ApiStatus GotoMapSpecial(Evt *script, b32 isInitialCall)
Makes the player go to the given map and at the given entrance with a unique fadeout effect.
ApiStatus ParentColliderToModel(Evt *script, b32 isInitialCall)
Associates a model with a collider and applies the model's transformation.
ApiStatus GetModelIndex(Evt *script, b32 isInitialCall)
Returns the given model's index.
ApiStatus SetRenderMode(Evt *script, b32 isInitialCall)
ApiStatus MakeLocalVertexCopy(Evt *script, b32 isInitialCall)
ApiStatus InvalidateModelTransform(Evt *script, b32 isInitialCall)
ApiStatus CloneModel(Evt *script, b32 isInitialCall)
Clones the given model.
ApiStatus GetLoadType(Evt *script, b32 isInitialCall)
Returns the way the player loaded into the map, commonly used by to put the player in the correct pos...
ApiStatus SetTexPanner(Evt *script, b32 isInitialCall)
Sets a model's pannerID and sets the texture pan flag.
ApiStatus GotoMapByID(Evt *script, b32 isInitialCall)
ApiStatus ModifyColliderFlags(Evt *script, b32 isInitialCall)
Set flags for collider + siblings + children.
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
MapSettings * get_current_map_settings(void)
Definition world.c:224
EntryList * entryList
Definition map.h:32
CollisionData gZoneCollisionData
Definition collision.c:36
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
GameStatus * gGameStatusPtr
Definition main_loop.c:32
CollisionData gCollisionData
Definition collision.c:35