Skip to content
Open
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 data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getTitle(uid)
end

function getLootRandom(modifier)
local multi = (configManager.getNumber(configKeys.RATE_LOOT) * SCHEDULE_LOOT_RATE) * (modifier or 1)
local multi = (configManager.getFloat(configKeys.RATE_LOOT) * SCHEDULE_LOOT_RATE) * (modifier or 1)
return math.random(0, MAX_LOOTCHANCE) * 100 / math.max(1, multi)
end

Expand Down
2 changes: 1 addition & 1 deletion data/libs/functions/monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ do
end

function MonsterType.getBossReward(self, lootFactor, topScore, equipmentOnly, lootTable, player)
if configManager.getNumber(configKeys.RATE_LOOT) <= 0 then
if configManager.getFloat(configKeys.RATE_LOOT) <= 0 then
return lootTable or {}
end

Expand Down
2 changes: 1 addition & 1 deletion data/libs/functions/monstertype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---@param config { factor: number, gut: boolean, filter?: fun(itemType: ItemType, unique: boolean): boolean }
---@return LootItems
function MonsterType:generateLootRoll(config, resultTable, player)
if configManager.getNumber(configKeys.RATE_LOOT) <= 0 then
if configManager.getFloat(configKeys.RATE_LOOT) <= 0 then
return resultTable or {}
end

Expand Down
2 changes: 1 addition & 1 deletion data/scripts/talkactions/player/server_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function serverInfo.onSay(player, words, param)

text = text
.. "\nLoot rate: "
.. configManager.getNumber(configKeys.RATE_LOOT)
.. configManager.getFloat(configKeys.RATE_LOOT)
.. "x"
.. "\nSpawns rate: "
.. configManager.getNumber(configKeys.RATE_SPAWN)
Expand Down
4 changes: 3 additions & 1 deletion src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ bool ConfigManager::load() {
loadIntConfig(L, PZ_LOCKED, "pzLocked", 60000);
loadIntConfig(L, RATE_EXPERIENCE, "rateExp", 1);
loadIntConfig(L, RATE_KILLING_IN_THE_NAME_OF_POINTS, "rateKillingInTheNameOfPoints", 1);
loadIntConfig(L, RATE_LOOT, "rateLoot", 1);
// rateLoot accepts decimals: loadIntConfig static_casts to int32_t and would
// silently drop the fractional part ("rateLoot = 2.5" became 2, with no warning).
loadFloatConfig(L, RATE_LOOT, "rateLoot", 1.0);
loadIntConfig(L, RATE_MAGIC, "rateMagic", 1);
loadIntConfig(L, RATE_SKILL, "rateSkill", 1);
loadIntConfig(L, RATE_SPAWN, "rateSpawn", 1);
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ void Monster::dropLoot(const std::shared_ptr<Container> &corpse, const std::shar
}
}

if (!this->isRewardBoss() && g_configManager().getNumber(RATE_LOOT) > 0) {
if (!this->isRewardBoss() && g_configManager().getFloat(RATE_LOOT) > 0) {
g_callbacks().executeCallback(EventCallback_t::monsterOnDropLoot, &EventCallback::monsterOnDropLoot, getMonster(), corpse);
g_callbacks().executeCallback(EventCallback_t::monsterPostDropLoot, &EventCallback::monsterPostDropLoot, getMonster(), corpse);
}
Expand Down
4 changes: 3 additions & 1 deletion src/server/network/protocol/protocolstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ void ProtocolStatus::sendStatusString() {
pugi::xml_node rates = tsqp.append_child("rates");
rates.append_attribute("experience") = std::to_string(g_configManager().getNumber(RATE_EXPERIENCE)).c_str();
rates.append_attribute("skill") = std::to_string(g_configManager().getNumber(RATE_SKILL)).c_str();
rates.append_attribute("loot") = std::to_string(g_configManager().getNumber(RATE_LOOT)).c_str();
// RATE_LOOT is stored as a float; getNumber() would hit the wrong type branch,
// return 0 and make the status protocol announce loot="0" while looting worked.
rates.append_attribute("loot") = fmt::format("{:g}", g_configManager().getFloat(RATE_LOOT)).c_str();
rates.append_attribute("magic") = std::to_string(g_configManager().getNumber(RATE_MAGIC)).c_str();
rates.append_attribute("spawn") = std::to_string(g_configManager().getNumber(RATE_SPAWN)).c_str();

Expand Down
Loading