Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Luciano committed Dec 13, 2023
1 parent efa5dfc commit 558c964
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 81 deletions.
10 changes: 5 additions & 5 deletions data-canary/scripts/spells/support/swift_foot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function spell.onCastSpell(creature, var)
local summon_t = summon:getType()
if summon_t and summon_t:familiar() then
local deltaSpeed = math.max(creature:getBaseSpeed() - summon:getBaseSpeed(), 0)
local FamiliarSpeed = ((summon:getBaseSpeed() + deltaSpeed) * 0.8) - 72
local FamiliarHaste = Condition(CONDITION_HASTE)
setConditionParam(FamiliarHaste, CONDITION_PARAM_TICKS, 10000)
setConditionParam(FamiliarHaste, CONDITION_PARAM_SPEED, FamiliarSpeed)
summon:addCondition(FamiliarHaste)
local familiarSpeed = ((summon:getBaseSpeed() + deltaSpeed) * 0.8) - 72
local familiarHaste = Condition(CONDITION_HASTE)
familiarHaste:setParameter(CONDITION_PARAM_TICKS, 10000)
familiarHaste:setParameter(CONDITION_PARAM_SPEED, familiarSpeed)
summon:addCondition(familiarHaste)
end
end
end
Expand Down
83 changes: 57 additions & 26 deletions data-otservbr-global/lib/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ MESSAGE_STATUS_CONSOLE_RED = MESSAGE_GAMEMASTER_CONSOLE

MESSAGE_STATUS_DEFAULT = MESSAGE_LOGIN
MESSAGE_STATUS_WARNING = MESSAGE_ADMINISTRADOR
MESSAGE_EVENT_ADVANCE = MESSAGE_EVENT_ADVANCE

MESSAGE_STATUS_SMALL = MESSAGE_FAILURE
MESSAGE_INFO_DESCR = MESSAGE_LOOK
MESSAGE_DAMAGE_DEALT = MESSAGE_DAMAGE_DEALT
MESSAGE_DAMAGE_RECEIVED = MESSAGE_DAMAGE_RECEIVED
MESSAGE_EVENT_DEFAULT = MESSAGE_STATUS

MESSAGE_EVENT_ORANGE = TALKTYPE_MONSTER_SAY
Expand All @@ -19,28 +16,14 @@ MESSAGE_STATUS_CONSOLE_ORANGE = TALKTYPE_MONSTER_YELL
if type(result) then
result = Result
end
result.getDataInt = result.getNumber
result.getDataLong = result.getNumber
result.getDataString = result.getString
result.getDataStream = result.getStream
result.getDataInt = Result.getNumber
result.getDataLong = Result.getNumber
result.getDataString = Result.getString
result.getDataStream = Result.getStream

LUA_ERROR = false
LUA_NO_ERROR = true

STACKPOS_GROUND = 0
STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE = 1
STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE = 2
STACKPOS_THIRD_ITEM_ABOVE_GROUNDTILE = 3
STACKPOS_FOURTH_ITEM_ABOVE_GROUNDTILE = 4
STACKPOS_FIFTH_ITEM_ABOVE_GROUNDTILE = 5
STACKPOS_TOP_CREATURE = 253
STACKPOS_TOP_FIELD = 254
STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE = 255

THING_TYPE_PLAYER = CREATURETYPE_PLAYER + 1
THING_TYPE_MONSTER = CREATURETYPE_MONSTER + 1
THING_TYPE_NPC = CREATURETYPE_NPC + 1

COMBAT_POISONDAMAGE = COMBAT_EARTHDAMAGE
CONDITION_EXHAUST = CONDITION_EXHAUST_WEAPON
TALKTYPE_ORANGE_1 = TALKTYPE_MONSTER_SAY
Expand Down Expand Up @@ -84,7 +67,7 @@ Combat.setCondition = function(...)
end

setCombatCondition = function(...)
logger.warn("[setCombatCondition] - Function was renamed to addCombatCondition and will be removed in the future")
logger.warn("[setCombatCondition] - Function was renamed to Combat.addCondition and will be removed in the future")
Combat.addCondition(...)
end

Expand All @@ -95,34 +78,58 @@ addDamageCondition = Condition.addDamage
addOutfitCondition = Condition.setOutfit

function doCombat(cid, combat, var)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'doCombat(cid, combat, var)' is outdated. Please use the new format 'combat:execute(cid, var)'. Update needed at: Line {}, Source: {}.", line, source)
return combat:execute(cid, var)
end

