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

Add energy pots #565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -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,
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
Expand Down