Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
weapon system revamp
Browse files Browse the repository at this point in the history
NOT TESTED ATM
  • Loading branch information
MqsterMorro committed May 5, 2024
1 parent 06af689 commit 75bb3f4
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 170 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ loom {
launchConfigs {
getByName("client") {
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("devauth.enabled", "false")
property("devauth.enabled", "true")
property("fml.coreMods.load", "dev.macrohq.swiftslayer.DevMixinLoader")
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ object SwiftSlayer {

@Subscribe
fun onRenderWorldLast(event: RenderWorldLastEvent) {
// this is here because im not sure if objects can have events cuz they are kinda static
RotationUtil.onRenderWorldLast()
RenderUtil.onRenderWorldLast(event)
KeyBindUtil.onRenderWorldLast()
Expand Down
94 changes: 24 additions & 70 deletions src/main/kotlin/dev/macrohq/swiftslayer/config/SwiftSlayerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import cc.polyfrost.oneconfig.config.data.Mod
import cc.polyfrost.oneconfig.config.data.ModType
import cc.polyfrost.oneconfig.libs.universal.UKeyboard
import dev.macrohq.swiftslayer.util.macroManager
import kotlin.math.*


class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftslayer.json") {
Expand All @@ -32,10 +31,30 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla
name = "Weapon type for mobs",
category = "General",
subcategory = "Slayer",
options = ["Spirit Sceptre", "Melee", "Fire Veil Wand", "Right click Melee"]
options = ["Hyperion", "Ranged", "Melee"]
)
var mobKillerWeapon = 0

@Slider(
name = "'Ranged' range",
category = "General",
subcategory = "Slayer",
min = 1f,
max = 15f,
step = 1
)
var rangedRange = 1

@Slider(
name = "'Ranged' cooldown (in seconds)",
category = "General",
subcategory = "Slayer",
min = 0f,
max = 25f,
step = 1
)
var rangedCooldown = 1

@Dropdown(
name = "Weapon type for boss",
category = "General",
Expand Down Expand Up @@ -116,7 +135,6 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla
var useHealingAt = 70



@Slider(
name = "Gui delay",
category = "General",
Expand All @@ -138,36 +156,7 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla
return (macroGuiDelay + Math.random().toFloat() * macroGuiDelayRandomness).toLong()
}

@Slider(
name = "Rotation time",
category = "General",
subcategory = "Advanced",
min = 100f,
max = 500f,
)
var macroRotationTime: Float = 250f

@Slider(
name = "Rotation time randomness",
category = "General",
subcategory = "Advanced",
min = 100f,
max = 1000f,
)
var macroRotationTimeRandomness: Float = 300f
fun getRandomRotationTime(): Long {
val ran = (macroRotationTime + Math.random().toFloat() * macroRotationTimeRandomness).toLong()
return ran
}

@Slider(
name = "Lock rotation smoothness",
category = "General",
subcategory = "Advanced",
min = 2f,
max = 10f,
)
var macroLockSmoothness: Float = 4f

@Dropdown(
name = "Boss killer movement",
Expand All @@ -187,41 +176,6 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla
@HUD(name = "HUD", category = "HUD")
var hud = SwiftSlayerHud()

fun calculateRotationTime(degrees: Double): Int {
val proportion = degrees / 180.0
return (getRandomRotationTime() * proportion).toInt()
}

fun calculateDegreeDistance(
initialYaw: Double,
initialPitch: Double,
targetYaw: Double,
targetPitch: Double
): Double {
// Calculate angular difference in yaw
val deltaYaw = Math.toDegrees(
atan2(
sin(Math.toRadians(targetYaw - initialYaw)), cos(
Math.toRadians(targetYaw - initialYaw)
)
)
)


val deltaPitch = Math.toDegrees(
atan2(
sin(Math.toRadians(targetPitch - initialPitch)), cos(
Math.toRadians(targetPitch - initialPitch)
)
)
)

val degreeDistance = sqrt(deltaYaw.pow(2.0) + deltaPitch.pow(2.0))

return degreeDistance
}



init {
initialize()
Expand All @@ -232,10 +186,10 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla
hideIf("useHealingAt") { !showAdvanced }
hideIf("macroGuiDelay") { !showAdvanced }
hideIf("macroGuiDelayRandomness") { !showAdvanced }
hideIf("macroRotationTime") { !showAdvanced }
hideIf("macroRotationTimeRandomness") { !showAdvanced }
hideIf("macroLockSmoothness") { !showAdvanced }
hideIf("movementType") { !showAdvanced }
hideIf("debugMode") { !showAdvanced }

hideIf("rangedRange") { mobKillerWeapon != 1}
hideIf("rangedCooldown") { mobKillerWeapon != 1}
}
}
46 changes: 23 additions & 23 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/AbstractMobKiller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package dev.macrohq.swiftslayer.macro
import dev.macrohq.swiftslayer.feature.helper.Angle
import dev.macrohq.swiftslayer.feature.helper.Target
import dev.macrohq.swiftslayer.util.*
import dev.macrohq.swiftslayer.util.rotation.Rotation
import dev.macrohq.swiftslayer.util.rotation.RotationManager
import net.minecraft.entity.EntityLiving
import kotlin.math.abs

abstract class AbstractMobKiller:IMobKiller {
abstract class AbstractMobKiller: IMobKiller {

override var enabled: Boolean = false
override var paused: Boolean = false
Expand Down Expand Up @@ -36,22 +37,16 @@ abstract class AbstractMobKiller:IMobKiller {

override fun lookAtEntity(entity: EntityLiving) {
when (config.mobKillerWeapon) {

0 -> RotationManager.getInstance().rotateTo(entity)
1 -> RotationManager.getInstance().rotateTo(entity)
2 -> {}
3 -> RotationManager.getInstance().rotateTo(entity, 1f)
0 -> RotationManager.getInstance().rotateTo(Rotation(AngleUtil.getAngles(entity).pitch, 90f), 1f)
else -> {
RotationManager.getInstance().rotateTo(entity)
}
}
// Logger.info(time)

}

override fun angleForWeapon(entity: EntityLiving): Angle {
return when (config.mobKillerWeapon) {
0 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0))
1 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0))
3 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0))
else -> Angle(0f,0f)
}
return Angle(0f, 0f)
}
override fun useWeapon() {
when (config.mobKillerWeapon) {
Expand All @@ -71,11 +66,12 @@ abstract class AbstractMobKiller:IMobKiller {

override fun attackDistance(): Int {
return when (config.mobKillerWeapon) {
0 -> 6
1 -> 3
0 -> 3
1 -> config.rangedRange
2 -> 4
3 -> 3
else -> 6
else -> {
4
}
}
}

Expand All @@ -100,12 +96,16 @@ abstract class AbstractMobKiller:IMobKiller {
override fun lookDone(): Boolean {
val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw) - AngleUtil.yawTo360(Target(currentTarget!!).getAngle().yaw))
val pitchDiff = abs(mc.thePlayer.rotationPitch - Target(currentTarget!!).getAngle().pitch)
return when (config.mobKillerWeapon) {
0 -> pitchDiff < 2
1 -> yawDiff < 10 && pitchDiff < 5
2 -> true
3 -> yawDiff < 10 && pitchDiff < 5
else -> true
when(config.mobKillerWeapon) {
1 -> {
return pitchDiff < 2 && yawDiff < 5
}
2 -> {
return pitchDiff < 4 && yawDiff < 10
}
else -> {
return true
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MacroManager {
fun onTick(event: ClientTickEvent) {
if (!enabled || mobKiller.getInstance().enabled || RevBossKiller.getInstance().enabled) return

if(!InventoryUtil.holdItem("Maddox Batphone")) state = State.KILL_MOBS
//if(!InventoryUtil.holdItem("Maddox Batphone")) state = State.KILL_MOBS

when (state) {
State.ACTIVATE_QUEST -> {
Expand All @@ -30,9 +30,7 @@ class MacroManager {
}
}
State.KILL_MOBS -> mobKiller.getInstance().enable()
State.KILL_BOSS -> {
//if (config.slayer == 3) endermanBossKiller.enable()
/* else*/ RevBossKiller.getInstance().enable()
State.KILL_BOSS -> { RevBossKiller.getInstance().enable()
}
}
state = State.entries[(state.ordinal + 1) % State.entries.size] // tf is this for?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RevBossKiller:AbstractBossKiller() {
1 -> { // move back
if(chosenBlock == null || findNewBlock) {
findBlock@
for (block: BlockPos in BlockUtil.getBlocks(BlockPos(mc.thePlayer.posX + mc.thePlayer.getLookVec().xCoord * -25, mc.thePlayer.posY, mc.thePlayer.posZ + mc.thePlayer.getLookVec().zCoord * -25), 15, 5, 15)) {
for (block: BlockPos in BlockUtil.getBlocks(BlockPos(mc.thePlayer.posX + mc.thePlayer.getLookVec().xCoord * -10, mc.thePlayer.posY, mc.thePlayer.posZ + mc.thePlayer.getLookVec().zCoord * -10), 6, 4, 6)) {
if (BlockUtil.getXZDistance(player.getStandingOnCeil(), block) > 6 && BlockUtil.blocksBetweenValid(CalculationContext(SwiftSlayer), player.getStandingOnCeil(), block) && !BlockUtil.isSingleCorner(block)) {
chosenBlock = block
break@findBlock
Expand All @@ -85,7 +85,6 @@ class RevBossKiller:AbstractBossKiller() {
}

MovementState.GOTO_BLOCK -> {
// AutoRotation.disable()
if(chosenBlock == null) {
movState = MovementState.FIND_BLOCK
Logger.info("null block")
Expand All @@ -100,9 +99,8 @@ class RevBossKiller:AbstractBossKiller() {

MovementState.VERIFY_PATHFINDIG -> {

if(blockTimer.isDone) {
if(blockTimer.isDone && SwiftSlayer.config.movementType == 1) {
movState = MovementState.FIND_BLOCK

return
}
//movement type = walking back
Expand Down Expand Up @@ -134,13 +132,8 @@ class RevBossKiller:AbstractBossKiller() {

//movement type = find corner
if(BlockUtil.getXZDistance(player.getStandingOnCeil(), chosenBlock!!) < 1 && SwiftSlayer.config.movementType == 0) {
if(BlockUtil.blocksBetweenValid(CalculationContext(SwiftSlayer), player.getStandingOnCeil(), chosenBlock!!)) {
movState = MovementState.GOTO_BLOCK
} else {
findNewBlock = true
movState = MovementState.FIND_BLOCK
chosenBlock = null
}

return
}
}
Expand Down Expand Up @@ -179,9 +172,14 @@ class RevBossKiller:AbstractBossKiller() {
when (rotState) {
RotationState.LOOK_AT_TARGET -> {
if(!currentTarget!!.onGround) return
if(mc.objectMouseOver.entityHit == null && !rotTimer.isDone) return


lookAtEntity(currentTarget!!)

if(mc.objectMouseOver.entityHit != null) {
rotTimer = Timer(50)
}
}

RotationState.VERIFY_LOOKING -> {
Expand All @@ -200,10 +198,10 @@ class RevBossKiller:AbstractBossKiller() {
}

override fun enable() {
if(SlayerUtil.getBoss() != null) {
currentTarget = SlayerUtil.getBoss()!!.first
if(SlayerUtil.getFakeBoss() != null) {
currentTarget = SlayerUtil.getFakeBoss()
}
if(SlayerUtil.getBoss() == null) return
if(SlayerUtil.getFakeBoss() == null) return

if(currentTarget == null) {
Logger.info("null entity!?")
Expand Down
Loading

0 comments on commit 75bb3f4

Please sign in to comment.