From 8abd53269d87f9298b25c06b177da4533b747ce5 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 29 Oct 2024 17:08:55 -0300 Subject: [PATCH] feat: crusher --- data-canary/scripts/lib/register_actions.lua | 26 +++++++++++++++++++ .../scripts/lib/register_actions.lua | 26 +++++++++++++++++++ data/scripts/actions/tools/crusher.lua | 8 ++++++ 3 files changed, 60 insertions(+) create mode 100644 data/scripts/actions/tools/crusher.lua diff --git a/data-canary/scripts/lib/register_actions.lua b/data-canary/scripts/lib/register_actions.lua index e59a46b3b03..3fb83529c41 100644 --- a/data-canary/scripts/lib/register_actions.lua +++ b/data-canary/scripts/lib/register_actions.lua @@ -10,6 +10,20 @@ local sandIds = { 231 } -- desert sand local fruits = { 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3595, 3596, 5096, 8011, 8012, 8013 } -- fruits to make decorated cake with knife local holes = { 593, 606, 608, 867, 21341 } -- holes opened by shovel local ropeSpots = { 386, 421, 12935, 12936, 14238, 17238, 21501, 21965, 21966, 21967, 21968, 23363 } +local gemFragments = { -- gem fragments workshop + [44602] = 46625, + [44605] = 46625, + [44608] = 46625, + [44611] = 46625, + [44603] = 46625, + [44606] = 46625, + [44609] = 46625, + [44612] = 46625, + [44604] = 46626, + [44607] = 46626, + [44610] = 46626, + [44613] = 46626, +} function destroyItem(player, item, fromPosition, target, toPosition, isHotkey) if type(target) ~= "userdata" or not target:isItem() then @@ -277,3 +291,15 @@ function onUseSpoon(player, item, fromPosition, target, toPosition, isHotkey) end return false end + +function onUseCrusher(player, item, fromPosition, target, toPosition, isHotkey) + local fragmentId = gemFragments[target.itemid] + if not fragmentId then + return false + end + + player:addItem(fragmentId, math.random(1, 3)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has disappeared.") + target:remove(1) + return false +end diff --git a/data-otservbr-global/scripts/lib/register_actions.lua b/data-otservbr-global/scripts/lib/register_actions.lua index ebb77654882..14b15acbc55 100644 --- a/data-otservbr-global/scripts/lib/register_actions.lua +++ b/data-otservbr-global/scripts/lib/register_actions.lua @@ -7,6 +7,20 @@ local holes = { 593, 606, 608, 867, 21341 } local jungleGrass = { 3696, 3702, 17153 } local wildGrowth = { 2130, 3635, 30224 } local fruits = { 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3595, 3596, 5096, 8011, 8012, 8013 } +local gemFragments = { -- gem fragments workshop + [44602] = 46625, + [44605] = 46625, + [44608] = 46625, + [44611] = 46625, + [44603] = 46625, + [44606] = 46625, + [44609] = 46625, + [44612] = 46625, + [44604] = 46626, + [44607] = 46626, + [44610] = 46626, + [44613] = 46626, +} local lava = { Position(32808, 32336, 11), Position(32809, 32336, 11), @@ -1072,3 +1086,15 @@ function onGrindItem(player, item, fromPosition, target, toPosition) end end end + +function onUseCrusher(player, item, fromPosition, target, toPosition, isHotkey) + local fragmentId = gemFragments[target.itemid] + if not fragmentId then + return false + end + + player:addItem(fragmentId, math.random(1, 3)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has disappeared.") + target:remove(1) + return false +end diff --git a/data/scripts/actions/tools/crusher.lua b/data/scripts/actions/tools/crusher.lua new file mode 100644 index 00000000000..66a44315e8a --- /dev/null +++ b/data/scripts/actions/tools/crusher.lua @@ -0,0 +1,8 @@ +local crusher = Action() + +function crusher.onUse(player, item, fromPosition, target, toPosition, isHotkey) + return onUseCrusher(player, item, fromPosition, target, toPosition, isHotkey) +end + +crusher:id(46627, 46628) +crusher:register()