Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create gem crusher function #3029

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 26 additions & 0 deletions data-canary/scripts/lib/register_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
26 changes: 26 additions & 0 deletions data-otservbr-global/scripts/lib/register_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions data/scripts/actions/tools/crusher.lua
Original file line number Diff line number Diff line change
@@ -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()
Loading