Add skill for swimming speed

This commit is contained in:
Vincent Foulon 2021-03-21 15:58:38 +01:00
parent 985c26dd0a
commit e06870702f
10 changed files with 84 additions and 10 deletions

View File

@ -74,4 +74,5 @@
Roll(Duration): Some(2), Roll(Duration): Some(2),
Climb(Cost): Some(2), Climb(Cost): Some(2),
Climb(Speed): Some(2), Climb(Speed): Some(2),
Swim(Speed): Some(2),
}) })

View File

@ -13,7 +13,8 @@
Roll(Strength), Roll(Strength),
Roll(Duration), Roll(Duration),
Climb(Cost), Climb(Cost),
Climb(Speed) Climb(Speed),
Swim(Speed),
], ],
Weapon(Sword): [ Weapon(Sword): [
Sword(InterruptingAttacks), Sword(InterruptingAttacks),

BIN
assets/voxygen/element/icons/skilltree/skill_swim.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -39,6 +39,10 @@
"hud.skill.climbing_cost": "Climbing uses 20% less stamina{SP}", "hud.skill.climbing_cost": "Climbing uses 20% less stamina{SP}",
"hud.skill.climbing_speed_title": "Climbing Speed", "hud.skill.climbing_speed_title": "Climbing Speed",
"hud.skill.climbing_speed": "Climb 20% faster{SP}", "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 // Sceptre
"hud.skill.sc_lifesteal_title": "Lifesteal Beam", "hud.skill.sc_lifesteal_title": "Lifesteal Beam",
"hud.skill.sc_lifesteal": "Drain the life from your enemies", "hud.skill.sc_lifesteal": "Drain the life from your enemies",

View File

@ -37,8 +37,12 @@
"hud.skill.climbing": "Sauter encore plus haut", "hud.skill.climbing": "Sauter encore plus haut",
"hud.skill.climbing_cost_title": "Coût d'endurance de l'Escalade", "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_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.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 // Sceptre
"hud.skill.sc_lifesteal_title": "Rayon de Vol-Vie", "hud.skill.sc_lifesteal_title": "Rayon de Vol-Vie",
"hud.skill.sc_lifesteal": "Draine la vie de vos ennemis", "hud.skill.sc_lifesteal": "Draine la vie de vos ennemis",

View File

@ -104,6 +104,7 @@ pub enum Skill {
UnlockGroup(SkillGroupKind), UnlockGroup(SkillGroupKind),
Roll(RollSkill), Roll(RollSkill),
Climb(ClimbSkill), Climb(ClimbSkill),
Swim(SwimSkill),
} }
pub enum SkillError { pub enum SkillError {
@ -257,6 +258,11 @@ pub enum ClimbSkill {
Speed, Speed,
} }
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum SwimSkill {
Speed,
}
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum SkillGroupKind { pub enum SkillGroupKind {
General, General,

View File

@ -4,7 +4,7 @@ use crate::{
inventory::slot::EquipSlot, inventory::slot::EquipSlot,
item::{Hands, ItemKind, Tool, ToolKind}, item::{Hands, ItemKind, Tool, ToolKind},
quadruped_low, quadruped_medium, quadruped_small, ship, quadruped_low, quadruped_medium, quadruped_small, ship,
skills::Skill, skills::{Skill, SwimSkill},
theropod, Body, CharacterAbility, CharacterState, InputKind, InventoryAction, StateUpdate, theropod, Body, CharacterAbility, CharacterState, InputKind, InventoryAction, StateUpdate,
}, },
consts::{FRIC_GROUND, GRAVITY}, 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 /// Updates components to move player as if theyre swimming
fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth: f32) { 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 velocity
update.vel.0 += Vec2::broadcast(data.dt.0) update.vel.0 += Vec2::broadcast(data.dt.0)
* data.inputs.move_dir * data.inputs.move_dir
* if update.vel.0.magnitude_squared() < BASE_HUMANOID_WATER_SPEED.powi(2) { * if update.vel.0.magnitude_squared() < water_speed.powi(2) {
BASE_HUMANOID_WATER_ACCEL water_accel
} else { } else {
0.0 0.0
} }
@ -324,7 +335,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth:
.inputs .inputs
.move_z .move_z
.clamped(-1.0, depth.clamped(0.0, 1.0).powi(3))) .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 /// Updates components to move entity as if it's flying

View File

@ -41,7 +41,7 @@ pub fn skill_to_db_string(skill: comp::skills::Skill) -> String {
item::tool::ToolKind, item::tool::ToolKind,
skills::{ skills::{
AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill, AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill,
Skill::*, SkillGroupKind, StaffSkill, SwordSkill, Skill::*, SkillGroupKind, StaffSkill, SwimSkill, SwordSkill,
}, },
}; };
let skill_string = match skill { 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", Roll(RollSkill::Duration) => "Roll Duration",
Climb(ClimbSkill::Cost) => "Climb Cost", Climb(ClimbSkill::Cost) => "Climb Cost",
Climb(ClimbSkill::Speed) => "Climb Speed", Climb(ClimbSkill::Speed) => "Climb Speed",
Swim(SwimSkill::Speed) => "Swim Speed",
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)) => "Unlock Weapon Sword", UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)) => "Unlock Weapon Sword",
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)) => "Unlock Weapon Axe", UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)) => "Unlock Weapon Axe",
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)) => "Unlock Weapon Hammer", 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, item::tool::ToolKind,
skills::{ skills::{
AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill, AxeSkill, BowSkill, ClimbSkill, GeneralSkill, HammerSkill, RollSkill, SceptreSkill,
Skill::*, SkillGroupKind, StaffSkill, SwordSkill, Skill::*, SkillGroupKind, StaffSkill, SwimSkill, SwordSkill,
}, },
}; };
match skill_string { match skill_string {
@ -261,6 +262,7 @@ pub fn db_string_to_skill(skill_string: &str) -> comp::skills::Skill {
"Roll Duration" => Roll(RollSkill::Duration), "Roll Duration" => Roll(RollSkill::Duration),
"Climb Cost" => Climb(ClimbSkill::Cost), "Climb Cost" => Climb(ClimbSkill::Cost),
"Climb Speed" => Climb(ClimbSkill::Speed), "Climb Speed" => Climb(ClimbSkill::Speed),
"Swim Speed" => Swim(SwimSkill::Speed),
"Unlock Weapon Sword" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)), "Unlock Weapon Sword" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)),
"Unlock Weapon Axe" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)), "Unlock Weapon Axe" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)),
"Unlock Weapon Hammer" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)), "Unlock Weapon Hammer" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)),

