Compare commits

...
Author SHA1 Message Date
tmetcalfe89 380b6d6cee flexibled the passive options
- Fainting doesn't passively heal unless both percent and timer are greater than 0.
- Health doesn't passively heal unless both percent and timer are greater than 0.
- New option to disable passively healing statuses.
2024-08-27 21:13:02 -07:00
2 changed files with 16 additions and 11 deletions

No files matched your search

@@ -92,7 +92,7 @@ open class PlayerPartyStore(
val random = Random.Default val random = Random.Default
for (pokemon in this) { for (pokemon in this) {
// Awake from fainted // Awake from fainted
if (pokemon.isFainted()) { if (pokemon.isFainted() && Cobblemon.config.faintAwakenHealthPercent > 0 && Cobblemon.config.defaultFaintTimer > 0) {
pokemon.faintedTimer -= 1 pokemon.faintedTimer -= 1
if (pokemon.faintedTimer <= -1) { if (pokemon.faintedTimer <= -1) {
val php = ceil(pokemon.hp * Cobblemon.config.faintAwakenHealthPercent) val php = ceil(pokemon.hp * Cobblemon.config.faintAwakenHealthPercent)
@@ -101,24 +101,26 @@ open class PlayerPartyStore(
} }
} }
// Passive healing while less than full health // Passive healing while less than full health
else if (pokemon.currentHealth < pokemon.hp) { else if (pokemon.currentHealth < pokemon.hp && Cobblemon.config.healTimer > 0 && Cobblemon.config.healPercent > 0) {
pokemon.healTimer-- pokemon.healTimer--
if (pokemon.healTimer <= -1) { if (pokemon.healTimer <= -1) {
pokemon.healTimer = Cobblemon.config.healTimer pokemon.healTimer = Cobblemon.config.healTimer
val healAmount = 1.0.coerceAtLeast(pokemon.hp.toDouble() * Cobblemon.config.healPercent) val healAmount = 1.0.coerceAtLeast(pokemon.hp.toDouble() * Cobblemon.config.healPercent)
pokemon.currentHealth = pokemon.currentHealth + round(healAmount).toInt() pokemon.currentHealth += round(healAmount).toInt()
} }
} }
// Statuses // Statuses
val status = pokemon.status if (Cobblemon.config.healPassiveStatuses) {
if (status != null && !player.isSleeping) { val status = pokemon.status
if (status.isExpired()) { if (status != null && !player.isSleeping) {
status.status.onStatusExpire(player, pokemon, random) if (status.isExpired()) {
pokemon.status = null status.status.onStatusExpire(player, pokemon, random)
} else { pokemon.status = null
status.status.onSecondPassed(player, pokemon, random) } else {
status.tickTimer() status.status.onSecondPassed(player, pokemon, random)
status.tickTimer()
}
} }
} }
@@ -147,6 +147,9 @@ class CobblemonConfig {
Statuses.BURN.configEntry() Statuses.BURN.configEntry()
) )
@NodeCategory(Category.PassiveStatus)
var healPassiveStatuses = true
@NodeCategory(Category.Healing) @NodeCategory(Category.Healing)
var infiniteHealerCharge = false var infiniteHealerCharge = false