mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-22 07:27:44 +00:00
Load model ids for items instead of hardcoding them
This makes non-female Miqotes load their racial starting gear correctly.
This commit is contained in:
parent
7f75a378f4
commit
68d3b07acb
2 changed files with 112 additions and 11 deletions
|
@ -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()),
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue