diff --git a/data-canary/scripts/actions/other/cask_kegs.lua b/data-canary/scripts/actions/other/cask_kegs.lua
index 2c1a7499e99..f437840e3fa 100644
--- a/data-canary/scripts/actions/other/cask_kegs.lua
+++ b/data-canary/scripts/actions/other/cask_kegs.lua
@@ -35,7 +35,7 @@ local targetIdList = {
local flasks = Action()
function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
- if not target or not player:getTile():getHouse() then
+ if not target or not target:getItem() then
return false
end
diff --git a/data-canary/scripts/actions/other/potions.lua b/data-canary/scripts/actions/other/potions.lua
index 485cdf34dbb..619356f44c0 100644
--- a/data-canary/scripts/actions/other/potions.lua
+++ b/data-canary/scripts/actions/other/potions.lua
@@ -159,7 +159,7 @@ local setting = {
local potions = Action()
function potions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
- if type(target) == "userdata" and not target:isPlayer() then
+ if not target or type(target) == "userdata" and not target:isPlayer() then
return false
end
diff --git a/data-otservbr-global/monster/demons/true_frost_flower_asura.lua b/data-otservbr-global/monster/demons/true_frost_flower_asura.lua
index 6aff33bd5d2..7a5a6998cf1 100644
--- a/data-otservbr-global/monster/demons/true_frost_flower_asura.lua
+++ b/data-otservbr-global/monster/demons/true_frost_flower_asura.lua
@@ -29,7 +29,7 @@ monster.Bestiary = {
monster.health = 4000
monster.maxHealth = 4000
monster.race = "blood"
-monster.corpse = 28668
+monster.corpse = 28667
monster.speed = 150
monster.manaCost = 0
diff --git a/data-otservbr-global/scripts/actions/other/cask_kegs.lua b/data-otservbr-global/scripts/actions/other/cask_kegs.lua
index 872d30d613c..9b95335d5d1 100644
--- a/data-otservbr-global/scripts/actions/other/cask_kegs.lua
+++ b/data-otservbr-global/scripts/actions/other/cask_kegs.lua
@@ -35,7 +35,7 @@ local targetIdList = {
local flasks = Action()
function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
- if not target then
+ if not target or not target:getItem() then
return false
end
diff --git a/data-otservbr-global/scripts/actions/other/potions.lua b/data-otservbr-global/scripts/actions/other/potions.lua
index cfa76f441a4..b25cd6cb37e 100644
--- a/data-otservbr-global/scripts/actions/other/potions.lua
+++ b/data-otservbr-global/scripts/actions/other/potions.lua
@@ -222,7 +222,7 @@ local potions = {
local flaskPotion = Action()
function flaskPotion.onUse(player, item, fromPosition, target, toPosition, isHotkey)
- if type(target) == "userdata" and not target:isPlayer() then
+ if not target or type(target) == "userdata" and not target:isPlayer() then
return false
end
diff --git a/data-otservbr-global/scripts/creaturescripts/quests/forgotten_knowledge/dragon_egg.lua b/data-otservbr-global/scripts/creaturescripts/quests/forgotten_knowledge/dragon_egg.lua
index 0554ec201e4..ccc452c87ae 100644
--- a/data-otservbr-global/scripts/creaturescripts/quests/forgotten_knowledge/dragon_egg.lua
+++ b/data-otservbr-global/scripts/creaturescripts/quests/forgotten_knowledge/dragon_egg.lua
@@ -22,7 +22,13 @@ local function revertHorror()
end
local function changeHorror()
- local melting = Tile(Position(32267, 31071, 14)):getTopCreature()
+ local meltingTile = Tile(Position(32267, 31071, 14))
+ if not meltingTile then
+ logger.error("Tile not exist on position '{}'", Position(32267, 31071, 14):toString())
+ return
+ end
+
+ local meltingCreature = meltingTile:getTopCreature()
local pos = 0
local specs, spec = Game.getSpectators(Position(32269, 31091, 14), false, false, 12, 12, 12, 12)
for i = 1, #specs do
@@ -30,7 +36,7 @@ local function changeHorror()
if spec:isMonster() and spec:getName():lower() == "solid frozen horror" then
pos = spec:getPosition()
spec:teleportTo(Position(32267, 31071, 14))
- melting:teleportTo(pos)
+ meltingCreature:teleportTo(pos)
end
end
addEvent(revertHorror, 20 * 1000)
diff --git a/data/items/items.xml b/data/items/items.xml
index b6c40daa730..40cdc597c63 100644
--- a/data/items/items.xml
+++ b/data/items/items.xml
@@ -48717,13 +48717,13 @@
-
+
-
-
+
-
@@ -48738,13 +48738,13 @@
-
+
-
-
+
-
diff --git a/data/libs/functions/container.lua b/data/libs/functions/container.lua
index 5f554ce0514..6ec5897c577 100644
--- a/data/libs/functions/container.lua
+++ b/data/libs/functions/container.lua
@@ -8,7 +8,7 @@ end
function Container:addLoot(loot)
for itemId, item in pairs(loot) do
logger.debug("[Container:addLoot] - Adding loot item id: {} to container id: {}", itemId, self:getId())
- local tmpItem = self:addItem(itemId, item.count)
+ local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT)
if tmpItem then
if tmpItem:isContainer() and item.childLoot then
if not tmpItem:addLoot(item.childLoot) then
@@ -32,7 +32,7 @@ function Container:addLoot(loot)
tmpItem:setText(item.text)
end
else
- Spdlog.warn(("Container:addLoot: failed to add item: %s"):format(ItemType(itemId):getName()))
+ logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
end
::continue::
diff --git a/data/libs/functions/game.lua b/data/libs/functions/game.lua
index cb77c296067..f9242c32d88 100644
--- a/data/libs/functions/game.lua
+++ b/data/libs/functions/game.lua
@@ -131,5 +131,10 @@ function Game.getStorageValue(key)
end
function Game.setStorageValue(key, value)
+ if key == nil then
+ logger.error("[Game.setStorageValue] Key is nil")
+ return
+ end
+
globalStorageTable[key] = value
end
diff --git a/src/lua/functions/items/container_functions.cpp b/src/lua/functions/items/container_functions.cpp
index 9bdc958b353..efd01eae743 100644
--- a/src/lua/functions/items/container_functions.cpp
+++ b/src/lua/functions/items/container_functions.cpp
@@ -117,6 +117,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
Container* container = getUserdata(L, 1);
if (!container) {
lua_pushnil(L);
+ reportErrorFunc("Container is nullptr");
return 1;
}
@@ -127,6 +128,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
itemId = Item::items.getItemIdByName(getString(L, 2));
if (itemId == 0) {
lua_pushnil(L);
+ reportErrorFunc("Item id is wrong");
return 1;
}
}
@@ -140,6 +142,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
Item* item = Item::CreateItem(itemId, count);
if (!item) {
lua_pushnil(L);
+ reportErrorFunc("Item is nullptr");
return 1;
}
@@ -151,6 +154,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
pushUserdata
- (L, item);
setItemMetatable(L, -1, item);
} else {
+ reportErrorFunc(fmt::format("Cannot add item to container, error code: '{}'", getReturnMessage(ret)));
delete item;
lua_pushnil(L);
}