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 {
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}
Bytecode * ptrReadPos
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
u8 modelIndex
Definition model.h:113
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 502 of file map_api.c.

502 {
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}
Collider * colliderList
s8 flags
Definition demo_api.c:15
@ 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
void modify_collider_family_flags(s32 index, s32 flags, s32 mode)
Definition map_api.c:502
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 597 of file map_api.c.

597 {
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}
s32 LastSafeFloor
Definition script_list.c:24
LavaReset * gLavaResetList
Definition script_list.c:23
MapSettings * get_current_map_settings(void)
Definition world.c:224
EntryList * entryList
Definition map.h:32
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Referenced by action_update_hit_lava().

◆ set_zone_enabled()

void set_zone_enabled ( s32 zoneID,
s32 enabled )

Definition at line 653 of file map_api.c.

653 {
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}
@ TEMP_SET_ZONE_ENABLED_FLAG_10000
Definition enums.h:5061
void set_zone_enabled(s32 zoneID, s32 enabled)
Definition map_api.c:653
CollisionData gZoneCollisionData
Definition collision.c:36

Referenced by set_zone_enabled().

◆ goto_map()

void goto_map ( Evt * script,
s32 mode )

Definition at line 695 of file map_api.c.

695 {
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}
@ TRANSITION_STANDARD
Definition enums.h:2362
s32 Bytecode
Definition evt.h:7
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 23 of file script_list.c.

Referenced by get_lava_reset_pos().

◆ LastSafeFloor

s32 LastSafeFloor
extern

Definition at line 24 of file script_list.c.

Referenced by get_lava_reset_pos().

◆ gCurrentModelTreeNodeInfo