mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'qutrin/command-stuff' into 'master'
Add /health command See merge request veloren/veloren!283
This commit is contained in:
commit
0f38fba897
@ -6,6 +6,7 @@ pub enum HealthSource {
|
|||||||
Attack { by: Uid }, // TODO: Implement weapon
|
Attack { by: Uid }, // TODO: Implement weapon
|
||||||
Suicide,
|
Suicide,
|
||||||
Revive,
|
Revive,
|
||||||
|
Command,
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,13 @@ lazy_static! {
|
|||||||
handle_empty,
|
handle_empty,
|
||||||
),
|
),
|
||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
"help", "", "/help: Display this message", handle_help)
|
"help", "", "/help: Display this message", handle_help),
|
||||||
|
ChatCommand::new(
|
||||||
|
"health",
|
||||||
|
"{}",
|
||||||
|
"/health : Set your current health",
|
||||||
|
handle_health,
|
||||||
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +211,31 @@ fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_health(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
|
||||||
|
let opt_hp = scan_fmt!(&args, action.arg_fmt, u32);
|
||||||
|
|
||||||
|
match server
|
||||||
|
.state
|
||||||
|
.ecs_mut()
|
||||||
|
.write_storage::<comp::Stats>()
|
||||||
|
.get_mut(entity)
|
||||||
|
{
|
||||||
|
Some(stats) => match opt_hp {
|
||||||
|
Some(hp) => stats.health.set_to(hp, comp::HealthSource::Command),
|
||||||
|
None => {
|
||||||
|
server.clients.notify(
|
||||||
|
entity,
|
||||||
|
ServerMsg::Chat(String::from("You must specify health amount!")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => server.clients.notify(
|
||||||
|
entity,
|
||||||
|
ServerMsg::Chat(String::from("You have no position.")),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_alias(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
|
fn handle_alias(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
|
||||||
let opt_alias = scan_fmt!(&args, action.arg_fmt, String);
|
let opt_alias = scan_fmt!(&args, action.arg_fmt, String);
|
||||||
match opt_alias {
|
match opt_alias {
|
||||||
|
Loading…
Reference in New Issue
Block a user