Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Add dungeon phases #1865

Merged
merged 23 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce4996d
start
martimavocado May 21, 2024
0a1323d
start dungeon phases
martimavocado May 22, 2024
bdcfa5f
move to dungeonapi
martimavocado May 22, 2024
415d8a1
finish phasechange event
martimavocado May 22, 2024
6abc939
add comments
martimavocado May 22, 2024
d59a8cf
Merge remote-tracking branch 'refs/remotes/hannibal/beta' into dungeo…
martimavocado Jun 15, 2024
900a64f
fix necron pattern, add regex test
martimavocado Jun 16, 2024
5f45d30
remove debug message
martimavocado Jun 16, 2024
84ecff8
Merge remote-tracking branch 'hannibal/beta' into dungeon-phases
martimavocado Jun 17, 2024
f603736
Merge remote-tracking branch 'hannibal002/beta' into dungeon-phases
martimavocado Sep 19, 2024
fee8daa
add more regex tests
martimavocado Sep 19, 2024
f6b340d
Merge branch 'beta' into dungeon-phases
CalMWolfs Oct 9, 2024
e4fca94
code fixes
CalMWolfs Oct 9, 2024
8193589
formatting
CalMWolfs Oct 9, 2024
96585e6
Merge remote-tracking branch 'hannibal002/beta' into dungeon-phases
martimavocado Oct 11, 2024
f2f890c
move to dungeonbossapi
martimavocado Oct 11, 2024
c8687b6
rename patterngroup
martimavocado Oct 11, 2024
b75ed2f
oops
martimavocado Oct 11, 2024
5c9845f
Merge branch 'refs/heads/beta' into fork/martimavocado/dungeon-phases
hannibal002 Oct 11, 2024
3d31a5f
renamed
hannibal002 Oct 11, 2024
4411748
fix typo
martimavocado Oct 11, 2024
84aee8c
Merge remote-tracking branch 'martimavocado/dungeon-phases' into dung…
martimavocado Oct 11, 2024
243f158
git haunts my dreams
martimavocado Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonBossAPI

class DungeonBossPhaseChangeEvent(val newPhase: DungeonBossAPI.DungeonBossPhase) : SkyHanniEvent()
171 changes: 171 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.events.DungeonBossPhaseChangeEvent
import at.hannibal2.skyhanni.events.DungeonCompleteEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.dungeonFloor
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object DungeonBossAPI {
var bossPhase: DungeonBossPhase? = null

enum class DungeonBossPhase {
F6_TERRACOTTA,
F6_GIANTS,
F6_SADAN,
F7_MAXOR,
F7_STORM,
F7_GOLDOR_1,
F7_GOLDOR_2,
F7_GOLDOR_3,
F7_GOLDOR_4,
F7_GOLDOR_5,
F7_NECRON,
M7_WITHER_KING,
}

private val patternGroup = RepoPattern.group("dungeon.boss.message")

/**
* REGEX-TEST: §c[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me\? Sadan\?!
*/
private val terracottaStartPattern by patternGroup.pattern(
"f6.terracotta",
"§c\\[BOSS] Sadan§r§f: So you made it all the way here\\.\\.\\. Now you wish to defy me\\? Sadan\\?!",
)

/**
* REGEX-TEST: §c[BOSS] Sadan§r§f: ENOUGH!
*/
private val giantsStartPattern by patternGroup.pattern(
"f6.giants",
"§c\\[BOSS] Sadan§r§f: ENOUGH!",
)

/**
* REGEX-TEST: §c[BOSS] Sadan§r§f: You did it. I understand now, you have earned my respect.
*/
private val sadanStartPattern by patternGroup.pattern(
"f6.sadan",
"§c\\[BOSS] Sadan§r§f: You did it\\. I understand now, you have earned my respect\\.",
)

/**
* REGEX-TEST: §4[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE!
*/
private val maxorStartPattern by patternGroup.pattern(
"f7.maxor",
"§4\\[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE!",
)

/**
* REGEX-TEST: §4[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected.
*/
private val stormStartPattern by patternGroup.pattern(
"f7.storm",
"§4\\[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected\\.",
)

/**
* REGEX-TEST: §4[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain?
*/
private val goldorStartPattern by patternGroup.pattern(
"f7.goldor.start",
"§4\\[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain\\?",
)

/**
* REGEX-TEST: §bmartimavocado§r§a activated a lever! (§r§c7§r§a/7)
* REGEX-TEST: §bmartimavocado§r§a completed a device! (§r§c3§r§a/8)
* REGEX-TEST: §bmartimavocado§r§a activated a terminal! (§r§c4§r§a/7)
*/
private val goldorTerminalPattern by patternGroup.pattern(
"f7.goldor.terminalcomplete",
"§.(?<playerName>\\w+)§r§a (?:activated|completed) a (?<type>lever|terminal|device)! \\(§r§c(?<currentTerminal>\\d)§r§a/(?<total>\\d)\\)",
)

/**
* REGEX-TEST: §aThe Core entrance is opening!
*/
private val goldor5StartPattern by patternGroup.pattern(
"f7.goldor.5",
"§aThe Core entrance is opening!",
)

/**
* REGEX-TEST: §4[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations.
*/
private val necronStartPattern by patternGroup.pattern(
"f7.necron.start",
"§4\\[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations\\.",
)

/**
* REGEX-TEST: §4[BOSS] Necron§r§c: §r§cAll this, for nothing...
*/
private val witherKingStartPattern by patternGroup.pattern(
"m7.witherking",
"§4\\[BOSS] Necron§r§c: §r§cAll this, for nothing\\.\\.\\.",
)

private fun handlePhaseMessage(message: String) {
if (dungeonFloor == "F6" || dungeonFloor == "M6") when { //move to enum
terracottaStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_TERRACOTTA)
giantsStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_GIANTS)
sadanStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_SADAN)
}

