From 0e5e2b46f20b499af1f3a99282b6ac3a4ea6e7f9 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 13 Sep 2021 22:16:01 -0400 Subject: [PATCH] Changed energy to internally use an integer with a high resolution, and externally to use a float. --- assets/common/abilities/axe/doublestrike.ron | 6 +- assets/common/abilities/axe/leap.ron | 2 +- assets/common/abilities/axe/spin.ron | 2 +- assets/common/abilities/bow/charged.ron | 4 +- assets/common/abilities/bow/repeater.ron | 2 +- assets/common/abilities/bow/shotgun.ron | 2 +- assets/common/abilities/bowsimple/basic.ron | 2 +- .../custom/birdlargebreathe/firebomb.ron | 2 +- .../custom/birdlargefire/firebomb.ron | 2 +- .../custom/birdlargefire/fireshockwave.ron | 2 +- .../abilities/custom/claygolem/laser.ron | 2 +- .../custom/quadlowbeam/lifestealbeam.ron | 2 +- .../common/abilities/custom/turret/arrows.ron | 2 +- assets/common/abilities/hammer/charged.ron | 2 +- assets/common/abilities/hammer/leap.ron | 2 +- .../common/abilities/hammer/singlestrike.ron | 6 +- .../common/abilities/sceptre/healingaura.ron | 2 +- .../abilities/sceptre/lifestealbeam.ron | 2 +- .../common/abilities/sceptre/wardingaura.ron | 2 +- assets/common/abilities/spear/dash.ron | 2 +- .../common/abilities/spear/doublestrike.ron | 2 +- assets/common/abilities/staff/firebomb.ron | 2 +- .../common/abilities/staff/fireshockwave.ron | 2 +- .../common/abilities/staff/flamethrower.ron | 2 +- .../common/abilities/staffsimple/firebomb.ron | 2 +- .../abilities/staffsimple/flamethrower.ron | 2 +- assets/common/abilities/sword/dash.ron | 4 +- assets/common/abilities/sword/spin.ron | 2 +- .../common/abilities/sword/triplestrike.ron | 4 +- assets/common/abilities/swordsimple/dash.ron | 2 +- .../common/items/armor/cloth/druid/back.ron | 2 +- .../common/items/armor/cloth/druid/belt.ron | 2 +- .../common/items/armor/cloth/druid/chest.ron | 2 +- .../common/items/armor/cloth/druid/foot.ron | 2 +- .../common/items/armor/cloth/druid/hand.ron | 2 +- .../common/items/armor/cloth/druid/pants.ron | 2 +- .../items/armor/cloth/druid/shoulder.ron | 2 +- .../common/items/armor/cloth/linen/back.ron | 2 +- .../common/items/armor/cloth/linen/belt.ron | 2 +- .../common/items/armor/cloth/linen/chest.ron | 2 +- .../common/items/armor/cloth/linen/foot.ron | 2 +- .../common/items/armor/cloth/linen/hand.ron | 2 +- .../common/items/armor/cloth/linen/pants.ron | 2 +- .../items/armor/cloth/linen/shoulder.ron | 2 +- .../items/armor/cloth/moonweave/back.ron | 2 +- .../items/armor/cloth/moonweave/belt.ron | 2 +- .../items/armor/cloth/moonweave/chest.ron | 2 +- .../items/armor/cloth/moonweave/foot.ron | 2 +- .../items/armor/cloth/moonweave/hand.ron | 2 +- .../items/armor/cloth/moonweave/pants.ron | 2 +- .../items/armor/cloth/moonweave/shoulder.ron | 2 +- .../common/items/armor/cloth/silken/back.ron | 2 +- .../common/items/armor/cloth/silken/belt.ron | 2 +- .../common/items/armor/cloth/silken/chest.ron | 2 +- .../common/items/armor/cloth/silken/foot.ron | 2 +- .../common/items/armor/cloth/silken/hand.ron | 2 +- .../common/items/armor/cloth/silken/pants.ron | 2 +- .../items/armor/cloth/silken/shoulder.ron | 2 +- .../common/items/armor/cloth/sunsilk/back.ron | 2 +- .../common/items/armor/cloth/sunsilk/belt.ron | 2 +- .../items/armor/cloth/sunsilk/chest.ron | 2 +- .../common/items/armor/cloth/sunsilk/foot.ron | 2 +- .../common/items/armor/cloth/sunsilk/hand.ron | 2 +- .../items/armor/cloth/sunsilk/pants.ron | 2 +- .../items/armor/cloth/sunsilk/shoulder.ron | 2 +- .../common/items/armor/cloth/woolen/back.ron | 2 +- .../common/items/armor/cloth/woolen/belt.ron | 2 +- .../common/items/armor/cloth/woolen/chest.ron | 2 +- .../common/items/armor/cloth/woolen/foot.ron | 2 +- .../common/items/armor/cloth/woolen/hand.ron | 2 +- .../common/items/armor/cloth/woolen/pants.ron | 2 +- .../items/armor/cloth/woolen/shoulder.ron | 2 +- assets/common/items/armor/cultist/belt.ron | 2 +- assets/common/items/armor/cultist/chest.ron | 2 +- assets/common/items/armor/cultist/foot.ron | 2 +- assets/common/items/armor/cultist/hand.ron | 2 +- assets/common/items/armor/cultist/pants.ron | 2 +- .../common/items/armor/cultist/shoulder.ron | 2 +- .../items/armor/misc/back/dungeon_purple.ron | 2 +- .../common/items/armor/misc/ring/emerald.ron | 2 +- assets/common/items/armor/misc/ring/ruby.ron | 2 +- assets/common/items/armor/misc/ring/topaz.ron | 2 +- assets/common/items/armor/pirate/belt.ron | 2 +- assets/common/items/armor/pirate/chest.ron | 2 +- assets/common/items/armor/pirate/foot.ron | 2 +- assets/common/items/armor/pirate/hand.ron | 2 +- assets/common/items/armor/pirate/hat.ron | 2 +- assets/common/items/armor/pirate/pants.ron | 2 +- assets/common/items/armor/pirate/shoulder.ron | 2 +- assets/common/items/armor/witch/back.ron | 2 +- assets/common/items/armor/witch/belt.ron | 2 +- assets/common/items/armor/witch/chest.ron | 2 +- assets/common/items/armor/witch/foot.ron | 2 +- assets/common/items/armor/witch/hand.ron | 2 +- assets/common/items/armor/witch/hat.ron | 2 +- assets/common/items/armor/witch/pants.ron | 2 +- assets/common/items/armor/witch/shoulder.ron | 2 +- assets/common/items/debug/admin.ron | 2 +- .../items/npc_armor/biped_large/warlock.ron | 2 +- common/src/bin/csv_import/main.rs | 2 +- common/src/combat.rs | 43 ++--- common/src/comp/ability.rs | 41 ++--- common/src/comp/body.rs | 18 +- common/src/comp/energy.rs | 174 ++++++++---------- common/src/comp/health.rs | 9 +- common/src/comp/inventory/item/armor.rs | 12 +- common/src/comp/mod.rs | 4 +- common/src/comp/stats.rs | 8 +- common/src/consts.rs | 2 +- common/src/event.rs | 4 +- common/src/states/basic_beam.rs | 14 +- common/src/states/basic_block.rs | 2 +- common/src/states/charged_melee.rs | 20 +- common/src/states/charged_ranged.rs | 17 +- common/src/states/climb.rs | 12 +- common/src/states/dash_melee.rs | 11 +- common/src/states/repeater_ranged.rs | 12 +- common/src/states/spin_melee.rs | 7 +- common/src/states/utils.rs | 2 +- common/systems/src/buff.rs | 10 +- common/systems/src/character_behavior.rs | 5 +- common/systems/src/stats.rs | 38 ++-- server/src/events/entity_manipulation.rs | 16 +- server/src/sys/agent.rs | 24 +-- voxygen/src/hud/bag.rs | 2 +- voxygen/src/hud/buffs.rs | 2 +- voxygen/src/hud/diary.rs | 2 +- voxygen/src/hud/group.rs | 4 +- voxygen/src/hud/overhead.rs | 2 +- voxygen/src/hud/skillbar.rs | 6 +- voxygen/src/ui/widgets/item_tooltip.rs | 15 +- 131 files changed, 336 insertions(+), 416 deletions(-) diff --git a/assets/common/abilities/axe/doublestrike.ron b/assets/common/abilities/axe/doublestrike.ron index 0521ee3cdf..59172a0787 100644 --- a/assets/common/abilities/axe/doublestrike.ron +++ b/assets/common/abilities/axe/doublestrike.ron @@ -45,9 +45,9 @@ ComboMelee( ))), ), ], - initial_energy_gain: 25, - max_energy_gain: 175, - energy_increase: 30, + initial_energy_gain: 2.5, + max_energy_gain: 17.5, + energy_increase: 3.0, speed_increase: 0.1, max_speed_increase: 0.6, scales_from_combo: 2, diff --git a/assets/common/abilities/axe/leap.ron b/assets/common/abilities/axe/leap.ron index 0f93a5672e..a236900af2 100644 --- a/assets/common/abilities/axe/leap.ron +++ b/assets/common/abilities/axe/leap.ron @@ -1,5 +1,5 @@ LeapMelee( - energy_cost: 450, + energy_cost: 45.0, buildup_duration: 0.2, movement_duration: 0.2, swing_duration: 0.2, diff --git a/assets/common/abilities/axe/spin.ron b/assets/common/abilities/axe/spin.ron index 5e314e583f..bc1628de4d 100644 --- a/assets/common/abilities/axe/spin.ron +++ b/assets/common/abilities/axe/spin.ron @@ -12,7 +12,7 @@ SpinMelee( strength: DamageFraction(0.1), chance: 0.1, ))), - energy_cost: 100, + energy_cost: 10.0, is_infinite: true, movement_behavior: AxeHover, is_interruptible: false, diff --git a/assets/common/abilities/bow/charged.ron b/assets/common/abilities/bow/charged.ron index 1f5b071528..4cac8d91fc 100644 --- a/assets/common/abilities/bow/charged.ron +++ b/assets/common/abilities/bow/charged.ron @@ -1,8 +1,8 @@ ChargedRanged( energy_cost: 0, energy_drain: 0, - initial_regen: 5, - scaled_regen: 120, + initial_regen: 0.5, + scaled_regen: 12.0, initial_damage: 0.5, scaled_damage: 14.0, initial_knockback: 0.0, diff --git a/assets/common/abilities/bow/repeater.ron b/assets/common/abilities/bow/repeater.ron index 5a5857a113..ca19187e91 100644 --- a/assets/common/abilities/bow/repeater.ron +++ b/assets/common/abilities/bow/repeater.ron @@ -1,5 +1,5 @@ RepeaterRanged( - energy_cost: 50, + energy_cost: 5.0, buildup_duration: 0.2, shoot_duration: 0.5, recover_duration: 0.8, diff --git a/assets/common/abilities/bow/shotgun.ron b/assets/common/abilities/bow/shotgun.ron index 30d9805bd8..de5111aa40 100644 --- a/assets/common/abilities/bow/shotgun.ron +++ b/assets/common/abilities/bow/shotgun.ron @@ -1,5 +1,5 @@ BasicRanged( - energy_cost: 300, + energy_cost: 30.0, buildup_duration: 0.4, recover_duration: 0.3, projectile_spread: 0.05, diff --git a/assets/common/abilities/bowsimple/basic.ron b/assets/common/abilities/bowsimple/basic.ron index 602741dd20..05cd0597f5 100644 --- a/assets/common/abilities/bowsimple/basic.ron +++ b/assets/common/abilities/bowsimple/basic.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Arrow( damage: 3.5, knockback: 5.0, - energy_regen: 40, + energy_regen: 4.0, ), projectile_body: Object(Arrow), projectile_light: None, diff --git a/assets/common/abilities/custom/birdlargebreathe/firebomb.ron b/assets/common/abilities/custom/birdlargebreathe/firebomb.ron index f91e9f7be0..f3d118976c 100644 --- a/assets/common/abilities/custom/birdlargebreathe/firebomb.ron +++ b/assets/common/abilities/custom/birdlargebreathe/firebomb.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Fireball( damage: 10.0, radius: 5.0, - energy_regen: 50, + energy_regen: 5.0, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/birdlargefire/firebomb.ron b/assets/common/abilities/custom/birdlargefire/firebomb.ron index f91e9f7be0..f3d118976c 100644 --- a/assets/common/abilities/custom/birdlargefire/firebomb.ron +++ b/assets/common/abilities/custom/birdlargefire/firebomb.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Fireball( damage: 10.0, radius: 5.0, - energy_regen: 50, + energy_regen: 5.0, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/birdlargefire/fireshockwave.ron b/assets/common/abilities/custom/birdlargefire/fireshockwave.ron index 2a467cd0b2..36671dc626 100644 --- a/assets/common/abilities/custom/birdlargefire/fireshockwave.ron +++ b/assets/common/abilities/custom/birdlargefire/fireshockwave.ron @@ -1,5 +1,5 @@ Shockwave( - energy_cost: 600, + energy_cost: 60.0, buildup_duration: 0.7, swing_duration: 0.1, recover_duration: 0.2, diff --git a/assets/common/abilities/custom/claygolem/laser.ron b/assets/common/abilities/custom/claygolem/laser.ron index 0a6360260d..cb07b26331 100644 --- a/assets/common/abilities/custom/claygolem/laser.ron +++ b/assets/common/abilities/custom/claygolem/laser.ron @@ -12,7 +12,7 @@ BasicBeam( strength: DamageFraction(0.75), chance: 0.75, ))), - energy_regen: 50, + energy_regen: 0, energy_drain: 0, ori_rate: 0.07, specifier: ClayGolem, diff --git a/assets/common/abilities/custom/quadlowbeam/lifestealbeam.ron b/assets/common/abilities/custom/quadlowbeam/lifestealbeam.ron index bc318299c3..ca19726b1e 100644 --- a/assets/common/abilities/custom/quadlowbeam/lifestealbeam.ron +++ b/assets/common/abilities/custom/quadlowbeam/lifestealbeam.ron @@ -7,7 +7,7 @@ BasicBeam( range: 25.0, max_angle: 1.0, damage_effect: Some(Lifesteal(0.15)), - energy_regen: 25, + energy_regen: 2.5, energy_drain: 0, ori_rate: 0.3, specifier: LifestealBeam, diff --git a/assets/common/abilities/custom/turret/arrows.ron b/assets/common/abilities/custom/turret/arrows.ron index a2aa3546d0..88867de18a 100644 --- a/assets/common/abilities/custom/turret/arrows.ron +++ b/assets/common/abilities/custom/turret/arrows.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Arrow( damage: 20.0, knockback: 5.0, - energy_regen: 100, + energy_regen: 10.0, ), projectile_body: Object(ArrowTurret), projectile_light: None, diff --git a/assets/common/abilities/hammer/charged.ron b/assets/common/abilities/hammer/charged.ron index b9fdb409bd..9d8a737382 100644 --- a/assets/common/abilities/hammer/charged.ron +++ b/assets/common/abilities/hammer/charged.ron @@ -1,6 +1,6 @@ ChargedMelee( energy_cost: 1, - energy_drain: 300, + energy_drain: 30.0, initial_damage: 1.0, scaled_damage: 16.0, initial_poise_damage: 5, diff --git a/assets/common/abilities/hammer/leap.ron b/assets/common/abilities/hammer/leap.ron index ee4d0fc9bc..f36ca54f1d 100644 --- a/assets/common/abilities/hammer/leap.ron +++ b/assets/common/abilities/hammer/leap.ron @@ -1,5 +1,5 @@ LeapMelee( - energy_cost: 500, + energy_cost: 50.0, buildup_duration: 0.1, movement_duration: 0.8, swing_duration: 0.15, diff --git a/assets/common/abilities/hammer/singlestrike.ron b/assets/common/abilities/hammer/singlestrike.ron index 3601cc404b..b5b0d54b84 100644 --- a/assets/common/abilities/hammer/singlestrike.ron +++ b/assets/common/abilities/hammer/singlestrike.ron @@ -15,9 +15,9 @@ ComboMelee( forward_movement: 0.0, damage_kind: Crushing, )], - initial_energy_gain: 50, - max_energy_gain: 150, - energy_increase: 50, + initial_energy_gain: 5.0, + max_energy_gain: 15.0, + energy_increase: 5.0, speed_increase: 0.1, max_speed_increase: 0.4, scales_from_combo: 2, diff --git a/assets/common/abilities/sceptre/healingaura.ron b/assets/common/abilities/sceptre/healingaura.ron index f68e67bfbf..08c7afcad2 100644 --- a/assets/common/abilities/sceptre/healingaura.ron +++ b/assets/common/abilities/sceptre/healingaura.ron @@ -11,7 +11,7 @@ BasicAura( ), aura_duration: 1.0, range: 25.0, - energy_cost: 200, + energy_cost: 20.0, scales_with_combo: true, specifier: HealingAura, ) diff --git a/assets/common/abilities/sceptre/lifestealbeam.ron b/assets/common/abilities/sceptre/lifestealbeam.ron index aa5f31caa4..4c739da0a6 100644 --- a/assets/common/abilities/sceptre/lifestealbeam.ron +++ b/assets/common/abilities/sceptre/lifestealbeam.ron @@ -7,7 +7,7 @@ BasicBeam( range: 25.0, max_angle: 1.0, damage_effect: Some(Lifesteal(0.125)), - energy_regen: 50, + energy_regen: 5.0, energy_drain: 0, ori_rate: 0.3, specifier: LifestealBeam diff --git a/assets/common/abilities/sceptre/wardingaura.ron b/assets/common/abilities/sceptre/wardingaura.ron index 1785bbd971..a39ae2eb52 100644 --- a/assets/common/abilities/sceptre/wardingaura.ron +++ b/assets/common/abilities/sceptre/wardingaura.ron @@ -11,7 +11,7 @@ BasicAura( ), aura_duration: 1.0, range: 25.0, - energy_cost: 400, + energy_cost: 40.0, scales_with_combo: false, specifier: WardingAura, ) diff --git a/assets/common/abilities/spear/dash.ron b/assets/common/abilities/spear/dash.ron index c20f1efa6a..0c295f6734 100644 --- a/assets/common/abilities/spear/dash.ron +++ b/assets/common/abilities/spear/dash.ron @@ -1,5 +1,5 @@ DashMelee( - energy_cost: 100, + energy_cost: 10.0, base_damage: 1.0, scaled_damage: 8.0, base_poise_damage: 0, diff --git a/assets/common/abilities/spear/doublestrike.ron b/assets/common/abilities/spear/doublestrike.ron index 082acb24c7..8d691b76bc 100644 --- a/assets/common/abilities/spear/doublestrike.ron +++ b/assets/common/abilities/spear/doublestrike.ron @@ -47,7 +47,7 @@ ComboMelee( ], initial_energy_gain: 0, max_energy_gain: 0, - energy_increase: 30, + energy_increase: 3.0, speed_increase: 0.0, max_speed_increase: 0.0, scales_from_combo: 2, diff --git a/assets/common/abilities/staff/firebomb.ron b/assets/common/abilities/staff/firebomb.ron index 07c8d16af7..21638365c7 100644 --- a/assets/common/abilities/staff/firebomb.ron +++ b/assets/common/abilities/staff/firebomb.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Fireball( damage: 9.0, radius: 4.0, - energy_regen: 60, + energy_regen: 6.0, ), projectile_body: Object(BoltFire), projectile_speed: 60.0, diff --git a/assets/common/abilities/staff/fireshockwave.ron b/assets/common/abilities/staff/fireshockwave.ron index 2a467cd0b2..36671dc626 100644 --- a/assets/common/abilities/staff/fireshockwave.ron +++ b/assets/common/abilities/staff/fireshockwave.ron @@ -1,5 +1,5 @@ Shockwave( - energy_cost: 600, + energy_cost: 60.0, buildup_duration: 0.7, swing_duration: 0.1, recover_duration: 0.2, diff --git a/assets/common/abilities/staff/flamethrower.ron b/assets/common/abilities/staff/flamethrower.ron index 6cc5091881..bc9b9b5e78 100644 --- a/assets/common/abilities/staff/flamethrower.ron +++ b/assets/common/abilities/staff/flamethrower.ron @@ -13,7 +13,7 @@ BasicBeam( chance: 0.25, ))), energy_regen: 0, - energy_drain: 350, + energy_drain: 35.0, ori_rate: 0.3, specifier: Flamethrower, ) diff --git a/assets/common/abilities/staffsimple/firebomb.ron b/assets/common/abilities/staffsimple/firebomb.ron index f417b8f694..1c8278e077 100644 --- a/assets/common/abilities/staffsimple/firebomb.ron +++ b/assets/common/abilities/staffsimple/firebomb.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Fireball( damage: 6.0, radius: 5.0, - energy_regen: 50, + energy_regen: 5.0, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/staffsimple/flamethrower.ron b/assets/common/abilities/staffsimple/flamethrower.ron index f6dfc11f4e..3762d8c722 100644 --- a/assets/common/abilities/staffsimple/flamethrower.ron +++ b/assets/common/abilities/staffsimple/flamethrower.ron @@ -13,7 +13,7 @@ BasicBeam( chance: 0.25, ))), energy_regen: 0, - energy_drain: 350, + energy_drain: 35.0, ori_rate: 0.3, specifier: Flamethrower, ) diff --git a/assets/common/abilities/sword/dash.ron b/assets/common/abilities/sword/dash.ron index 84c8884584..ac9b370d02 100644 --- a/assets/common/abilities/sword/dash.ron +++ b/assets/common/abilities/sword/dash.ron @@ -1,5 +1,5 @@ DashMelee( - energy_cost: 100, + energy_cost: 10.0, base_damage: 8.0, scaled_damage: 16.0, base_poise_damage: 0, @@ -8,7 +8,7 @@ DashMelee( scaled_knockback: 7.0, range: 4.0, angle: 60.0, - energy_drain: 300, + energy_drain: 30.0, forward_speed: 3.0, buildup_duration: 0.25, charge_duration: 1.2, diff --git a/assets/common/abilities/sword/spin.ron b/assets/common/abilities/sword/spin.ron index 99a541276c..8509c6a9b4 100644 --- a/assets/common/abilities/sword/spin.ron +++ b/assets/common/abilities/sword/spin.ron @@ -12,7 +12,7 @@ SpinMelee( strength: DamageFraction(0.1), chance: 0.1, ))), - energy_cost: 150, + energy_cost: 15.0, is_infinite: false, movement_behavior: ForwardGround, is_interruptible: true, diff --git a/assets/common/abilities/sword/triplestrike.ron b/assets/common/abilities/sword/triplestrike.ron index 20e92526ba..84a55425d2 100644 --- a/assets/common/abilities/sword/triplestrike.ron +++ b/assets/common/abilities/sword/triplestrike.ron @@ -68,8 +68,8 @@ ComboMelee( ), ], initial_energy_gain: 0, - max_energy_gain: 200, - energy_increase: 25, + max_energy_gain: 20.0, + energy_increase: 2.5, speed_increase: 0.1, max_speed_increase: 0.8, scales_from_combo: 2, diff --git a/assets/common/abilities/swordsimple/dash.ron b/assets/common/abilities/swordsimple/dash.ron index 0768c992cf..3cdadb7323 100644 --- a/assets/common/abilities/swordsimple/dash.ron +++ b/assets/common/abilities/swordsimple/dash.ron @@ -1,5 +1,5 @@ DashMelee( - energy_cost: 100, + energy_cost: 10.0, base_damage: 9.0, scaled_damage: 16.0, base_poise_damage: 40, diff --git a/assets/common/items/armor/cloth/druid/back.ron b/assets/common/items/armor/cloth/druid/back.ron index 08087cafea..6cea0b35be 100644 --- a/assets/common/items/armor/cloth/druid/back.ron +++ b/assets/common/items/armor/cloth/druid/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.034, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/belt.ron b/assets/common/items/armor/cloth/druid/belt.ron index 5a747d685a..7bfc4c0825 100644 --- a/assets/common/items/armor/cloth/druid/belt.ron +++ b/assets/common/items/armor/cloth/druid/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.034, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/chest.ron b/assets/common/items/armor/cloth/druid/chest.ron index 44cd558182..dff8c9f0f3 100644 --- a/assets/common/items/armor/cloth/druid/chest.ron +++ b/assets/common/items/armor/cloth/druid/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(18.0), poise_resilience: Normal(0.0), - energy_max: 198, + energy_max: 19.8, energy_reward: 0.2, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/foot.ron b/assets/common/items/armor/cloth/druid/foot.ron index 5d8720c3fe..4dd639a99c 100644 --- a/assets/common/items/armor/cloth/druid/foot.ron +++ b/assets/common/items/armor/cloth/druid/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(6.0), poise_resilience: Normal(0.0), - energy_max: 66, + energy_max: 6.6, energy_reward: 0.067, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/hand.ron b/assets/common/items/armor/cloth/druid/hand.ron index bc5cecde74..3aabca3954 100644 --- a/assets/common/items/armor/cloth/druid/hand.ron +++ b/assets/common/items/armor/cloth/druid/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(6.0), poise_resilience: Normal(0.0), - energy_max: 66, + energy_max: 6.6, energy_reward: 0.067, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/pants.ron b/assets/common/items/armor/cloth/druid/pants.ron index 84a2155e69..70debc99dd 100644 --- a/assets/common/items/armor/cloth/druid/pants.ron +++ b/assets/common/items/armor/cloth/druid/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(12.0), poise_resilience: Normal(0.0), - energy_max: 132, + energy_max: 13.2, energy_reward: 0.134, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/druid/shoulder.ron b/assets/common/items/armor/cloth/druid/shoulder.ron index ff4064d554..d4b442f4d7 100644 --- a/assets/common/items/armor/cloth/druid/shoulder.ron +++ b/assets/common/items/armor/cloth/druid/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(12.0), poise_resilience: Normal(0.0), - energy_max: 132, + energy_max: 13.2, energy_reward: 0.134, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/back.ron b/assets/common/items/armor/cloth/linen/back.ron index 50b30f320c..1caf486e23 100644 --- a/assets/common/items/armor/cloth/linen/back.ron +++ b/assets/common/items/armor/cloth/linen/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(1.0), poise_resilience: Normal(0.0), - energy_max: 8, + energy_max: 0.8, energy_reward: 0.009, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/belt.ron b/assets/common/items/armor/cloth/linen/belt.ron index 0495dc29cb..3c3a9cfb09 100644 --- a/assets/common/items/armor/cloth/linen/belt.ron +++ b/assets/common/items/armor/cloth/linen/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(1.0), poise_resilience: Normal(0.0), - energy_max: 8, + energy_max: 0.8, energy_reward: 0.009, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/chest.ron b/assets/common/items/armor/cloth/linen/chest.ron index f4e386d26b..34980bf48e 100644 --- a/assets/common/items/armor/cloth/linen/chest.ron +++ b/assets/common/items/armor/cloth/linen/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(5.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.051, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/foot.ron b/assets/common/items/armor/cloth/linen/foot.ron index 8712c18208..6d666db6cb 100644 --- a/assets/common/items/armor/cloth/linen/foot.ron +++ b/assets/common/items/armor/cloth/linen/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 17, + energy_max: 1.7, energy_reward: 0.017, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/hand.ron b/assets/common/items/armor/cloth/linen/hand.ron index 77b8e9d35b..77c8cc5091 100644 --- a/assets/common/items/armor/cloth/linen/hand.ron +++ b/assets/common/items/armor/cloth/linen/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 17, + energy_max: 1.7, energy_reward: 0.017, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/pants.ron b/assets/common/items/armor/cloth/linen/pants.ron index ea71095ca9..7261b8ad73 100644 --- a/assets/common/items/armor/cloth/linen/pants.ron +++ b/assets/common/items/armor/cloth/linen/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.034, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/linen/shoulder.ron b/assets/common/items/armor/cloth/linen/shoulder.ron index 2db1b2b460..922b7846b5 100644 --- a/assets/common/items/armor/cloth/linen/shoulder.ron +++ b/assets/common/items/armor/cloth/linen/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.034, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/back.ron b/assets/common/items/armor/cloth/moonweave/back.ron index aca1662b22..dc2e77895b 100644 --- a/assets/common/items/armor/cloth/moonweave/back.ron +++ b/assets/common/items/armor/cloth/moonweave/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(4.0), poise_resilience: Normal(0.0), - energy_max: 41, + energy_max: 4.1, energy_reward: 0.042, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/belt.ron b/assets/common/items/armor/cloth/moonweave/belt.ron index 6c96fad42e..2f0c172f4e 100644 --- a/assets/common/items/armor/cloth/moonweave/belt.ron +++ b/assets/common/items/armor/cloth/moonweave/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(4.0), poise_resilience: Normal(0.0), - energy_max: 41, + energy_max: 4.1, energy_reward: 0.042, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/chest.ron b/assets/common/items/armor/cloth/moonweave/chest.ron index e254605f7e..287d9f916c 100644 --- a/assets/common/items/armor/cloth/moonweave/chest.ron +++ b/assets/common/items/armor/cloth/moonweave/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(23.0), poise_resilience: Normal(0.0), - energy_max: 248, + energy_max: 24.8, energy_reward: 0.252, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/foot.ron b/assets/common/items/armor/cloth/moonweave/foot.ron index 56d10545d9..acae2ffb95 100644 --- a/assets/common/items/armor/cloth/moonweave/foot.ron +++ b/assets/common/items/armor/cloth/moonweave/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(0.0), - energy_max: 83, + energy_max: 8.3, energy_reward: 0.084, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/hand.ron b/assets/common/items/armor/cloth/moonweave/hand.ron index a9e4ae8d00..40b47155f8 100644 --- a/assets/common/items/armor/cloth/moonweave/hand.ron +++ b/assets/common/items/armor/cloth/moonweave/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(0.0), - energy_max: 83, + energy_max: 8.3, energy_reward: 0.084, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/pants.ron b/assets/common/items/armor/cloth/moonweave/pants.ron index 3a62c88d96..b87fdc4f18 100644 --- a/assets/common/items/armor/cloth/moonweave/pants.ron +++ b/assets/common/items/armor/cloth/moonweave/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(17.0), poise_resilience: Normal(0.0), - energy_max: 165, + energy_max: 16.5, energy_reward: 0.168, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/moonweave/shoulder.ron b/assets/common/items/armor/cloth/moonweave/shoulder.ron index 7e66e648dd..310719adec 100644 --- a/assets/common/items/armor/cloth/moonweave/shoulder.ron +++ b/assets/common/items/armor/cloth/moonweave/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(17.0), poise_resilience: Normal(0.0), - energy_max: 165, + energy_max: 16.5, energy_reward: 0.168, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/back.ron b/assets/common/items/armor/cloth/silken/back.ron index e2a085d8da..816626787e 100644 --- a/assets/common/items/armor/cloth/silken/back.ron +++ b/assets/common/items/armor/cloth/silken/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 25, + energy_max: 2.5, energy_reward: 0.025, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/belt.ron b/assets/common/items/armor/cloth/silken/belt.ron index e0c3e2909e..425f4d89cd 100644 --- a/assets/common/items/armor/cloth/silken/belt.ron +++ b/assets/common/items/armor/cloth/silken/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 25, + energy_max: 2.5, energy_reward: 0.025, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/chest.ron b/assets/common/items/armor/cloth/silken/chest.ron index 5241cde002..bdcecee312 100644 --- a/assets/common/items/armor/cloth/silken/chest.ron +++ b/assets/common/items/armor/cloth/silken/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(14.0), poise_resilience: Normal(0.0), - energy_max: 149, + energy_max: 14.9, energy_reward: 0.15, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/foot.ron b/assets/common/items/armor/cloth/silken/foot.ron index faccd273dd..1f8ae1599c 100644 --- a/assets/common/items/armor/cloth/silken/foot.ron +++ b/assets/common/items/armor/cloth/silken/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(5.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.05, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/hand.ron b/assets/common/items/armor/cloth/silken/hand.ron index 58bfc16ae5..8222c32389 100644 --- a/assets/common/items/armor/cloth/silken/hand.ron +++ b/assets/common/items/armor/cloth/silken/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(5.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.05, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/pants.ron b/assets/common/items/armor/cloth/silken/pants.ron index c03f76a11c..01dcd6ac0a 100644 --- a/assets/common/items/armor/cloth/silken/pants.ron +++ b/assets/common/items/armor/cloth/silken/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(9.0), poise_resilience: Normal(0.0), - energy_max: 99, + energy_max: 9.9, energy_reward: 0.1, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/silken/shoulder.ron b/assets/common/items/armor/cloth/silken/shoulder.ron index 9e56ffb2a8..35d25dbc56 100644 --- a/assets/common/items/armor/cloth/silken/shoulder.ron +++ b/assets/common/items/armor/cloth/silken/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(9.0), poise_resilience: Normal(0.0), - energy_max: 99, + energy_max: 9.9, energy_reward: 0.1, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/back.ron b/assets/common/items/armor/cloth/sunsilk/back.ron index 94afc9e513..499dde0ca7 100644 --- a/assets/common/items/armor/cloth/sunsilk/back.ron +++ b/assets/common/items/armor/cloth/sunsilk/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(5.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.05, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/belt.ron b/assets/common/items/armor/cloth/sunsilk/belt.ron index 69c1bf9bae..c871e73458 100644 --- a/assets/common/items/armor/cloth/sunsilk/belt.ron +++ b/assets/common/items/armor/cloth/sunsilk/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(5.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.05, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/chest.ron b/assets/common/items/armor/cloth/sunsilk/chest.ron index 068900625b..e5c2dacc50 100644 --- a/assets/common/items/armor/cloth/sunsilk/chest.ron +++ b/assets/common/items/armor/cloth/sunsilk/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(27.0), poise_resilience: Normal(0.0), - energy_max: 300, + energy_max: 30.0, energy_reward: 0.3, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/foot.ron b/assets/common/items/armor/cloth/sunsilk/foot.ron index fd54b7f249..d72f1f5885 100644 --- a/assets/common/items/armor/cloth/sunsilk/foot.ron +++ b/assets/common/items/armor/cloth/sunsilk/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(9.0), poise_resilience: Normal(0.0), - energy_max: 100, + energy_max: 10.0, energy_reward: 0.1, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/hand.ron b/assets/common/items/armor/cloth/sunsilk/hand.ron index 6aed42b202..659b31a805 100644 --- a/assets/common/items/armor/cloth/sunsilk/hand.ron +++ b/assets/common/items/armor/cloth/sunsilk/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(9.0), poise_resilience: Normal(0.0), - energy_max: 100, + energy_max: 10.0, energy_reward: 0.1, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/pants.ron b/assets/common/items/armor/cloth/sunsilk/pants.ron index 3b2ac44ef9..6970a77e8c 100644 --- a/assets/common/items/armor/cloth/sunsilk/pants.ron +++ b/assets/common/items/armor/cloth/sunsilk/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(18.0), poise_resilience: Normal(0.0), - energy_max: 200, + energy_max: 20.0, energy_reward: 0.2, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/sunsilk/shoulder.ron b/assets/common/items/armor/cloth/sunsilk/shoulder.ron index a8b4fe3c3e..0b77df7347 100644 --- a/assets/common/items/armor/cloth/sunsilk/shoulder.ron +++ b/assets/common/items/armor/cloth/sunsilk/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(18.0), poise_resilience: Normal(0.0), - energy_max: 200, + energy_max: 20.0, energy_reward: 0.2, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/back.ron b/assets/common/items/armor/cloth/woolen/back.ron index 2ce0b243c4..1a72134758 100644 --- a/assets/common/items/armor/cloth/woolen/back.ron +++ b/assets/common/items/armor/cloth/woolen/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 17, + energy_max: 1.7, energy_reward: 0.017, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/belt.ron b/assets/common/items/armor/cloth/woolen/belt.ron index 6f345bbf6c..c9986bafdb 100644 --- a/assets/common/items/armor/cloth/woolen/belt.ron +++ b/assets/common/items/armor/cloth/woolen/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(2.0), poise_resilience: Normal(0.0), - energy_max: 17, + energy_max: 1.7, energy_reward: 0.017, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/chest.ron b/assets/common/items/armor/cloth/woolen/chest.ron index ca2205e2ae..6849484a13 100644 --- a/assets/common/items/armor/cloth/woolen/chest.ron +++ b/assets/common/items/armor/cloth/woolen/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(9.0), poise_resilience: Normal(0.0), - energy_max: 99, + energy_max: 9.9, energy_reward: 0.099, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/foot.ron b/assets/common/items/armor/cloth/woolen/foot.ron index ed6129ef15..10ddd95ed2 100644 --- a/assets/common/items/armor/cloth/woolen/foot.ron +++ b/assets/common/items/armor/cloth/woolen/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.033, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/hand.ron b/assets/common/items/armor/cloth/woolen/hand.ron index 45e9528e72..9d7e0c2319 100644 --- a/assets/common/items/armor/cloth/woolen/hand.ron +++ b/assets/common/items/armor/cloth/woolen/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(3.0), poise_resilience: Normal(0.0), - energy_max: 33, + energy_max: 3.3, energy_reward: 0.033, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/pants.ron b/assets/common/items/armor/cloth/woolen/pants.ron index 4cf18467e1..8f9f6bd5cd 100644 --- a/assets/common/items/armor/cloth/woolen/pants.ron +++ b/assets/common/items/armor/cloth/woolen/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(6.0), poise_resilience: Normal(0.0), - energy_max: 66, + energy_max: 6.6, energy_reward: 0.066, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cloth/woolen/shoulder.ron b/assets/common/items/armor/cloth/woolen/shoulder.ron index bf9a0041f6..4ec9b3f912 100644 --- a/assets/common/items/armor/cloth/woolen/shoulder.ron +++ b/assets/common/items/armor/cloth/woolen/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(6.0), poise_resilience: Normal(0.0), - energy_max: 66, + energy_max: 6.6, energy_reward: 0.066, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/belt.ron b/assets/common/items/armor/cultist/belt.ron index 89619d4ac0..39662f95b5 100644 --- a/assets/common/items/armor/cultist/belt.ron +++ b/assets/common/items/armor/cultist/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(1.0), - energy_max: 20, + energy_max: 2.0, energy_reward: 0.025, crit_power: 0.02, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/chest.ron b/assets/common/items/armor/cultist/chest.ron index a20727ed72..218ae54668 100644 --- a/assets/common/items/armor/cultist/chest.ron +++ b/assets/common/items/armor/cultist/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(48.0), poise_resilience: Normal(6.0), - energy_max: 135, + energy_max: 13.5, energy_reward: 0.135, crit_power: 0.125, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/foot.ron b/assets/common/items/armor/cultist/foot.ron index 0e396bf4f1..2d93397bf6 100644 --- a/assets/common/items/armor/cultist/foot.ron +++ b/assets/common/items/armor/cultist/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/hand.ron b/assets/common/items/armor/cultist/hand.ron index f9e140b28f..63148ed4b1 100644 --- a/assets/common/items/armor/cultist/hand.ron +++ b/assets/common/items/armor/cultist/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/pants.ron b/assets/common/items/armor/cultist/pants.ron index 022ce3e037..2b0e9536c4 100644 --- a/assets/common/items/armor/cultist/pants.ron +++ b/assets/common/items/armor/cultist/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(4.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/cultist/shoulder.ron b/assets/common/items/armor/cultist/shoulder.ron index 8aa550f853..67e2509f5f 100644 --- a/assets/common/items/armor/cultist/shoulder.ron +++ b/assets/common/items/armor/cultist/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/misc/back/dungeon_purple.ron b/assets/common/items/armor/misc/back/dungeon_purple.ron index 7f7a7dd305..aa786891e3 100644 --- a/assets/common/items/armor/misc/back/dungeon_purple.ron +++ b/assets/common/items/armor/misc/back/dungeon_purple.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(1.0), - energy_max: 20, + energy_max: 2.0, energy_reward: 0.025, crit_power: 0.02, stealth: 0.0, diff --git a/assets/common/items/armor/misc/ring/emerald.ron b/assets/common/items/armor/misc/ring/emerald.ron index 16b7ba430c..ed668c9a8a 100644 --- a/assets/common/items/armor/misc/ring/emerald.ron +++ b/assets/common/items/armor/misc/ring/emerald.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(0.0), poise_resilience: Normal(0.0), - energy_max: 100, + energy_max: 10.0, energy_reward: 0.0, crit_power: -0.025, stealth: 0.0, diff --git a/assets/common/items/armor/misc/ring/ruby.ron b/assets/common/items/armor/misc/ring/ruby.ron index 9f2d8b147d..92d98e1db2 100644 --- a/assets/common/items/armor/misc/ring/ruby.ron +++ b/assets/common/items/armor/misc/ring/ruby.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(0.0), poise_resilience: Normal(0.0), - energy_max: -100, + energy_max: -10.0, energy_reward: 0.05, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/misc/ring/topaz.ron b/assets/common/items/armor/misc/ring/topaz.ron index 4156ca723a..f8d01214df 100644 --- a/assets/common/items/armor/misc/ring/topaz.ron +++ b/assets/common/items/armor/misc/ring/topaz.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(0.0), poise_resilience: Normal(0.0), - energy_max: 50, + energy_max: 5.0, energy_reward: 0.00, crit_power: 0.0, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/belt.ron b/assets/common/items/armor/pirate/belt.ron index 0357a62dfa..f13cc7568d 100644 --- a/assets/common/items/armor/pirate/belt.ron +++ b/assets/common/items/armor/pirate/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(1.0), - energy_max: 20, + energy_max: 2.0, energy_reward: 0.025, crit_power: 0.02, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/chest.ron b/assets/common/items/armor/pirate/chest.ron index ef04ede29a..6c0d4dee30 100644 --- a/assets/common/items/armor/pirate/chest.ron +++ b/assets/common/items/armor/pirate/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(48.0), poise_resilience: Normal(6.0), - energy_max: 135, + energy_max: 13.5, energy_reward: 0.135, crit_power: 0.125, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/foot.ron b/assets/common/items/armor/pirate/foot.ron index 0a4cb0d41b..2f114392f3 100644 --- a/assets/common/items/armor/pirate/foot.ron +++ b/assets/common/items/armor/pirate/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/hand.ron b/assets/common/items/armor/pirate/hand.ron index f79a1ede29..a51a6f63a1 100644 --- a/assets/common/items/armor/pirate/hand.ron +++ b/assets/common/items/armor/pirate/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/hat.ron b/assets/common/items/armor/pirate/hat.ron index 531f6d437f..1dafd9addd 100644 --- a/assets/common/items/armor/pirate/hat.ron +++ b/assets/common/items/armor/pirate/hat.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/pants.ron b/assets/common/items/armor/pirate/pants.ron index 06647a6cce..9022213d11 100644 --- a/assets/common/items/armor/pirate/pants.ron +++ b/assets/common/items/armor/pirate/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(4.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/pirate/shoulder.ron b/assets/common/items/armor/pirate/shoulder.ron index 81d40d728d..e52e84f27e 100644 --- a/assets/common/items/armor/pirate/shoulder.ron +++ b/assets/common/items/armor/pirate/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/witch/back.ron b/assets/common/items/armor/witch/back.ron index 18cd167dbe..eec0b31826 100644 --- a/assets/common/items/armor/witch/back.ron +++ b/assets/common/items/armor/witch/back.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/witch/belt.ron b/assets/common/items/armor/witch/belt.ron index 0f371fc99c..6f6c065ef9 100644 --- a/assets/common/items/armor/witch/belt.ron +++ b/assets/common/items/armor/witch/belt.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(8.0), poise_resilience: Normal(1.0), - energy_max: 20, + energy_max: 2.0, energy_reward: 0.025, crit_power: 0.02, stealth: 0.0, diff --git a/assets/common/items/armor/witch/chest.ron b/assets/common/items/armor/witch/chest.ron index 801df9f900..d5e9ac441d 100644 --- a/assets/common/items/armor/witch/chest.ron +++ b/assets/common/items/armor/witch/chest.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(48.0), poise_resilience: Normal(6.0), - energy_max: 135, + energy_max: 13.5, energy_reward: 0.135, crit_power: 0.125, stealth: 0.0, diff --git a/assets/common/items/armor/witch/foot.ron b/assets/common/items/armor/witch/foot.ron index 4459722774..389514b9f9 100644 --- a/assets/common/items/armor/witch/foot.ron +++ b/assets/common/items/armor/witch/foot.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/witch/hand.ron b/assets/common/items/armor/witch/hand.ron index 7f17d65f3a..132f58f02a 100644 --- a/assets/common/items/armor/witch/hand.ron +++ b/assets/common/items/armor/witch/hand.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(16.0), poise_resilience: Normal(2.0), - energy_max: 45, + energy_max: 4.5, energy_reward: 0.045, crit_power: 0.04, stealth: 0.0, diff --git a/assets/common/items/armor/witch/hat.ron b/assets/common/items/armor/witch/hat.ron index 1a679bcfe4..9c07c78e4e 100644 --- a/assets/common/items/armor/witch/hat.ron +++ b/assets/common/items/armor/witch/hat.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/witch/pants.ron b/assets/common/items/armor/witch/pants.ron index 1b19308180..a8ca56d496 100644 --- a/assets/common/items/armor/witch/pants.ron +++ b/assets/common/items/armor/witch/pants.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(4.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/armor/witch/shoulder.ron b/assets/common/items/armor/witch/shoulder.ron index 59121af896..de1070c7ad 100644 --- a/assets/common/items/armor/witch/shoulder.ron +++ b/assets/common/items/armor/witch/shoulder.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(32.0), poise_resilience: Normal(5.0), - energy_max: 90, + energy_max: 9.0, energy_reward: 0.1, crit_power: 0.08, stealth: 0.0, diff --git a/assets/common/items/debug/admin.ron b/assets/common/items/debug/admin.ron index 851f7e20df..3b8ddd1a58 100644 --- a/assets/common/items/debug/admin.ron +++ b/assets/common/items/debug/admin.ron @@ -7,7 +7,7 @@ ItemDef( stats: ( protection: Invincible, poise_resilience: Invincible, - energy_max: 9000, + energy_max: 900.0, energy_reward: 9.0, crit_power: 0.0, stealth: 1000.0, diff --git a/assets/common/items/npc_armor/biped_large/warlock.ron b/assets/common/items/npc_armor/biped_large/warlock.ron index c144ad8c1a..3ebd816020 100644 --- a/assets/common/items/npc_armor/biped_large/warlock.ron +++ b/assets/common/items/npc_armor/biped_large/warlock.ron @@ -6,7 +6,7 @@ ItemDef( stats: ( protection: Normal(250.0), poise_resilience: Normal(1.0), - energy_max: 1000, + energy_max: 100.0, energy_reward: 1.0, crit_power: 0.0, stealth: 0.0, diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index 67f10dfa87..671d8b766b 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -122,7 +122,7 @@ fn armor_stats() -> Result<(), Box> { "Could not unwrap max energy value for {:?}", item.item_definition_id() ); - 0 + 0.0 }; let energy_reward = if let Some(energy_reward_raw) = diff --git a/common/src/combat.rs b/common/src/combat.rs index 104d65a206..cdd5be06c6 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -12,8 +12,8 @@ use crate::{ }, poise::PoiseChange, skills::SkillGroupKind, - Alignment, Body, CharacterState, Combo, Energy, EnergyChange, EnergySource, Health, - HealthChange, Inventory, Ori, Player, Poise, SkillSet, Stats, + Alignment, Body, CharacterState, Combo, Energy, Health, HealthChange, Inventory, Ori, + Player, Poise, SkillSet, Stats, }, event::ServerEvent, outcome::Outcome, @@ -251,12 +251,7 @@ impl Attack { if let Some(attacker) = attacker { emit(ServerEvent::EnergyChange { entity: attacker.entity, - change: EnergyChange { - amount: (*ec - * compute_energy_reward_mod(attacker.inventory)) - as i32, - source: EnergySource::HitEnemy, - }, + change: *ec * compute_energy_reward_mod(attacker.inventory), }); } }, @@ -335,14 +330,11 @@ impl Attack { .. }) = attacker { - let sufficient_energy = e.current() as f32 >= *r; + let sufficient_energy = e.current() >= *r; if sufficient_energy { emit(ServerEvent::EnergyChange { entity, - change: EnergyChange { - amount: -(*r as i32), - source: EnergySource::Ability, - }, + change: -*r, }); } @@ -387,11 +379,7 @@ impl Attack { if let Some(attacker) = attacker { emit(ServerEvent::EnergyChange { entity: attacker.entity, - change: EnergyChange { - amount: (ec * compute_energy_reward_mod(attacker.inventory)) - as i32, - source: EnergySource::HitEnemy, - }, + change: ec * compute_energy_reward_mod(attacker.inventory), }); } }, @@ -915,10 +903,8 @@ pub fn combat_rating( / 100.0 / (1.0 - Damage::compute_damage_reduction(Some(inventory), None, None)).max(0.00001); - let energy_rating = energy.maximum() as f32 - * (1.0 + compute_max_energy_mod(energy, Some(inventory))) - * compute_energy_reward_mod(Some(inventory)) - / 200.0; + // Assumes a "standard" max energy of 100 and energy reward multiplier of 1.0 + let energy_rating = 5.0 * energy.maximum() * compute_energy_reward_mod(Some(inventory)) / 100.0; let poise_rating = 10.0 / (1.0 - Poise::compute_poise_damage_reduction(inventory)).max(0.00001); @@ -986,12 +972,12 @@ pub fn compute_energy_reward_mod(inventory: Option<&Inventory>) -> f32 { }) } -/// Computes the modifier that should be applied to max energy from the +/// Computes the additive modifier that should be applied to max energy from the /// currently equipped items #[cfg(not(target_arch = "wasm32"))] -pub fn compute_max_energy_mod(energy: &Energy, inventory: Option<&Inventory>) -> f32 { +pub fn compute_max_energy_mod(inventory: Option<&Inventory>) -> f32 { // Defaults to a value of 0 if no inventory is present - let energy_increase = inventory.map_or(0, |inv| { + inventory.map_or(0.0, |inv| { inv.equipped_items() .filter_map(|item| { if let ItemKind::Armor(armor) = &item.kind() { @@ -1001,10 +987,5 @@ pub fn compute_max_energy_mod(energy: &Energy, inventory: Option<&Inventory>) -> } }) .sum() - }); - // Returns the energy increase divided by base max of energy. - // This value is then added to the max_energy_modifier field on stats component. - // Adding is important here, as it ensures that a flat modifier is applied - // correctly. - energy_increase as f32 / energy.base_max() as f32 + }) } diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index e95fbadfe9..1669418d67 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -6,7 +6,7 @@ use crate::{ inventory::item::tool::{Stats, ToolKind}, projectile::ProjectileConstructor, skills::{self, SKILL_MODIFIERS}, - Body, CharacterState, EnergySource, LightEmitter, StateUpdate, + Body, CharacterState, LightEmitter, StateUpdate, }, states::{ behavior::JoinData, @@ -336,10 +336,7 @@ impl CharacterAbility { CharacterAbility::Roll { energy_cost, .. } => { data.physics.on_ground.is_some() && data.inputs.move_dir.magnitude_squared() > 0.25 - && update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) - .is_ok() + && update.energy.try_change_by(-*energy_cost).is_ok() }, CharacterAbility::DashMelee { energy_cost, .. } | CharacterAbility::BasicMelee { energy_cost, .. } @@ -349,20 +346,15 @@ impl CharacterAbility { | CharacterAbility::ChargedMelee { energy_cost, .. } | CharacterAbility::Shockwave { energy_cost, .. } | CharacterAbility::BasicBlock { energy_cost, .. } - | CharacterAbility::SelfBuff { energy_cost, .. } => update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) - .is_ok(), + | CharacterAbility::SelfBuff { energy_cost, .. } => { + update.energy.try_change_by(-*energy_cost).is_ok() + }, // Consumes energy within state, so value only checked before entering state CharacterAbility::RepeaterRanged { energy_cost, .. } => { - update.energy.current() as f32 >= *energy_cost + update.energy.current() >= *energy_cost }, CharacterAbility::LeapMelee { energy_cost, .. } => { - update.vel.0.z >= 0.0 - && update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) - .is_ok() + update.vel.0.z >= 0.0 && update.energy.try_change_by(-*energy_cost).is_ok() }, CharacterAbility::BasicAura { energy_cost, @@ -370,10 +362,7 @@ impl CharacterAbility { .. } => { ((*scales_with_combo && data.combo.counter() > 0) | !*scales_with_combo) - && update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) - .is_ok() + && update.energy.try_change_by(-*energy_cost).is_ok() }, CharacterAbility::ComboMelee { .. } | CharacterAbility::Boost { .. } @@ -386,7 +375,7 @@ impl CharacterAbility { pub fn default_roll() -> CharacterAbility { CharacterAbility::Roll { - energy_cost: 120.0, + energy_cost: 12.0, buildup_duration: 0.05, movement_duration: 0.33, recover_duration: 0.125, @@ -856,7 +845,7 @@ impl CharacterAbility { self } - pub fn get_energy_cost(&self) -> u32 { + pub fn get_energy_cost(&self) -> f32 { use CharacterAbility::*; match self { BasicMelee { energy_cost, .. } @@ -871,19 +860,19 @@ impl CharacterAbility { | Shockwave { energy_cost, .. } | BasicAura { energy_cost, .. } | BasicBlock { energy_cost, .. } - | SelfBuff { energy_cost, .. } => *energy_cost as u32, + | SelfBuff { energy_cost, .. } => *energy_cost, BasicBeam { energy_drain, .. } => { if *energy_drain > f32::EPSILON { - 1 + 1.0 } else { - 0 + 0.0 } }, Boost { .. } | ComboMelee { .. } | Blink { .. } | BasicSummon { .. } - | SpriteSummon { .. } => 0, + | SpriteSummon { .. } => 0.0, } } @@ -1620,7 +1609,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { recover_duration: Duration::from_secs_f32(*recover_duration), max_angle: *max_angle, block_strength: *block_strength, - energy_cost: *energy_cost as i32, + energy_cost: *energy_cost, ability_info, }, timer: Duration::default(), diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index fe389bae7e..e4cfc07e56 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -474,20 +474,20 @@ impl Body { /// Height from the bottom to the top (in metres) pub fn height(&self) -> f32 { self.dimensions().z } - pub fn base_energy(&self) -> u32 { + pub fn base_energy(&self) -> u16 { match self { Body::BipedLarge(biped_large) => match biped_large.species { - biped_large::Species::Dullahan => 4000, - _ => 3000, + biped_large::Species::Dullahan => 400, + _ => 300, }, Body::BirdLarge(body) => match body.species { - bird_large::Species::Cockatrice => 4000, - bird_large::Species::Phoenix => 6000, - bird_large::Species::Roc => 5000, - bird_large::Species::FlameWyvern => 6000, + bird_large::Species::Cockatrice => 400, + bird_large::Species::Phoenix => 600, + bird_large::Species::Roc => 500, + bird_large::Species::FlameWyvern => 600, }, - Body::Humanoid(_) => 750, - _ => 1000, + Body::Humanoid(_) => 75, + _ => 100, } } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index 0451625a9d..4fad5479f9 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -1,128 +1,110 @@ -use crate::{comp::Body, consts::ENERGY_PER_LEVEL}; +use crate::{comp, consts::ENERGY_PER_LEVEL}; use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; +use std::ops::Mul; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +/// Energy is represented by u32s within the module, but treated as a float by +/// the rest of the game. +// As a general rule, all input and output values to public functions should be +// floats rather than integers. pub struct Energy { + // Current and base_max are scaled by 256 within this module compared to what is visible to + // outside this module. The scaling is done to allow energy to function as a fixed point while + // still having the advantages of being an integer. The scaling of 256 was chosen so that max + // energy could be u16::MAX - 1, and then the scaled energy could fit inside an f32 with no + // precision loss + /// Current energy is how much energy the entity currently has current: u32, + /// Base max is the amount of energy the entity has without considering + /// temporary modifiers such as buffs base_max: u32, + /// Maximum is the amount of energy the entity has after temporary modifiers + /// are considered maximum: u32, pub regen_rate: f32, - pub last_change: Option<(i32, f64, EnergySource)>, -} - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] -pub enum EnergySource { - Ability, - Climb, - LevelUp, - HitEnemy, - Regen, - Revive, - Unknown, -} - -#[derive(Debug)] -pub enum StatChangeError { - Underflow, - Overflow, } impl Energy { - pub fn new(body: Body, level: u16) -> Energy { - let mut energy = Energy::empty(); + /// Used when comparisons to energy are needed outside this module. + // This value is chosen as anything smaller than this is more precise than our + // units of energy. + pub const ENERGY_EPSILON: f32 = 0.5 / Self::MAX_SCALED_ENERGY as f32; + /// Maximum value allowed for energy before scaling + const MAX_ENERGY: u16 = u16::MAX - 1; + /// The maximum value allowed for current and maximum energy + /// Maximum value is (u16:MAX - 1) * 256, which only requires 24 bits. This + /// can fit into an f32 with no loss to precision + // Cast to u32 done as u32::from cannot be called inside constant + const MAX_SCALED_ENERGY: u32 = Self::MAX_ENERGY as u32 * Self::SCALING_FACTOR_INT; + /// The amount energy is scaled by within this module + const SCALING_FACTOR_FLOAT: f32 = 256.; + const SCALING_FACTOR_INT: u32 = Self::SCALING_FACTOR_FLOAT as u32; - energy.update_max_energy(Some(body), level); - energy.set_to(energy.maximum(), EnergySource::Revive); + /// Returns the current value of energy casted to a float + pub fn current(&self) -> f32 { self.current as f32 / Self::SCALING_FACTOR_FLOAT } - energy - } + /// Returns the base maximum value of energy casted to a float + pub fn base_max(&self) -> f32 { self.base_max as f32 / Self::SCALING_FACTOR_FLOAT } - pub fn empty() -> Self { - Energy { - current: 0, - maximum: 0, - base_max: 0, - regen_rate: 0.0, - last_change: None, - } - } + /// Returns the maximum value of energy casted to a float + pub fn maximum(&self) -> f32 { self.maximum as f32 / Self::SCALING_FACTOR_FLOAT } - pub fn current(&self) -> u32 { self.current } + /// Returns the fraction of energy an entity has remaining + pub fn fraction(&self) -> f32 { self.current() / self.maximum().max(1.0) } - pub fn base_max(&self) -> u32 { self.base_max } - - pub fn maximum(&self) -> u32 { self.maximum } - - pub fn set_to(&mut self, amount: u32, cause: EnergySource) { - let amount = amount.min(self.maximum); - self.last_change = Some((amount as i32 - self.current as i32, 0.0, cause)); - self.current = amount; - } - - pub fn change_by(&mut self, change: EnergyChange) { - self.current = ((self.current as i32 + change.amount).max(0) as u32).min(self.maximum); - self.last_change = Some((change.amount, 0.0, change.source)); - } - - /// This function changes the modified max energy value, not the base energy - /// value. The modified energy value takes into account buffs and other - /// temporary changes to max energy. - pub fn set_maximum(&mut self, amount: u32) { - self.maximum = amount; + /// Updates the maximum value for energy + pub fn update_maximum(&mut self, modifiers: comp::stats::StatsModifier) { + let maximum = modifiers + .compute_maximum(self.base_max()) + .mul(Self::SCALING_FACTOR_FLOAT) + // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 + .clamp(0.0, Self::MAX_SCALED_ENERGY as f32) as u32; + self.maximum = maximum; self.current = self.current.min(self.maximum); } - /// Scales the temporary max energy by a modifier. - pub fn scale_maximum(&mut self, scaled: f32) { - let scaled_max = (self.base_max as f32 * scaled) as u32; - self.set_maximum(scaled_max); + pub fn new(body: comp::Body, level: u16) -> Self { + let energy = u32::from( + body.base_energy() + .saturating_add(ENERGY_PER_LEVEL.saturating_mul(level)), + ) * Self::SCALING_FACTOR_INT; + Energy { + current: energy, + base_max: energy, + maximum: energy, + regen_rate: 0.0, + } } - pub fn try_change_by( - &mut self, - amount: i32, - cause: EnergySource, - ) -> Result<(), StatChangeError> { - if self.current as i32 + amount < 0 { - Err(StatChangeError::Underflow) - } else if self.current as i32 + amount > self.maximum as i32 { - Err(StatChangeError::Overflow) + pub fn change_by(&mut self, change: f32) { + self.current = (((self.current() + change).clamp(0.0, f32::from(Self::MAX_ENERGY)) + * Self::SCALING_FACTOR_FLOAT) as u32) + .min(self.maximum); + } + + #[allow(clippy::result_unit_err)] + pub fn try_change_by(&mut self, change: f32) -> Result<(), ()> { + let new_val = self.current() + change; + if new_val < 0.0 || new_val > self.maximum() { + Err(()) } else { - self.change_by(EnergyChange { - amount, - source: cause, - }); + self.change_by(change); Ok(()) } } - pub fn update_max_energy(&mut self, body: Option, level: u16) { - if let Some(body) = body { - // Checks the current difference between maximum and base max - let current_difference = self.maximum as i32 - self.base_max as i32; - // Sets base max to new value based off of new level provided - self.base_max = body.base_energy() + ENERGY_PER_LEVEL * level as u32; - // Calculates new maximum by adding difference to new base max - let new_maximum = (self.base_max as i32 + current_difference).max(0) as u32; - // Sets maximum to calculated value - self.set_maximum(new_maximum); - // Awards energy - self.change_by(EnergyChange { - amount: ENERGY_PER_LEVEL as i32, - source: EnergySource::LevelUp, - }); - } + pub fn update_max_energy(&mut self, body: comp::Body, level: u16) { + let old_max = self.base_max; + self.base_max = u32::from( + body.base_energy() + .saturating_add(ENERGY_PER_LEVEL.saturating_mul(level)), + ) * Self::SCALING_FACTOR_INT; + self.current = (self.current + self.base_max - old_max).min(self.maximum); } - /// Returns the fraction of energy an entity has remaining - pub fn fraction(&self) -> f32 { self.current as f32 / self.maximum.max(1) as f32 } -} - -pub struct EnergyChange { - pub amount: i32, - pub source: EnergySource, + pub fn refresh(&mut self) { self.current = self.maximum; } } impl Component for Energy { diff --git a/common/src/comp/health.rs b/common/src/comp/health.rs index 3e2d69ac99..fbe7927b0e 100644 --- a/common/src/comp/health.rs +++ b/common/src/comp/health.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage}; #[cfg(not(target_arch = "wasm32"))] use specs_idvs::IdvStorage; +use std::ops::Mul; /// Specifies what and how much changed current health #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] @@ -78,12 +79,13 @@ impl Health { /// Updates the maximum value for health pub fn update_maximum(&mut self, modifiers: comp::stats::StatsModifier) { let maximum = modifiers - .compute_maximum(self.base_max as f32) + .compute_maximum(self.base_max()) + .mul(Self::SCALING_FACTOR_FLOAT) // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 .clamp(0.0, Self::MAX_SCALED_HEALTH as f32) as u32; self.maximum = maximum; // Clamp the current health to enforce the current <= maximum invariant. - self.current = self.current.min(maximum); + self.current = self.current.min(self.maximum); } #[cfg(not(target_arch = "wasm32"))] @@ -119,8 +121,7 @@ impl Health { #[cfg(not(target_arch = "wasm32"))] pub fn change_by(&mut self, change: HealthChange) { self.current = (((self.current() + change.amount).clamp(0.0, f32::from(Self::MAX_HEALTH)) - as u32 - * Self::SCALING_FACTOR_INT) as u32) + * Self::SCALING_FACTOR_FLOAT) as u32) .min(self.maximum); self.last_change = (0.0, change); } diff --git a/common/src/comp/inventory/item/armor.rs b/common/src/comp/inventory/item/armor.rs index 13b7b9cced..80ac97f12a 100644 --- a/common/src/comp/inventory/item/armor.rs +++ b/common/src/comp/inventory/item/armor.rs @@ -35,9 +35,7 @@ pub struct Stats { /// poise damage reduction using (prot / (60 + prot)) poise_resilience: Protection, /// Energy max is summed, and then applied directly to the max energy stat - /// (multiply values by 10 for expected results, as energy internally is 10x - /// larger to allow smaller changes to occur with an integer) - energy_max: i32, + energy_max: f32, /// Energy recovery is summed, and then added to 1.0. When attacks reward /// energy, it is then multiplied by this value before the energy is /// rewarded. @@ -54,7 +52,7 @@ impl Stats { pub fn new( protection: Protection, poise_resilience: Protection, - energy_max: i32, + energy_max: f32, energy_reward: f32, crit_power: f32, stealth: f32, @@ -73,7 +71,7 @@ impl Stats { pub fn poise_resilience(&self) -> Protection { self.poise_resilience } - pub fn energy_max(&self) -> i32 { self.energy_max } + pub fn energy_max(&self) -> f32 { self.energy_max } pub fn energy_reward(&self) -> f32 { self.energy_reward } @@ -145,7 +143,7 @@ impl Armor { pub fn poise_resilience(&self) -> Protection { self.stats.poise_resilience } - pub fn energy_max(&self) -> i32 { self.stats.energy_max } + pub fn energy_max(&self) -> f32 { self.stats.energy_max } pub fn energy_reward(&self) -> f32 { self.stats.energy_reward } @@ -164,7 +162,7 @@ impl Armor { stats: Stats { protection, poise_resilience, - energy_max: 0, + energy_max: 0.0, energy_reward: 0.0, crit_power: 0.0, stealth: 0.0, diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index be6b7d5c4e..c41978ddcd 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -72,7 +72,7 @@ pub use self::{ InputKind, InventoryAction, InventoryEvent, InventoryManip, MountState, Mounting, UtteranceKind, }, - energy::{Energy, EnergyChange, EnergySource}, + energy::Energy, fluid_dynamics::Fluid, group::Group, inputs::CanBuild, @@ -95,7 +95,7 @@ pub use self::{ projectile::{Projectile, ProjectileConstructor}, shockwave::{Shockwave, ShockwaveHitEntities}, skills::{Skill, SkillGroup, SkillGroupKind, SkillSet}, - stats::Stats, + stats::{Stats, StatsModifier}, visual::{LightAnimation, LightEmitter}, }; diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index d1a20c91a7..cdbdb4655a 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -31,7 +31,7 @@ impl StatsModifier { } pub fn update_maximum(&self) -> bool { - self.add_mod > 0.0 || (self.mult_mod - 1.0).abs() > f32::EPSILON + self.add_mod.abs() > f32::EPSILON || (self.mult_mod - 1.0).abs() > f32::EPSILON } } @@ -53,7 +53,7 @@ pub struct Stats { pub move_speed_modifier: f32, pub attack_speed_modifier: f32, pub friction_modifier: f32, - pub max_energy_modifier: f32, + pub max_energy_modifiers: StatsModifier, } impl Stats { @@ -65,7 +65,7 @@ impl Stats { move_speed_modifier: 1.0, attack_speed_modifier: 1.0, friction_modifier: 1.0, - max_energy_modifier: 1.0, + max_energy_modifiers: StatsModifier::default(), } } @@ -80,7 +80,7 @@ impl Stats { self.move_speed_modifier = 1.0; self.attack_speed_modifier = 1.0; self.friction_modifier = 1.0; - self.max_energy_modifier = 1.0; + self.max_energy_modifiers = StatsModifier::default(); } } diff --git a/common/src/consts.rs b/common/src/consts.rs index 48c0adfaac..00afd49eaa 100644 --- a/common/src/consts.rs +++ b/common/src/consts.rs @@ -28,5 +28,5 @@ pub const MIN_RECOMMENDED_TOKIO_THREADS: usize = 2; pub const SOUND_TRAVEL_DIST_PER_VOLUME: f32 = 3.0; // Stat increase per level (multiplied by 10 compared to what you'll see in UI) -pub const ENERGY_PER_LEVEL: u32 = 50; +pub const ENERGY_PER_LEVEL: u16 = 5; pub const HUMANOID_HP_PER_LEVEL: u16 = 5; diff --git a/common/src/event.rs b/common/src/event.rs index cdc068cba3..6dfe89f24b 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -162,7 +162,7 @@ pub enum ServerEvent { }, EnergyChange { entity: EcsEntity, - change: comp::EnergyChange, + change: f32, }, ComboChange { entity: EcsEntity, @@ -170,7 +170,7 @@ pub enum ServerEvent { }, Parry { entity: EcsEntity, - energy_cost: i32, + energy_cost: f32, }, RequestSiteInfo { entity: EcsEntity, diff --git a/common/src/states/basic_beam.rs b/common/src/states/basic_beam.rs index a9da6c3f24..5ec392b5aa 100644 --- a/common/src/states/basic_beam.rs +++ b/common/src/states/basic_beam.rs @@ -3,10 +3,7 @@ use crate::{ Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageKind, DamageSource, GroupTarget, }, - comp::{ - beam, body::biped_large, Body, CharacterState, EnergyChange, EnergySource, Ori, Pos, - StateUpdate, - }, + comp::{beam, body::biped_large, Body, CharacterState, Ori, Pos, StateUpdate}, event::ServerEvent, states::{ behavior::{CharacterBehavior, JoinData}, @@ -98,7 +95,7 @@ impl CharacterBehavior for Data { StageSection::Action => { if input_is_pressed(data, self.static_data.ability_info.input) && (self.static_data.energy_drain <= f32::EPSILON - || update.energy.current() > 0) + || update.energy.current() > 0.0) { let speed = self.static_data.range / self.static_data.beam_duration.as_secs_f32(); @@ -185,10 +182,9 @@ impl CharacterBehavior for Data { }); // Consumes energy if there's enough left and ability key is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain * data.dt.0); } else { update.character = CharacterState::BasicBeam(Data { timer: Duration::default(), diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index bfbcaf51d5..273f9d8ab3 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -20,7 +20,7 @@ pub struct StaticData { /// What key is used to press ability pub ability_info: AbilityInfo, /// Energy consumed to initiate the block - pub energy_cost: i32, + pub energy_cost: f32, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/states/charged_melee.rs b/common/src/states/charged_melee.rs index f3c480f6da..5d3ca259e4 100644 --- a/common/src/states/charged_melee.rs +++ b/common/src/states/charged_melee.rs @@ -1,6 +1,6 @@ use crate::{ combat::{Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement}, - comp::{tool::ToolKind, CharacterState, EnergyChange, EnergySource, Melee, StateUpdate}, + comp::{tool::ToolKind, CharacterState, Melee, StateUpdate}, event::LocalEvent, outcome::Outcome, states::{ @@ -79,7 +79,7 @@ impl CharacterBehavior for Data { match self.stage_section { StageSection::Charge => { if input_is_pressed(data, self.static_data.ability_info.input) - && update.energy.current() as f32 >= self.static_data.energy_cost + && update.energy.current() >= self.static_data.energy_cost && self.timer < self.static_data.charge_duration { let charge = (self.timer.as_secs_f32() @@ -94,12 +94,11 @@ impl CharacterBehavior for Data { }); // Consumes energy if there's enough left and RMB is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain * data.dt.0); } else if input_is_pressed(data, self.static_data.ability_info.input) - && update.energy.current() as f32 >= self.static_data.energy_cost + && update.energy.current() >= self.static_data.energy_cost { // Maintains charge update.character = CharacterState::ChargedMelee(Data { @@ -108,10 +107,9 @@ impl CharacterBehavior for Data { }); // Consumes energy if there's enough left and RMB is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0 / 5.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain as f32 * data.dt.0 / 5.0); } else { // Transitions to swing update.character = CharacterState::ChargedMelee(Data { diff --git a/common/src/states/charged_ranged.rs b/common/src/states/charged_ranged.rs index c435d3695d..cbe3dfc482 100644 --- a/common/src/states/charged_ranged.rs +++ b/common/src/states/charged_ranged.rs @@ -1,7 +1,6 @@ use crate::{ comp::{ - projectile::ProjectileConstructor, Body, CharacterState, EnergyChange, EnergySource, - LightEmitter, Pos, StateUpdate, + projectile::ProjectileConstructor, Body, CharacterState, LightEmitter, Pos, StateUpdate, }, event::ServerEvent, states::{ @@ -147,10 +146,9 @@ impl CharacterBehavior for Data { }); // Consumes energy if there's enough left and input is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain * data.dt.0); } else if input_is_pressed(data, self.static_data.ability_info.input) { // Holds charge update.character = CharacterState::ChargedRanged(Data { @@ -159,10 +157,9 @@ impl CharacterBehavior for Data { }); // Consumes energy if there's enough left and RMB is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0 / 5.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain * data.dt.0 / 5.0); } }, StageSection::Recover => { diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index e0d2ddfb11..0ccd3bd106 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ skills::{ClimbSkill::*, Skill, SKILL_MODIFIERS}, - CharacterState, Climb, EnergySource, InputKind, Ori, StateUpdate, + CharacterState, Climb, InputKind, Ori, StateUpdate, }, consts::GRAVITY, event::LocalEvent, @@ -46,7 +46,7 @@ impl Default for Data { fn default() -> Self { Data { static_data: StaticData { - energy_cost: 5.0, + energy_cost: 15.0, movement_speed: 5.0, }, } @@ -91,14 +91,14 @@ impl CharacterBehavior for Data { // Expend energy if climbing let energy_use = match climb { - Climb::Up => self.static_data.energy_cost as i32, - Climb::Down => 1, - Climb::Hold => 1, + Climb::Up => self.static_data.energy_cost, + Climb::Down => 1.0, + Climb::Hold => 1.0, }; if update .energy - .try_change_by(-energy_use, EnergySource::Climb) + .try_change_by(-energy_use * data.dt.0) .is_err() { update.character = CharacterState::Idle {}; diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index d616c30b3c..efe2ddcfdc 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -1,6 +1,6 @@ use crate::{ combat::{Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement}, - comp::{tool::ToolKind, CharacterState, EnergyChange, EnergySource, Melee, StateUpdate}, + comp::{tool::ToolKind, CharacterState, Melee, StateUpdate}, states::{ behavior::{CharacterBehavior, JoinData}, utils::*, @@ -102,7 +102,7 @@ impl CharacterBehavior for Data { if self.timer < self.charge_end_timer && (input_is_pressed(data, self.static_data.ability_info.input) || (self.auto_charge && self.timer < self.static_data.charge_duration)) - && update.energy.current() > 0 + && update.energy.current() > 0.0 { // Forward movement let charge_frac = (self.timer.as_secs_f32() @@ -233,10 +233,9 @@ impl CharacterBehavior for Data { } // Consumes energy if there's enough left and charge has not stopped - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32, - source: EnergySource::Ability, - }); + update + .energy + .change_by(-self.static_data.energy_drain * data.dt.0); } else { // Transitions to swing section of stage update.character = CharacterState::DashMelee(Data { diff --git a/common/src/states/repeater_ranged.rs b/common/src/states/repeater_ranged.rs index a3606b9991..8e498d3ecb 100644 --- a/common/src/states/repeater_ranged.rs +++ b/common/src/states/repeater_ranged.rs @@ -1,8 +1,5 @@ use crate::{ - comp::{ - Body, CharacterState, EnergyChange, EnergySource, LightEmitter, Pos, ProjectileConstructor, - StateUpdate, - }, + comp::{Body, CharacterState, LightEmitter, Pos, ProjectileConstructor, StateUpdate}, event::ServerEvent, states::{ behavior::{CharacterBehavior, JoinData}, @@ -85,7 +82,7 @@ impl CharacterBehavior for Data { ..*self }); } else if input_is_pressed(data, self.static_data.ability_info.input) - && update.energy.current() as f32 >= self.static_data.energy_cost + && update.energy.current() >= self.static_data.energy_cost { // Fire if input is pressed still let (crit_chance, crit_mult) = @@ -114,10 +111,7 @@ impl CharacterBehavior for Data { // Removes energy from character when arrow is fired update.server_events.push_front(ServerEvent::EnergyChange { entity: data.entity, - change: EnergyChange { - amount: -self.static_data.energy_cost as i32, - source: EnergySource::Ability, - }, + change: -self.static_data.energy_cost, }); // Sets new speed of shoot. Scales based off of the number of projectiles fired. diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index e8372abcec..5baf929409 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -3,7 +3,7 @@ use crate::{ Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageKind, DamageSource, GroupTarget, Knockback, }, - comp::{tool::ToolKind, CharacterState, EnergyChange, EnergySource, Melee, StateUpdate}, + comp::{tool::ToolKind, CharacterState, Melee, StateUpdate}, consts::GRAVITY, states::{ behavior::{CharacterBehavior, JoinData}, @@ -185,10 +185,7 @@ impl CharacterBehavior for Data { ..*self }); // Consumes energy if there's enough left and RMB is held down - update.energy.change_by(EnergyChange { - amount: -(self.static_data.energy_cost as i32), - source: EnergySource::Ability, - }); + update.energy.change_by(-self.static_data.energy_cost); } else { // Transitions to recover section of stage update.character = CharacterState::SpinMelee(Data { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index ddcfa0312b..9d1d4ffb69 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -597,7 +597,7 @@ pub fn handle_climb(data: &JoinData<'_>, update: &mut StateUpdate) -> bool { .unwrap_or(false) //&& update.vel.0.z < 0.0 && data.body.can_climb() - && update.energy.current() > 100 + && update.energy.current() > 10.0 { update.character = CharacterState::Climb(climb::Data::create_adjusted_by_skills(data)); true diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index 76f5927757..a99d26b3d6 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -6,7 +6,7 @@ use common::{ Buffs, }, fluid_dynamics::{Fluid, LiquidKind}, - Energy, Health, HealthChange, Inventory, LightEmitter, ModifierKind, PhysicsState, Stats, + Health, HealthChange, Inventory, LightEmitter, ModifierKind, PhysicsState, Stats, }, event::{EventBus, ServerEvent}, resources::DeltaTime, @@ -28,7 +28,6 @@ pub struct ReadData<'a> { inventories: ReadStorage<'a, Inventory>, healths: ReadStorage<'a, Health>, physics_states: ReadStorage<'a, PhysicsState>, - energies: ReadStorage<'a, Energy>, } #[derive(Default)] @@ -74,10 +73,9 @@ impl<'a> System<'a> for Sys { light_emitters.remove(entity); } } - for (entity, mut buff_comp, energy, mut stat, health, physics_state) in ( + for (entity, mut buff_comp, mut stat, health, physics_state) in ( &read_data.entities, &mut buffs, - &read_data.energies, &mut stats, &read_data.healths, read_data.physics_states.maybe(), @@ -228,10 +226,10 @@ impl<'a> System<'a> for Sys { }, BuffEffect::MaxEnergyModifier { value, kind } => match kind { ModifierKind::Additive => { - stat.max_energy_modifier += *value / (energy.base_max() as f32); + stat.max_energy_modifiers.add_mod += *value; }, ModifierKind::Fractional => { - stat.max_energy_modifier *= *value; + stat.max_energy_modifiers.mult_mod *= *value; }, }, BuffEffect::DamageReduction(dr) => { diff --git a/common/systems/src/character_behavior.rs b/common/systems/src/character_behavior.rs index d78b319b7d..1ff200a097 100644 --- a/common/systems/src/character_behavior.rs +++ b/common/systems/src/character_behavior.rs @@ -312,10 +312,7 @@ impl Sys { *join.vel = state_update.vel; *join.ori = state_update.ori; *join.density = state_update.density; - // Note: might be changed every tick by timer anyway - if *join.energy != state_update.energy { - *join.energy = state_update.energy - }; + *join.energy = state_update.energy; join.controller .queued_inputs .append(&mut state_update.queued_inputs); diff --git a/common/systems/src/stats.rs b/common/systems/src/stats.rs index 4c821dbc9d..2101f37f33 100644 --- a/common/systems/src/stats.rs +++ b/common/systems/src/stats.rs @@ -3,8 +3,8 @@ use common::{ comp::{ self, skills::{GeneralSkill, Skill}, - Body, CharacterState, Combo, Energy, EnergyChange, EnergySource, Health, Inventory, Poise, - PoiseChange, PoiseSource, Pos, SkillSet, Stats, + Body, CharacterState, Combo, Energy, Health, Inventory, Poise, PoiseChange, PoiseSource, + Pos, SkillSet, Stats, StatsModifier, }, event::{EventBus, ServerEvent}, outcome::Outcome, @@ -18,7 +18,7 @@ use specs::{ }; use vek::Vec3; -const ENERGY_REGEN_ACCEL: f32 = 10.0; +const ENERGY_REGEN_ACCEL: f32 = 1.0; const POISE_REGEN_ACCEL: f32 = 2.0; #[derive(SystemData)] @@ -121,23 +121,23 @@ impl<'a> System<'a> for Sys { health.update_maximum(stat.max_health_modifiers); } - let (change_energy, energy_scaling) = { + let (change_energy, energy_mods) = { // Calculates energy scaling from stats and inventory - let new_energy_scaling = - combat::compute_max_energy_mod(&energy, inventory) + stat.max_energy_modifier; - let current_energy_scaling = energy.maximum() as f32 / energy.base_max() as f32; - // Only changes energy if new modifier different from old modifer - // TODO: Look into using wider threshold incase floating point imprecision makes - // this always true + let energy_mods = StatsModifier { + add_mod: stat.max_energy_modifiers.add_mod + + combat::compute_max_energy_mod(inventory), + mult_mod: stat.max_energy_modifiers.mult_mod, + }; ( - (current_energy_scaling - new_energy_scaling).abs() > f32::EPSILON, - new_energy_scaling, + energy_mods.update_maximum() + || (energy.base_max() - energy.maximum()).abs() > Energy::ENERGY_EPSILON, + energy_mods, ) }; // If modifier sufficiently different, mutably access energy if change_energy { - energy.scale_maximum(energy_scaling); + energy.update_maximum(energy_mods); } let skills_to_level = skill_set @@ -184,7 +184,7 @@ impl<'a> System<'a> for Sys { .skill_level(Skill::General(GeneralSkill::EnergyIncrease)) .unwrap_or(None) .unwrap_or(0); - energy.update_max_energy(Some(*body), energy_level); + energy.update_max_energy(*body, energy_level); skill_set.modify_energy = false; } } @@ -209,14 +209,8 @@ impl<'a> System<'a> for Sys { if res { let energy = &mut *energy; - // Have to account for Calc I differential equations due to acceleration - energy.change_by(EnergyChange { - amount: (energy.regen_rate * dt + ENERGY_REGEN_ACCEL * dt.powi(2) / 2.0) - as i32, - source: EnergySource::Regen, - }); - energy.regen_rate = - (energy.regen_rate + ENERGY_REGEN_ACCEL * dt).min(100.0); + energy.change_by(energy.regen_rate * dt); + energy.regen_rate = (energy.regen_rate + ENERGY_REGEN_ACCEL * dt).min(10.0); } let res_poise = { poise.current() < poise.maximum() }; diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 1386657929..66333056ee 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -17,9 +17,8 @@ use common::{ self, aura, buff, chat::{KillSource, KillType}, inventory::item::MaterialStatManifest, - object, Alignment, Auras, Body, CharacterState, Energy, EnergyChange, EnergySource, Group, - Health, HealthChange, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, SkillSet, - Stats, + object, Alignment, Auras, Body, CharacterState, Energy, Group, Health, HealthChange, + Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, SkillSet, Stats, }, event::{EventBus, ServerEvent}, lottery::{LootSpec, Lottery}, @@ -342,7 +341,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt .get_mut(entity) .map(|mut energy| { let energy = &mut *energy; - energy.set_to(energy.maximum(), comp::EnergySource::Revive) + energy.refresh() }); let _ = state .ecs() @@ -1130,7 +1129,7 @@ pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::Bu } } -pub fn handle_energy_change(server: &Server, entity: EcsEntity, change: EnergyChange) { +pub fn handle_energy_change(server: &Server, entity: EcsEntity, change: f32) { let ecs = &server.state.ecs(); if let Some(mut energy) = ecs.write_storage::().get_mut(entity) { energy.change_by(change); @@ -1196,16 +1195,13 @@ pub fn handle_combo_change(server: &Server, entity: EcsEntity, change: i32) { } } -pub fn handle_parry(server: &Server, entity: EcsEntity, energy_cost: i32) { +pub fn handle_parry(server: &Server, entity: EcsEntity, energy_cost: f32) { let ecs = &server.state.ecs(); if let Some(mut character) = ecs.write_storage::().get_mut(entity) { *character = CharacterState::Wielding; }; if let Some(mut energy) = ecs.write_storage::().get_mut(entity) { - energy.change_by(EnergyChange { - amount: energy_cost, - source: EnergySource::Ability, - }); + energy.change_by(energy_cost); } } diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index c8112b25ca..2dc9432bb4 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -2136,12 +2136,12 @@ impl<'a> AgentData<'a> { .actions .push(ControlAction::CancelInput(InputKind::Secondary)); agent.action_state.timer = 0.0; - } else if agent.action_state.timer > 2.5 && has_energy(10) { + } else if agent.action_state.timer > 2.5 && has_energy(10.0) { controller .actions .push(ControlAction::basic_input(InputKind::Secondary)); agent.action_state.timer += read_data.dt.0; - } else if has_leap() && has_energy(450) && thread_rng().gen_bool(0.5) { + } else if has_leap() && has_energy(45.0) && thread_rng().gen_bool(0.5) { controller .actions .push(ControlAction::basic_input(InputKind::Ability(0))); @@ -2156,7 +2156,7 @@ impl<'a> AgentData<'a> { self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None); if attack_data.dist_sqrd < 32.0f32.powi(2) && has_leap() - && has_energy(500) + && has_energy(50.0) && can_see_tgt( &read_data.terrain, self.pos, @@ -2212,7 +2212,7 @@ impl<'a> AgentData<'a> { .actions .push(ControlAction::basic_input(InputKind::Secondary)); agent.action_state.timer += read_data.dt.0; - } else if has_leap() && has_energy(500) && thread_rng().gen_bool(0.9) { + } else if has_leap() && has_energy(50.0) && thread_rng().gen_bool(0.9) { use_leap(controller); agent.action_state.timer += read_data.dt.0; } else { @@ -2225,7 +2225,7 @@ impl<'a> AgentData<'a> { self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None); if attack_data.dist_sqrd < 32.0f32.powi(2) && has_leap() - && has_energy(500) + && has_energy(50.0) && can_see_tgt( &read_data.terrain, self.pos, @@ -2262,7 +2262,7 @@ impl<'a> AgentData<'a> { .skill_set .has_skill(Skill::Sword(SwordSkill::UnlockSpin)) && agent.action_state.timer < 2.0 - && self.energy.current() > 600 + && self.energy.current() > 60.0 { controller .actions @@ -2317,7 +2317,7 @@ impl<'a> AgentData<'a> { ) { const MIN_CHARGE_FRAC: f32 = 0.5; const OPTIMAL_TARGET_VELOCITY: f32 = 5.0; - const DESIRED_ENERGY_LEVEL: u32 = 500; + const DESIRED_ENERGY_LEVEL: f32 = 50.0; // Logic to use abilities if let CharacterState::ChargedRanged(c) = self.char_state { if !matches!(c.stage_section, StageSection::Recover) { @@ -2339,7 +2339,7 @@ impl<'a> AgentData<'a> { } // Else don't send primary input to release the shot } - } else if matches!(self.char_state, CharacterState::RepeaterRanged(c) if self.energy.current() > 50 && !matches!(c.stage_section, StageSection::Recover)) + } else if matches!(self.char_state, CharacterState::RepeaterRanged(c) if self.energy.current() > 5.0 && !matches!(c.stage_section, StageSection::Recover)) { // If in repeater ranged, have enough energy, and aren't in recovery, try to // keep firing @@ -2360,7 +2360,7 @@ impl<'a> AgentData<'a> { if self .skill_set .has_skill(Skill::Bow(BowSkill::UnlockShotgun)) - && self.energy.current() > 450 + && self.energy.current() > 45.0 && thread_rng().gen_bool(0.5) { // Use shotgun if target close and have sufficient energy @@ -2635,7 +2635,7 @@ impl<'a> AgentData<'a> { tgt_data: &TargetData, read_data: &ReadData, ) { - const DESIRED_ENERGY_LEVEL: u32 = 500; + const DESIRED_ENERGY_LEVEL: f32 = 50.0; const DESIRED_COMBO_LEVEL: u32 = 8; // Logic to use abilities if attack_data.dist_sqrd > attack_data.min_attack_dist.powi(2) @@ -3535,7 +3535,7 @@ impl<'a> AgentData<'a> { self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None); } // If energy higher than 600 and random chance - else if self.energy.current() > 600 && thread_rng().gen_bool(0.4) { + else if self.energy.current() > 60.0 && thread_rng().gen_bool(0.4) { // Shockwave controller .actions @@ -3642,7 +3642,7 @@ impl<'a> AgentData<'a> { controller.inputs.move_z = 1.0; } else if attack_data.dist_sqrd > (3.0 * attack_data.min_attack_dist).powi(2) { self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None); - } else if self.energy.current() > 600 + } else if self.energy.current() > 60.0 && agent.action_state.timer < 3.0 && attack_data.angle < 15.0 { diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index f2f8126ae4..8c9c2d81bc 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -897,7 +897,7 @@ impl<'a> Widget for Bag<'a> { as i32 ); let health_txt = format!("{}", self.health.maximum().round() as usize); - let energy_txt = format!("{}", (self.energy.maximum() as f32 / 10.0) as usize); + let energy_txt = format!("{}", self.energy.maximum().round() as usize); let combat_rating_txt = format!("{}", (combat_rating * 10.0) as usize); let stun_res_txt = format!( "{}", diff --git a/voxygen/src/hud/buffs.rs b/voxygen/src/hud/buffs.rs index b8b9bece57..1b1c8c094f 100644 --- a/voxygen/src/hud/buffs.rs +++ b/voxygen/src/hud/buffs.rs @@ -131,7 +131,7 @@ impl<'a> Widget for BuffsBar<'a> { || (self.health.current() - self.health.maximum()).abs() > Health::HEALTH_EPSILON || decayed_health > 0.0; let show_energy = self.global_state.settings.interface.always_show_bars - || self.energy.current() != self.energy.maximum(); + || (self.energy.current() - self.energy.maximum()).abs() > Energy::ENERGY_EPSILON; let offset = if show_energy && show_health { 140.0 } else if show_health || show_energy { diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index a179878555..e00c598d50 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -2100,7 +2100,7 @@ fn general_skill_strings(skill: GeneralSkill, i18n: &Localization) -> (&str, Cow i18n, "hud.skill.inc_energy_title", "hud.skill.inc_energy", - ENERGY_PER_LEVEL / 10, + u32::from(ENERGY_PER_LEVEL), ), } } diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index d519bc6fb0..2f4069f448 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -489,10 +489,10 @@ impl<'a> Widget for Group<'a> { .color(if is_leader { ERROR_COLOR } else { GROUP_COLOR }) .w(300.0) // limit name length display .set(state.ids.member_panels_txt[i], ui); - let stam_perc = energy.current() as f64 / energy.maximum() as f64; + let stam_perc = energy.current() / energy.maximum(); // Energy Image::new(self.imgs.bar_content) - .w_h(100.0 * stam_perc, 8.0) + .w_h(100.0 * f64::from(stam_perc), 8.0) .color(Some(STAMINA_COLOR)) .top_left_with_margins_on(state.ids.member_panels_bg[i], 26.0, 2.0) .set(state.ids.member_energy[i], ui); diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index be6aa772c2..e021a92d81 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -390,7 +390,7 @@ impl<'a> Widget for Overhead<'a> { // % Mana Filling if let Some(energy) = energy { - let energy_factor = energy.current() as f64 / energy.maximum() as f64; + let energy_factor = f64::from(energy.current() / energy.maximum()); let size_factor = energy_factor * BARSIZE; let w = if self.in_group { 80.0 * size_factor diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index d9e763eee9..71362c9b51 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -380,7 +380,7 @@ impl<'a> Skillbar<'a> { let show_health = self.global_state.settings.interface.always_show_bars || (self.health.current() - self.health.maximum()).abs() > Health::HEALTH_EPSILON; let show_energy = self.global_state.settings.interface.always_show_bars - || self.energy.current() != self.energy.maximum(); + || (self.energy.current() - self.energy.maximum()).abs() > Energy::ENERGY_EPSILON; let decayed_health = 1.0 - self.health.maximum() as f64 / self.health.base_max() as f64; if show_health && !self.health.is_dead || decayed_health > 0.0 { @@ -465,8 +465,8 @@ impl<'a> Skillbar<'a> { ), format!( "{}/{}", - (self.energy.current() / 10) as u32, - (self.energy.maximum() / 10) as u32 + self.energy.current().round() as u32, + self.energy.maximum().round() as u32 ), )) } else if let BarNumbers::Percent = bar_values { diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index 86c3ef1ad4..b7e11cbe26 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -8,9 +8,12 @@ use crate::hud::{ use client::Client; use common::{ combat, - comp::item::{ - armor::{ArmorKind, Protection}, - Item, ItemDesc, ItemKind, ItemTag, MaterialStatManifest, Quality, + comp::{ + item::{ + armor::{ArmorKind, Protection}, + Item, ItemDesc, ItemKind, ItemTag, MaterialStatManifest, Quality, + }, + Energy, }, trade::SitePrices, }; @@ -734,7 +737,7 @@ impl<'a> Widget for ItemTooltip<'a> { // Armour let protection = armor.protection(); let poise_res = armor.poise_resilience(); - let energy_max = armor.energy_max() / 10; + let energy_max = armor.energy_max(); let energy_reward = armor.energy_reward() * 10.0; let crit_power = armor.crit_power(); let stealth = armor.stealth(); @@ -890,8 +893,8 @@ impl<'a> Widget for ItemTooltip<'a> { diff_text(text, poise_res_diff.1, 0) } - if diff.energy_max() != 0.0 as i32 { - let text = format!("{} {}", &energy_max_diff.0, diff.energy_max() / 10); + if diff.energy_max() > Energy::ENERGY_EPSILON { + let text = format!("{} {:.1}", &energy_max_diff.0, diff.energy_max()); diff_text(text, energy_max_diff.1, 1) }