Skip to content

Commit

Permalink
Feature to enable players to put items in ammo slot (usable to use sh…
Browse files Browse the repository at this point in the history
…opping functions and others).
  • Loading branch information
elsongabriel committed Feb 19, 2024
1 parent 1c4bea7 commit 3a5e8c9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ onlyPremiumAccount = false
-- NOTE: teleportPlayerToVocationRoom will enable oressa to teleport player to his/her room vocation
-- NOTE: toggleReceiveReward = true, will enable players to choose one of reward exercise weapon by command !reward
-- NOTE: randomMonsterSpawn = true, will enable monsters from the same spawn to be randomized between them, thus making a variable hunt
-- NOTE: enablePlayerPutItemInAmmoSlot = true, will enable players to put any items on ammo slot, more used in custom shopping system
weatherRain = false
thunderEffect = false
allConsoleLog = false
Expand All @@ -257,6 +258,7 @@ toggleReceiveReward = false
randomMonsterSpawn = false
lootPouchMaxLimit = 2000
storeInboxMaxLimit = 2000
enablePlayerPutItemInAmmoSlot = false

-- Teleport summon
-- Set to true will never remove the summon
Expand Down
1 change: 1 addition & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum ConfigKey_t : uint16_t {
DISCORD_WEBHOOK_DELAY_MS,
DISCORD_WEBHOOK_URL,
EMOTE_SPELLS,
ENABLE_PLAYER_PUT_ITEM_IN_AMMO_SLOT,
EXPERIENCE_FROM_PLAYERS,
EXP_FROM_PLAYERS_LEVEL_RANGE,
EX_ACTIONS_DELAY_INTERVAL,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ bool ConfigManager::load() {
loadIntConfig(L, BUY_AOL_COMMAND_FEE, "buyAolCommandFee", 0);
loadIntConfig(L, BUY_BLESS_COMMAND_FEE, "buyBlessCommandFee", 0);
loadBoolConfig(L, TELEPORT_PLAYER_TO_VOCATION_ROOM, "teleportPlayerToVocationRoom", true);
loadBoolConfig(L, ENABLE_PLAYER_PUT_ITEM_IN_AMMO_SLOT, "enablePlayerPutItemInAmmoSlot", false);

loadBoolConfig(L, TOGGLE_HAZARDSYSTEM, "toogleHazardSystem", true);
loadIntConfig(L, HAZARD_CRITICAL_INTERVAL, "hazardCriticalInterval", 2000);
Expand Down
24 changes: 17 additions & 7 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3177,12 +3177,18 @@ ReturnValue Player::queryAdd(int32_t index, const std::shared_ptr<Thing> &thing,
ReturnValue ret = RETURNVALUE_NOERROR;

const int32_t &slotPosition = item->getSlotPosition();
if ((slotPosition & SLOTP_HEAD) || (slotPosition & SLOTP_NECKLACE) || (slotPosition & SLOTP_BACKPACK) || (slotPosition & SLOTP_ARMOR) || (slotPosition & SLOTP_LEGS) || (slotPosition & SLOTP_FEET) || (slotPosition & SLOTP_RING)) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (slotPosition & SLOTP_TWO_HAND) {
ret = RETURNVALUE_PUTTHISOBJECTINBOTHHANDS;
} else if ((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
ret = RETURNVALUE_CANNOTBEDRESSED;

bool allowPutItemsOnAmmoSlot = g_configManager().getBoolean(ENABLE_PLAYER_PUT_ITEM_IN_AMMO_SLOT, __FUNCTION__);
if (allowPutItemsOnAmmoSlot && index == CONST_SLOT_AMMO) {
ret = RETURNVALUE_NOERROR;
} else {
if ((slotPosition & SLOTP_HEAD) || (slotPosition & SLOTP_NECKLACE) || (slotPosition & SLOTP_BACKPACK) || (slotPosition & SLOTP_ARMOR) || (slotPosition & SLOTP_LEGS) || (slotPosition & SLOTP_FEET) || (slotPosition & SLOTP_RING)) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (slotPosition & SLOTP_TWO_HAND) {
ret = RETURNVALUE_PUTTHISOBJECTINBOTHHANDS;
} else if ((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
ret = RETURNVALUE_CANNOTBEDRESSED;
}
}

switch (index) {
Expand Down Expand Up @@ -3324,8 +3330,12 @@ ReturnValue Player::queryAdd(int32_t index, const std::shared_ptr<Thing> &thing,
}

case CONST_SLOT_AMMO: {
if ((slotPosition & SLOTP_AMMO)) {
if (allowPutItemsOnAmmoSlot) {
ret = RETURNVALUE_NOERROR;
} else {
if ((slotPosition & SLOTP_AMMO)) {
ret = RETURNVALUE_NOERROR;
}
}
break;
}
Expand Down

0 comments on commit 3a5e8c9

Please sign in to comment.