Skip to content

Commit

Permalink
Retain fast arrow switches
Browse files Browse the repository at this point in the history
Update equipment data to make fast arrow switching permanent
(fixes #76)

This also makes it clearer what the current arrow type is.

Thanks to @PhlexPlexico for help and the initial implementation!
  • Loading branch information
leoetlino committed Dec 15, 2019
1 parent 9e9b940 commit deff9fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 9 additions & 6 deletions source/game/common_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ struct __attribute__((packed)) __attribute__((aligned(2))) PlayerData {
static_assert(sizeof(PlayerData) == 0x32);
static_assert(rst::util::OffsetOf(&PlayerData::magic) == 0x1F);

struct FormEquipmentData {
ItemId item_btn_b;
ItemId item_btn_y;
ItemId item_btn_x;
ItemId item_btn_i;
ItemId item_btn_ii;
union FormEquipmentData {
std::array<ItemId, 5> item_btns;
struct {
ItemId item_btn_b;
ItemId item_btn_y;
ItemId item_btn_x;
ItemId item_btn_i;
ItemId item_btn_ii;
};
};

struct EquipmentData {
Expand Down
2 changes: 1 addition & 1 deletion source/game/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct Player : public Actor {

char field_1F8;
FormParamIndex form_param_idx;
char field_1FA;
u8 item_btn_slot;
Action current_action;
ItemId held_item;
FormParamIndex form_param_idx2;
Expand Down
2 changes: 2 additions & 0 deletions source/rst/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ void HandleFastArrowSwitch(game::act::Player* player) {
} while (!can_use_arrow(idx));

s_fast_arrow_state.override_action = static_cast<game::Action>(idx + first);
player->current_action = player->action = *s_fast_arrow_state.override_action;
cdata.save.equipment.data[0].item_btns[player->item_btn_slot] = s_arrow_types[idx].required_item;
util::Print("%s: override_action is now %u (%s)", __func__,
u8(*s_fast_arrow_state.override_action), s_arrow_types[idx].name);

Expand Down

0 comments on commit deff9fc

Please sign in to comment.