Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/fix-lua-get-number-overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 30, 2023
2 parents 3f311e2 + fab347c commit 27469d9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
12 changes: 9 additions & 3 deletions data/scripts/talkactions/player/emote_spell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
local emoteSpell = TalkAction("!emote")

function emoteSpell.onSay(player, words, param)
if configManager.getBoolean(configKeys.EMOTE_SPELLS) == false then
player:sendTextMessage(MESSAGE_LOOK, "Emote spells have been disabled by the administrator.")
return true
end

if param == "" then
player:sendCancelMessage("You need to specify on/off param.")
player:sendCancelMessage("Please specify the parameter: 'on' to activate or 'off' to deactivate.")
return true
end

if param == "on" then
player:setStorageValue(STORAGEVALUE_EMOTE, 1)
player:sendTextMessage(MESSAGE_LOOK, "You activated emoted spells")
player:sendTextMessage(MESSAGE_LOOK, "You have activated emote spells.")
elseif param == "off" then
player:setStorageValue(STORAGEVALUE_EMOTE, 0)
player:sendTextMessage(MESSAGE_LOOK, "You desactivated emoted spells")
player:sendTextMessage(MESSAGE_LOOK, "You have deactivated emote spells.")
end
return true
end
Expand Down
2 changes: 0 additions & 2 deletions data/scripts/talkactions/player/flask.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ function flask.onSay(player, words, param)
return true
end
if param == "on" and player:getStorageValueByName("talkaction.potions.flask") ~= 1 then
player:setStorageValue(STORAGEVALUE_EMOTE, 1)
player:setStorageValueByName("talkaction.potions.flask", 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You will not receive flasks!")
player:getPosition():sendMagicEffect(CONST_ME_REDSMOKE)
elseif param == "off" then
player:setStorageValue(STORAGEVALUE_EMOTE, 0)
player:setStorageValueByName("talkaction.potions.flask", 0)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You will receive flasks.")
player:getPosition():sendMagicEffect(CONST_ME_REDSMOKE)
Expand Down
20 changes: 20 additions & 0 deletions data/scripts/talkactions/player/hidden_npc_sell_shop_items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local talkaction = TalkAction("!hiddenshop")

function talkaction.onSay(player, words, param)
if param == "" then
player:sendCancelMessage("You need to specify on/off param.")
return true
end
if param == "on" then
player:kv():set("npc-shop-hidden-sell-item", true)
player:sendTextMessage(MESSAGE_LOOK, "You activated hidden sell shop items.")
elseif param == "off" then
player:kv():set("npc-shop-hidden-sell-item", false)
player:sendTextMessage(MESSAGE_LOOK, "You desactivated hidden sell shop items")
end
return true
end

talkaction:separator(" ")
talkaction:groupType("normal")
talkaction:register()
2 changes: 1 addition & 1 deletion src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void Npc::onPlayerSellItem(std::shared_ptr<Player> player, uint16_t itemId, uint
}

auto toRemove = amount;
for (auto inventoryItems = player->getInventoryItemsFromId(itemId, ignore); auto item : inventoryItems) {
for (auto item : player->getInventoryItemsFromId(itemId, ignore)) {
if (!item || item->getTier() > 0 || item->hasImbuements()) {
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6820,7 +6820,9 @@ bool Player::saySpell(
// Send to client
for (std::shared_ptr<Creature> spectator : spectators) {
if (std::shared_ptr<Player> tmpPlayer = spectator->getPlayer()) {
valueEmote = tmpPlayer->getStorageValue(STORAGEVALUE_EMOTE);
if (g_configManager().getBoolean(EMOTE_SPELLS, __FUNCTION__)) {
valueEmote = tmpPlayer->getStorageValue(STORAGEVALUE_EMOTE);
}
if (!ghostMode || tmpPlayer->canSeeCreature(static_self_cast<Player>())) {
if (valueEmote == 1) {
tmpPlayer->sendCreatureSay(static_self_cast<Player>(), TALKTYPE_MONSTER_SAY, text, pos);
Expand Down
12 changes: 12 additions & 0 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7655,6 +7655,18 @@ void ProtocolGame::AddShopItem(NetworkMessage &msg, const ShopBlock &shopBlock)
return;
}

// Hidden sell items from the shop if they are not in the player's inventory
auto talkactionHidden = player->kv()->get("npc-shop-hidden-sell-item");
if (talkactionHidden && talkactionHidden->get<BooleanType>() == true) {
std::map<uint16_t, uint16_t> inventoryMap;
player->getAllSaleItemIdAndCount(inventoryMap);
auto inventoryItems = inventoryMap.find(shopBlock.itemId);
if (inventoryItems == inventoryMap.end() && shopBlock.itemSellPrice > 0 && shopBlock.itemBuyPrice == 0) {
AddHiddenShopItem(msg);
return;
}
}

const ItemType &it = Item::items[shopBlock.itemId];
msg.add<uint16_t>(shopBlock.itemId);
if (it.isSplash() || it.isFluidContainer()) {
Expand Down

0 comments on commit 27469d9

Please sign in to comment.