Skip to content

Commit

Permalink
refactor: scroll of ascencion and swimming to core (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires authored Feb 29, 2024
1 parent d73f9f1 commit 414ddc1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 75 deletions.
17 changes: 0 additions & 17 deletions data-canary/scripts/actions/other/scroll_of_ascension.lua

This file was deleted.

33 changes: 0 additions & 33 deletions data-canary/scripts/movements/swimming.lua

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions data/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ SCARLETT_MAY_DIE = 0

ropeSpots = { 386, 421, 386, 7762, 12202, 12936, 14238, 17238, 23363, 21965, 21966, 21967, 21968 }
specialRopeSpots = { 12935 }
swimmingTiles = { 629, 630, 631, 632, 633, 634, 4809, 4810, 4811, 4812, 4813, 4814 }

-- Global tables for systems
if not _G.GlobalBosses then
Expand Down
27 changes: 27 additions & 0 deletions data/scripts/actions/items/scroll_of_ascension.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local scrollOfAscension = Action()

function scrollOfAscension.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion("scroll-of-ascension") then
return true
end

local playerTile = Tile(player:getPosition())
if playerTile and playerTile:getGround() and table.contains(swimmingTiles, playerTile:getGround():getId()) then
player:say("The scroll could get wet, step out of the water first.", TALKTYPE_MONSTER_SAY)
return true
end

if math.random(10) > 1 then
player:setMonsterOutfit("Demon", 30 * 10 * 1000)
else
player:setMonsterOutfit("Ferumbras", 30 * 10 * 1000)
end

player:setExhaustion("scroll-of-ascension", 60 * 60)
player:say("Magical sparks whirl around the scroll as you read it and then your appearance is changing.", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
end

scrollOfAscension:id(22771)
scrollOfAscension:register()
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,35 @@ local conditions = {
local swimming = MoveEvent()

function swimming.onStepIn(creature, item, position, fromPosition)
if not creature:isPlayer() then
local player = creature:getPlayer()
if not player then
return false
end

for i = 1, #conditions do
creature:removeCondition(conditions[i])
player:removeCondition(conditions[i])
end
creature:addCondition(condition)

player:addCondition(condition)
return true
end

swimming:type("stepin")
swimming:id(629, 630, 631, 632, 633, 634)
swimming:id(unpack(swimmingTiles))
swimming:register()

swimming = MoveEvent()

function swimming.onStepOut(creature, item, position, fromPosition)
if not creature:isPlayer() then
local player = creature:getPlayer()
if not player then
return false
end

creature:removeCondition(CONDITION_OUTFIT)
player:removeCondition(CONDITION_OUTFIT)
return true
end

swimming:type("stepout")
swimming:id(629, 630, 631, 632, 633, 634)
swimming:id(unpack(swimmingTiles))
swimming:register()

0 comments on commit 414ddc1

Please sign in to comment.