diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 762ff7b200..453d1cb786 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -5,8 +5,7 @@ use crate::{ self, aura, beam, buff, inventory::item::tool::{Stats, ToolKind}, projectile::ProjectileConstructor, - skills::{self, Boost}, - Body, CharacterState, EnergySource, LightEmitter, StateUpdate, + skills, Body, CharacterState, EnergySource, LightEmitter, StateUpdate, }, states::{ behavior::JoinData, @@ -785,22 +784,22 @@ impl CharacterAbility { ref mut charge_through, .. } => { - skills::adjust_with_level(skillset, Sword(DCost), |m, level| { - *energy_cost *= m.powi(level.into()) - }); - skills::adjust_with_level(skillset, Sword(DDrain), |m, level| { - *energy_drain *= m.powi(level.into()) - }); - skills::adjust_with_level(skillset, Sword(DDamage), |m, level| { - *base_damage *= m.powi(level.into()) - }); - skills::adjust_with_level(skillset, Sword(DScaling), |m, level| { - *scaled_damage *= m.powi(level.into()) - }); - skills::set_if_has(skillset, Sword(DSpeed), |m| { - *forward_speed *= m; - }); *is_interruptible = skillset.has_skill(Sword(InterruptingAttacks)); + if let Ok(Some(level)) = skillset.skill_level(Sword(DCost)) { + *energy_cost *= 0.75_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sword(DDrain)) { + *energy_drain *= 0.75_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sword(DDamage)) { + *base_damage *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sword(DScaling)) { + *scaled_damage *= 1.2_f32.powi(level.into()); + } + if skillset.has_skill(Sword(DSpeed)) { + *forward_speed *= 1.15; + } *charge_through = skillset.has_skill(Sword(DInfinite)); }, SpinMelee { @@ -811,16 +810,16 @@ impl CharacterAbility { ref mut num_spins, .. } => { - skills::adjust_with_level(skillset, Sword(SDamage), |m, level| { - *base_damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sword(SSpeed), |m, level| { - *swing_duration *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sword(SCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); *is_interruptible = skillset.has_skill(Sword(InterruptingAttacks)); + if let Ok(Some(level)) = skillset.skill_level(Sword(SDamage)) { + *base_damage *= 1.4_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sword(SSpeed)) { + *swing_duration *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sword(SCost)) { + *energy_cost *= 0.75_f32.powi(level.into()); + } *num_spins = skillset .skill_level(Sword(SSpins)) .unwrap_or(None) @@ -877,21 +876,21 @@ impl CharacterAbility { ref mut movement_behavior, .. } => { - skills::adjust_with_level(skillset, Axe(SDamage), |m, level| { - *base_damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Axe(SSpeed), |m, level| { - *swing_duration *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Axe(SCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); *is_infinite = skillset.has_skill(Axe(SInfinite)); *movement_behavior = if skillset.has_skill(Axe(SHelicopter)) { spin_melee::MovementBehavior::AxeHover } else { spin_melee::MovementBehavior::ForwardGround }; + if let Ok(Some(level)) = skillset.skill_level(Axe(SDamage)) { + *base_damage *= 1.3_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Axe(SSpeed)) { + *swing_duration *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Axe(SCost)) { + *energy_cost *= 0.75_f32.powi(level.into()); + } }, LeapMelee { ref mut base_damage, @@ -901,19 +900,19 @@ impl CharacterAbility { ref mut vertical_leap_strength, .. } => { - skills::adjust_with_level(skillset, Axe(LDamage), |m, level| { - *base_damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Axe(LKnockback), |m, level| { - *knockback *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Axe(LCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Axe(LDistance), |m, level| { - *forward_leap_strength *= m.powi(level.into()); - *vertical_leap_strength *= m.powi(level.into()); - }); + if let Ok(Some(level)) = skillset.skill_level(Axe(LDamage)) { + *base_damage *= 1.35_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Axe(LKnockback)) { + *knockback *= 1.4_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Axe(LCost)) { + *energy_cost *= 0.75_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Axe(LDistance)) { + *forward_leap_strength *= 1.2_f32.powi(level.into()); + *vertical_leap_strength *= 1.2_f32.powi(level.into()); + } }, _ => {}, } @@ -929,13 +928,12 @@ impl CharacterAbility { ref mut scales_from_combo, .. } => { - skills::adjust_with_level(skillset, Hammer(SsKnockback), |m, level| { - let knockback_mult = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Hammer(SsKnockback)) { *stage_data = (*stage_data) .iter() - .map(|s| s.modify_strike(knockback_mult)) + .map(|s| s.modify_strike(1.5_f32.powi(level.into()))) .collect::<Vec<combo_melee::Stage<f32>>>(); - }); + } let speed_segments = Hammer(SsSpeed).max_level().unwrap_or(1) as f32; let speed_level = skillset .skill_level(Hammer(SsSpeed)) @@ -968,18 +966,18 @@ impl CharacterAbility { ref mut speed, .. } => { - skills::adjust_with_level(skillset, Hammer(CDamage), |m, level| { - *scaled_damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(CKnockback), |m, level| { - *scaled_knockback *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(CDrain), |m, level| { - *energy_drain *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(CSpeed), |m, level| { - *speed *= m.powi(level.into()); - }); + if let Ok(Some(level)) = skillset.skill_level(Hammer(CDamage)) { + *scaled_damage *= 1.25_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(CKnockback)) { + *scaled_knockback *= 1.5_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(CDrain)) { + *energy_drain *= 0.75_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(CSpeed)) { + *speed *= 1.25_f32.powi(level.into()); + } }, LeapMelee { ref mut base_damage, @@ -990,22 +988,22 @@ impl CharacterAbility { ref mut range, .. } => { - skills::adjust_with_level(skillset, Hammer(LDamage), |m, level| { - *base_damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(LKnockback), |m, level| { - *knockback *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(LCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Hammer(LDistance), |m, level| { - *forward_leap_strength *= m.powi(level.into()); - *vertical_leap_strength *= m.powi(level.into()); - }); - skills::adjust_counter_with_level(skillset, Hammer(LRange), |m, level| { - *range += (m * level) as f32; - }); + if let Ok(Some(level)) = skillset.skill_level(Hammer(LDamage)) { + *base_damage *= 1.4_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(LKnockback)) { + *knockback *= 1.5_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(LCost)) { + *energy_cost *= 0.75_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(LDistance)) { + *forward_leap_strength *= 1.25_f32.powi(level.into()); + *vertical_leap_strength *= 1.25_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Hammer(LRange)) { + *range += 1.0 * level as f32; + } }, _ => {}, } @@ -1026,32 +1024,32 @@ impl CharacterAbility { ref mut scaled_projectile_speed, .. } => { - skills::adjust_with_level(skillset, Bow(ProjSpeed), |m, level| { - let projectile_speed_scaling = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Bow(ProjSpeed)) { + let projectile_speed_scaling = 1.2_f32.powi(level.into()); *initial_projectile_speed *= projectile_speed_scaling; *scaled_projectile_speed *= projectile_speed_scaling; - }); - skills::adjust_with_level(skillset, Bow(CDamage), |m, level| { - let damage_scaling = m.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(CDamage)) { + let damage_scaling = 1.2_f32.powi(level.into()); *initial_damage *= damage_scaling; *scaled_damage *= damage_scaling; - }); - skills::adjust_with_level(skillset, Bow(CRegen), |m, level| { - let regen_scaling = m.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(CRegen)) { + let regen_scaling = 1.2_f32.powi(level.into()); *initial_regen *= regen_scaling; *scaled_regen *= regen_scaling; - }); - skills::adjust_with_level(skillset, Bow(CKnockback), |m, level| { - let knockback_scaling = m.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(CKnockback)) { + let knockback_scaling = 1.2_f32.powi(level.into()); *initial_knockback *= knockback_scaling; *scaled_knockback *= knockback_scaling; - }); - skills::adjust_with_level(skillset, Bow(CSpeed), |m, level| { - *speed *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Bow(CMove), |m, level| { - *move_speed *= m.powi(level.into()); - }); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(CSpeed)) { + *speed *= 1.1_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(CMove)) { + *move_speed *= 1.1_f32.powi(level.into()); + } }, RepeaterRanged { ref mut energy_cost, @@ -1060,19 +1058,19 @@ impl CharacterAbility { ref mut projectile_speed, .. } => { - skills::adjust_with_level(skillset, Bow(ProjSpeed), |m, level| { - *projectile_speed *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Bow(RDamage), |m, level| { - let power = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Bow(ProjSpeed)) { + *projectile_speed *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(RDamage)) { + let power = 1.2_f32.powi(level.into()); *projectile = projectile.modified_projectile(power, 1_f32, 1_f32); - }); - skills::adjust_with_level(skillset, Bow(RCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Bow(RSpeed), |m, level| { - *max_speed *= m.powi(level.into()); - }); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(RCost)) { + *energy_cost *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(RSpeed)) { + *max_speed *= 1.2_f32.powi(level.into()); + } }, BasicRanged { ref mut projectile, @@ -1082,22 +1080,22 @@ impl CharacterAbility { ref mut projectile_speed, .. } => { - skills::adjust_with_level(skillset, Bow(ProjSpeed), |m, level| { - *projectile_speed *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Bow(SDamage), |m, level| { - let power = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Bow(ProjSpeed)) { + *projectile_speed *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(SDamage)) { + let power = 1.2_f32.powi(level.into()); *projectile = projectile.modified_projectile(power, 1_f32, 1_f32); - }); - skills::adjust_with_level(skillset, Bow(SCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); - skills::adjust_counter_with_level(skillset, Bow(SArrows), |m, level| { - *num_projectiles += (m * level) as u32; - }); - skills::adjust_with_level(skillset, Bow(SSpread), |m, level| { - *projectile_spread *= m.powi(level.into()); - }); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(SCost)) { + *energy_cost *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Bow(SArrows)) { + *num_projectiles += level as u32; + } + if let Ok(Some(level)) = skillset.skill_level(Bow(SSpread)) { + *projectile_spread *= 0.8_f32.powi(level.into()); + } }, _ => {}, } @@ -1108,39 +1106,21 @@ impl CharacterAbility { BasicRanged { ref mut projectile, .. } => { - let power = { - let skill = Staff(BDamage); - let level = skillset.skill_level(skill).unwrap_or(None).unwrap_or(0); - if let Some(m) = skill.boost().as_mult_maybe() { - m.powi(level.into()) - } else { - skills::invalid_skill_boost(skill); - 1.0 - } - }; - - let regen = { - let skill = Staff(BRegen); - let level = skillset.skill_level(skill).unwrap_or(None).unwrap_or(0); - if let Some(m) = skill.boost().as_mult_maybe() { - m.powi(level.into()) - } else { - skills::invalid_skill_boost(skill); - 1.0 - } - }; - - let range = { - let skill = Staff(BRadius); - let level = skillset.skill_level(skill).unwrap_or(None).unwrap_or(0); - if let Some(m) = skill.boost().as_mult_maybe() { - m.powi(level.into()) - } else { - skills::invalid_skill_boost(skill); - 1.0 - } - }; - + let damage_level = skillset + .skill_level(Staff(BDamage)) + .unwrap_or(None) + .unwrap_or(0); + let regen_level = skillset + .skill_level(Staff(BRegen)) + .unwrap_or(None) + .unwrap_or(0); + let range_level = skillset + .skill_level(Staff(BRadius)) + .unwrap_or(None) + .unwrap_or(0); + let power = 1.2_f32.powi(damage_level.into()); + let regen = 1.2_f32.powi(regen_level.into()); + let range = 1.15_f32.powi(range_level.into()); *projectile = projectile.modified_projectile(power, regen, range); }, BasicBeam { @@ -1150,23 +1130,23 @@ impl CharacterAbility { ref mut beam_duration, .. } => { - skills::adjust_with_level(skillset, Staff(FDamage), |m, level| { - *damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Staff(FRange), |m, level| { - let range_mod = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Staff(FDamage)) { + *damage *= 1.3_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(FRange)) { + let range_mod = 1.25_f32.powi(level.into()); *range *= range_mod; // Duration modified to keep velocity constant *beam_duration *= range_mod; - }); - skills::adjust_with_level(skillset, Staff(FDrain), |m, level| { - *energy_drain *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Staff(FVelocity), |m, level| { - let velocity_increase = m.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(FDrain)) { + *energy_drain *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(FVelocity)) { + let velocity_increase = 1.25_f32.powi(level.into()); let duration_mod = 1.0 / (1.0 + velocity_increase); *beam_duration *= duration_mod; - }); + } }, Shockwave { ref mut damage, @@ -1175,19 +1155,18 @@ impl CharacterAbility { ref mut energy_cost, .. } => { - skills::adjust_with_level(skillset, Staff(SDamage), |m, level| { - *damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Staff(SKnockback), |m, level| { - let strength_modifier = m.powi(level.into()); - *knockback = knockback.modify_strength(strength_modifier); - }); - skills::adjust_with_level(skillset, Staff(SRange), |m, level| { - *shockwave_duration *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Staff(SCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); + if let Ok(Some(level)) = skillset.skill_level(Staff(SDamage)) { + *damage *= 1.3_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(SKnockback)) { + *knockback = knockback.modify_strength(1.3_f32.powi(level.into())); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(SRange)) { + *shockwave_duration *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Staff(SCost)) { + *energy_cost *= 0.8_f32.powi(level.into()); + } }, _ => {}, } @@ -1203,24 +1182,23 @@ impl CharacterAbility { ref mut energy_regen, .. } => { - skills::adjust_with_level(skillset, Sceptre(LDamage), |m, level| { - *damage *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sceptre(LRange), |m, level| { - let range_mod = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Sceptre(LDamage)) { + *damage *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(LRange)) { + let range_mod = 1.2_f32.powi(level.into()); *range *= range_mod; // Duration modified to keep velocity constant *beam_duration *= range_mod; - }); - skills::adjust_with_level(skillset, Sceptre(LRegen), |m, level| { - *energy_regen *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sceptre(LLifesteal), |m, level| { - if let Some(CombatEffect::Lifesteal(ref mut lifesteal)) = damage_effect - { - *lifesteal *= m.powi(level.into()); - } - }); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(LRegen)) { + *energy_regen *= 1.2_f32.powi(level.into()); + } + if let (Ok(Some(level)), Some(CombatEffect::Lifesteal(ref mut lifesteal))) = + (skillset.skill_level(Sceptre(LLifesteal)), damage_effect) + { + *lifesteal *= 1.15_f32.powi(level.into()); + } }, HealingBeam { ref mut heal, @@ -1229,18 +1207,18 @@ impl CharacterAbility { ref mut beam_duration, .. } => { - skills::adjust_with_level(skillset, Sceptre(HHeal), |m, level| { - *heal *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sceptre(HRange), |m, level| { - let range_mod = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HHeal)) { + *heal *= 1.2_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HRange)) { + let range_mod = 1.2_f32.powi(level.into()); *range *= range_mod; // Duration modified to keep velocity constant *beam_duration *= range_mod; - }); - skills::adjust_with_level(skillset, Sceptre(HCost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HCost)) { + *energy_cost *= 0.8_f32.powi(level.into()); + } }, BasicAura { ref mut aura, @@ -1248,20 +1226,20 @@ impl CharacterAbility { ref mut energy_cost, .. } => { - skills::adjust_with_level(skillset, Sceptre(AStrength), |m, level| { - aura.strength *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sceptre(ADuration), |m, level| { + if let Ok(Some(level)) = skillset.skill_level(Sceptre(AStrength)) { + aura.strength *= 1.15_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ADuration)) { if let Some(ref mut duration) = aura.duration { - *duration *= m.powi(level.into()); + *duration *= 1.2_f32.powi(level.into()); } - }); - skills::adjust_with_level(skillset, Sceptre(ARange), |m, level| { - *range *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Sceptre(ACost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ARange)) { + *range *= 1.25_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ACost)) { + *energy_cost *= 0.85_f32.powi(level.into()); + } }, _ => {}, } @@ -1275,12 +1253,12 @@ impl CharacterAbility { .. } = self { - skills::adjust_with_level(skillset, Pick(Speed), |m, level| { - let speed = m.powi(level.into()); + if let Ok(Some(level)) = skillset.skill_level(Pick(Speed)) { + let speed = 1.1_f32.powi(level.into()); *buildup_duration /= speed; *swing_duration /= speed; *recover_duration /= speed; - }); + } } }, None => { @@ -1292,15 +1270,15 @@ impl CharacterAbility { } = self { use skills::RollSkill::*; - skills::adjust_with_level(skillset, Skill::Roll(Cost), |m, level| { - *energy_cost *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Skill::Roll(Strength), |m, level| { - *roll_strength *= m.powi(level.into()); - }); - skills::adjust_with_level(skillset, Skill::Roll(Duration), |m, level| { - *movement_duration *= m.powi(level.into()); - }); + if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Cost)) { + *energy_cost *= 0.9_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Strength)) { + *roll_strength *= 1.1_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Duration)) { + *movement_duration *= 1.1_f32.powi(level.into()); + } } }, Some(_) => {}, @@ -1894,55 +1872,3 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { } } } - -#[cfg(test)] -mod tests { - use super::*; - use comp::{ - inventory::item::{Item, ItemKind}, - tool, - }; - #[test] - // As we have only player skills, test it with starter tools - // Load ability_config of each tool and try each CharacterAbility of it - fn test_adjusting_by_skills() { - let test_tools = [ - "common.items.weapons.sword.starter", - "common.items.weapons.hammer.starter_hammer", - "common.items.weapons.bow.starter", - "common.items.weapons.axe.starter_axe", - "common.items.weapons.staff.starter_staff", - "common.items.weapons.sceptre.starter_sceptre", - "common.items.tool.pickaxe_stone", - ]; - - let dummy_skillset = skills::SkillSet::default(); - // check non-combat abilities - let dummy_ability = CharacterAbility::default(); - dummy_ability.adjusted_by_skills(&dummy_skillset, None); - for tool_id in test_tools { - let item = Item::new_from_asset_expect(tool_id); - let tool::AbilitySet { - primary, - secondary, - abilities, - } = &item.item_config_expect().abilities; - - // It should be a tool, I swear - if let ItemKind::Tool(tool) = &item.kind { - primary - .clone() - .adjusted_by_skills(&dummy_skillset, Some(tool.kind)); - secondary - .clone() - .adjusted_by_skills(&dummy_skillset, Some(tool.kind)); - for entry in abilities { - let (_, ability) = entry; - ability - .clone() - .adjusted_by_skills(&dummy_skillset, Some(tool.kind)); - } - } - } - } -} diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 6867d93375..71d87e84ec 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,6 +1,6 @@ use crate::{ comp::{ - skills::{self, ClimbSkill::*, Skill}, + skills::{ClimbSkill::*, Skill}, CharacterState, Climb, EnergySource, InputKind, Ori, StateUpdate, }, consts::GRAVITY, @@ -31,12 +31,12 @@ pub struct Data { impl Data { pub fn create_adjusted_by_skills(join_data: &JoinData) -> Self { let mut data = Data::default(); - skills::adjust_with_level(join_data.skill_set, Skill::Climb(Cost), |m, level| { - data.static_data.energy_cost *= m.powi(level.into()); - }); - skills::adjust_with_level(join_data.skill_set, Skill::Climb(Speed), |m, level| { - data.static_data.movement_speed *= m.powi(level.into()); - }); + if let Ok(Some(level)) = join_data.skill_set.skill_level(Skill::Climb(Cost)) { + data.static_data.energy_cost *= 0.8_f32.powi(level.into()); + } + if let Ok(Some(level)) = join_data.skill_set.skill_level(Skill::Climb(Speed)) { + data.static_data.movement_speed *= 1.2_f32.powi(level.into()); + } data } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 1ec8c0a078..095e1e92c0 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -5,7 +5,7 @@ use crate::{ inventory::slot::{EquipSlot, Slot}, item::{Hands, ItemKind, Tool, ToolKind}, quadruped_low, quadruped_medium, quadruped_small, - skills::{self, Skill, SwimSkill}, + skills::{Skill, SwimSkill}, theropod, Body, CharacterAbility, CharacterState, Density, InputAttr, InputKind, InventoryAction, StateUpdate, }, @@ -366,9 +366,9 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, submers let force = efficiency * force; let mut water_accel = force / data.mass.0; - skills::adjust_with_level(data.skill_set, Skill::Swim(SwimSkill::Speed), |m, level| { - water_accel *= m.powi(level.into()); - }); + if let Ok(Some(level)) = data.skill_set.skill_level(Skill::Swim(SwimSkill::Speed)) { + water_accel *= 1.4_f32.powi(level.into()); + } let dir = if data.body.can_strafe() { data.inputs.move_dir diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index 6c734a0570..bf5047154b 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -337,40 +337,28 @@ pub fn handle_mine_block( xp_pools: HashSet::from_iter(vec![SkillGroupKind::Weapon(tool)]), }); } - use common::comp::skills::{self, MiningSkill, Skill}; + use common::comp::skills::{MiningSkill, Skill}; use rand::Rng; let mut rng = rand::thread_rng(); - let chance_add_ore = || { - let mut chance = 0.0; - skills::adjust_with_level( - &skillset, - Skill::Pick(MiningSkill::OreGain), - |m, level| { - chance = (m - 1.0) * level as f32; - }, - ); - - chance as f64 - }; - let chance_add_gem = || { - let mut chance = 0.0; - skills::adjust_with_level( - &skillset, - Skill::Pick(MiningSkill::GemGain), - |m, level| { - chance = (m - 1.0) * level as f32; - }, - ); - - chance as f64 - }; if item.item_definition_id().contains("mineral.ore.") - && rng.gen_bool(chance_add_ore()) + && rng.gen_bool( + 0.05 * skillset + .skill_level(Skill::Pick(MiningSkill::OreGain)) + .ok() + .flatten() + .unwrap_or(0) as f64, + ) { let _ = item.increase_amount(1); } if item.item_definition_id().contains("mineral.gem.") - && rng.gen_bool(chance_add_gem()) + && rng.gen_bool( + 0.05 * skillset + .skill_level(Skill::Pick(MiningSkill::GemGain)) + .ok() + .flatten() + .unwrap_or(0) as f64, + ) { let _ = item.increase_amount(1); }