aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon <brandon.wamboldt@gmail.com>2023-09-24 08:04:59 -0300
committerGitHub <noreply@github.com>2023-09-24 13:04:59 +0200
commitd0e6a9cd5b50288a5075e75bde63c0c09892cbb7 (patch)
tree409371e121ac3a071c5eff0ba305fe85322853aa
parent0381d759c3f4859b2bc4d93345018e32d47bae77 (diff)
downloadskyhanni-d0e6a9cd5b50288a5075e75bde63c0c09892cbb7.tar.gz
skyhanni-d0e6a9cd5b50288a5075e75bde63c0c09892cbb7.tar.bz2
skyhanni-d0e6a9cd5b50288a5075e75bde63c0c09892cbb7.zip
Mage Item Cooldown #480
* Compensate for mage ability cooldown reduction while in dungeons
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt31
3 files changed, 69 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
index 50585d56e..ba37d76ac 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
@@ -2,18 +2,25 @@ package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.*
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf
+import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.TabListData
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DungeonData {
private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?<floor>.*)\\)".toPattern()
+ private val uniqueClassBonus = "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex()
companion object {
var dungeonFloor: String? = null
var started = false
var inBossRoom = false
+ var playerClass: DungeonClass? = null
+ var playerClassLevel = -1
+ var isUniqueClass = false
fun inDungeon() = dungeonFloor != null
@@ -60,6 +67,17 @@ class DungeonData {
}
}
}
+ if (dungeonFloor != null && playerClass == null) {
+ val playerTeam = TabListData.getTabList().firstOrNull { it.contains(LorenzUtils.getPlayerName()) }?.removeColor() ?: ""
+
+ DungeonClass.entries.forEach {
+ if (playerTeam.contains("(${it.scoreboardName} ")) {
+ val level = playerTeam.split(" ").last().trimEnd(')').romanToDecimalIfNeeded()
+ playerClass = it
+ playerClassLevel = level
+ }
+ }
+ }
}
@SubscribeEvent
@@ -67,6 +85,9 @@ class DungeonData {
dungeonFloor = null
started = false
inBossRoom = false
+ isUniqueClass = false
+ playerClass = null
+ playerClassLevel = -1
}
@SubscribeEvent
@@ -77,6 +98,17 @@ class DungeonData {
started = true
DungeonStartEvent(floor).postAndCatch()
}
+ if (event.message.removeColor().matches(uniqueClassBonus)) {
+ isUniqueClass = true
+ }
}
}
+
+ enum class DungeonClass(public val scoreboardName: String) {
+ ARCHER("Archer"),
+ BERSERK("Berserk"),
+ HEALER("Healer"),
+ MAGE("Mage"),
+ TANK("Tank")
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
index de6f1521f..3b1481215 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
@@ -73,12 +73,19 @@ enum class ItemAbility(
lastActivation = System.currentTimeMillis() - ((cooldownInSeconds * 1000) - customCooldown)
}
- fun isOnCooldown(): Boolean = lastActivation + getCooldown() > System.currentTimeMillis()
+ fun isOnCooldown(cooldownMultiplier: Double): Boolean = lastActivation + getCooldown(cooldownMultiplier) > System.currentTimeMillis()
- fun getCooldown(): Long = 1000L * cooldownInSeconds
+ fun getCooldown(cooldownMultiplier: Double): Long {
+ // Some items aren't really a cooldown but an effect over time, so don't apply cooldown multipliers
+ if (this == WAND_OF_ATONEMENT || this == RAGNAROCK_AXE) {
+ return 1000L * cooldownInSeconds
+ }
+
+ return (1000L * cooldownInSeconds * cooldownMultiplier).toLong()
+ }
- fun getDurationText(): String {
- var duration: Long = lastActivation + getCooldown() - System.currentTimeMillis()
+ fun getDurationText(cooldownMultiplier: Double): String {
+ var duration: Long = lastActivation + getCooldown(cooldownMultiplier) - System.currentTimeMillis()
return if (duration < 1600) {
duration /= 100
var d = duration.toDouble()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index a664bd0ce..d0f5c488b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.events.*
+import at.hannibal2.skyhanni.features.dungeon.DungeonData
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
@@ -18,6 +19,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.floor
+import kotlin.math.max
class ItemAbilityCooldown {
private var lastAbility = ""
@@ -27,6 +30,23 @@ class ItemAbilityCooldown {
private val WEIRDER_TUBA = "WEIRDER_TUBA".asInternalName()
private val VOODOO_DOLL_WILTED = "VOODOO_DOLL_WILTED".asInternalName()
+ fun getAbilityCooldownMultiplier(): Double {
+ var abilityCooldownMultiplier = 1.0
+
+ if (LorenzUtils.inDungeons && DungeonData.playerClass == DungeonData.DungeonClass.MAGE) {
+ abilityCooldownMultiplier -= if (DungeonData.isUniqueClass) {
+ 0.5 // 50% base reduction at level 0
+ } else {
+ 0.25 // 25% base reduction at level 0
+ }
+
+ // 1% ability reduction every other level
+ abilityCooldownMultiplier -= 0.01 * floor(DungeonData.playerClassLevel / 2f)
+ }
+
+ return abilityCooldownMultiplier
+ }
+
@SubscribeEvent
fun onSoundEvent(event: PlaySoundEvent) {
if (event.soundName == "mob.zombie.remedy") {
@@ -188,7 +208,7 @@ class ItemAbilityCooldown {
handleOldAbilities(message)
if (message.contains("§lCASTING IN ")) {
- if (!ItemAbility.RAGNAROCK_AXE.isOnCooldown()) {
+ if (!ItemAbility.RAGNAROCK_AXE.isOnCooldown(getAbilityCooldownMultiplier())) {
ItemAbility.RAGNAROCK_AXE.activate(LorenzColor.WHITE, 3_000)
}
} else if (message.contains("§lCASTING")) {
@@ -249,12 +269,13 @@ class ItemAbilityCooldown {
private fun createItemText(ability: ItemAbility): ItemText {
val specialColor = ability.specialColor
- return if (ability.isOnCooldown()) {
+ val cooldownMultiplier = getAbilityCooldownMultiplier()
+ return if (ability.isOnCooldown(cooldownMultiplier)) {
val duration: Long =
- ability.lastActivation + ability.getCooldown() - System.currentTimeMillis()
+ ability.lastActivation + ability.getCooldown(cooldownMultiplier) - System.currentTimeMillis()
val color =
specialColor ?: if (duration < 600) LorenzColor.RED else LorenzColor.YELLOW
- ItemText(color, ability.getDurationText(), true, ability.alternativePosition)
+ ItemText(color, ability.getDurationText(cooldownMultiplier), true, ability.alternativePosition)
} else {
if (specialColor != null) {
ability.specialColor = null
@@ -273,7 +294,7 @@ class ItemAbilityCooldown {
}
if (ability == ItemAbility.RAGNAROCK_AXE) {
if (specialColor == LorenzColor.DARK_PURPLE) {
- ability.activate(null, 7_000)
+ ability.activate(null, max((20_000 * getAbilityCooldownMultiplier()) - 13_000, 0.0).toInt())
}
}
}