Skip to content

Commit

Permalink
improve: warning about compat file workarounds (#2326)
Browse files Browse the repository at this point in the history
Close #1974

---------

Co-authored-by: Luan Luciano <[email protected]>
  • Loading branch information
omarcopires and luanzera authored Feb 27, 2024
1 parent a43d91c commit 06c4bcd
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 153 deletions.
43 changes: 26 additions & 17 deletions data-otservbr-global/npc/cranky_lizard_crone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ local already = "It seems you already have this addon, don't you try to mock me

--WAYFARER START --
function WayfarerFirst(npc, creature, message, keywords, parameters, node)
if isPremium(creature) then
local addon = getPlayerStorageValue(creature, Storage.WayfarerOutfit)
if addon == -1 then
if getPlayerItemCount(creature, 11701) >= 1 then
if doPlayerRemoveItem(creature, 11701, 1) then
local player = Player(creature)
if not player then
return
end

if player:isPremium() then
if player:getStorageValue(Storage.WayfarerOutfit) < 1 then
if player:getItemCount(11701) > 0 then
if player:removeItem(11701, 1) then
npcHandler:say(newaddon, npc, creature)
doSendMagicEffect(getCreaturePosition(creature), 13)
doPlayerAddOutfit(creature, 366, 1)
doPlayerAddOutfit(creature, 367, 1)
setPlayerStorageValue(creature, Storage.WayfarerOutfit, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:addOutfitAddon(366, 1)
player:addOutfitAddon(367, 1)
player:setStorageValue(Storage.WayfarerOutfit, 1)
end
else
npcHandler:say(noItems, npc, creature)
Expand All @@ -69,15 +73,20 @@ function WayfarerFirst(npc, creature, message, keywords, parameters, node)
end

function WayfarerSecond(npc, creature, message, keywords, parameters, node)
if isPremium(creature) then
if getPlayerStorageValue(creature, Storage.WayfarerOutfit + 1) == -1 then
if getPlayerItemCount(creature, 11700) >= 1 then
if doPlayerRemoveItem(creature, 11700, 1) then
local player = Player(creature)
if not player then
return
end

if player:isPremium() then
if player:getStorageValue(Storage.WayfarerOutfit + 1) < 1 then
if player:getItemCount(11700) > 0 then
if player:removeItem(11700, 1) then
npcHandler:say(newaddon, npc, creature)
doSendMagicEffect(getCreaturePosition(creature), 13)
doPlayerAddOutfit(creature, 366, 2)
doPlayerAddOutfit(creature, 367, 2)
setPlayerStorageValue(creature, Storage.WayfarerOutfit + 1, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:addOutfitAddon(366, 2)
player:addOutfitAddon(367, 2)
player:setStorageValue(Storage.WayfarerOutfit + 1, 1)
end
else
npcHandler:say(noItems, npc, creature)
Expand Down
60 changes: 38 additions & 22 deletions data-otservbr-global/npc/eruaran.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,20 @@ local ACTION = {

-- dream START --
local function dreamFirst(npc, creature, message, keywords, parameters, node)
if isPremium(creature) then
if getPlayerStorageValue(creature, storage + 1) == -1 then
if getPlayerItemCount(creature, 20276) >= 1 then
if doPlayerRemoveItem(creature, 20276, 1) then
npcHandler:say(newAddon, npc, creature)
doSendMagicEffect(getCreaturePosition(creature), 13)
doPlayerAddOutfit(creature, 577, 1)
doPlayerAddOutfit(creature, 578, 1)
setPlayerStorageValue(creature, storage + 1, 1)
local player = Player(creature)
if not player then
return
end

if player:isPremium() then
if player:getStorageValue(storage + 1) < 1 then
if player:getItemCount(20276) > 0 then
if player:removeItem(20276, 1) then
npcHandler:say(newaddon, npc, creature)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:addOutfitAddon(577, 1)
player:addOutfitAddon(577, 1)
player:setStorageValue(storage + 1, 1)
end
else
npcHandler:say(noItems, npc, creature)
Expand All @@ -170,15 +175,20 @@ local function dreamFirst(npc, creature, message, keywords, parameters, node)
end

local function dreamSecond(npc, creature, message, keywords, parameters, node)
if isPremium(creature) then
if getPlayerStorageValue(creature, storage) == -1 then
if getPlayerItemCount(creature, 20275) >= 1 then
if doPlayerRemoveItem(creature, 20275, 1) then
npcHandler:say(newAddon, npc, creature)
doSendMagicEffect(getCreaturePosition(creature), 13)
doPlayerAddOutfit(creature, 577, 2)
doPlayerAddOutfit(creature, 578, 2)
setPlayerStorageValue(creature, storage, 1)
local player = Player(creature)
if not player then
return
end

if player:isPremium() then
if player:getStorageValue(storage) < 1 then
if player:getItemCount(20275) > 0 then
if player:removeItem(20275, 1) then
npcHandler:say(newaddon, npc, creature)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:addOutfitAddon(577, 2)
player:addOutfitAddon(577, 2)
player:setStorageValue(storage, 1)
end
else
npcHandler:say(noItems, npc, creature)
Expand All @@ -192,7 +202,9 @@ end

local function greetCallback(npc, creature)
local player = Player(creature)
local playerId = player:getId()
if not player then
return true
end

if player:getStorageValue(Storage.EruaranGreeting) > 0 then
npcHandler:setMessage(MESSAGE_GREET, "Ashari Lillithy, so we meet {again}! What brings you here this time, general {information}, {transform}, {improve}, {create}, {outfit}, or {talk}?")
Expand All @@ -204,13 +216,17 @@ local function greetCallback(npc, creature)
end

local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()

if not npcHandler:checkInteraction(npc, creature) then
return false
end

local player = Player(creature)
if not player then
return true
end

local playerId = player:getId()

if MsgContains(message, "create") then
npcHandler:say("You can try to create {sword}s, {axe}s, {club}s, {bow}s, {crossbow}s and {spellbook}s.", npc, creature)
npcHandler:setTopic(playerId, 1)
Expand Down
48 changes: 12 additions & 36 deletions data-otservbr-global/scripts/actions/other/string_of_mending.lua
Original file line number Diff line number Diff line change
@@ -1,46 +1,22 @@
------------
-- Alternative to no-magic style.
-- Description here
----

---- string of mending id "20208"-----
local ITEMS = {
[12737] = { -----Broken Ring Id "12737" Ring of ending "20182"
{ "ring of ending", 50.50 }, ----- 1.97 es la probabilidad de crear el item
},
}

local stringOfMending = Action()

---- onUse [opt]
-- @param cid Player ID
-- @param item Item ID
-- @param fromPosition Current Position
-- @param[opt] itemEx Item change
-- @param[opt] toPosition Nem position
function stringOfMending.onUse(cid, item, fromPosition, itemEx, toPosition)
local cadena = ITEMS[itemEx.itemid]
if cadena == nil then
function stringOfMending.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or target.itemid ~= 12737 then
return false
end

local iEx = Item(itemEx.uid)
local random, chance = math.random() * 100, 0

for i = 1, #cadena do
chance = chance + cadena[i][2]
if random <= chance then
iEx:transform(cadena[i][1])
iEx:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
Item(item.uid):remove(1)
return true
end
local random = math.random(100)
if random <= 50 then
target:transform(20182) -- ring of ending
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
item:remove(1)
return true
end

iEx:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
Item(item.uid):remove(1)
iEx:remove()
doCreatureSay(cid, "50% chance, the item was broken.", TALKTYPE_MONSTER_SAY)
target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
item:remove(1)
target:remove()
player:say("50% chance, the item was broken.", TALKTYPE_MONSTER_SAY)
return true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ local function changeArea()
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
if theHungerKilled == false then
for _, c in pairs(creatures) do
if isMonster(c) then
c:teleportTo({ x = 32244, y = 31369, z = 14 })
for _, creature in pairs(creatures) do
local monster = Monster(creature)
if monster then
monster:teleportTo({ x = 32244, y = 31369, z = 14 })
end
end
else
Expand All @@ -97,9 +98,10 @@ local function changeArea()
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
if theDestructionKilled == false then
for _, c in pairs(creatures) do
if isMonster(c) then
c:teleportTo({ x = 32271, y = 31313, z = 14 })
for _, creature in pairs(creatures) do
local monster = Monster(creature)
if monster then
monster:teleportTo({ x = 32271, y = 31313, z = 14 })
end
end
else
Expand All @@ -125,9 +127,10 @@ local function changeArea()
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
if theRageKilled == false then
for _, c in pairs(creatures) do
if isMonster(c) then
c:teleportTo({ x = 32299, y = 31369, z = 14 })
for _, creature in pairs(creatures) do
local monster = Monster(creature)
if monster then
monster:teleportTo({ x = 32299, y = 31369, z = 14 })
end
end
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ function renewSparks()
if tile then
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
for _, c in pairs(creatures) do
local cPos = c:getPosition()
if isMonster(c) and c:getName() == "Unstable Spark" then
cPos:sendMagicEffect(3)
c:remove()
for _, creature in pairs(creatures) do
local monster = Monster(creature)
if monster and monster:getName() == "Unstable Spark" then
monster:getPosition():sendMagicEffect(3)
monster:remove()
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local mysterious = Action()
function mysterious.onUse(cid, item, fromPosition, itemEx, toPosition)
local p = { x = 33672, y = 31884, z = 5 } -- where to tp to 33672, 31884, 5
doCreatureSay(cid, "This metal egg seems to be locked by a strange mechanism. The time for it to reveal its contents has not yet come.", TALKTYPE_MONSTER_SAY)

function mysterious.onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:say("This metal egg seems to be locked by a strange mechanism. The time for it to reveal its contents has not yet come.", TALKTYPE_MONSTER_SAY)
end

mysterious:id(19065, 22739)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
local rottinWoodCorpse = Action()
function rottinWoodCorpse.onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)

function rottinWoodCorpse.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 12189 then
if (getPlayerStorageValue(cid, Storage.RottinWoodAndMaried.Mission03) == 5) and getPlayerStorageValue(cid, Storage.RottinWoodAndMaried.Corpse) < 4 then
doCreatureSay(cid, "You take no more gold than you actually need and release the merchant who makes away the very second you remove the ropes.", TALKTYPE_MONSTER_SAY)
doPlayerAddItem(cid, 3031, 100)
doRemoveItem(item.uid, 1)
setPlayerStorageValue(cid, Storage.RottinWoodAndMaried.Corpse, getPlayerStorageValue(cid, Storage.RottinWoodAndMaried.Corpse) + 1)
local storageRottinWoodAndMariedCorpse = player:getStorageValue(Storage.RottinWoodAndMaried.Corpse)
if player:getStorageValue(Storage.RottinWoodAndMaried.Mission03) == 5 and storageRottinWoodAndMariedCorpse < 4 then
player:say("You take no more gold than you actually need and release the merchant who makes away the very second you remove the ropes.", TALKTYPE_MONSTER_SAY)
player:addItem(3031, 1)
player:setStorageValue(Storage.RottinWoodAndMaried.Corpse, storageRottinWoodAndMariedCorpse + 1)
item:remove(1)
end
end
return true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
function removeMonster()
doRemoveItem(getTileItemById({ x = 32662, y = 32190, z = 7 }, 2768).uid, 1)
doSendMagicEffect({ x = 32662, y = 32190, z = 7 }, 45)
TOP_LEFT_CORNER = { x = 32651, y = 32178, z = 7, stackpos = 253 }
BOTTOM_RIGHT_CORNER = { x = 32668, y = 32190, z = 7, stackpos = 253 }
Position(32662, 32190, 7):sendMagicEffect(CONST_ME_STONES)
local TOP_LEFT_CORNER = { x = 32651, y = 32178, z = 7 }
local BOTTOM_RIGHT_CORNER = { x = 32668, y = 32190, z = 7 }

for Py = TOP_LEFT_CORNER.y, BOTTOM_RIGHT_CORNER.y do
for Px = TOP_LEFT_CORNER.x, BOTTOM_RIGHT_CORNER.x do
creature = getThingfromPos({ x = Px, y = Py, z = 7, stackpos = 253 })
if isMonster(creature.uid) then
if getCreatureName(creature.uid) == "Travelling Merchant" then
--doRemoveCreature(creature.uid)
doSendMagicEffect({ x = Px, y = Py, z = 7 }, 45)
local tile = Tile(Position({ x = Px, y = Py, z = 7 }))
if tile then
local monster = tile:getTopCreature()
if monster and monster:isMonster() and monster:getName() == "Travelling Merchant" then
-- monster:remove()
monster:getPosition():sendMagicEffect(CONST_ME_STONES)
--setPlayerStorageValue(cid, Storage.RottinWoodAndMaried.Trap, -1)
end
end
Expand All @@ -19,8 +21,8 @@ function removeMonster()
end

function removeTrap()
TOP_LEFT_CORNER = { x = 32651, y = 32178, z = 7, stackpos = 253 }
BOTTOM_RIGHT_CORNER = { x = 32668, y = 32190, z = 7, stackpos = 253 }
local TOP_LEFT_CORNER = { x = 32651, y = 32178, z = 7, stackpos = 253 }
local BOTTOM_RIGHT_CORNER = { x = 32668, y = 32190, z = 7, stackpos = 253 }
for Py = TOP_LEFT_CORNER.y, BOTTOM_RIGHT_CORNER.y do
for Px = TOP_LEFT_CORNER.x, BOTTOM_RIGHT_CORNER.x do
local trap = getTileItemById({ x = Px, y = Py, z = 7 }, 12187)
Expand Down Expand Up @@ -48,7 +50,7 @@ function rottinWoodtrap.onUse(cid, item, fromPosition, itemEx, toPosition, isHot
doRemoveItem(item.uid, 1)
Game.createItem(12187, 1, toPosition)
doTeleportThing(cid, { x = 32660, y = 32193, z = 7 })
doSendMagicEffect(getCreaturePosition(cid), 45)
Player(cid):getPosition():sendMagicEffect(CONST_ME_STONES)
Game.createItem(2768, 1, { x = 32662, y = 32190, z = 7 }) -- small fir tree
----------------------- SUMMON MERCHANT -----------------------------
doSummonCreature("Travelling Merchant", { x = 32656, y = 32182, z = 7 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ local function setStorage()
if tile then
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
for _, c in pairs(creatures) do
if isPlayer(c) then
if c:getStorageValue(14322) < 1 then
c:setStorageValue(14322, 1) -- Access to boss Anomaly
for _, creature in pairs(creatures) do
local player = Player(creature)
if player then
if player:getStorageValue(14322) < 1 then
player:setStorageValue(14322, 1) -- Access to boss Anomaly
end
end
end
Expand Down
11 changes: 8 additions & 3 deletions data-otservbr-global/scripts/movements/others/trap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ function trap.onStepIn(creature, item, position, fromPosition)
return true
end

if Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
local tile = Tile(position)
if not tile then
return true
end

if tile:hasFlag(TILESTATE_PROTECTIONZONE) then
return true
end

if Tile(position):getItemCountById(3482) > 1 then
if tile:getItemCountById(3482) > 1 then
return true
end

Expand All @@ -30,7 +35,7 @@ function trap.onStepIn(creature, item, position, fromPosition)
item:transform(trap.transformTo)
end

if item.itemid == 12368 and getCreatureName(creature.uid) == "Starving Wolf" then
if item.itemid == 12368 and creature:getName() == "Starving Wolf" then
position:sendMagicEffect(CONST_ME_STUN)
creature:remove()
Game.createItem(12369, 1, position)
Expand Down
Loading

0 comments on commit 06c4bcd

Please sign in to comment.