1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-22 20:47:45 +00:00

Calculate base racial attribute stats, send to client

This commit is contained in:
Joshua Goins 2025-03-29 09:02:31 -04:00
parent 0d95f0d5b8
commit 31c000b823
2 changed files with 50 additions and 2 deletions

View file

@ -1,8 +1,8 @@
use std::sync::{Arc, Mutex};
use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType};
use kawari::common::timestamp_secs;
use kawari::common::{Position, determine_initial_starting_zone, get_citystate, get_world_name};
use kawari::common::{get_racial_base_attributes, timestamp_secs};
use kawari::config::get_config;
use kawari::lobby::CharaMake;
use kawari::oodle::OodleNetwork;
@ -246,11 +246,19 @@ async fn main() {
// Stats
{
let attributes = get_racial_base_attributes(
chara_details.chara_make.customize.subrace,
);
let ipc = ServerZoneIpcSegment {
op_code: ServerZoneIpcType::PlayerStats,
timestamp: timestamp_secs(),
data: ServerZoneIpcData::PlayerStats(PlayerStats {
strength: 1,
strength: attributes.strength,
dexterity: attributes.dexterity,
vitality: attributes.vitality,
intelligence: attributes.intelligence,
mind: attributes.mind,
hp: 100,
mp: 100,
..Default::default()

View file

@ -153,6 +153,46 @@ pub fn determine_initial_starting_zone(citystate_id: u8) -> u16 {
}
}
pub struct Attributes {
pub strength: u32,
pub dexterity: u32,
pub vitality: u32,
pub intelligence: u32,
pub mind: u32,
}
pub fn get_racial_base_attributes(tribe_id: u8) -> Attributes {
// The Tribe Excel sheet only has deltas (e.g. 2 or -2) which are applied to a base 20 number... from somewhere
let base_stat = 20;
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("Tribe").unwrap();
let exd = game_data
.read_excel_sheet("Tribe", &exh, Language::English, 0)
.unwrap();
let tribe_row = &exd.read_row(&exh, tribe_id as u32).unwrap()[0];
let get_column = |column_index: usize| {
let physis::exd::ColumnData::Int8(delta) = &tribe_row.data[column_index] else {
panic!("Unexpected type!");
};
*delta
};
Attributes {
strength: (base_stat + get_column(4)) as u32,
dexterity: (base_stat + get_column(6)) as u32,
vitality: (base_stat + get_column(5)) as u32,
intelligence: (base_stat + get_column(7)) as u32,
mind: (base_stat + get_column(8)) as u32,
}
}
#[cfg(test)]
mod tests {
use super::*;