Skip to content

Commit

Permalink
[JP] Action Commands, Battle Partners/Items/Moves and some more
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshigure committed Aug 31, 2024
1 parent 5f1f696 commit c93b3ca
Show file tree
Hide file tree
Showing 15 changed files with 1,936 additions and 185 deletions.
2 changes: 0 additions & 2 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -2414,9 +2414,7 @@ enum DoorSounds {
DOOR_SOUNDS_UNUSED = 6,
};

#if VERSION_US || VERSION_PAL || VERSION_IQUE
#include "sprite/sprite_shading_profiles.h"
#endif

enum LightSourceFlags {
LIGHT_SOURCE_DISABLED = 0,
Expand Down
5 changes: 0 additions & 5 deletions src/evt/demo_api.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#include "common.h"
#include "ld_addrs.h"

#if VERSION_JP // TODO remove once this part is split
#define SHADING_NONE 0xFFFFFFFF
extern Addr sprite_shading_profiles_ROM_START;
#endif

// TODO: not sure where these go
u8 ReflectWallPrevAlpha = 254;
u8 ReflectFloorPrevAlpha = 254;
Expand Down
6 changes: 6 additions & 0 deletions src/menu_hud_scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ HudScript HES_FilenameCaret = {

HudScript HES_FilenameSpace = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_files_filename_space, 8, 8);

#if VERSION_JP
HudScript HES_HeaderStats = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_spirits, 32, 16);

HudScript HES_HeaderBadges = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_map, 32, 16);
#else
HudScript HES_HeaderStats = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_stats, 48, 16);

HudScript HES_HeaderBadges = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_badges, 48, 16);
Expand All @@ -67,6 +72,7 @@ HudScript HES_HeaderParty = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_party, 48
HudScript HES_HeaderSpirits = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_spirits, 48, 16);

HudScript HES_HeaderMap = HES_TEMPLATE_CI_CUSTOM_SIZE(ui_pause_label_map, 48, 16);
#endif

#if VERSION_PAL
HudScript HES_HeaderStats_de = HES_TEMPLATE_CI_CUSTOM_SIZE(de_ui_pause_label_stats, 48, 16);
Expand Down
1 change: 0 additions & 1 deletion src/world/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void action_update_use_tweester(void);
void action_update_state_23(void);

#if VERSION_JP // TODO remove once segments are split
extern Addr world_use_item_VRAM;
extern Addr world_action_idle_ROM_START;
extern Addr world_action_idle_ROM_END;
extern Addr world_action_walk_ROM_START;
Expand Down
10 changes: 10 additions & 0 deletions src/world/partner/goombario.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,20 @@ API_CALLABLE(N(SelectTattleMsg)) {

switch (script->USE_STATE) {
case USE_TATTLE_INIT:
#if VERSION_JP
if (!(goombario->flags & NPC_FLAG_GROUNDED)) {
return ApiStatus_DONE2;
}
if (playerStatus->inputDisabledCount != 0) {
script->VAR_MSG = -1;
return ApiStatus_DONE2;
}
#else
if (!(goombario->flags & NPC_FLAG_GROUNDED) || playerStatus->inputDisabledCount != 0) {
script->VAR_MSG = -1;
return ApiStatus_DONE2;
}
#endif
script->functionTemp[1] = 3;
disable_player_input();
N(IsTattleActive) = TRUE;
Expand Down
51 changes: 51 additions & 0 deletions src/world/partner/lakilester.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ s32 N(can_dismount)(void) {
return canDismount;
}

#if !VERSION_JP
s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) {
f32 x = gPlayerStatus.pos.x;
f32 y = gPlayerStatus.pos.y + height;
Expand Down Expand Up @@ -306,6 +307,7 @@ s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) {
}
return FALSE;
}
#endif

void N(apply_riding_static_collisions)(Npc* lakilester) {
f32 radius = lakilester->collisionDiameter * 0.8f;
Expand Down Expand Up @@ -543,6 +545,37 @@ void N(update_riding_physics)(Npc* lakilester) {
}
}

