Skip to content

Commit

Permalink
Merge branch 'main' into fix-display-xp-boosted
Browse files Browse the repository at this point in the history
  • Loading branch information
luanluciano93 authored Sep 9, 2024
2 parents cccb21c + b330a33 commit 10d81ea
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ monster.loot = {
{ name = "two-headed turtle heads", chance = 8700 },
{ name = "strong mana potion", chance = 13373 },
{ name = "hydrophytes", chance = 11000 },
{ id = 1047, chance = 6388 }, -- bone
{ id = 3115, chance = 6388 }, -- bone
{ name = "glacier shoes", chance = 4650 },
{ id = 281, chance = 3582 }, -- giant shimmering pearl (green)
{ name = "small tropical fish", chance = 3582 },
Expand Down
19 changes: 12 additions & 7 deletions data-otservbr-global/startup/others/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function loadLuaMapAction(tablename)
if not value.itemId == false and tile:getItemCountById(value.itemId) == 0 then
logger.error("[loadLuaMapAction] - Wrong item id {} found", value.itemId)
logger.warn("Action id: {}, position {}", index, tile:getPosition():toString())
break
goto continue
end

if value.itemId ~= false and tile:getItemCountById(value.itemId) > 0 then
Expand All @@ -49,6 +49,7 @@ function loadLuaMapAction(tablename)
tile:getGround():setAttribute(ITEM_ATTRIBUTE_ACTIONID, index)
end
end
::continue::
end
end
end
Expand All @@ -64,19 +65,21 @@ function loadLuaMapUnique(tablename)
if not value.itemId == false and tile:getItemCountById(value.itemId) == 0 then
logger.error("[loadLuaMapUnique] - Wrong item id {} found", value.itemId)
logger.warn("Unique id: {}, position {}", index, tile:getPosition():toString())
break
goto continue
end
if tile:getItemCountById(value.itemId) < 1 or value.itemId == false then
logger.warn("[loadLuaMapUnique] - Wrong item id {} found", value.itemId)
logger.warn("Unique id: {}, position {}, item id: wrong", index, tile:getPosition():toString())
break
goto continue
end
item = tile:getItemById(value.itemId)
-- If he found the item, add the unique id
if item then
item:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, index)
end
end

::continue::
end
end

Expand All @@ -91,7 +94,7 @@ function loadLuaMapSign(tablename)
if tile:getItemCountById(value.itemId) == 0 then
logger.error("[loadLuaMapSign] - Wrong item id {} found", value.itemId)
logger.warn("Sign id: {}, position {}, item id: wrong", index, tile:getPosition():toString())
break
goto continue
end
if tile:getItemCountById(value.itemId) == 1 then
item = tile:getItemById(value.itemId)
Expand All @@ -101,6 +104,7 @@ function loadLuaMapSign(tablename)
item:setAttribute(ITEM_ATTRIBUTE_TEXT, value.text)
end
end
::continue::
end
end

