Added command to give yourself skill points.

adjusted social window

Changelog
This commit is contained in:
Sam 2021-01-05 20:26:21 -05:00
parent 986c05621a
commit 89766b2b34
7 changed files with 115 additions and 18 deletions

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added an additional Ring loadout slot - Added an additional Ring loadout slot
- The inventory can now be expanded to fill the whole window - The inventory can now be expanded to fill the whole window
- Added /dropall admin command (drops all inventory items on the ground) - Added /dropall admin command (drops all inventory items on the ground)
- Skill trees
### Changed ### Changed
@ -38,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SSAAx4 option - SSAAx4 option
- The Stats button and associated screen were removed - The Stats button and associated screen were removed
- Levels
### Fixed ### Fixed

Binary file not shown.

Binary file not shown.

View File

@ -72,6 +72,7 @@ pub enum ChatCommand {
RemoveLights, RemoveLights,
Say, Say,
SetMotd, SetMotd,
SkillPoint,
Spawn, Spawn,
Sudo, Sudo,
Tell, Tell,
@ -123,6 +124,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
ChatCommand::RemoveLights, ChatCommand::RemoveLights,
ChatCommand::Say, ChatCommand::Say,
ChatCommand::SetMotd, ChatCommand::SetMotd,
ChatCommand::SkillPoint,
ChatCommand::Spawn, ChatCommand::Spawn,
ChatCommand::Sudo, ChatCommand::Sudo,
ChatCommand::Tell, ChatCommand::Tell,
@ -149,6 +151,10 @@ lazy_static! {
.iter() .iter()
.map(|s| s.to_string()) .map(|s| s.to_string())
.collect(); .collect();
static ref SKILL_TREES: Vec<String> = vec!["general", "sword", "axe", "hammer", "bow", "staff", "sceptre"]
.iter()
.map(|s| s.to_string())
.collect();
/// TODO: Make this use hot-reloading /// TODO: Make this use hot-reloading
static ref ENTITIES: Vec<String> = { static ref ENTITIES: Vec<String> = {
let npc_names = &*npc::NPC_NAMES.read(); let npc_names = &*npc::NPC_NAMES.read();
@ -372,6 +378,14 @@ impl ChatCommand {
ChatCommand::SetMotd => { ChatCommand::SetMotd => {
cmd(vec![Message(Optional)], "Set the server description", Admin) 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( ChatCommand::Spawn => cmd(
vec![ vec![
Enum("alignment", ALIGNMENTS.clone(), Required), Enum("alignment", ALIGNMENTS.clone(), Required),
@ -464,6 +478,7 @@ impl ChatCommand {
ChatCommand::RemoveLights => "remove_lights", ChatCommand::RemoveLights => "remove_lights",
ChatCommand::Say => "say", ChatCommand::Say => "say",
ChatCommand::SetMotd => "set_motd", ChatCommand::SetMotd => "set_motd",
ChatCommand::SkillPoint => "skill_point",
ChatCommand::Spawn => "spawn", ChatCommand::Spawn => "spawn",
ChatCommand::Sudo => "sudo", ChatCommand::Sudo => "sudo",
ChatCommand::Tell => "tell", ChatCommand::Tell => "tell",

View File

@ -112,6 +112,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
ChatCommand::RemoveLights => handle_remove_lights, ChatCommand::RemoveLights => handle_remove_lights,
ChatCommand::Say => handle_say, ChatCommand::Say => handle_say,
ChatCommand::SetMotd => handle_set_motd, ChatCommand::SetMotd => handle_set_motd,
ChatCommand::SkillPoint => handle_skill_point,
ChatCommand::Spawn => handle_spawn, ChatCommand::Spawn => handle_spawn,
ChatCommand::Sudo => handle_sudo, ChatCommand::Sudo => handle_sudo,
ChatCommand::Tell => handle_tell, ChatCommand::Tell => handle_tell,
@ -1987,6 +1988,85 @@ spawn_rate {:?} "#,
} }
} }
fn find_target(
ecs: &specs::World,
opt_alias: Option<String>,
fallback: EcsEntity,
) -> Result<EcsEntity, ServerGeneral> {
if let Some(alias) = opt_alias {
(&ecs.entities(), &ecs.read_storage::<comp::Player>())
.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::<comp::Stats>()
.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<comp::skills::SkillGroupType> {
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( fn handle_debug(
server: &mut Server, server: &mut Server,
client: EcsEntity, client: EcsEntity,

View File

@ -969,7 +969,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Triple Strike Damage", "Triple Strike Damage",
"Increases damage scaling on triple strike", "Increases the damage each successive strike does",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -990,7 +990,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Triple Strike Speed", "Triple Strike Speed",
"Increases attack speed scaling on triple strike", "Increases attack speed gained by each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1011,7 +1011,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Triple Strike Regen", "Triple Strike Regen",
"Increases enery regen scaling on triple strike", "Increases stamina gain on each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1324,7 +1324,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Double Strike Damage", "Double Strike Damage",
"Increases damage scaling in combo", "Increases the damage dealt in each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1345,7 +1345,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Double Strike Speed", "Double Strike Speed",
"Increases speed scaling in combo", "Increases the attack speed with each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1366,7 +1366,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Double Strike Regen", "Double Strike Regen",
"Increases energy regen scaling in combo", "Increases stamina gain with each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1636,7 +1636,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Single Strike Damage", "Single Strike Damage",
"Increases damage scaling in combo", "Increases the damage with each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1657,7 +1657,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Single Strike Speed", "Single Strike Speed",
"Increases speed scaling in combo", "Increases the attack speed with each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )
@ -1678,7 +1678,7 @@ impl<'a> Widget for Diary<'a> {
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
"Single Strike Regen", "Single Strike Regen",
"Increases energy regen scaling in combo", "Increases stamina gain with each successive strike",
&diary_tooltip, &diary_tooltip,
TEXT_COLOR, TEXT_COLOR,
) )

View File

@ -303,7 +303,7 @@ impl<'a> Widget for Social<'a> {
// //
if Button::image(self.imgs.nothing) if Button::image(self.imgs.nothing)
.w_h(133.0, 18.0) .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(&self.localized_strings.get("hud.social.name"))
.label_font_size(self.fonts.cyri.scale(14)) .label_font_size(self.fonts.cyri.scale(14))
.label_y(conrod_core::position::Relative::Scalar(0.0)) .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) if Button::image(self.imgs.nothing)
.w_h(39.0, 18.0) .w_h(39.0, 18.0)
.right_from(state.ids.name_txt, 2.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_font_size(self.fonts.cyri.scale(14))
.label_y(conrod_core::position::Relative::Scalar(0.0)) .label_y(conrod_core::position::Relative::Scalar(0.0))
.label_font_id(self.fonts.cyri.conrod_id) .label_font_id(self.fonts.cyri.conrod_id)
@ -330,7 +330,7 @@ impl<'a> Widget for Social<'a> {
if Button::image(self.imgs.nothing) if Button::image(self.imgs.nothing)
.w_h(93.0, 18.0) .w_h(93.0, 18.0)
.right_from(state.ids.level_txt, 2.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_font_size(self.fonts.cyri.scale(14))
.label_y(conrod_core::position::Relative::Scalar(0.0)) .label_y(conrod_core::position::Relative::Scalar(0.0))
.label_font_id(self.fonts.cyri.conrod_id) .label_font_id(self.fonts.cyri.conrod_id)
@ -412,7 +412,7 @@ impl<'a> Widget for Social<'a> {
self.imgs.selection self.imgs.selection
}); });
let button = if i == 0 { 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 { } else {
button.down_from(state.ids.player_names[i - 1], 1.0) button.down_from(state.ids.player_names[i - 1], 1.0)
}; };
@ -422,7 +422,7 @@ impl<'a> Widget for Social<'a> {
alias alias
); );
button button
.w_h(133.0, 20.0) .w_h(260.0, 20.0)
.hover_image(if selected { .hover_image(if selected {
self.imgs.selection self.imgs.selection
} else { } else {