Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: weapons missile for chain and equip hotkey for two-handed #2476

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ void Combat::setupChain(const std::shared_ptr<Weapon> &weapon) {
}

const auto &weaponType = weapon->getWeaponType();
if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE) {
if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE || weaponType == WEAPON_MISSILE) {
return;
}

Expand Down
38 changes: 25 additions & 13 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3153,28 +3153,40 @@ void Game::playerEquipItem(uint32_t playerId, uint16_t itemId, bool hasTier /* =

auto slotItem = player->getInventoryItem(slot);
auto equipItem = searchForItem(backpack, it.id, hasTier, tier);
ReturnValue ret = RETURNVALUE_NOERROR;
if (slotItem && slotItem->getID() == it.id && (!it.stackable || slotItem->getItemCount() == slotItem->getStackSize() || !equipItem)) {
internalMoveItem(slotItem->getParent(), player, CONST_SLOT_WHEREEVER, slotItem, slotItem->getItemCount(), nullptr);
ret = internalMoveItem(slotItem->getParent(), player, CONST_SLOT_WHEREEVER, slotItem, slotItem->getItemCount(), nullptr);
g_logger().debug("Item {} was unequipped", slotItem->getName());
} else if (equipItem) {
// Shield slot item
const auto &rightItem = player->getInventoryItem(CONST_SLOT_RIGHT);
// Check Ammo item
if (it.weaponType == WEAPON_AMMO) {
auto quiver = player->getInventoryItem(CONST_SLOT_RIGHT);
if (quiver && quiver->isQuiver()) {
internalMoveItem(equipItem->getParent(), quiver->getContainer(), 0, equipItem, equipItem->getItemCount(), nullptr);
return;
if (rightItem && rightItem->isQuiver()) {
ret = internalMoveItem(equipItem->getParent(), rightItem->getContainer(), 0, equipItem, equipItem->getItemCount(), nullptr);
}
} else {
const int32_t &slotPosition = equipItem->getSlotPosition();
// Checks if a two-handed item is being equipped in the left slot when the right slot is already occupied and move to backpack
if (slotPosition & SLOTP_LEFT && rightItem && (slotPosition & SLOTP_TWO_HAND)) {
ret = internalCollectManagedItems(player, rightItem, getObjectCategory(rightItem), false);
}
}

if (slotItem) {
internalMoveItem(slotItem->getParent(), player, INDEX_WHEREEVER, slotItem, slotItem->getItemCount(), nullptr);
g_logger().debug("Item {} was moved back to player", slotItem->getName());
}
if (slotItem) {
ret = internalMoveItem(slotItem->getParent(), player, INDEX_WHEREEVER, slotItem, slotItem->getItemCount(), nullptr);
g_logger().debug("Item {} was moved back to player", slotItem->getName());
}

auto ret = internalMoveItem(equipItem->getParent(), player, slot, equipItem, equipItem->getItemCount(), nullptr);
if (ret == RETURNVALUE_NOERROR) {
g_logger().debug("Item {} was equipped", equipItem->getName());
ret = internalMoveItem(equipItem->getParent(), player, slot, equipItem, equipItem->getItemCount(), nullptr);
if (ret == RETURNVALUE_NOERROR) {
g_logger().debug("Item {} was equipped", equipItem->getName());
}
}
}

if (ret != RETURNVALUE_NOERROR) {
player->sendCancelMessage(ret);
}
}

void Game::playerMove(uint32_t playerId, Direction direction) {
Expand Down
Loading