#if VERSION_JP
s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) {
f32 x = gPlayerStatus.pos.x;
f32 y = gPlayerStatus.pos.y + height;
f32 z = gPlayerStatus.pos.z;
f32 depth = dist;
f32 hitRx, hitRz;
f32 hitDirX, hitDirZ;
f32 deltaY;

N(MountingDeltaY) = 0;

if (npc_raycast_down_around(0, &x, &y, &z, &depth,
lakilester->yaw, lakilester->collisionDiameter))
{
deltaY = y - lakilester->moveToPos.y;
if (deltaY != 0.0f) {
if (fabs(deltaY) < 10.0) {
N(MountingDeltaY) = deltaY;
lakilester->moveToPos.y = y;
return TRUE;
} else {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
#endif

s32 N(test_dismount_height)(f32* posY) {
f32 colliderHeight = gPlayerStatus.colliderHeight;
f32 hitDirX, hitDirZ;
Expand Down Expand Up @@ -643,7 +676,11 @@ API_CALLABLE(N(UseAbility)) {

switch (N(AbilityState)) {
case RIDE_STATE_BEGIN:
#if VERSION_JP
if (playerStatus->inputDisabledCount != 0) {
#else
if (playerStatus->flags & PS_FLAG_HIT_FIRE || playerStatus->inputDisabledCount != 0) {
#endif
playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
return ApiStatus_DONE2;
}
Expand All @@ -653,6 +690,7 @@ API_CALLABLE(N(UseAbility)) {
N(AbilityState)++; // RIDE_STATE_DELAY
break;
case RIDE_STATE_DELAY:
#if !VERSION_JP
if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
if (N(LockingPlayerInput)) {
Expand All @@ -661,6 +699,7 @@ API_CALLABLE(N(UseAbility)) {
}
return ApiStatus_DONE2;
}
#endif

if (playerStatus->animFlags & PA_FLAG_CHANGING_MAP) {
if (script->functionTemp[2] < playerStatus->inputDisabledCount) {
Expand Down Expand Up @@ -733,7 +772,9 @@ API_CALLABLE(N(UseAbility)) {
N(AbilityState)++;
// fallthrough
case RIDE_STATE_MOUNT_4:
#if !VERSION_JP
if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) {
#endif
lakilester->pos.x += (lakilester->moveToPos.x - lakilester->pos.x) / lakilester->duration;
lakilester->pos.z += (lakilester->moveToPos.z - lakilester->pos.z) / lakilester->duration;
lakilester->pos.y += (lakilester->moveToPos.y - lakilester->pos.y) / lakilester->duration;
Expand Down Expand Up @@ -773,17 +814,27 @@ API_CALLABLE(N(UseAbility)) {
N(AbilityState) = RIDE_STATE_START_RIDING;
playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER;
}
#if !VERSION_JP
} else {
N(AbilityState) = RIDE_STATE_FINISH_1;
}
#endif
break;
case RIDE_STATE_START_RIDING:
#if !VERSION_JP
if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
N(AbilityState) = RIDE_STATE_FINISH_1;
break;
}
#endif
lakilester->duration--;
if (lakilester->duration != 0) {
#if VERSION_JP
if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
N(AbilityState) = RIDE_STATE_FINISH_1;
break;
}
#endif
if (partnerStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) {
if (N(can_dismount)()) {
N(AbilityState) = RIDE_STATE_DISMOUNT_1;
Expand Down
4 changes: 4 additions & 0 deletions src/world/partner/sushie.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ void N(update_riding_physics)(Npc* sushie) {
z = sushie->pos.z;
depth = (sushie->collisionHeight * 0.5f) + playerStatus->colliderHeight;
if (npc_raycast_up_corners(sushie->collisionChannel, &x, &y, &z, &depth, sushie->yaw, sushie->collisionDiameter * 0.3f) > NO_COLLIDER) {
#if VERSION_JP
sushie->moveToPos.y = y;
#else
sushie->moveToPos.y += (((sushie->moveToPos.y - y) + depth) - ((sushie->collisionHeight * 0.5f) + playerStatus->colliderHeight)) * 0.2f;
#endif
if (N(DiveTime) % 9 == 0) {
fx_rising_bubble(0, sushie->pos.x, sushie->moveToPos.y + (sushie->collisionHeight * 0.5f), sushie->pos.z,
(N(WaterSurfaceY) - sushie->moveToPos.y) - (sushie->collisionHeight * 0.5f));
Expand Down
39 changes: 39 additions & 0 deletions src/world/partner/watt.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,42 @@ API_CALLABLE(N(UseAbility)) {
break;
case SHINING_STATE_HOLDING:
N(sync_held_position)();
#if VERSION_JP
// wait for begin holding cooldown
if (script->functionTemp[1] != 0) {
script->functionTemp[1]--;
break;
}
if (playerStatus->actionState == ACTION_STATE_USE_SPINNING_FLOWER) {
break;
}
// allow stop-holding input
actionState = playerStatus->actionState;
if ((actionState == ACTION_STATE_IDLE
|| actionState == ACTION_STATE_WALK
|| actionState == ACTION_STATE_RUN
|| actionState == ACTION_STATE_LAND)
&& partnerStatus->pressedButtons & BUTTON_B
|| playerStatus->flags & PS_FLAG_HIT_FIRE
) {
case SHINING_STATE_RELEASE:
playerStatus->animFlags &= ~(PA_FLAG_WATT_IN_HANDS | PA_FLAG_USING_WATT);
npc->curAnim = ANIM_WorldWatt_Idle;
partner_clear_player_tracking(npc);
N(IsPlayerHolding) = FALSE;
partnerStatus->actingPartner = PARTNER_NONE;
partnerStatus->partnerActionState = PARTNER_ACTION_NONE;
gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE;
N(AbilityState) = SHINING_STATE_BEGIN;
npc_set_palswap_mode_A(npc, NPC_PAL_ADJUST_NONE);
if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) {
set_action_state(ACTION_STATE_IDLE);
} else {
set_action_state(ACTION_STATE_HIT_LAVA);
}
return ApiStatus_DONE1;
}
#else
// immediately cancel state on touching fire
if ((playerStatus->flags & PS_FLAG_HIT_FIRE)) {
N(AbilityState) = SHINING_STATE_RELEASE;
Expand All @@ -364,9 +400,11 @@ API_CALLABLE(N(UseAbility)) {
) {
N(AbilityState) = SHINING_STATE_RELEASE;
}
#endif
break;
}

#if !VERSION_JP
if (N(AbilityState) == SHINING_STATE_RELEASE) {
playerStatus->animFlags &= ~(PA_FLAG_WATT_IN_HANDS | PA_FLAG_USING_WATT);
npc->curAnim = ANIM_WorldWatt_Idle;
Expand All @@ -382,6 +420,7 @@ API_CALLABLE(N(UseAbility)) {
}
return ApiStatus_DONE1;
}
#endif

if (N(StaticEffect) != NULL) {
N(StaticEffect)->data.staticStatus->pos.x = npc->pos.x;
Expand Down
39 changes: 0 additions & 39 deletions src/world/partners.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,45 +113,6 @@ extern HudScript HES_StatusSPIncrement7;

extern EvtScript EVS_World_UseItem;

#if VERSION_JP // TODO remove once segments are split
extern Addr world_use_item_ROM_START;
extern Addr world_use_item_ROM_END;
extern Addr world_use_item_VRAM;
extern Addr world_partner_goombario_ROM_START;
extern Addr world_partner_goombario_ROM_END;
extern Addr world_partner_goombario_VRAM;
extern Addr world_partner_kooper_ROM_START;
extern Addr world_partner_kooper_ROM_END;
extern Addr world_partner_kooper_VRAM;
extern Addr world_partner_bombette_ROM_START;
extern Addr world_partner_bombette_ROM_END;
extern Addr world_partner_bombette_VRAM;
extern Addr world_partner_parakarry_ROM_START;
extern Addr world_partner_parakarry_ROM_END;
extern Addr world_partner_parakarry_VRAM;
extern Addr world_partner_goompa_ROM_START;
extern Addr world_partner_goompa_ROM_END;
extern Addr world_partner_goompa_VRAM;
extern Addr world_partner_watt_ROM_START;
extern Addr world_partner_watt_ROM_END;
extern Addr world_partner_watt_VRAM;
extern Addr world_partner_sushie_ROM_START;
extern Addr world_partner_sushie_ROM_END;
extern Addr world_partner_sushie_VRAM;
extern Addr world_partner_lakilester_ROM_START;
extern Addr world_partner_lakilester_ROM_END;
extern Addr world_partner_lakilester_VRAM;
extern Addr world_partner_bow_ROM_START;
extern Addr world_partner_bow_ROM_END;
extern Addr world_partner_bow_VRAM;
extern Addr world_partner_goombaria_ROM_START;
extern Addr world_partner_goombaria_ROM_END;
extern Addr world_partner_goombaria_VRAM;
extern Addr world_partner_twink_ROM_START;
extern Addr world_partner_twink_ROM_END;
extern Addr world_partner_twink_VRAM;
#endif

s32 partner_is_idle(Npc* partner);
s32 world_partner_can_open_menus_default(Npc* partner);
void _use_partner_ability(void);
Expand Down
10 changes: 10 additions & 0 deletions src/world/script_api/shops.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include "model.h"
#include "pause/pause_common.h"

#if !VERSION_JP
extern u8 MessagePlural[];
extern u8 MessageSingular[];
#endif
extern HudScript HES_Item_Coin;

s32 shop_get_sell_price(s32 itemID);
Expand Down Expand Up @@ -98,13 +100,15 @@ s32 shop_owner_buy_dialog(s32 messageIndex, s32 itemName, s32 coinCost, s32 bpCo

if (bpCost > 0) {
set_message_int_var(bpCost, 2);
#if !VERSION_JP
} else {
if (coinCost == 1) {
suffix = MessageSingular;
} else {
suffix = MessagePlural;
}
set_message_text_var((s32) suffix, 2);
#endif
}

script = start_script(&EVS_ShopBeginSpeech, EVT_PRIORITY_1, 0);
Expand Down Expand Up @@ -137,13 +141,15 @@ s32 shop_owner_continue_speech_with_quantity(s32 messageIndex, s32 amount) {

set_message_int_var(amount, 0);

#if !VERSION_JP
if (amount == 1) {
suffixMsg = MessageSingular;
} else {
suffixMsg = MessagePlural;
}

set_message_text_var((s32) suffixMsg, 1);
#endif

script = start_script(&EVS_ShopContinueSpeech, EVT_PRIORITY_1, 0);
script->varTable[0] = shopMsgID;
Expand Down Expand Up @@ -944,7 +950,11 @@ API_CALLABLE(MakeShop) {
hud_element_clear_flags(shop->costIconID, HUD_ELEMENT_FLAG_FILTER_TEX);
get_worker(create_worker_frontUI(NULL, draw_shop_items));
set_window_properties(WINDOW_ID_ITEM_INFO_NAME, 100, 66, 120, 28, WINDOW_PRIORITY_0, shop_draw_item_name, NULL, -1);
#if VERSION_JP
set_window_properties(WINDOW_ID_ITEM_INFO_DESC, 39, 184, 242, 32, WINDOW_PRIORITY_1, shop_draw_item_desc, NULL, -1);
#else
set_window_properties(WINDOW_ID_ITEM_INFO_DESC, 32, 184, 256, 32, WINDOW_PRIORITY_1, shop_draw_item_desc, NULL, -1);
#endif
gWindowStyles[10].defaultStyleID = WINDOW_STYLE_9;
gWindowStyles[11].defaultStyleID = WINDOW_STYLE_3;
shop->curItemSlot = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/world_use_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@ API_CALLABLE(WorldItem_RestoreFP) {

API_CALLABLE(WorldItem_PauseTime) {
set_time_freeze_mode(TIME_FREEZE_FULL);
#if !VERSION_JP
gOverrideFlags |= GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS;
#endif
return ApiStatus_DONE2;
}

API_CALLABLE(WorldItem_UnpauseTime) {
set_time_freeze_mode(TIME_FREEZE_NORMAL);
#if !VERSION_JP
gOverrideFlags &= ~GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS;
#endif
return ApiStatus_DONE2;
}

Expand Down
Loading

0 comments on commit c93b3ca

Please sign in to comment.