diff options
Diffstat (limited to 'src')
3 files changed, 53 insertions, 36 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 ba37d76ac..52a7e3cba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt @@ -12,7 +12,8 @@ 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() + 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 @@ -68,7 +69,10 @@ class DungeonData { } } if (dungeonFloor != null && playerClass == null) { - val playerTeam = TabListData.getTabList().firstOrNull { it.contains(LorenzUtils.getPlayerName()) }?.removeColor() ?: "" + val playerTeam = + TabListData.getTabList().firstOrNull { + it.contains(LorenzUtils.getPlayerName()) + }?.removeColor() ?: "" DungeonClass.entries.forEach { if (playerTeam.contains("(${it.scoreboardName} ")) { @@ -104,7 +108,7 @@ class DungeonData { } } - enum class DungeonClass(public val scoreboardName: String) { + enum class DungeonClass(val scoreboardName: String) { ARCHER("Archer"), BERSERK("Berserk"), HEALER("Healer"), 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 3b1481215..fb1169d83 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 @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown +import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import kotlin.math.floor enum class ItemAbility( val abilityName: String, @@ -14,15 +16,16 @@ enum class ItemAbility( var specialColor: LorenzColor? = null, var lastItemClick: Long = 0L, val actionBarDetection: Boolean = true, + private val ignoreMageCooldownReduction: Boolean = false, ) { //TODO add into repo - HYPERION(5, "SCYLLA", "VALKYRIE", "ASTRAEA"), + HYPERION(5, "SCYLLA", "VALKYRIE", "ASTRAEA", ignoreMageCooldownReduction = true), GYROKINETIC_WAND_LEFT(30, "GYROKINETIC_WAND", alternativePosition = true), GYROKINETIC_WAND_RIGHT(10, "GYROKINETIC_WAND"), GIANTS_SWORD(30), ICE_SPRAY_WAND(5), - ATOMSPLIT_KATANA(4, "VORPAL_KATANA", "VOIDEDGE_KATANA"), + ATOMSPLIT_KATANA(4, "VORPAL_KATANA", "VOIDEDGE_KATANA", ignoreMageCooldownReduction = true), RAGNAROCK_AXE(20), WAND_OF_ATONEMENT(7, "WAND_OF_HEALING", "WAND_OF_MENDING", "WAND_OF_RESTORATION"), @@ -60,7 +63,14 @@ enum class ItemAbility( cooldownInSeconds: Int, vararg alternateInternalNames: String, alternativePosition: Boolean = false, - ) : this("no name", cooldownInSeconds, actionBarDetection = false, alternativePosition = alternativePosition) { + ignoreMageCooldownReduction: Boolean = false, + ) : this( + "no name", + cooldownInSeconds, + actionBarDetection = false, + alternativePosition = alternativePosition, + ignoreMageCooldownReduction = ignoreMageCooldownReduction + ) { newVariant = true alternateInternalNames.forEach { internalNames.add(it.asInternalName()) @@ -73,19 +83,19 @@ enum class ItemAbility( lastActivation = System.currentTimeMillis() - ((cooldownInSeconds * 1000) - customCooldown) } - fun isOnCooldown(cooldownMultiplier: Double): Boolean = lastActivation + getCooldown(cooldownMultiplier) > System.currentTimeMillis() + fun isOnCooldown(): Boolean = lastActivation + getCooldown() > System.currentTimeMillis() - fun getCooldown(cooldownMultiplier: Double): Long { + fun getCooldown(): 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() + return (1000L * cooldownInSeconds * getMultiplier()).toLong() } - fun getDurationText(cooldownMultiplier: Double): String { - var duration: Long = lastActivation + getCooldown(cooldownMultiplier) - System.currentTimeMillis() + fun getDurationText(): String { + var duration: Long = lastActivation + getCooldown() - System.currentTimeMillis() return if (duration < 1600) { duration /= 100 var d = duration.toDouble() @@ -107,6 +117,28 @@ enum class ItemAbility( fun getByInternalName(internalName: NEUInternalName): ItemAbility? { return entries.firstOrNull { it.newVariant && internalName in it.internalNames } } + + fun ItemAbility.getMultiplier(): Double { + return getMageCooldownReduction() ?: 1.0 + } + + private fun ItemAbility.getMageCooldownReduction(): Double? { + if (ignoreMageCooldownReduction) return null + if (!LorenzUtils.inDungeons) return null + if (DungeonData.playerClass != DungeonData.DungeonClass.MAGE) return null + + var abilityCooldownMultiplier = 1.0 + 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 + } } }
\ No newline at end of file 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 d0f5c488b..f644cdd76 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,7 +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.features.itemabilities.abilitycooldown.ItemAbility.Companion.getMultiplier import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName @@ -19,7 +19,6 @@ 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 { @@ -30,23 +29,6 @@ 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") { @@ -208,7 +190,7 @@ class ItemAbilityCooldown { handleOldAbilities(message) if (message.contains("§lCASTING IN ")) { - if (!ItemAbility.RAGNAROCK_AXE.isOnCooldown(getAbilityCooldownMultiplier())) { + if (!ItemAbility.RAGNAROCK_AXE.isOnCooldown()) { ItemAbility.RAGNAROCK_AXE.activate(LorenzColor.WHITE, 3_000) } } else if (message.contains("§lCASTING")) { @@ -269,13 +251,12 @@ class ItemAbilityCooldown { private fun createItemText(ability: ItemAbility): ItemText { val specialColor = ability.specialColor - val cooldownMultiplier = getAbilityCooldownMultiplier() - return if (ability.isOnCooldown(cooldownMultiplier)) { + return if (ability.isOnCooldown()) { val duration: Long = - ability.lastActivation + ability.getCooldown(cooldownMultiplier) - System.currentTimeMillis() + ability.lastActivation + ability.getCooldown() - System.currentTimeMillis() val color = specialColor ?: if (duration < 600) LorenzColor.RED else LorenzColor.YELLOW - ItemText(color, ability.getDurationText(cooldownMultiplier), true, ability.alternativePosition) + ItemText(color, ability.getDurationText(), true, ability.alternativePosition) } else { if (specialColor != null) { ability.specialColor = null @@ -294,7 +275,7 @@ class ItemAbilityCooldown { } if (ability == ItemAbility.RAGNAROCK_AXE) { if (specialColor == LorenzColor.DARK_PURPLE) { - ability.activate(null, max((20_000 * getAbilityCooldownMultiplier()) - 13_000, 0.0).toInt()) + ability.activate(null, max((20_000 * ability.getMultiplier()) - 13_000, 0.0).toInt()) } } } |