diff --git a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/Potion.kt b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/Potion.kt index 569675593..5aa606f27 100644 --- a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/Potion.kt +++ b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/Potion.kt @@ -345,4 +345,24 @@ enum class Potion( replacement = Items.VIAL, potionType = PotionType.SUPER_ANTIPOISON, ), + ENERGY4( + item = Items.ENERGY_POTION_4, + replacement = Items.ENERGY_POTION_3, + potionType = PotionType.ENERGY, + ), + ENERGY3( + item = Items.ENERGY_POTION_3, + replacement = Items.ENERGY_POTION_2, + potionType = PotionType.ENERGY, + ), + ENERGY2( + item = Items.ENERGY_POTION_2, + replacement = Items.ENERGY_POTION_1, + potionType = PotionType.ENERGY, + ), + ENERGY1( + item = Items.ENERGY_POTION_1, + replacement = Items.VIAL, + potionType = PotionType.ENERGY, + ), } diff --git a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/PotionType.kt b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/PotionType.kt index 81db5bb74..a2d40ba61 100644 --- a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/PotionType.kt +++ b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/items/potion/PotionType.kt @@ -8,6 +8,7 @@ import gg.rsmod.plugins.api.Skills import gg.rsmod.plugins.api.ext.heal import gg.rsmod.plugins.api.ext.restorePrayer import gg.rsmod.plugins.content.mechanics.poison.Poison +import gg.rsmod.plugins.content.mechanics.run.RunEnergy import kotlin.math.floor enum class PotionType( @@ -269,6 +270,11 @@ enum class PotionType( override fun apply(p: Player) { applyBoost(p, alteredSkills, alterStrategy) } + }, + ENERGY { + override fun apply(p: Player) { + RunEnergy.renew(p, 20.0) + } }, ; abstract fun apply(p: Player) diff --git a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/mechanics/run/RunEnergy.kt b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/mechanics/run/RunEnergy.kt index ac4fb6d96..60dd9bdaa 100644 --- a/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/mechanics/run/RunEnergy.kt +++ b/game/plugins/src/main/kotlin/gg/rsmod/plugins/content/mechanics/run/RunEnergy.kt @@ -7,6 +7,7 @@ import gg.rsmod.game.model.entity.Player import gg.rsmod.game.model.timer.TimerKey import gg.rsmod.plugins.api.Skills import gg.rsmod.plugins.api.ext.* +import kotlin.math.min import kotlin.math.pow /** @@ -59,6 +60,14 @@ object RunEnergy { } } + fun renew( + p: Player, + amount: Double, + ) { + p.runEnergy = min(100.0, p.runEnergy + amount) + p.sendRunEnergy(p.runEnergy.toInt()) + } + private fun recoverRateWalking(agilityLevel: Int) = agilityLevel.interpolate(0.27, 0.36, 1, 99) private fun recoverRateResting(agilityLevel: Int) = agilityLevel.interpolate(1.68, 2.4, 1, 99)