From 50af5486368488e8b7702a32311987fb14383178 Mon Sep 17 00:00:00 2001 From: Vincent Foulon Date: Sun, 21 Mar 2021 15:58:38 +0100 Subject: [PATCH] Add skill for swimming speed --- .../common/skill_trees/skill_max_levels.ron | 1 + .../skills_skill-groups_manifest.ron | 3 +- .../element/icons/skilltree/skill_swim.png | Bin 0 -> 255 bytes assets/voxygen/i18n/en/skills.ron | 4 ++ assets/voxygen/i18n/fr_FR/skills.ron | 6 ++- common/src/comp/skills.rs | 6 +++ common/src/states/utils.rs | 19 ++++++-- server/src/persistence/json_models.rs | 6 ++- voxygen/src/hud/diary.rs | 45 +++++++++++++++++- voxygen/src/hud/img_ids.rs | 1 + 10 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 assets/voxygen/element/icons/skilltree/skill_swim.png diff --git a/assets/common/skill_trees/skill_max_levels.ron b/assets/common/skill_trees/skill_max_levels.ron index f0c1f07fad..dc87e72922 100644 --- a/assets/common/skill_trees/skill_max_levels.ron +++ b/assets/common/skill_trees/skill_max_levels.ron @@ -74,4 +74,5 @@ Roll(Duration): Some(2), Climb(Cost): Some(2), Climb(Speed): Some(2), + Swim(Speed): Some(2), }) \ No newline at end of file diff --git a/assets/common/skill_trees/skills_skill-groups_manifest.ron b/assets/common/skill_trees/skills_skill-groups_manifest.ron index f75d99d35b..5d9f33d7cb 100644 --- a/assets/common/skill_trees/skills_skill-groups_manifest.ron +++ b/assets/common/skill_trees/skills_skill-groups_manifest.ron @@ -13,7 +13,8 @@ Roll(Strength), Roll(Duration), Climb(Cost), - Climb(Speed) + Climb(Speed), + Swim(Speed), ], Weapon(Sword): [ Sword(InterruptingAttacks), diff --git a/assets/voxygen/element/icons/skilltree/skill_swim.png b/assets/voxygen/element/icons/skilltree/skill_swim.png new file mode 100644 index 0000000000000000000000000000000000000000..1f942e9028261dcc5238c144ad761a44c5cc55fb GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1Igot`d^Ar`&K zfByfscfQ%9`d@Md!!DyF2}$qe`pdc!4Gy^Y9+m)th=2c=uVT)8aH#%2$LpGCeyotO;Le%sBho93{>wQsM}D(YzU3g6B)Wg+#)d{9aCA{-TracO z?Tp|n^*83`Vh3^;ifk}2NchgSvtdb#Z;yXOL1s$Aff7qYyMtK@s*VnYac=xh&VAC?tLOj!|LGTcY`vx)sjb~;s>~qq&2`?cRr4Z&o?!5F^>bP0l+XkKN&8_F literal 0 HcmV?d00001 diff --git a/assets/voxygen/i18n/en/skills.ron b/assets/voxygen/i18n/en/skills.ron index d152f525bd..e6fa12cbf7 100644 --- a/assets/voxygen/i18n/en/skills.ron +++ b/assets/voxygen/i18n/en/skills.ron @@ -39,6 +39,10 @@ "hud.skill.climbing_cost": "Climbing uses 20% less stamina{SP}", "hud.skill.climbing_speed_title": "Climbing Speed", "hud.skill.climbing_speed": "Climb 20% faster{SP}", + "hud.skill.swim_title": "Swimming", + "hud.skill.swim": "Moving in wet environment", + "hud.skill.swim_speed_title": "Swimming Speed", + "hud.skill.swim_speed": "Swim 40% faster{SP}", // Sceptre "hud.skill.sc_lifesteal_title": "Lifesteal Beam", "hud.skill.sc_lifesteal": "Drain the life from your enemies", diff --git a/assets/voxygen/i18n/fr_FR/skills.ron b/assets/voxygen/i18n/fr_FR/skills.ron index f9ef193b72..cbdfcc9045 100644 --- a/assets/voxygen/i18n/fr_FR/skills.ron +++ b/assets/voxygen/i18n/fr_FR/skills.ron @@ -37,8 +37,12 @@ "hud.skill.climbing": "Sauter encore plus haut", "hud.skill.climbing_cost_title": "Coût d'endurance de l'Escalade", "hud.skill.climbing_cost": "Escalader coûte 20% moins d'endurance{SP}", - "hud.skill.climbing_speed_title": "Climbing Speed", + "hud.skill.climbing_speed_title": "Vitesse d'Escalade", "hud.skill.climbing_speed": "Escalader 20% plus vite{SP}", + "hud.skill.swim_title": "Nage", + "hud.skill.swim": "Déplacement en environnement humide", + "hud.skill.swim_speed_title": "Vitesse de nage", + "hud.skill.swim_speed": "Nager 40% plus vite{SP}", // Sceptre "hud.skill.sc_lifesteal_title": "Rayon de Vol-Vie", "hud.skill.sc_lifesteal": "Draine la vie de vos ennemis", diff --git a/common/src/comp/skills.rs b/common/src/comp/skills.rs index 9892b2672a..7582fddf3a 100644 --- a/common/src/comp/skills.rs +++ b/common/src/comp/skills.rs @@ -104,6 +104,7 @@ pub enum Skill { UnlockGroup(SkillGroupKind), Roll(RollSkill), Climb(ClimbSkill), + Swim(SwimSkill), } pub enum SkillError { @@ -257,6 +258,11 @@ pub enum ClimbSkill { Speed, } +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] +pub enum SwimSkill { + Speed, +} + #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] pub enum SkillGroupKind { General, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index d3c72284ea..e463dd44d8 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -4,7 +4,7 @@ use crate::{ inventory::slot::EquipSlot, item::{Hands, ItemKind, Tool, ToolKind}, quadruped_low, quadruped_medium, quadruped_small, ship, - skills::Skill, + skills::{Skill, SwimSkill}, theropod, Body, CharacterAbility, CharacterState, InputKind, InventoryAction, StateUpdate, }, consts::{FRIC_GROUND, GRAVITY}, @@ -299,11 +299,22 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, rate: f32) /// Updates components to move player as if theyre swimming fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth: f32) { + let mut water_accel = BASE_HUMANOID_WATER_ACCEL; + let mut water_speed = BASE_HUMANOID_WATER_SPEED; + if let Ok(Some(level)) = data + .stats + .skill_set + .skill_level(Skill::Swim(SwimSkill::Speed)) + { + water_speed *= 1.4_f32.powi(level.into()); + water_accel *= 1.4_f32.powi(level.into()); + } + // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < BASE_HUMANOID_WATER_SPEED.powi(2) { - BASE_HUMANOID_WATER_ACCEL + * if update.vel.0.magnitude_squared() < water_speed.powi(2) { + water_accel } else { 0.0 } @@ -324,7 +335,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth: .inputs .move_z .clamped(-1.0, depth.clamped(0.0, 1.0).powi(3))) - .min(BASE_HUMANOID_WATER_SPEED); + .min(water_speed); } /// Updates components to move entity as if it's flying diff --git a/server/src/persistence/json_models.rs b/server/src/persistence/json_models.rs index ba33df2c9c..05333b0120 100644 --- a/server/src/persistence/json_models.rs +++ b/server/src/persistence/json_models.rs @@ -41,7 +41,7 @@ pub fn skill_to_db_string(skill: comp::skills::Skill) -> String { item::tool::ToolKind, skills::{ AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill, - Skill::*, SkillGroupKind, StaffSkill, SwordSkill, + Skill::*, SkillGroupKind, StaffSkill, SwimSkill, SwordSkill, }, }; let skill_string = match skill { @@ -136,6 +136,7 @@ pub fn skill_to_db_string(skill: comp::skills::Skill) -> String { Roll(RollSkill::Duration) => "Roll Duration", Climb(ClimbSkill::Cost) => "Climb Cost", Climb(ClimbSkill::Speed) => "Climb Speed", + Swim(SwimSkill::Speed) => "Swim Speed", UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)) => "Unlock Weapon Sword", UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)) => "Unlock Weapon Axe", UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)) => "Unlock Weapon Hammer", @@ -166,7 +167,7 @@ pub fn db_string_to_skill(skill_string: &str) -> comp::skills::Skill { item::tool::ToolKind, skills::{ AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill, - Skill::*, SkillGroupKind, StaffSkill, SwordSkill, + Skill::*, SkillGroupKind, StaffSkill, SwimSkill, SwordSkill, }, }; match skill_string { @@ -261,6 +262,7 @@ pub fn db_string_to_skill(skill_string: &str) -> comp::skills::Skill { "Roll Duration" => Roll(RollSkill::Duration), "Climb Cost" => Climb(ClimbSkill::Cost), "Climb Speed" => Climb(ClimbSkill::Speed), + "Swim Speed" => Swim(SwimSkill::Speed), "Unlock Weapon Sword" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)), "Unlock Weapon Axe" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)), "Unlock Weapon Hammer" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)), diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index 3bc72a3cf0..1ac9a256de 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -166,6 +166,8 @@ widget_ids! { skill_general_climb_0, skill_general_climb_1, skill_general_climb_2, + skill_general_swim_0, + skill_general_swim_1, } } @@ -575,7 +577,7 @@ impl<'a> Widget for Diary<'a> { _ => 0, }; let skills_bot_r = match sel_tab { - SelectedSkillTree::General => 3, + SelectedSkillTree::General => 5, SelectedSkillTree::Weapon(ToolKind::Sword) => 1, SelectedSkillTree::Weapon(ToolKind::Bow) => 1, _ => 0, @@ -706,10 +708,11 @@ impl<'a> Widget for Diary<'a> { match sel_tab { SelectedSkillTree::General => { use skills::{ - ClimbSkill::{self}, + ClimbSkill, GeneralSkill::*, RollSkill::{self, *}, SkillGroupKind::*, + SwimSkill, }; use ToolKind::*; // General Combat @@ -1115,6 +1118,44 @@ impl<'a> Widget for Diary<'a> { { events.push(Event::UnlockSkill(skill)); }; + + Button::image(self.imgs.skill_swim_skill) + .w_h(74.0, 74.0) + .mid_top_with_margin_on(state.skills_bot_r[3], 3.0) + .with_tooltip( + self.tooltip_manager, + &self.localized_strings.get("hud.skill.swim_title"), + &self.localized_strings.get("hud.skill.swim"), + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_swim_0, ui); + let skill = Skill::Swim(SwimSkill::Speed); + if create_skill_button( + self.imgs.utility_speed_skill, + state.skills_bot_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + &self.localized_strings.get("hud.skill.swim_speed_title"), + &add_sp_cost_tooltip( + &self.localized_strings.get("hud.skill.swim_speed"), + skill, + &self.stats.skill_set, + &self.localized_strings, + ), + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_swim_1, ui) + .was_clicked() + { + events.push(Event::UnlockSkill(skill)); + }; }, SelectedSkillTree::Weapon(ToolKind::Sword) => { use skills::SwordSkill::*; diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 6c71300cba..5a29788a40 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -182,6 +182,7 @@ image_ids! { unlock_sword_skill: "voxygen.element.icons.skilltree.unlock_sword", skill_dodge_skill: "voxygen.element.icons.skilltree.skill_dodge", skill_climbing_skill: "voxygen.element.icons.skilltree.skill_climbing", + skill_swim_skill: "voxygen.element.icons.skilltree.skill_swim", buff_amount_skill: "voxygen.element.icons.skilltree.buff_amount", buff_combo_skill: "voxygen.element.icons.skilltree.buff_combo",