diff --git a/Cargo.lock b/Cargo.lock index 59ef27e..7806aa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,7 @@ dependencies = [ [[package]] name = "icarus" version = "0.0.0" -source = "git+https://github.com/redstrate/Icarus?branch=ver%2F2025.06.10.0000.0000#67c49d1e161f140fb5e1ee2bb051e8901ba3f6eb" +source = "git+https://github.com/redstrate/Icarus?branch=ver%2F2025.06.10.0000.0000#c6eb3b05ebe54b86c25d09dbc0bfc7b30f5cdadf" dependencies = [ "physis", ] @@ -1048,7 +1048,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "physis" version = "0.5.0" -source = "git+https://github.com/redstrate/physis#6ebb7acfcdcf80e2de9ce8d36fae42bb964d9cfc" +source = "git+https://github.com/redstrate/physis#862b16b681e8593f2b327442deddc12922209531" dependencies = [ "binrw", "bitflags", diff --git a/resources/scripts/events/Events.lua b/resources/scripts/events/Events.lua index bca0a8b..e5e56fd 100644 --- a/resources/scripts/events/Events.lua +++ b/resources/scripts/events/Events.lua @@ -308,6 +308,7 @@ common_events = { -- NPC shops that accept gil for purchasing items generic_gil_shops = { + 262157, -- Tanie , New Gridania 263220, -- Neon , Solution Nine } diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 8b4a9c1..6b19373 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -6,6 +6,7 @@ use kawari::RECEIVE_BUFFER_SIZE; use kawari::common::Position; use kawari::common::{GameData, timestamp_secs}; use kawari::config::get_config; +use kawari::inventory::Item; use kawari::ipc::chat::{ServerChatIpcData, ServerChatIpcSegment}; use kawari::ipc::zone::{ ActorControlCategory, ActorControlSelf, PlayerEntry, PlayerSpawn, PlayerStatus, SocialList, @@ -790,8 +791,21 @@ async fn client_loop( ClientZoneIpcData::GilShopTransaction { event_id, unk1: _, buy_sell_mode, item_index, item_quantity, unk2: _ } => { tracing::info!("Client is interacting with a shop! {event_id:#?} {buy_sell_mode:#?} {item_quantity:#?} {item_index:#?}"); - // TODO: update the client's inventory, adjust their gil, and send the proper response packets! - connection.send_message("Shops are not implemented yet. Cancelling event...").await; + let item_id; + { + let mut game_data = connection.gamedata.lock().unwrap(); + item_id = game_data.get_gilshop_item(*event_id, *item_index as u16); + } + + if let Some(item_id) = item_id { + // TODO: adjust their gil, and send the proper response packets! + connection.send_message("Shops are not implemented fully yet. Giving you a free item...").await; + + connection.player_data.inventory.add_in_next_free_slot(Item::new(1, item_id as u32)); + connection.send_inventory(false).await; + } else { + connection.send_message(&format!("Unable to find shop item, this is a bug in Kawari!")).await; + } // Cancel the event for now so the client doesn't get stuck connection.event_finish(*event_id).await; diff --git a/src/common/gamedata.rs b/src/common/gamedata.rs index 030abec..b3e93bb 100644 --- a/src/common/gamedata.rs +++ b/src/common/gamedata.rs @@ -2,6 +2,7 @@ use icarus::Action::ActionSheet; use icarus::Aetheryte::AetheryteSheet; use icarus::ClassJob::ClassJobSheet; use icarus::EquipSlotCategory::EquipSlotCategorySheet; +use icarus::GilShopItem::GilShopItemSheet; use icarus::PlaceName::PlaceNameSheet; use icarus::TerritoryType::TerritoryTypeSheet; use icarus::WeatherRate::WeatherRateSheet; @@ -329,6 +330,14 @@ impl GameData { pub fn get_exp_array_index(&self, classjob_id: u16) -> Option { self.classjob_exp_indexes.get(classjob_id as usize).copied() } + + /// Gets the item and it's cost from the specified shop. + pub fn get_gilshop_item(&mut self, gilshop_id: u32, index: u16) -> Option { + let sheet = GilShopItemSheet::read_from(&mut self.game_data, Language::None)?; + let row = sheet.get_subrow(gilshop_id, index)?; + + row.Item().into_i32().copied() + } } // Simple enum for GameData::get_territory_name