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

refactor: die to core and add missing achievement #2387

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
23 changes: 0 additions & 23 deletions data-canary/scripts/actions/other/die.lua

This file was deleted.

18 changes: 0 additions & 18 deletions data-otservbr-global/scripts/actions/other/dice.lua

This file was deleted.

36 changes: 36 additions & 0 deletions data/scripts/actions/items/die.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
local die = Action()

function die.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local position = item:getPosition()
local value = math.random(1, 6)
local isInGhostMode = player:isInGhostMode()

if not isInGhostMode then
position:sendMagicEffect(CONST_ME_CRAPS)

local spectators = Game.getSpectators(position, false, true, 3, 3)
for _, spectator in ipairs(spectators) do
player:say(player:getName() .. " rolled a " .. value .. ".", TALKTYPE_MONSTER_SAY, isInGhostMode, spectator, position)
end
end

local rolledSixCount = player:kv():get("die-rolled-six") or 0
if value == 6 then
player:kv():set("die-rolled-six", rolledSixCount + 1)

if rolledSixCount == 2 then
player:addAchievement("Number of the Beast")
end
else
player:kv():remove("die-rolled-six")
end
omarcopires marked this conversation as resolved.
Show resolved Hide resolved

item:transform(5792 + value)
omarcopires marked this conversation as resolved.
Show resolved Hide resolved
return true
end

for items = 5792, 5797 do
die:id(items)
end

die:register()
Loading