From 89766b2b34001c0ff38ddec9c5c79c4a18d2ec34 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 5 Jan 2021 20:26:21 -0500 Subject: [PATCH] Added command to give yourself skill points. adjusted social window Changelog --- CHANGELOG.md | 2 + assets/voxygen/element/misc_bg/social_bg.png | 4 +- .../voxygen/element/misc_bg/social_frame.png | 4 +- common/src/cmd.rs | 15 ++++ server/src/cmd.rs | 80 +++++++++++++++++++ voxygen/src/hud/diary.rs | 18 ++--- voxygen/src/hud/social.rs | 10 +-- 7 files changed, 115 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c00aea2b9..c293dae685 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added an additional Ring loadout slot - The inventory can now be expanded to fill the whole window - Added /dropall admin command (drops all inventory items on the ground) +- Skill trees ### Changed @@ -38,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SSAAx4 option - The Stats button and associated screen were removed +- Levels ### Fixed diff --git a/assets/voxygen/element/misc_bg/social_bg.png b/assets/voxygen/element/misc_bg/social_bg.png index 6e57026acb..47e0a7f419 100644 --- a/assets/voxygen/element/misc_bg/social_bg.png +++ b/assets/voxygen/element/misc_bg/social_bg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ee5e1459b78ef37b9947250401c8732a3011e6105c379260dc99feefcbfcef9 -size 6369 +oid sha256:16787447875fa7af882cfdd6c049e96050cacd4fc84cdbff7ab1d9a516149787 +size 6109 diff --git a/assets/voxygen/element/misc_bg/social_frame.png b/assets/voxygen/element/misc_bg/social_frame.png index f0216d61f0..ca73967d15 100644 --- a/assets/voxygen/element/misc_bg/social_frame.png +++ b/assets/voxygen/element/misc_bg/social_frame.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22ca239ce2b26552546465f85bc2c3c8499553cc06cfaff897f88b3a01e2af2e -size 5880 +oid sha256:da031950b47f5536cd461aa357a5a8c5ec197c79f89e21ff89209a91f391441a +size 6579 diff --git a/common/src/cmd.rs b/common/src/cmd.rs index db12192d91..6b5cfb26f5 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -72,6 +72,7 @@ pub enum ChatCommand { RemoveLights, Say, SetMotd, + SkillPoint, Spawn, Sudo, Tell, @@ -123,6 +124,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[ ChatCommand::RemoveLights, ChatCommand::Say, ChatCommand::SetMotd, + ChatCommand::SkillPoint, ChatCommand::Spawn, ChatCommand::Sudo, ChatCommand::Tell, @@ -149,6 +151,10 @@ lazy_static! { .iter() .map(|s| s.to_string()) .collect(); + static ref SKILL_TREES: Vec = vec!["general", "sword", "axe", "hammer", "bow", "staff", "sceptre"] + .iter() + .map(|s| s.to_string()) + .collect(); /// TODO: Make this use hot-reloading static ref ENTITIES: Vec = { let npc_names = &*npc::NPC_NAMES.read(); @@ -372,6 +378,14 @@ impl ChatCommand { ChatCommand::SetMotd => { cmd(vec![Message(Optional)], "Set the server description", Admin) }, + ChatCommand::SkillPoint => cmd( + vec![ + Enum("skill tree", SKILL_TREES.clone(), Required), + Integer("amount", 1, Optional), + ], + "Give yourself skill points for a particular skill tree", + Admin, + ), ChatCommand::Spawn => cmd( vec![ Enum("alignment", ALIGNMENTS.clone(), Required), @@ -464,6 +478,7 @@ impl ChatCommand { ChatCommand::RemoveLights => "remove_lights", ChatCommand::Say => "say", ChatCommand::SetMotd => "set_motd", + ChatCommand::SkillPoint => "skill_point", ChatCommand::Spawn => "spawn", ChatCommand::Sudo => "sudo", ChatCommand::Tell => "tell", diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 3df7c049a8..79a6841d27 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -112,6 +112,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler { ChatCommand::RemoveLights => handle_remove_lights, ChatCommand::Say => handle_say, ChatCommand::SetMotd => handle_set_motd, + ChatCommand::SkillPoint => handle_skill_point, ChatCommand::Spawn => handle_spawn, ChatCommand::Sudo => handle_sudo, ChatCommand::Tell => handle_tell, @@ -1987,6 +1988,85 @@ spawn_rate {:?} "#, } } +fn find_target( + ecs: &specs::World, + opt_alias: Option, + fallback: EcsEntity, +) -> Result { + if let Some(alias) = opt_alias { + (&ecs.entities(), &ecs.read_storage::()) + .join() + .find(|(_, player)| player.alias == alias) + .map(|(entity, _)| entity) + .ok_or_else(|| { + ServerGeneral::server_msg( + ChatType::CommandError, + format!("Player '{}' not found!", alias), + ) + }) + } else { + Ok(fallback) + } +} + +fn handle_skill_point( + server: &mut Server, + client: EcsEntity, + target: EcsEntity, + args: String, + action: &ChatCommand, +) { + let (a_skill_tree, a_sp, a_alias) = + scan_fmt_some!(&args, &action.arg_fmt(), String, u16, String); + + if let (Some(skill_tree), Some(sp)) = (a_skill_tree, a_sp) { + let target = find_target(&server.state.ecs(), a_alias, target); + + let mut error_msg = None; + + match target { + Ok(player) => { + if let Some(skill_tree) = parse_skill_tree(&skill_tree) { + if let Some(mut stats) = server + .state + .ecs_mut() + .write_storage::() + .get_mut(player) + { + stats.skill_set.add_skill_points(skill_tree, sp); + } else { + error_msg = Some(ServerGeneral::server_msg( + ChatType::CommandError, + "Player has no stats!", + )); + } + } + }, + Err(e) => { + error_msg = Some(e); + }, + } + + if let Some(msg) = error_msg { + server.notify_client(client, msg); + } + } +} + +fn parse_skill_tree(skill_tree: &str) -> Option { + use comp::{item::tool::ToolKind, skills::SkillGroupType}; + match skill_tree { + "general" => Some(SkillGroupType::General), + "sword" => Some(SkillGroupType::Weapon(ToolKind::Sword)), + "axe" => Some(SkillGroupType::Weapon(ToolKind::Axe)), + "hammer" => Some(SkillGroupType::Weapon(ToolKind::Hammer)), + "bow" => Some(SkillGroupType::Weapon(ToolKind::Bow)), + "staff" => Some(SkillGroupType::Weapon(ToolKind::Staff)), + "sceptre" => Some(SkillGroupType::Weapon(ToolKind::Sceptre)), + _ => None, + } +} + fn handle_debug( server: &mut Server, client: EcsEntity, diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index aa1f1d2a2b..9bbd451cd7 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -969,7 +969,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Triple Strike Damage", - "Increases damage scaling on triple strike", + "Increases the damage each successive strike does", &diary_tooltip, TEXT_COLOR, ) @@ -990,7 +990,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Triple Strike Speed", - "Increases attack speed scaling on triple strike", + "Increases attack speed gained by each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1011,7 +1011,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Triple Strike Regen", - "Increases enery regen scaling on triple strike", + "Increases stamina gain on each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1324,7 +1324,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Double Strike Damage", - "Increases damage scaling in combo", + "Increases the damage dealt in each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1345,7 +1345,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Double Strike Speed", - "Increases speed scaling in combo", + "Increases the attack speed with each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1366,7 +1366,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Double Strike Regen", - "Increases energy regen scaling in combo", + "Increases stamina gain with each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1636,7 +1636,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Single Strike Damage", - "Increases damage scaling in combo", + "Increases the damage with each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1657,7 +1657,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Single Strike Speed", - "Increases speed scaling in combo", + "Increases the attack speed with each successive strike", &diary_tooltip, TEXT_COLOR, ) @@ -1678,7 +1678,7 @@ impl<'a> Widget for Diary<'a> { .with_tooltip( self.tooltip_manager, "Single Strike Regen", - "Increases energy regen scaling in combo", + "Increases stamina gain with each successive strike", &diary_tooltip, TEXT_COLOR, ) diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index 045ad96726..fb0dd8e63e 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -303,7 +303,7 @@ impl<'a> Widget for Social<'a> { // if Button::image(self.imgs.nothing) .w_h(133.0, 18.0) - .top_left_with_margins_on(state.ids.frame, 52.0, 7.0) + .mid_top_with_margin_on(state.ids.frame, 52.0) .label(&self.localized_strings.get("hud.social.name")) .label_font_size(self.fonts.cyri.scale(14)) .label_y(conrod_core::position::Relative::Scalar(0.0)) @@ -317,7 +317,7 @@ impl<'a> Widget for Social<'a> { if Button::image(self.imgs.nothing) .w_h(39.0, 18.0) .right_from(state.ids.name_txt, 2.0) - .label(&self.localized_strings.get("hud.social.level")) + .label("") .label_font_size(self.fonts.cyri.scale(14)) .label_y(conrod_core::position::Relative::Scalar(0.0)) .label_font_id(self.fonts.cyri.conrod_id) @@ -330,7 +330,7 @@ impl<'a> Widget for Social<'a> { if Button::image(self.imgs.nothing) .w_h(93.0, 18.0) .right_from(state.ids.level_txt, 2.0) - .label(&self.localized_strings.get("hud.social.zone")) + .label("") // TODO: Enable zone here later .label_font_size(self.fonts.cyri.scale(14)) .label_y(conrod_core::position::Relative::Scalar(0.0)) .label_font_id(self.fonts.cyri.conrod_id) @@ -412,7 +412,7 @@ impl<'a> Widget for Social<'a> { self.imgs.selection }); let button = if i == 0 { - button.mid_top_with_margin_on(state.ids.names_align, 1.0) + button.mid_top_with_margin_on(state.ids.online_align, 1.0) } else { button.down_from(state.ids.player_names[i - 1], 1.0) }; @@ -422,7 +422,7 @@ impl<'a> Widget for Social<'a> { alias ); button - .w_h(133.0, 20.0) + .w_h(260.0, 20.0) .hover_image(if selected { self.imgs.selection } else {