Added /kit command(admin only) that gives end game cultist gear for combat testing.

This commit is contained in:
Scott Williams
2021-03-25 12:51:39 +00:00
parent 2bfbdf74e3
commit d21e396cac
2 changed files with 43 additions and 0 deletions

View File

@ -62,6 +62,7 @@ pub enum ChatCommand {
Kick,
Kill,
KillNpcs,
Kit,
Lantern,
Light,
MakeBlock,
@ -116,6 +117,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
ChatCommand::Kick,
ChatCommand::Kill,
ChatCommand::KillNpcs,
ChatCommand::Kit,
ChatCommand::Lantern,
ChatCommand::Light,
ChatCommand::MakeBlock,
@ -325,6 +327,7 @@ impl ChatCommand {
),
ChatCommand::Kill => cmd(vec![], "Kill yourself", NoAdmin),
ChatCommand::KillNpcs => cmd(vec![], "Kill the NPCs", Admin),
ChatCommand::Kit => cmd(vec![], "Place all combat testing items into your pack.", Admin),
ChatCommand::Lantern => cmd(
vec![
Float("strength", 5.0, Required),
@ -482,6 +485,7 @@ impl ChatCommand {
ChatCommand::Kick => "kick",
ChatCommand::Kill => "kill",
ChatCommand::KillNpcs => "kill_npcs",
ChatCommand::Kit => "kit",
ChatCommand::Lantern => "lantern",
ChatCommand::Light => "light",
ChatCommand::MakeBlock => "make_block",

View File

@ -103,6 +103,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
ChatCommand::Kick => handle_kick,
ChatCommand::Kill => handle_kill,
ChatCommand::KillNpcs => handle_kill_npcs,
ChatCommand::Kit => handle_kit,
ChatCommand::Lantern => handle_lantern,
ChatCommand::Light => handle_light,
ChatCommand::MakeBlock => handle_make_block,
@ -1245,6 +1246,44 @@ fn handle_kill_npcs(
);
}
fn handle_kit(
server: &mut Server,
_client: EcsEntity,
target: EcsEntity,
_args: String,
_action: &ChatCommand,
) {
let item_list = [
comp::Item::new_from_asset_expect("common.items.armor.cultist.chest"),
comp::Item::new_from_asset_expect("common.items.armor.cultist.pants"),
comp::Item::new_from_asset_expect("common.items.armor.cultist.hand"),
comp::Item::new_from_asset_expect("common.items.armor.cultist.foot"),
comp::Item::new_from_asset_expect("common.items.armor.cultist.shoulder"),
comp::Item::new_from_asset_expect("common.items.armor.cultist.belt"),
comp::Item::new_from_asset_expect("common.items.weapons.hammer.cultist_purp_2h-0"),
comp::Item::new_from_asset_expect("common.items.weapons.staff.cultist_staff"),
comp::Item::new_from_asset_expect("common.items.weapons.sword.cultist"),
comp::Item::new_from_asset_expect("common.items.weapons.bow.velorite"),
comp::Item::new_from_asset_expect("common.items.weapons.axe.malachite_axe-0")
];
for item in &item_list {
server
.state()
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(target)
.map(|mut inv| inv.push(item.clone()));
let _ = server
.state
.ecs()
.write_storage::<comp::InventoryUpdate>()
.insert(
target,
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Debug),
);
}
}
#[allow(clippy::float_cmp)] // TODO: Pending review in #587
#[allow(clippy::needless_return)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587