Skip to content

Commit

Permalink
Decouple "ParseItem Attributes" in it own file (#140)
Browse files Browse the repository at this point in the history
ItemParse has been refactored and decoupled in a own file to allow for better organization and avoid breakage in the compilation
Fixed some bugs, such as fields in items.xml
This commit is necessary for the pull request (12.72 protocol) to work correctly: #143

Co-authored-by @dudantas <eduardo.dantas@hotmail.com.br>
  • Loading branch information
beats-dh authored Nov 23, 2021
1 parent f368616 commit 304efb8
Show file tree
Hide file tree
Showing 11 changed files with 1,880 additions and 1,089 deletions.
23 changes: 15 additions & 8 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ function Player:onLook(thing, position, distance)
local description = "You see "
description = description .. thing:getDescription(distance)
if thing:isItem() then
local item = thing:getType()
if (item and item:getImbuingSlots() > 0) then
local itemType = thing:getType()
if (itemType and itemType:getImbuingSlots() > 0) then
local imbuingSlots = "Imbuements: ("
for slot = 0, item:getImbuingSlots() - 1 do
for slot = 0, itemType:getImbuingSlots() - 1 do
if slot > 0 then
imbuingSlots = string.format("%s, ", imbuingSlots)
end
Expand All @@ -25,6 +25,13 @@ function Player:onLook(thing, position, distance)
imbuingSlots = string.format("%s).", imbuingSlots)
description = string.gsub(description, "It weighs", imbuingSlots.. "\nIt weighs")
end
elseif thing:isMonster() then
description = description .. thing:getDescription(distance)
local master = thing:getMaster()
if master and table.contains(FAMILIARSNAME, thing:getName():lower()) then
description = description..' (Master: ' .. master:getName() .. '). \z
It will disappear in ' .. getTimeinWords(master:getStorageValue(Storage.PetSummon) - os.time())
end
end

if self:getGroup():getAccess() then
Expand All @@ -41,18 +48,18 @@ function Player:onLook(thing, position, distance)
description = string.format("%s, Unique ID: %d", description, uniqueId)
end

local item = thing:getType()
local itemType = thing:getType()

if item then
local transformEquipId = item:getTransformEquipId()
local transformDeEquipId = item:getTransformDeEquipId()
if itemType then
local transformEquipId = itemType:getTransformEquipId()
local transformDeEquipId = itemType:getTransformDeEquipId()
if transformEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
elseif transformDeEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
end

local decayId = item:getDecayId()
local decayId = itemType:getDecayId()
if decayId ~= -1 then
description = string.format("%s\nDecays to: %d", description, decayId)
end
Expand Down
7 changes: 7 additions & 0 deletions data/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ staminaBonus = {
eventsPz = {} -- stamina in Pz
}

FAMILIARSNAME = {
"sorcerer familiar",
"knight familiar",
"druid familiar",
"paladin familiar"
}

function addStamina(playerId, ...)
-- Creature:onTargetCombat
if playerId then
Expand Down
Loading

0 comments on commit 304efb8

Please sign in to comment.