Skip to content

Commit

Permalink
bugfix Tan #392
Browse files Browse the repository at this point in the history
  • Loading branch information
brightrim committed Jul 9, 2024
1 parent b8ae9f3 commit 067837c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion magic/arcane/enchanting/effects/tan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local M = {}

function M.reduceCastTime(user)

local chance = {min = 0.1, bonus = 0.4}
local chance = {min = 0.1, bonus = 0.2}

local success = shared.activateGlyph(user, "tan", chance, 1)

Expand Down
19 changes: 15 additions & 4 deletions magic/magicfighting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ local function isMagicAttackLoaded(attackerStruct, defender, neededCastTime)
return false
end

if not mageLoad["tanCheckedThisCycle"] then
if tan.reduceCastTime(attackerStruct.Char) then
mageLoad["tan"] = true
end
mageLoad["tanCheckedThisCycle"] = true
end

if mageLoad["tan"] then
neededCastTime = neededCastTime/2
end

-- Same reasonsing as in aiming time applies:
-- We cannot check for the end of a fight but need to stop the start aiming, stop aiming, wait, attack immediately mechanic
if (world:getTime("unix") - mageLoad["started"])*10 > neededCastTime + 20 then
Expand All @@ -113,6 +124,8 @@ local function isMagicAttackLoaded(attackerStruct, defender, neededCastTime)
return false
end

mageLoad["tanCheckedThisCycle"] = false
mageLoad["tan"] = false
return true
end

Expand Down Expand Up @@ -266,9 +279,7 @@ function M.onMagicAttack(attackerStruct, defenderStruct)

local neededCastTime = calculateCastTime(attackerStruct)

if tan.reduceCastTime(attackerStruct.Char) then
neededCastTime = neededCastTime/2
end
local manaNeeded = getNeededMana(neededCastTime)

-- Any attack must preload a given time before he can be executed
if not isMagicAttackLoaded(attackerStruct, defenderStruct.Char, neededCastTime) then
Expand All @@ -282,7 +293,7 @@ function M.onMagicAttack(attackerStruct, defenderStruct)

-- Handle mana usage
attackerStruct["mana"] = attackerStruct.Char:increaseAttrib("mana", 0)
local neededMana = magic.getValueWithGemBonus(attackerStruct.Char, getNeededMana(neededCastTime))
local neededMana = magic.getValueWithGemBonus(attackerStruct.Char, manaNeeded)
if (attackerStruct.mana < neededMana) then
attackerStruct.Char:inform("Dein Mana reicht nicht aus", "Your mana is depleted")
return
Expand Down

0 comments on commit 067837c

Please sign in to comment.