View File

@ -166,6 +166,8 @@ widget_ids! {
skill_general_climb_0, skill_general_climb_0,
skill_general_climb_1, skill_general_climb_1,
skill_general_climb_2, skill_general_climb_2,
skill_general_swim_0,
skill_general_swim_1,
} }
} }
@ -575,7 +577,7 @@ impl<'a> Widget for Diary<'a> {
_ => 0, _ => 0,
}; };
let skills_bot_r = match sel_tab { let skills_bot_r = match sel_tab {
SelectedSkillTree::General => 3, SelectedSkillTree::General => 5,
SelectedSkillTree::Weapon(ToolKind::Sword) => 1, SelectedSkillTree::Weapon(ToolKind::Sword) => 1,
SelectedSkillTree::Weapon(ToolKind::Bow) => 1, SelectedSkillTree::Weapon(ToolKind::Bow) => 1,
_ => 0, _ => 0,
@ -706,10 +708,11 @@ impl<'a> Widget for Diary<'a> {
match sel_tab { match sel_tab {
SelectedSkillTree::General => { SelectedSkillTree::General => {
use skills::{ use skills::{
ClimbSkill::{self}, ClimbSkill,
GeneralSkill::*, GeneralSkill::*,
RollSkill::{self, *}, RollSkill::{self, *},
SkillGroupKind::*, SkillGroupKind::*,
SwimSkill,
}; };
use ToolKind::*; use ToolKind::*;
// General Combat // General Combat
@ -1115,6 +1118,44 @@ impl<'a> Widget for Diary<'a> {
{ {
events.push(Event::UnlockSkill(skill)); 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) => { SelectedSkillTree::Weapon(ToolKind::Sword) => {
use skills::SwordSkill::*; use skills::SwordSkill::*;

View File

@ -182,6 +182,7 @@ image_ids! {
unlock_sword_skill: "voxygen.element.icons.skilltree.unlock_sword", unlock_sword_skill: "voxygen.element.icons.skilltree.unlock_sword",
skill_dodge_skill: "voxygen.element.icons.skilltree.skill_dodge", skill_dodge_skill: "voxygen.element.icons.skilltree.skill_dodge",
skill_climbing_skill: "voxygen.element.icons.skilltree.skill_climbing", 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_amount_skill: "voxygen.element.icons.skilltree.buff_amount",
buff_combo_skill: "voxygen.element.icons.skilltree.buff_combo", buff_combo_skill: "voxygen.element.icons.skilltree.buff_combo",