Skip to content

Commit

Permalink
fix: dry/reset storages
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosEDev committed Mar 18, 2024
1 parent e6fa059 commit 350af75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
-- reset global storage state to default / ensure sqm's reset for the next team
Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1)
Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1)
Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1)
monster:registerEvent("facelessBaneImmunity")
monster:registerEvent("facelessBaneOnDeath")
monster:setReward(true)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function resetBoss(creature, deaths)
Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, deaths + 1)
Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 0)
Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1)
return true
end

local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity")
Expand All @@ -30,9 +31,10 @@ local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity")
function facelessBaneImmunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
if creature and creature:isMonster() and creature:getName() == bossName then
local creatureHealthPercent = (creature:getHealth() * 100) / creature:getMaxHealth()
local facelessBaneDeathsStorage = Game.getStorageValue(GlobalStorage.FacelessBaneDeaths)

if creatureHealthPercent <= 20 and Game.getStorageValue(GlobalStorage.FacelessBaneDeaths) < 1 then
resetBoss(creature, Game.getStorageValue(GlobalStorage.FacelessBaneDeaths))
if creatureHealthPercent <= 20 and facelessBaneDeathsStorage < 1 then
resetBoss(creature, facelessBaneDeathsStorage)
return true
end

Expand Down

This file was deleted.

0 comments on commit 350af75

Please sign in to comment.