Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
MonitorMusicProximityTrigger.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3
4/*
5 The current BGM can be modified based on the player's proximity to a specified point.
6 When closer than the inner distance, the modified tracks(?) play at half volume. If the
7 player moves beyond the outer distance, the modified tracks are muted.
8 Setting an event flags overries the normal music with the modified music until the outer
9 distance is exceeded.
10*/
11API_CALLABLE(N(MonitorMusicProximityTrigger)) {
12 Bytecode* args = script->ptrReadPos;
13 MusicProximityTrigger* trigger;
14 s32 cond = FALSE;
15 f32 dist;
16
17 if (isInitialCall) {
18 script->functionTemp[0] = evt_get_variable(script, *args);
19 script->functionTemp[1] = MUSIC_PROXIMITY_FAR;
20 script->functionTemp[2] = ((MusicProximityTrigger*)(script->functionTemp[0]))->manualActivationFlag;
21 }
22
23 trigger = script->functionTempPtr[0];
24
25 if (evt_get_variable(script, script->functionTemp[2])) {
26 if (script->functionTemp[1] != MUSIC_PROXIMITY_FULL) {
27 script->functionTemp[1] = MUSIC_PROXIMITY_FULL;
28 cond = TRUE;
29 }
30 } else {
31 dist = dist2D(gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z, trigger->pos.x, trigger->pos.z);
32
33 switch (script->functionTemp[1]) {
35 if (dist < trigger->innerDist) {
36 script->functionTemp[1] = MUSIC_PROXIMITY_NEAR;
37 cond = TRUE;
38 }
39 break;
41 if (dist > trigger->outerDist) {
42 script->functionTemp[1] = MUSIC_PROXIMITY_FAR;
43 cond = TRUE;
44 }
45 break;
47 script->functionTemp[1] = MUSIC_PROXIMITY_NEAR;
48 cond = TRUE;
49 break;
50 }
51 }
52
53 if (cond) {
54 bgm_adjust_proximity(0, trigger->unk, script->functionTemp[1]);
55 }
56
57 return ApiStatus_BLOCK;
58}
@ MUSIC_PROXIMITY_NEAR
Definition enums.h:1784
@ MUSIC_PROXIMITY_FULL
Definition enums.h:1785
@ MUSIC_PROXIMITY_FAR
Definition enums.h:1783
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 bgm_adjust_proximity(s32 playerIndex, s32 arg1, s16 arg2)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
PlayerStatus * gPlayerStatusPtr