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 HudElemID itemHID;
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
17 if (player_team_is_ability_active(player, ABILITY_REFUND) && sellValue > 0) {
18 s32 iconX;
19 s32 iconY;
20 s32 iconZ;
21 s32 i;
22
23 // 75% of the item's sell value, rounded up
24 sellValue = (sellValue * 75 + 99) / 100;
25
26 for (i = 0; i < sellValue; i++) {
27 posX = player->curPos.x;
28 posZ = player->curPos.z;
29
30 make_item_entity(ITEM_COIN, posX, posY, posZ, ITEM_SPAWN_MODE_TOSS_FADE1, 1 + 3 * i, angle, 0);
31 add_coins(1);
32
33 angle += 30.0f;
34 }
35
36 delayTime = (i * 3) + 30;
37
38 posX = player->curPos.x;
39 posY = player->curPos.y;
40 posZ = player->curPos.z;
41
42 get_screen_coords(gCurrentCameraID, posX, posY, posZ, &iconX, &iconY, &iconZ);
43
44#if VERSION_PAL
45 switch (gCurrentLanguage) {
46 case LANGUAGE_EN:
47 itemIcon = hid = hud_element_create(&HES_Refund);
48 break;
49 case LANGUAGE_DE:
50 itemIcon = hid = hud_element_create(&HES_Refund_de);
51 break;
52 case LANGUAGE_FR:
53 itemIcon = hid = hud_element_create(&HES_Refund_fr);
54 break;
55 case LANGUAGE_ES:
56 itemIcon = hid = hud_element_create(&HES_Refund_es);
57 break;
58 }
59 hud_element_set_render_pos(hid, iconX + 36, iconY - 63);
60#else
62 hud_element_set_render_pos(itemHID, iconX + 36, iconY - 63);
63#endif
64 }
65
66 script->varTable[0] = delayTime;
67
68 return ApiStatus_DONE2;
69}
70
71API_CALLABLE(N(GiveRefundCleanup)) {
72 BattleStatus* battleStatus = &gBattleStatus;
73 s32 sellValue = gItemTable[battleStatus->moveArgument].sellValue;
74
75 if (player_team_is_ability_active(battleStatus->playerActor, ABILITY_REFUND) && sellValue > 0) {
76 hud_element_free(itemHID);
77 }
78
79 return ApiStatus_DONE2;
80}
s32 HudElemID
Vec2bu size
Vec3f curPos
@ LANGUAGE_DE
Definition enums.h:5992
@ LANGUAGE_ES
Definition enums.h:5994
@ LANGUAGE_EN
Definition enums.h:5991
@ LANGUAGE_FR
Definition enums.h:5993
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2300
@ ABILITY_REFUND
Definition enums.h:465
#define ApiStatus_DONE2
Definition evt.h:119
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2495
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:409
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:2075
HudScript HES_Refund
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_free(s32 id)
struct Actor * playerActor
ItemData gItemTable[]
#define gCurrentLanguage
Definition variables.h:119
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gCurrentCameraID
Definition cam_math.c:5