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

Go to the source code of this file.

Enumerations

enum  { SHOW_MESSAGE_SPEAK_TO_PLAYER = 0 , SHOW_MESSAGE_END_SPEECH = 1 , SHOW_MESSAGE_CONTINUE_SPEECH = 2 , SHOW_MESSAGE_SPEAK_TO_NPC = 3 }
 

Functions

ApiStatus _show_message (Evt *script, s32 isInitialCall, s32 mode)
 
s32 cancel_current_message (void)
 

Variables

s32 ShowMessageScreenOffsetX
 
s32 ShowMessageScreenOffsetY
 
s32 D_802DAE58 [2]
 
char D_802DAE60 [0x400]
 
MessagePrintStategCurrentPrintContext
 
s32 D_802DB264
 
MessagePrintStateD_802DB268
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
SHOW_MESSAGE_SPEAK_TO_PLAYER 
SHOW_MESSAGE_END_SPEECH 
SHOW_MESSAGE_CONTINUE_SPEECH 
SHOW_MESSAGE_SPEAK_TO_NPC 

Definition at line 13 of file msg_api.c.

13 {
18};
@ SHOW_MESSAGE_END_SPEECH
Definition msg_api.c:15
@ SHOW_MESSAGE_SPEAK_TO_NPC
Definition msg_api.c:17
@ SHOW_MESSAGE_CONTINUE_SPEECH
Definition msg_api.c:16
@ SHOW_MESSAGE_SPEAK_TO_PLAYER
Definition msg_api.c:14

Function Documentation

◆ _show_message()

s32 _show_message ( Evt * script,
s32 isInitialCall,
s32 mode )

Definition at line 36 of file msg_api.c.

