Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
ItemRefund.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "hud_element.h"
3
4static s32 itemIcon;
5
6// out LVar0: time caller should wait for coin spawns
7API_CALLABLE(N(GiveRefund)) {
8 BattleStatus* battleStatus = &gBattleStatus;
10 s32 sellValue = gItemTable[battleStatus->moveArgument].sellValue;
11 f32 posX;
12 f32 posY = player->curPos.y + player->size.y;
13 f32 posZ;
14 f32 angle = 0.0f;
15 s32 delayTime = 0;
16 s32 tempIcon;
17
18 if (player_team_is_ability_active(player, ABILITY_REFUND) && sellValue > 0) {
19 s32 iconX;
20 s32 iconY;
21 s32 iconZ;
22 s32 i;
23
24 // 75% of the item's sell value, rounded up
25 sellValue = (sellValue * 75 + 99) / 100;
26
27 for (i = 0; i < sellValue; i++) {
28 posX = player->curPos.x;
29 posZ = player->curPos.z;
30
31 make_item_entity(ITEM_COIN, posX, posY, posZ, ITEM_SPAWN_MODE_TOSS_FADE1, 1 + 3 * i, angle, 0);
32 add_coins(1);
33
34 angle += 30.0f;
35 }
36
37 delayTime = (i * 3) + 30;
38
39 posX = player->curPos.x;
40 posY = player->curPos.y;
41 posZ = player->curPos.z;
42
43 get_screen_coords(gCurrentCameraID, posX, posY, posZ, &iconX, &iconY, &iconZ);
44
45#if VERSION_PAL
46 switch (gCurrentLanguage) {
47 case LANGUAGE_EN:
48 itemIcon = tempIcon = hud_element_create(&HES_Refund);
49 break;
50 case LANGUAGE_DE:
51 itemIcon = tempIcon = hud_element_create(&HES_Refund_de);
52 break;
53 case LANGUAGE_FR:
54 itemIcon = tempIcon = hud_element_create(&HES_Refund_fr);
55 break;
56 case LANGUAGE_ES:
57 itemIcon = tempIcon = hud_element_create(&HES_Refund_es);
58 break;
59 }
60 hud_element_set_render_pos(tempIcon, iconX + 36, iconY - 63);
61#else
62 itemIcon = hud_element_create(&HES_Refund);
63 hud_element_set_render_pos(itemIcon, iconX + 36, iconY - 63);
64#endif
65 }
66
67 script->varTable[0] = delayTime;
68
69 return ApiStatus_DONE2;
70}
71
72API_CALLABLE(N(GiveRefundCleanup)) {
73 BattleStatus* battleStatus = &gBattleStatus;
74 s32 sellValue = gItemTable[battleStatus->moveArgument].sellValue;
75
76 if (player_team_is_ability_active(battleStatus->playerActor, ABILITY_REFUND) && sellValue > 0) {
77 hud_element_free(itemIcon);
78 }
79
80 return ApiStatus_DONE2;
81}
Vec2bu size
Vec3f curPos
@ LANGUAGE_DE
Definition enums.h:6401
@ LANGUAGE_ES
Definition enums.h:6403
@ LANGUAGE_EN
Definition enums.h:6400
@ LANGUAGE_FR
Definition enums.h:6402
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2314
@ ABILITY_REFUND
Definition enums.h:465
#define ApiStatus_DONE2
Definition evt.h:118
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:410
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupVar)
s32 add_coins(s32 amt)
Definition inventory.c:2065
HudScript HES_Refund
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_free(s32 id)
struct Actor * playerActor
ItemData gItemTable[]
#define gCurrentLanguage
Definition variables.h:115
BattleStatus gBattleStatus
Definition battle.c:11
s32 gCurrentCameraID
Definition cam_math.c:4