Skip to content

Commit

Permalink
hotfix: breaking wands in wand magic was not functioning correctly fo…
Browse files Browse the repository at this point in the history
…r the past 7 years, I have now fixed it
  • Loading branch information
brightrim committed Mar 6, 2025
1 parent 51442b7 commit d63f6f2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function M.calculateItemQualityDurability (quality, durability)
else
durabilityNumber= tonumber(durability)
end
if durabilityNumber < 1 or durabilityNumber > M.ITEM_MAX_DURABILITY then
if durabilityNumber < 0 or durabilityNumber > M.ITEM_MAX_DURABILITY then --We allow 0 now for broken items
durabilityNumber = M.ITEM_DEFAULT_DURABILITY
end

Expand Down
2 changes: 0 additions & 2 deletions base/magic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ function M.wandDegrade(user, wand, chance)
common.InformNLS(user,
"Deine Waffe '"..nameText.."' zerbricht.",
"Your weapon '"..nameText.."' shatters.")

return
end

common.setItemDurability(wand, durability)
Expand Down
21 changes: 21 additions & 0 deletions item/wands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,24 @@ local magicWands = {}
magicWands[2785] = true
magicWands[3608] = true

local function checkForWand(user)

local wand = common.getItemInHand(user, magic.wandIds)

if not wand then return false end --You need a wand to do any enchanting

if common.isBroken(wand) then
user:inform("Dein Zauberstab ist zerbrochen. Du solltest ihn reparieren lassen, bevor du versuchst, ihn zu benutzen.", "Your wand is broken. You should see to its repairs before trying to use it.")
return false
end

return true
end

function M.enchantingSelection(user, wand, actionstate)

if not checkForWand(user) then return end

if not magic.hasMageAttributes(user) then
user:inform("Mit deinem Mangel an magischen Attributen wüsstest du nicht einmal, wo du anfangen sollst, einen Schrein wie diesen zu benutzen.", "With your lack of magical attributes, you wouldn't know where to begin using a shrine like this.") --chatGPT german
return
Expand Down Expand Up @@ -120,6 +136,11 @@ end

local function selectMagicType(user, wand, actionstate)

if common.isBroken(wand) then
user:inform("Dein Zauberstab ist zerbrochen. Du solltest ihn reparieren lassen, bevor du versuchst, ihn zu benutzen.", "Your wand is broken. You should see to its repairs before trying to use it.")
return
end

local callback = function (dialog)

if not dialog:getSuccess() or not common.IsItemInHands(wand) then
Expand Down
16 changes: 16 additions & 0 deletions magic/arcane/spatial.lua
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,23 @@ function M.startCycle(user, actionState, oralCast)
teleport(user, actionState, portal, destination, oralCast)
end

end

local function checkForWand(user)

local wand = common.getItemInHand(user, magic.wandIds)

if not wand then return true end --You can cast spatial magic without a wand just without the boni of wielding one

if common.isBroken(wand) then
user:inform("Dein Zauberstab ist zerbrochen. Du solltest ihn reparieren lassen, bevor du versuchst, ihn zu benutzen.", "Your wand is broken. You should see to its repairs before trying to use it.")
return false
end

return true
end


local function chooseLocation(user, actionState, portal)

if not checkIfEnoughMana(user) then
Expand Down Expand Up @@ -685,6 +698,9 @@ local function skipPortalMenu(user, actionState, incantation)
end

function M.castSpatialMagic(user, actionState, oralCast)

if not checkForWand(user) then return end

if actionState == Action.none then
if not oralCast then
portalMenu(user, actionState)
Expand Down

0 comments on commit d63f6f2

Please sign in to comment.