diff --git a/USAGE.md b/USAGE.md index f81898a..83c4425 100644 --- a/USAGE.md +++ b/USAGE.md @@ -114,6 +114,7 @@ These special debug commands start with `!` and are custom to Kawari. * `!festival `: Sets the festival in the current zone. Multiple festivals can be set together to create interesting effects. * `!reload`: Reloads `Global.lua` that is normally only loaded once at start-up. * `!finishevent`: Forcefully finishes the current event, useful if the script has an error and you're stuck talking to something. +* `!item `: Gives you an item matching by name. ### GM commands diff --git a/src/world/chat_handler.rs b/src/world/chat_handler.rs index 7e3105b..9379c7a 100644 --- a/src/world/chat_handler.rs +++ b/src/world/chat_handler.rs @@ -1,5 +1,5 @@ use crate::{ - inventory::Storage, + inventory::{Item, Storage}, ipc::zone::{ChatMessage, GameMasterRank}, world::ToServer, }; @@ -78,6 +78,23 @@ impl ChatHandler { connection.send_inventory(true).await; true } + "!item" => { + let (_, name) = chat_message.message.split_once(' ').unwrap(); + + { + let mut gamedata = connection.gamedata.lock().unwrap(); + + if let Some((_, id)) = gamedata.get_item_by_name(name) { + connection + .player_data + .inventory + .add_in_next_free_slot(Item { quantity: 1, id }); + } + } + + connection.send_inventory(false).await; + true + } "!reload" => { connection.reload_scripts(); connection.send_message("Scripts reloaded!").await;