function isCreature(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isCreature(cid)' is outdated. Please use the new format 'Creature(cid)'. Update needed at: Line {}, Source: {}.", line, source)
return Creature(cid) ~= nil
end

function isPlayer(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isPlayer(cid)' is outdated. Please use the new format 'Player(cid)'. Update needed at: Line {}, Source: {}.", line, source)
return Player(cid) ~= nil
end

function isMonster(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isMonster(cid)' is outdated. Please use the new format 'Monster(cid)'. Update needed at: Line {}, Source: {}.", line, source)
return Monster(cid) ~= nil
end

function isSummon(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isSummon(cid)' is outdated. Please use the new format 'c:getMaster()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
return Creature(cid):getMaster() ~= nil
end

function isNpc(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isNpc(cid)' is outdated. Please use the new format 'Npc(cid)'. Update needed at: Line {}, Source: {}.", line, source)
return Npc(cid) ~= nil
end

function isItem(uid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isItem(uid)' is outdated. Please use the new format 'Item(uid)'. Update needed at: Line {}, Source: {}.", line, source)
return Item(uid) ~= nil
end

function isContainer(uid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'isContainer(uid)' is outdated. Please use the new format 'Container(uid)'. Update needed at: Line {}, Source: {}.", line, source)
return Container(uid) ~= nil
end

Expand Down Expand Up @@ -159,21 +166,33 @@ function getCreaturePosition(cid)
end

function getCreatureOutfit(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'getCreatureOutfit(cid)' is outdated. Please use the new format 'c:getOutfit()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:getOutfit() or false
end

function getCreatureSpeed(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'getCreatureSpeed(cid)' is outdated. Please use the new format 'c:getSpeed()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:getSpeed() or false
end

function getCreatureBaseSpeed(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'getCreatureBaseSpeed(cid)' is outdated. Please use the new format 'c:getBaseSpeed()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:getBaseSpeed() or false
end

function getCreatureTarget(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'getCreatureTarget(cid)' is outdated. Please use the new format 'c:getTarget():getId()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
if c then
local target = c:getTarget()
Expand All @@ -183,6 +202,9 @@ function getCreatureTarget(cid)
end

function getCreatureMaster(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'getCreatureMaster(cid)' is outdated. Please use the new format 'c:getMaster():getId()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
if c then
local master = c:getMaster()
Expand All @@ -193,7 +215,7 @@ end

function getCreatureSummons(cid)
local c = Creature(cid)
if c == nil then
if not c then
return false
end

Expand All @@ -207,16 +229,25 @@ end
getCreaturePos = getCreaturePosition

function doCreatureAddHealth(cid, health)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'doCreatureAddHealth(cid, health)' is outdated. Please use the new format 'c:addHealth(health)', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:addHealth(health) or false
end

function doRemoveCreature(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'doRemoveCreature(cid)' is outdated. Please use the new format 'c:remove()', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:remove() or false
end

function doCreatureSetLookDir(cid, direction)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("Deprecation Warning: The function 'doCreatureSetLookDir(cid, direction)' is outdated. Please use the new format 'c:setDirection(direction)', where 'c' refers to a Creature (player or monster). Update needed at: Line {}, Source: {}.", line, source)
local c = Creature(cid)
return c and c:setDirection(direction) or false
end
Expand Down Expand Up @@ -604,7 +635,7 @@ function getPlayerGUIDByName(name)
local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId ~= false then
local guid = Result.getNumber(resultId, "id")
result.free(resultId)
Result.free(resultId)
return guid
end
return 0
Expand All @@ -619,7 +650,7 @@ function getAccountNumberByPlayerName(name)
local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId ~= false then
local accountId = Result.getNumber(resultId, "account_id")
result.free(resultId)
Result.free(resultId)
return accountId
end
return 0
Expand Down Expand Up @@ -1054,7 +1085,7 @@ function getGuildId(guildName)
end

local guildId = Result.getNumber(resultId, "id")
result.free(resultId)
Result.free(resultId)
return guildId
end

Expand Down
13 changes: 13 additions & 0 deletions data-otservbr-global/lib/core/constants.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
STACKPOS_GROUND = 0
STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE = 1
STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE = 2
STACKPOS_THIRD_ITEM_ABOVE_GROUNDTILE = 3
STACKPOS_FOURTH_ITEM_ABOVE_GROUNDTILE = 4
STACKPOS_FIFTH_ITEM_ABOVE_GROUNDTILE = 5
STACKPOS_TOP_CREATURE = 253
STACKPOS_TOP_FIELD = 254
STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE = 255

THING_TYPE_PLAYER = CREATURETYPE_PLAYER + 1
THING_TYPE_MONSTER = CREATURETYPE_MONSTER + 1
THING_TYPE_NPC = CREATURETYPE_NPC + 1
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
@@ -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
5 changes: 0 additions & 5 deletions data-otservbr-global/scripts/creaturescripts/others/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ local function onMovementRemoveProtection(cid, oldPos, time)
addEvent(onMovementRemoveProtection, 1000, cid, oldPos, time - 1)
end

local function protectionZoneCheck(playerName)
doRemoveCreature(playerName)
return true
end

local playerLogin = CreatureEvent("PlayerLogin")

function playerLogin.onLogin(player)
Expand Down

0 comments on commit 558c964

Please sign in to comment.