diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 17bf7c0..ece6a29 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -2,7 +2,9 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex}; use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType}; -use kawari::common::{Position, determine_initial_starting_zone, get_citystate, get_world_name}; +use kawari::common::{ + Position, determine_initial_starting_zone, get_citystate, get_primary_model_id, get_world_name, +}; use kawari::common::{get_racial_base_attributes, timestamp_secs}; use kawari::config::get_config; use kawari::lobby::CharaMake; @@ -420,16 +422,86 @@ async fn main() { fc_tag: "LOCAL".to_string(), display_flags: DisplayFlag::UNK, models: [ - 0, // head - 89, // body - 89, // hands - 89, // legs - 89, // feet - 0, // ears - 0, // neck - 0, // wrists - 0, // left finger - 0, // right finger + get_primary_model_id( + connection + .inventory + .equipped + .head + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .body + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .hands + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .legs + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .feet + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .ears + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .neck + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .wrists + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .left_ring + .id, + ) + as u32, + get_primary_model_id( + connection + .inventory + .equipped + .right_ring + .id, + ) + as u32, ], pos: exit_position .unwrap_or(Position::default()), diff --git a/src/common/mod.rs b/src/common/mod.rs index 1d78239..50b87dc 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -153,6 +153,35 @@ pub fn determine_initial_starting_zone(citystate_id: u8) -> u16 { } } +/// Gets the primary model ID for a given item ID +pub fn get_primary_model_id(item_id: u32) -> u16 { + let config = get_config(); + + let mut game_data = GameData::from_existing(Platform::Win32, &config.game_location).unwrap(); + + let exh = game_data.read_excel_sheet_header("Item").unwrap(); + for (i, _) in exh.pages.iter().enumerate() { + let exd = game_data + .read_excel_sheet("Item", &exh, Language::English, i) + .unwrap(); + + if let Some(row) = exd.read_row(&exh, item_id) { + let item_row = &row[0]; + + let physis::exd::ColumnData::UInt64(id) = &item_row.data[47] else { + panic!("Unexpected type!"); + }; + + return *id as u16; + } + } + + // TODO: just turn this into an Option<> + tracing::warn!("Failed to get model id for {item_id}, this is most likely a bug!"); + + 0 +} + pub struct Attributes { pub strength: u32, pub dexterity: u32,