From 2deb5079522b8fae06f39e3e4d39f2e498736798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sun, 10 Aug 2025 11:54:29 +0100 Subject: [PATCH] Add methods `item:SetRandomProperties` and `item:SetRandomSuffix` (#274) --- src/LuaEngine/LuaFunctions.cpp | 2 ++ src/LuaEngine/methods/ItemMethods.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index a404bf4..2c23c01 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -927,6 +927,8 @@ ElunaRegister ItemMethods[] = { "SetOwner", &LuaItem::SetOwner }, { "SetBinding", &LuaItem::SetBinding }, { "SetCount", &LuaItem::SetCount }, + { "SetRandomProperty", &LuaItem::SetRandomProperty }, + { "SetRandomSuffix", &LuaItem::SetRandomSuffix }, // Boolean { "IsSoulBound", &LuaItem::IsSoulBound }, diff --git a/src/LuaEngine/methods/ItemMethods.h b/src/LuaEngine/methods/ItemMethods.h index 30a6687..2476594 100644 --- a/src/LuaEngine/methods/ItemMethods.h +++ b/src/LuaEngine/methods/ItemMethods.h @@ -683,6 +683,32 @@ namespace LuaItem return 1; } + + /** + * Sets the random properties for the [Item] from a given random property ID. + * + * @param uint32 randomPropId : The ID of the random property to be applied. + */ + int SetRandomProperty(lua_State* L, Item* item) + { + uint32 randomPropId = Eluna::CHECKVAL(L, 2); + item->SetItemRandomProperties(randomPropId); + return 0; + } + + /** + * Sets the random suffix for the [Item] from a given random suffix ID. + * + * @param uint32 randomSuffixId : The ID of the random suffix to be applied. + */ + int SetRandomSuffix(lua_State* L, Item* item) + { + uint32 randomPropId = Eluna::CHECKVAL(L, 2); + item->SetItemRandomProperties(-randomPropId); + return 0; + } + + /* OTHER */ /** * Removes an enchant from the [Item] by the specified slot