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

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 {
37 PlayerStatus* playerStatus = &gPlayerStatus;
38 Bytecode* args = script->ptrReadPos;
39 s32 screenX, screenY, screenZ;
40 Npc* speakerNpc;
41 Npc* targetNpc;
42 f32 reverseAngle;
43 f32 angle;
44 f32* listenerYaw;
45 s32 speakerNpcID;
46 s32 targetNpcID;
47 s32 msgID;
48 s32 animID;
49 s32 ret;
50
51 targetNpc = NULL;
52
53 if (isInitialCall) {
54 D_802DB264 = 0;
55 speakerNpcID = evt_get_variable(script, *args++);
56 script->varTable[13] = evt_get_variable(script, *args++);
57 script->varTable[14] = evt_get_variable(script, *args++);
58 script->functionTemp[1] = evt_get_variable(script, *args++);
61
62 if (script->functionTemp[1] & SPEECH_FLAG_HAS_OFFSET) {
65 }
66
67 switch (mode) {
69 msgID = evt_get_variable(script, *args++);
71 break;
74 break;
76 msgID = evt_get_variable(script, *args++);
78 break;
80 targetNpcID = evt_get_variable(script, *args++);
81 msgID = evt_get_variable(script, *args++);
82 targetNpc = resolve_npc(script, targetNpcID);
84 break;
85 }
86
87 if (speakerNpcID == NPC_PLAYER) {
89 playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z,
90 &screenX, &screenY, &screenZ);
91 script->functionTemp[3] = playerStatus->anim;
92 speakerNpc = (Npc*) NPC_PLAYER;
93 script->varTable[15] = playerStatus->targetYaw;
94 } else {
95 speakerNpc = resolve_npc(script, speakerNpcID);
96 get_screen_coords(gCurrentCameraID, speakerNpc->pos.x, speakerNpc->pos.y + speakerNpc->collisionHeight, speakerNpc->pos.z,
97 &screenX, &screenY, &screenZ);
98 script->functionTemp[3] = speakerNpc->curAnim;
99 script->varTable[15] = speakerNpc->yaw;
100 }
101
103 screenX + ShowMessageScreenOffsetX,
104 screenY + ShowMessageScreenOffsetY);
105 script->varTablePtr[12] = speakerNpc;
106
107 if (speakerNpc != (Npc*) NPC_PLAYER) {
108 if (mode == SHOW_MESSAGE_SPEAK_TO_NPC) {
109 listenerYaw = &targetNpc->yaw;
110 angle = atan2(speakerNpc->pos.x, speakerNpc->pos.z, targetNpc->pos.x, targetNpc->pos.z);
111 } else {
112 listenerYaw = &playerStatus->targetYaw;
113 angle = atan2(speakerNpc->pos.x, speakerNpc->pos.z, playerStatus->pos.x, playerStatus->pos.z);
114 }
115
116 reverseAngle = clamp_angle(angle + 180.0f);
117 switch (script->functionTemp[1] & SPEECH_ORIENTATION_MASK) {
119 speakerNpc->yaw = angle;
120 *listenerYaw = reverseAngle;
121 break;
123 speakerNpc->yaw = reverseAngle;
124 *listenerYaw = reverseAngle;
125 break;
127 speakerNpc->yaw = angle;
128 *listenerYaw = angle;
129 break;
131 speakerNpc->yaw = reverseAngle;
132 *listenerYaw = angle;
133 break;
135 speakerNpc->yaw = angle;
136 break;
137 case 5:
138 break;
139 }
140 }
141 }
142
143 speakerNpc = script->varTablePtr[12];
144 if (speakerNpc != (Npc*) NPC_PLAYER) {
145 get_screen_coords(gCurrentCameraID, speakerNpc->pos.x, speakerNpc->pos.y + speakerNpc->collisionHeight, speakerNpc->pos.z, &screenX, &screenY, &screenZ);
146 animID = script->varTable[13];
147 if (animID != -1) {
149 animID = script->varTable[14];
150 }
151 set_npc_animation(speakerNpc, animID);
152 }
153 } else {
154 get_screen_coords(gCurrentCameraID, playerStatus->pos.x, playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z, &screenX, &screenY, &screenZ);
155 if (script->varTable[13] != -1) {
157 playerStatus->anim = script->varTable[13];
158 } else {
159 playerStatus->anim = script->varTable[14];
160 }
161 }
162 }
163
164 if (!(script->functionTemp[1] & SPEECH_FLAG_200)) {
166 }
167
169 return TRUE;
170 }
171
172 if (D_802DB264 != 1) {
173 return FALSE;
174 }
175
176 if (script->varTable[13] != -1) {
177 if (speakerNpc != (Npc*) NPC_PLAYER) {
178 set_npc_animation(speakerNpc, script->functionTemp[3]);
179 } else {
180 playerStatus->anim = script->functionTemp[3];
181 }
182 }
183 if (script->functionTemp[1] & SPEECH_FLAG_10) {
184 speakerNpc->yaw = script->varTable[0xF];
185 }
186 return TRUE;
187}
Bytecode * ptrReadPos
#define clamp_angle
#define atan2
@ MSG_STATE_FLAG_40
Definition enums.h:6244
@ MSG_STATE_FLAG_SPEAKING
Definition enums.h:6245
@ SPEECH_FLAG_10
Definition enums.h:1936
@ SPEECH_FACE_LIKE_LISTENER
Definition enums.h:1944
@ SPEECH_FACE_SPEAKER_ONLY
Definition enums.h:1941
@ SPEECH_FLAG_HAS_OFFSET
Definition enums.h:1937
@ SPEECH_ORIENTATION_MASK
Definition enums.h:1940
@ SPEECH_FACE_AWAY_FROM
Definition enums.h:1942
@ SPEECH_FACE_EACH_OTHER
Definition enums.h:1945
@ SPEECH_FLAG_200
Definition enums.h:1938
@ SPEECH_FACE_LIKE_SPEAKER
Definition enums.h:1943
@ NPC_PLAYER
Definition enums.h:2527
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
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:1489
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:410
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1568
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
Definition msg.c:1424
Npc * resolve_npc(Evt *script, s32 npcIdOrPtr)
Definition npc_api.c:8
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1474
s32 ShowMessageScreenOffsetY
Definition script_list.c:37
MessagePrintState * gCurrentPrintContext
Definition script_list.c:38
s32 ShowMessageScreenOffsetX
Definition script_list.c:36
s32 D_802DB264
Definition script_list.c:40
AnimID curAnim
s16 collisionHeight
Vec3f pos
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4

◆ cancel_current_message()

s32 cancel_current_message ( void )

Definition at line 312 of file msg_api.c.

312 {
314 return 0;
315}
s32 cancel_message(MessagePrintState *msgPrintState)
Definition msg.c:1507

Referenced by pre_battle().

Variable Documentation

◆ ShowMessageScreenOffsetX

s32 ShowMessageScreenOffsetX
extern

Definition at line 36 of file script_list.c.

Referenced by _show_message().

◆ ShowMessageScreenOffsetY

s32 ShowMessageScreenOffsetY
extern

Definition at line 37 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 38 of file script_list.c.

Referenced by _show_message(), and cancel_current_message().

◆ D_802DB264

s32 D_802DB264
extern

Definition at line 40 of file script_list.c.

Referenced by _show_message().

◆ D_802DB268

MessagePrintState* D_802DB268
extern

Definition at line 39 of file script_list.c.