Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
map_api.c File Reference

Go to the source code of this file.

Functions

void apply_transform_to_children (ApiStatus(*apiFunc)(Evt *, s32), Evt *script)
 
void modify_collider_family_flags (s32 index, s32 flags, s32 mode)
 
s32 get_lava_reset_pos (f32 *outX, f32 *outY, f32 *outZ)
 
void set_zone_enabled (s32 zoneID, s32 enabled)
 
void goto_map (Evt *script, s32 mode)
 

Variables

LavaResetgLavaResetList
 
s32 LastSafeFloor
 
ModelTreeInfoListgCurrentModelTreeNodeInfo
 

Function Documentation

◆ apply_transform_to_children()

void apply_transform_to_children ( ApiStatus(*)(Evt *, s32) apiFunc,
Evt * script )

Definition at line 282 of file map_api.c.

282 {
288 s32 modelIndex;
289 s32 firstChild;
291 s32 i;
292
293 firstChild = -1;
295 modelIndex = (*gCurrentModelTreeNodeInfo)[parentModelID].modelIndex;
296 lastChild = -1;
297
298 if (modelIndex < 0xFF) {
299 firstChild = lastChild = modelIndex;
300 } else {
301 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[parentModelID].treeDepth;
302
303 // check all models with a lowerID in the tree
304 for (i = parentModelID - 1; i >= 0; i--) {
305 childModelInfo = &(*gCurrentModelTreeNodeInfo)[i];
306
307 if (treeDepth < childModelInfo->treeDepth) {
308 s32 childModelIndex = childModelInfo->modelIndex;
309
310 if (childModelIndex < 0xFF) {
311 if (lastChild == -1) {
313 }
314 firstChild = childModelIndex;
315 }
316 } else {
317 // if node is no longer deeper than parent, we've exhausted the children
318 break;
319 }
320 }
321 }
322
323 // copy the input script into a local one we will modify
324 localEvt = *script;
325
326 argsPtr = localEvt.ptrReadPos;
328
329 for (i = firstChild; i <= lastChild; i++) {
330 Model* model = (*gCurrentModels)[i];
331
332 localEvt.ptrReadPos = argsPtr;
334
335 apiFunc(&localEvt, true);
336 }
337
339}
BSS s32 PopupMenu_SelectedIndex
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
u16 modelID
Definition model.h:61
Definition model.h:59

◆ modify_collider_family_flags()

void modify_collider_family_flags ( s32 index,
s32 flags,
s32 mode )

Definition at line 501 of file map_api.c.

501 {
503
504 if (collider->nextSibling >= 0) {
505 modify_collider_family_flags(collider->nextSibling, flags, mode);
506 }
507
508 if (collider->firstChild >= 0) {
509 modify_collider_family_flags(collider->firstChild, flags, mode);
510 }
511
512 switch (mode) {
514 collider->flags |= flags;
515 break;
517 collider->flags &= ~flags;
518 break;
520 collider->flags = flags;
521 break;
523 collider->flags &= ~0xFF;
524 collider->flags |= flags & 0xFF;
525 break;
526
527 }
528}
Collider * colliderList
s8 flags
Definition demo_api.c:15
@ MODIFY_COLLIDER_FLAGS_SET_BITS
Definition enums.h:4290
@ MODIFY_COLLIDER_FLAGS_SET_SURFACE
Definition enums.h:4293
@ MODIFY_COLLIDER_FLAGS_SET_VALUE
Definition enums.h:4292
@ MODIFY_COLLIDER_FLAGS_CLEAR_BITS
Definition enums.h:4291
void modify_collider_family_flags(s32 index, s32 flags, s32 mode)
Definition map_api.c:501
CollisionData gCollisionData
Definition collision.c:35

Referenced by modify_collider_family_flags().

◆ get_lava_reset_pos()

s32 get_lava_reset_pos ( f32 * outX,
f32 * outY,
f32 * outZ )

Definition at line 596 of file map_api.c.

596 {
597 Vec4f *temp_v0;
599
600 if (LastSafeFloor == -1) {
602 *outX = temp_v0->x;
603 *outY = temp_v0->y;
604 *outZ = temp_v0->z;
605 return -1;
606 }
607
608 while (true) {
609 if (lavaReset->colliderID == -1) {
610 break;
611 }
612
613 if (lavaReset->colliderID == LastSafeFloor) {
614 *outX = lavaReset->pos.x;
615 *outY = lavaReset->pos.y;
616 *outZ = lavaReset->pos.z;
617 return 1;
618 }
619 lavaReset++;
620 }
621 return 0;
622}
s32 LastSafeFloor
Definition script_list.c:26
LavaReset * gLavaResetList
Definition script_list.c:25
MapSettings * get_current_map_settings(void)
Definition world.c:224
EntryList * entryList
Definition map.h:24
GameStatus * gGameStatusPtr
Definition main_loop.c:31

Referenced by action_update_hit_lava().

◆ set_zone_enabled()

void set_zone_enabled ( s32 zoneID,
s32 enabled )

Definition at line 651 of file map_api.c.

651 {
653
654 if (zone->nextSibling >= 0) {
655 set_zone_enabled(zone->nextSibling, enabled);
656 }
657 if (zone->firstChild >= 0) {
658 set_zone_enabled(zone->firstChild, enabled);
659 }
660
661 switch (enabled) {
662 case 0:
664 break;
665 case 1:
667 break;
668 }
669}
@ TEMP_SET_ZONE_ENABLED_FLAG_10000
Definition enums.h:4646
void set_zone_enabled(s32 zoneID, s32 enabled)
Definition map_api.c:651
CollisionData gZoneCollisionData
Definition collision.c:36

Referenced by set_zone_enabled().

◆ goto_map()

void goto_map ( Evt * script,
s32 mode )

Definition at line 693 of file map_api.c.

693 {
694 Bytecode* args = script->ptrReadPos;
695 s16 mapID;
696 s16 areaID;
698
699 if (mode == 2) {
700 areaID = evt_get_variable(script, *args++);
701 mapID = evt_get_variable(script, *args++);
702 } else {
703 get_map_IDs_by_name_checked((char*)evt_get_variable(script, *args++), &areaID, &mapID);
704 }
705
706 gGameStatusPtr->areaID = areaID;
707 gGameStatusPtr->mapID = mapID;
709
710 if (mode == 1) {
712 }
713
716}
@ TRANSITION_STANDARD
Definition enums.h:2348
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 set_map_transition_effect(ScreenTransition)
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_CHANGE_MAP
Definition game_modes.h:13

Variable Documentation

◆ gLavaResetList

LavaReset* gLavaResetList
extern

Definition at line 25 of file script_list.c.

Referenced by get_lava_reset_pos().

◆ LastSafeFloor

s32 LastSafeFloor
extern

Definition at line 26 of file script_list.c.

Referenced by get_lava_reset_pos().

◆ gCurrentModelTreeNodeInfo