if (dungeonFloor == "F7" || dungeonFloor == "M7") { //move to enum
goldorTerminalPattern.matchMatcher(message) {
val currentTerminal = group("currentTerminal").toIntOrNull() ?: return
val totalTerminals = group("total").toIntOrNull() ?: return
if (currentTerminal != totalTerminals) return
changePhase(
when (bossPhase) {
DungeonBossPhase.F7_GOLDOR_1 -> DungeonBossPhase.F7_GOLDOR_2
DungeonBossPhase.F7_GOLDOR_2 -> DungeonBossPhase.F7_GOLDOR_3
DungeonBossPhase.F7_GOLDOR_3 -> DungeonBossPhase.F7_GOLDOR_4
else -> return
},
)
}
when {
maxorStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_MAXOR)
stormStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_STORM)
goldorStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_GOLDOR_1)
goldor5StartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_GOLDOR_5)
necronStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_NECRON)
witherKingStartPattern.matches(message) -> if (bossPhase != null) changePhase(DungeonBossPhase.M7_WITHER_KING)
}
}
}

private fun changePhase(newPhase: DungeonBossPhase) {
DungeonBossPhaseChangeEvent(newPhase).post()
bossPhase = newPhase
}

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
bossPhase = null
}

@SubscribeEvent
fun onDungeonEnd(event: DungeonCompleteEvent) {
bossPhase = null
}

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!LorenzUtils.inSkyBlock) return

handlePhaseMessage(event.message)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager
Expand All @@ -15,37 +14,23 @@ object TerracottaPhase {

private val config get() = SkyHanniMod.feature.dungeon.terracottaPhase

private var inTerracottaPhase = false

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return

if (event.message == "§c[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me? Sadan?!") {
inTerracottaPhase = true
}

if (event.message == "§c[BOSS] Sadan§r§f: ENOUGH!") {
inTerracottaPhase = false
}
}

@SubscribeEvent(priority = EventPriority.HIGH)
fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) {
if (isActive() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) {
if (isEnabled() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) {
event.cancel()
}
}

@SubscribeEvent
fun onReceiveParticle(event: ReceiveParticleEvent) {
if (isActive() && config.hideParticles) {
if (isEnabled() && config.hideParticles) {
event.cancel()
}
}

private fun isActive() = isEnabled() && inTerracottaPhase

private fun isEnabled() =
DungeonAPI.inDungeon() && DungeonAPI.inBossRoom && DungeonAPI.getCurrentBoss() == DungeonFloor.F6
DungeonAPI.inDungeon() &&
DungeonAPI.inBossRoom &&
DungeonAPI.getCurrentBoss() == DungeonFloor.F6 &&
DungeonBossAPI.bossPhase == DungeonBossAPI.DungeonBossPhase.F6_TERRACOTTA
}
Loading