Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
DisableRandomAbility.inc.c
Go to the documentation of this file.
1#include "common.h"
2
3s32 N(hammer_icons)[] = {
4 ITEM_MENU_HAMMER1,
5 ITEM_MENU_HAMMER2,
6 ITEM_MENU_HAMMER3,
7};
8
9s32 N(hammer_text)[] = {
13};
14
15s32 N(jump_icons)[] = {
16 ITEM_MENU_BOOTS1,
17 ITEM_MENU_BOOTS2,
18 ITEM_MENU_BOOTS3,
19};
20
21s32 N(jump_text)[] = {
25};
26
27API_CALLABLE(N(DisableRandomAbility)) {
28 Bytecode* args = script->ptrReadPos;
29 BattleStatus* battleStatus = &gBattleStatus;
30 PlayerData* playerData = &gPlayerData;
31 s32 turnsLost;
32 s32 i = 0;
33 s32 temp[3];
34
35 if (battleStatus->hammerLossTurns == -1) {
36 temp[i++] = 0;
37 }
38
39 if (battleStatus->jumpLossTurns == -1) {
40 temp[i++] = 1;
41 }
42
43 if (battleStatus->itemLossTurns == -1) {
44 temp[i++] = 2;
45 }
46
47 turnsLost = rand_int(2) + 2;
48 switch (temp[rand_int(i - 1)]) {
49 case 0:
50 battleStatus->hammerLossTurns = turnsLost;
51 evt_set_variable(script, *args++, N(hammer_icons)[playerData->hammerLevel]);
52 evt_set_variable(script, *args++, N(hammer_text)[playerData->hammerLevel]);
53 break;
54
55 case 1:
56 battleStatus->jumpLossTurns = turnsLost;
57 evt_set_variable(script, *args++, N(jump_icons)[playerData->bootsLevel]);
58 evt_set_variable(script, *args++, N(jump_text)[playerData->bootsLevel]);
59 break;
60
61 case 2:
62 battleStatus->itemLossTurns = turnsLost;
63 evt_set_variable(script, *args++, ITEM_MENU_ITEMS);
65 break;
66 }
67
68 return ApiStatus_DONE2;
69}
#define rand_int
@ BTL_MSG_JUMP_DISABLED_1
Definition enums.h:4136
@ BTL_MSG_ITEMS_DISABLED
Definition enums.h:4139
@ BTL_MSG_HAMMER_DISABLED_3
Definition enums.h:4135
@ BTL_MSG_JUMP_DISABLED_3
Definition enums.h:4138
@ BTL_MSG_JUMP_DISABLED_2
Definition enums.h:4137
@ BTL_MSG_HAMMER_DISABLED_1
Definition enums.h:4133
@ BTL_MSG_HAMMER_DISABLED_2
Definition enums.h:4134
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11