Skip to content

Commit

Permalink
feat: gooey mass
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Nov 1, 2024
1 parent 4ff4bfe commit 31902fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
14 changes: 0 additions & 14 deletions data-otservbr-global/scripts/actions/valuables/random_items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ local config = {
},
effect = CONST_ME_POFF,
},
[14172] = { -- gooey mass
chances = {
{ from = 1, to = 2 },
{ from = 3, to = 2167, itemId = 14084, count = 10 },
{ from = 2168, to = 4243, itemId = 3035, count = 2 },
{ from = 4244, to = 6196, itemId = 3027, count = 2 },
{ from = 6197, to = 8149, itemId = 239, count = 2 },
{ from = 8150, to = 9823, itemId = 238, count = 2 },
{ from = 9824, to = 9923, itemId = 9058 },
{ from = 9924, to = 9990, itemId = 14143 },
{ from = 9991, to = 10001, itemId = 14089 },
},
effect = CONST_ME_HITBYPOISON,
},
[15698] = { -- gnomish supply package
chances = {
{ from = 1, to = 1440, itemId = 3723, count = 20 },
Expand Down
34 changes: 34 additions & 0 deletions data/scripts/actions/items/gooey_mass.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local config = {
{ chanceFrom = 0, chanceTo = 38 }, -- nothing
{ chanceFrom = 39, chanceTo = 2132, itemId = 3035, count = 2 }, -- platinum coin
{ chanceFrom = 2133, chanceTo = 4187, itemId = 14084, count = 10 }, -- larvae
{ chanceFrom = 4188, chanceTo = 6040, itemId = 3027, count = 2 }, -- black pearl
{ chanceFrom = 6041, chanceTo = 7951, itemId = 239, count = 2 }, -- great health potion
{ chanceFrom = 7952, chanceTo = 9843, itemId = 238, count = 2 }, -- great mana potion
{ chanceFrom = 9844, chanceTo = 9941, itemId = 9058 }, -- gold ingot
{ chanceFrom = 9942, chanceTo = 9987, itemId = 14143 }, -- four-leaf clover
{ chanceFrom = 9988, chanceTo = 10000, itemId = 14089 }, -- hive scythe
}

local gooeyMass = Action()

function gooeyMass.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local randomChance = math.random(0, 10000)
for _, rewardItem in ipairs(config) do
if randomChance >= rewardItem.chanceFrom and randomChance <= rewardItem.chanceTo then
if rewardItem.itemId then
local count = rewardItem.count or 1
player:addItem(rewardItem.itemId, count)
end

break
end
end

item:getPosition():sendMagicEffect(CONST_ME_HITBYPOISON)
item:remove(1)
return true
end

gooeyMass:id(14172)
gooeyMass:register()

0 comments on commit 31902fd

Please sign in to comment.