36 {
38 Bytecode* args = script->ptrReadPos;
43 f32 angle;
46 s32 targetNpcID;
47 s32 msgID;
48 s32 animID;
49
50 targetNpc = nullptr;
51
52 if (isInitialCall) {
53 D_802DB264 = 0;
55 script->varTable[13] = evt_get_variable(script, *args++);
56 script->varTable[14] = evt_get_variable(script, *args++);
57 script->functionTemp[1] = evt_get_variable(script, *args++);
60
61 if (script->functionTemp[1] & SPEECH_FLAG_HAS_OFFSET) {
64 }
65
66 switch (mode) {
68 msgID = evt_get_variable(script, *args++);
70 break;
73 break;
75 msgID = evt_get_variable(script, *args++);
77 break;
79 targetNpcID = evt_get_variable(script, *args++);
80 msgID = evt_get_variable(script, *args++);
81 targetNpc = resolve_npc(script, targetNpcID);
83 break;
84 }
85
86 if (speakerNpcID == NPC_PLAYER) {
88 playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z,
90 script->functionTemp[3] = playerStatus->anim;
92 script->varTable[15] = playerStatus->targetYaw;
93 } else {
95 get_screen_coords(gCurrentCameraID, speakerNpc->pos.x, speakerNpc->pos.y + speakerNpc->collisionHeight, speakerNpc->pos.z,
97 script->functionTemp[3] = speakerNpc->curAnim;
98 script->varTable[15] = speakerNpc->yaw;
99 }
100
104 script->varTablePtr[12] = speakerNpc;
105
106 if (speakerNpc != (Npc*) NPC_PLAYER) {
107 if (mode == SHOW_MESSAGE_SPEAK_TO_NPC) {
108 listenerYaw = &targetNpc->yaw;
109 angle = atan2(speakerNpc->pos.x, speakerNpc->pos.z, targetNpc->pos.x, targetNpc->pos.z);
110 } else {
111 listenerYaw = &playerStatus->targetYaw;
112 angle = atan2(speakerNpc->pos.x, speakerNpc->pos.z, playerStatus->pos.x, playerStatus->pos.z);
113 }
114
115 reverseAngle = clamp_angle(angle + 180.0f);
116 switch (script->functionTemp[1] & SPEECH_ORIENTATION_MASK) {
118 speakerNpc->yaw = angle;
120 break;
124 break;
126 speakerNpc->yaw = angle;
127 *listenerYaw = angle;
128 break;
131 *listenerYaw = angle;
132 break;
134 speakerNpc->yaw = angle;
135 break;
136 case 5:
137 break;
138 }
139 }
140 }
141
142 speakerNpc = script->varTablePtr[12];
143 if (speakerNpc != (Npc*) NPC_PLAYER) {
144 get_screen_coords(gCurrentCameraID, speakerNpc->pos.x, speakerNpc->pos.y + speakerNpc->collisionHeight, speakerNpc->pos.z, &screenX, &screenY, &screenZ);
145 animID = script->varTable[13];
146 if (animID != -1) {
148 animID = script->varTable[14];
149 }
151 }
152 } else {
154 if (script->varTable[13] != -1) {
156 playerStatus->anim = script->varTable[13];
157 } else {
158 playerStatus->anim = script->varTable[14];
159 }
160 }
161 }
162
163 if (!(script->functionTemp[1] & SPEECH_FLAG_200)) {
165 }
166
168 return true;
169 }
170
171 if (D_802DB264 != 1) {
172 return false;
173 }
174
175 if (script->varTable[13] != -1) {
176 if (speakerNpc != (Npc*) NPC_PLAYER) {
177 set_npc_animation(speakerNpc, script->functionTemp[3]);
178 } else {
179 playerStatus->anim = script->functionTemp[3];
180 }
181 }
182 if (script->functionTemp[1] & SPEECH_FLAG_10) {
183 speakerNpc->yaw = script->varTable[0xF];
184 }
185 return true;
186}
BSS s32 PopupMenu_SelectedIndex
#define clamp_angle
#define atan2
@ MSG_STATE_FLAG_40
Definition enums.h:5829
@ MSG_STATE_FLAG_SPEAKING
Definition enums.h:5830
@ SPEECH_FLAG_10
Definition enums.h:1962
@ SPEECH_FACE_LIKE_LISTENER
Definition enums.h:1970
@ SPEECH_FACE_SPEAKER_ONLY
Definition enums.h:1967
@ SPEECH_FLAG_HAS_OFFSET
Definition enums.h:1963
@ SPEECH_ORIENTATION_MASK
Definition enums.h:1966
@ SPEECH_FACE_AWAY_FROM
Definition enums.h:1968
@ SPEECH_FACE_EACH_OTHER
Definition enums.h:1971
@ SPEECH_FLAG_200
Definition enums.h:1964
@ SPEECH_FACE_LIKE_SPEAKER
Definition enums.h:1969
@ NPC_PLAYER
Definition enums.h:2513
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
void set_npc_animation(Npc *npc, u32 animID)
Definition npc_api.c:18
void msg_printer_set_origin_pos(MessagePrintState *msgPrintState, s32 x, s32 y)
Definition msg.c:1491
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:409
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1570
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
Definition msg.c:1426
Npc * resolve_npc(Evt *script, s32 npcIdOrPtr)
Definition npc_api.c:8
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1476
s32 ShowMessageScreenOffsetY
Definition script_list.c:39
MessagePrintState * gCurrentPrintContext
Definition script_list.c:40
s32 ShowMessageScreenOffsetX
Definition script_list.c:38
s32 D_802DB264
Definition script_list.c:42
PlayerStatus gPlayerStatus
Definition 77480.c:38
s32 gCurrentCameraID
Definition cam_math.c:5

◆ cancel_current_message()

s32 cancel_current_message ( void )

Definition at line 311 of file msg_api.c.

311 {
313 return 0;
314}
s32 cancel_message(MessagePrintState *msgPrintState)
Definition msg.c:1509

Referenced by pre_battle().

Variable Documentation

◆ ShowMessageScreenOffsetX

s32 ShowMessageScreenOffsetX
extern

Definition at line 38 of file script_list.c.

Referenced by _show_message().

◆ ShowMessageScreenOffsetY

s32 ShowMessageScreenOffsetY
extern

Definition at line 39 of file script_list.c.

Referenced by _show_message().

◆ D_802DAE58

s32 D_802DAE58[2]
extern

◆ D_802DAE60

char D_802DAE60[0x400]
extern

◆ gCurrentPrintContext

MessagePrintState* gCurrentPrintContext
extern

Definition at line 40 of file script_list.c.

Referenced by _show_message(), and cancel_current_message().

◆ D_802DB264

s32 D_802DB264
extern

Definition at line 42 of file script_list.c.

Referenced by _show_message().

◆ D_802DB268

MessagePrintState* D_802DB268
extern

Definition at line 41 of file script_list.c.