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

Overload fixes and revisions #533

Merged
merged 11 commits into from
May 18, 2024
2 changes: 1 addition & 1 deletion data/map/areas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ wilderness:
x: [ 3327, 3038, 3030, 3030, 3027, 3025, 3020, 3015, 3007, 3000, 2994, 2994, 2945, 2945, 2948, 2951, 2950, 2950, 2948, 2947, 2947, 2945, 2955, 2947, 2945, 2945, 2943, 2941, 2940, 2940, 2940, 3391, 3391, 3381, 3390, 3390, 3386, 3373, 3373, 3382, 3387, 3383, 3385, 3379, 3379, 3387, 3387, 3374, 3374, 3382, 3383, 3391, 3391 ]
y: [ 3524, 3524, 3532, 3533, 3540, 3543, 3546, 3543, 3544, 3536, 3536, 3525, 3525, 3572, 3617, 3623, 3625, 3654, 3657, 3688, 3764, 3824, 3835, 3842, 3862, 3904, 3904, 3906, 3923, 3925, 3969, 3969, 3776, 3761, 3745, 3727, 3724, 3724, 3710, 3708, 3699, 3692, 3683, 3671, 3653, 3648, 3644, 3625, 3609, 3609, 3606, 3592, 3528 ]
tags: [ wilderness ]
main_wilderness_multi_area:
wilderness_main_multi_area:
area:
x: [ 3200, 3392, 3392, 3328, 3328, 3136, 3136, 3192, 3192, 3152, 3152, 3136, 3136, 3112, 3112, 3072, 3072, 3048, 3048, 3056, 3056, 3048, 3048, 3008, 3008, 3200 ]
y: [ 3968, 3968, 3840, 3840, 3520, 3520, 3648, 3648, 3752, 3752, 3840, 3840, 3872, 3872, 3880, 3880, 3896, 3896, 3872, 3872, 3864, 3864, 3856, 3856, 3904, 3904 ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package world.gregs.voidps.world.interact.entity.player.combat.consume.drink

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.entity.character.mode.move.enterArea
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.character.player.chat.ChatType
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.character.setGraphic
Expand All @@ -10,13 +12,17 @@ import world.gregs.voidps.engine.queue.queue
import world.gregs.voidps.engine.timer.timerStart
import world.gregs.voidps.engine.timer.timerStop
import world.gregs.voidps.engine.timer.timerTick
import world.gregs.voidps.engine.timer.toTicks
import world.gregs.voidps.world.interact.entity.combat.hit.directHit
import world.gregs.voidps.world.interact.entity.combat.inWilderness
import world.gregs.voidps.world.interact.entity.player.combat.consume.canConsume

fun inWilderness() = false
import java.util.concurrent.TimeUnit

canConsume("overload*") { player ->
if (player.timers.contains("overload")) {
if (player.inWilderness) {
player.message("You cannot drink an overload potion while you're in the wilderness.", ChatType.Game)
cancel()
} else if (player.timers.contains("overload")) {
player.message("You may only use this potion every five minutes.")
cancel()
} else if (player.levels.get(Skill.Constitution) < 500) {
Expand All @@ -25,17 +31,32 @@ canConsume("overload*") { player ->
}
}

enterArea("wilderness") {
if (!player.timers.contains("overload")) {
return@enterArea
}
for (skill in skills) {
val max = player.levels.get(skill)
val offset = player.levels.getOffset(skill)
val superBoost = (max * if (skill == Skill.Ranged) 0.1 else 0.15).toInt() + (if (skill == Skill.Ranged) 4 else 5)
if (offset > superBoost) {
player.levels.drain(skill, offset - superBoost)
}
}
}

playerSpawn { player ->
if (player["overload_refreshes_remaining", 0] > 0) {
player.timers.restart("overload")
}
}

timerStart("overload") { player ->
interval = 25
interval = TimeUnit.SECONDS.toTicks(15)
if (restart) {
return@timerStart
}
applyBoost(player)
player.queue(name = "overload_hits") {
repeat(5) {
player.directHit(100)
Expand All @@ -51,32 +72,43 @@ timerTick("overload") { player ->
cancel()
return@timerTick
}
if (inWilderness()) {
player.levels.boost(Skill.Attack, 5, 0.15)
player.levels.boost(Skill.Strength, 5, 0.15)
player.levels.boost(Skill.Defence, 5, 0.15)
player.levels.boost(Skill.Magic, 5, 0.15)
player.levels.boost(Skill.Ranged, 5, 0.15)
} else {
player.levels.boost(Skill.Attack, 5, 0.22)
player.levels.boost(Skill.Strength, 5, 0.22)
player.levels.boost(Skill.Defence, 5, 0.22)
player.levels.boost(Skill.Magic, 7)
player.levels.boost(Skill.Ranged, 4, 0.1923)
if (!player.inWilderness) {
applyBoost(player)
}
}

timerStop("overload") { player ->
reset(player, Skill.Attack)
reset(player, Skill.Strength)
reset(player, Skill.Defence)
reset(player, Skill.Magic)
reset(player, Skill.Ranged)
if (logout) {
return@timerStop
}
removeBoost(player)
player.levels.restore(Skill.Constitution, 500)
player.message("<dark_red>The effects of overload have worn off and you feel normal again.")
player["overload_refreshes_remaining"] = 0
}

fun applyBoost(player: Player) {
player.levels.boost(Skill.Attack, 5, 0.22)
player.levels.boost(Skill.Strength, 5, 0.22)
player.levels.boost(Skill.Defence, 5, 0.22)
player.levels.boost(Skill.Magic, 7)
player.levels.boost(Skill.Ranged, 4, 0.1923)
}

val skills = listOf(
Skill.Attack,
Skill.Strength,
Skill.Defence,
Skill.Magic,
Skill.Ranged
)

fun removeBoost(player: Player) {
for (skill in skills) {
reset(player, skill)
}
}

fun reset(player: Player, skill: Skill) {
if (player.levels.getOffset(skill) > 0) {
player.levels.clear(skill)
Expand Down
Loading