Expand Down Expand Up @@ -137,17 +141,18 @@ function loadLuaMapBookDocument(tablename)
totals[2] = totals[2] + 1
else
logger.warn("[loadLuaMapBookDocument] - Item not found! Index: {}, itemId: {}", index, value.itemId)
break
goto continue
end
else
logger.warn("[loadLuaMapBookDocument] - Container not found! Index: {}, containerId: {}", index, value.containerId)
break
goto continue
end
else
logger.warn("[loadLuaMapBookDocument] - Tile not found! Index: {}, position: x: {} y: {} z: {}", index, value.position.x, value.position.y, value.position.z)
break
goto continue
end
end
::continue::
end
if totals[1] == totals[2] then
logger.debug("Loaded {} books and documents in the map", totals[2])
Expand Down
6 changes: 3 additions & 3 deletions data/libs/functions/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ function Container:addLoot(loot)
local countToAdd = math.min(remainingCount, stackSize)
local tmpItem = self:addItem(itemId, countToAdd, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add stackable item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add stackable item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
goto continue
end
remainingCount = remainingCount - countToAdd
end
elseif iType:getCharges() ~= 0 then
local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add charge item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add charge item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
end
else
for i = 1, item.count do
local tmpItem = self:addItem(itemId, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
goto continue
end

Expand Down
6 changes: 1 addition & 5 deletions data/scripts/talkactions/god/icons_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ function bakragoreIcon.onSay(player, words, param)
end

if param == "remove" then
for i = 1, 10 do
if player:hasCondition(CONDITION_BAKRAGORE, i) then
player:removeCondition(CONDITION_BAKRAGORE, i)
end
end
player:removeIconBakragore()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Removed all Bakragore icons.")
return true
end
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ void Npc::onPlayerBuyItem(std::shared_ptr<Player> player, uint16_t itemId, uint8
return;
}

// Check if the player not have empty slots
if (!ignore && player->getFreeBackpackSlots() == 0) {
// Check if the player not have empty slots or the item is not a container
if (!ignore && (player->getFreeBackpackSlots() == 0 && (player->getInventoryItem(CONST_SLOT_BACKPACK) || (!Item::items[itemId].isContainer() || !(Item::items[itemId].slotPosition & SLOTP_BACKPACK))))) {
player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM);
return;
}
Expand Down
14 changes: 14 additions & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6209,6 +6209,20 @@ void Player::sendIconBakragore(const IconBakragore icon) {
}
}

void Player::removeBakragoreIcons() {
for (auto icon : magic_enum::enum_values<IconBakragore>()) {
if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) {
removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true);
}
}
}

void Player::removeBakragoreIcon(const IconBakragore icon) {
if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) {
removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true);
}
}

void Player::sendCyclopediaCharacterAchievements(uint16_t secretsUnlocked, std::vector<std::pair<Achievement, uint32_t>> achievementsUnlocked) {
if (client) {
client->sendCyclopediaCharacterAchievements(secretsUnlocked, achievementsUnlocked);
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ class Player final : public Creature, public Cylinder, public Bankable {
void sendClosePrivate(uint16_t channelId);
void sendIcons();
void sendIconBakragore(const IconBakragore icon);
void removeBakragoreIcons();
void removeBakragoreIcon(const IconBakragore icon);
void sendClientCheck() const {
if (client) {
client->sendClientCheck();
Expand Down
19 changes: 19 additions & 0 deletions src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4412,3 +4412,22 @@ int PlayerFunctions::luaPlayerSendIconBakragore(lua_State* L) {
pushBoolean(L, true);
return 1;
}

int PlayerFunctions::luaPlayerRemoveIconBakragore(lua_State* L) {
// player:removeIconBakragore(iconType or nil for remove all bakragore icons)
const auto &player = getUserdataShared<Player>(L, 1);
if (!player) {
lua_pushnil(L);
return 1;
}

auto iconType = getNumber<IconBakragore>(L, 2, IconBakragore::None);
if (iconType == IconBakragore::None) {
player->removeBakragoreIcons();
} else {
player->removeBakragoreIcon(iconType);
}

pushBoolean(L, true);
return 1;
}
2 changes: 2 additions & 0 deletions src/lua/functions/creatures/player/player_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class PlayerFunctions final : LuaScriptInterface {
registerMethod(L, "Player", "takeScreenshot", PlayerFunctions::luaPlayerTakeScreenshot);

registerMethod(L, "Player", "sendIconBakragore", PlayerFunctions::luaPlayerSendIconBakragore);
registerMethod(L, "Player", "removeIconBakragore", PlayerFunctions::luaPlayerRemoveIconBakragore);

GroupFunctions::init(L);
GuildFunctions::init(L);
Expand Down Expand Up @@ -743,6 +744,7 @@ class PlayerFunctions final : LuaScriptInterface {

static int luaPlayerTakeScreenshot(lua_State* L);
static int luaPlayerSendIconBakragore(lua_State* L);
static int luaPlayerRemoveIconBakragore(lua_State* L);

friend class CreatureFunctions;
};
1 change: 1 addition & 0 deletions src/lua/functions/items/container_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
setItemMetatable(L, -1, item);
} else {
reportErrorFunc(fmt::format("Cannot add item to container, error code: '{}'", getReturnMessage(ret)));
pushBoolean(L, false);
}
return 1;
}
Expand Down

0 comments on commit 10d81ea

Please sign in to comment.