Skip to content

Commit

Permalink
Merge pull request #1562 from fmatthew5876/fixed_equip
Browse files Browse the repository at this point in the history
Support Cursed (fixed equipment) Items and states
  • Loading branch information
Ghabry committed Dec 13, 2018
2 parents 43c6e30 + a0988c1 commit 8c49f35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/game_actor.cpp
Expand Up @@ -855,7 +855,17 @@ bool Game_Actor::IsEquippable(int item_id) const {
}

bool Game_Actor::IsEquipmentFixed() const {
return GetData().lock_equipment;
if (GetData().lock_equipment) {
return true;
}

for (auto state_id: GetInflictedStates()) {
auto* state = ReaderUtil::GetElement(Data::states, state_id);
if (state && state->cursed) {
return true;
}
}
return false;
}

bool Game_Actor::HasStrongDefense() const {
Expand Down
13 changes: 12 additions & 1 deletion src/scene_equip.cpp
Expand Up @@ -114,12 +114,23 @@ void Scene_Equip::UpdateStatusWindow() {
equipstatus_window->Update();
}

static bool CanRemoveEquipment(const Game_Actor& actor, int index) {
if (actor.IsEquipmentFixed()) {
return false;
}
auto* item = actor.GetEquipment(index + 1);
if (item && item->cursed) {
return false;
}
return true;
}

void Scene_Equip::UpdateEquipSelection() {
if (Input::IsTriggered(Input::CANCEL)) {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Cancel));
Scene::Pop();
} else if (Input::IsTriggered(Input::DECISION)) {
if (actor.IsEquipmentFixed()) {
if (!CanRemoveEquipment(actor, equip_window->GetIndex())) {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
return;
}
Expand Down

0 comments on commit 8c49f35

Please sign in to comment.