diff --git a/src/jsonmanager/avatar_skill.rs b/src/jsonmanager/avatar_skill.rs new file mode 100644 index 0000000..f7fa478 --- /dev/null +++ b/src/jsonmanager/avatar_skill.rs @@ -0,0 +1,24 @@ +use serde::{Serialize, Deserialize}; + +#[derive(Deserialize, Clone)] +#[serde(rename_all="PascalCase")] +pub struct AvatarSkill { + pub id: u32, + pub name_text_map_hash: u32, + pub ability_name: String, + pub desc_text_map_hash: u32, + pub skill_icon: String, + pub cost_stamina: Option, + pub max_charge_num: u32, + pub trigger_id: Option, + pub lock_shape: String, // TODO: probably an enum + pub lock_weight_params: Vec, + pub drag_type: Option, // TODO: an enum + #[serde(default)] + pub show_icon_arrow: bool, + #[serde(default)] + pub is_attack_camera_lock: bool, + pub proud_skill_group_id: Option, + pub buff_icon: String, + pub global_value_key: String, +} \ No newline at end of file diff --git a/src/jsonmanager/json_manager.rs b/src/jsonmanager/json_manager.rs index d1b3d4f..63316eb 100644 --- a/src/jsonmanager/json_manager.rs +++ b/src/jsonmanager/json_manager.rs @@ -23,6 +23,7 @@ use super::world_level::WorldLevel; use super::gadget_prop::GadgetProp; use crate::jsonmanager::avatar::Avatar; +use crate::jsonmanager::avatar_skill::AvatarSkill; use crate::jsonmanager::proud_skill::ProudSkill; fn group_nonconsec_by(v: I, key: fn (&B) -> A) -> BTreeMap> @@ -67,6 +68,8 @@ pub struct JsonManager { pub avatars: HashMap, pub proud_skills: HashMap, + + pub avatar_skills: HashMap, } impl std::fmt::Debug for JsonManager { // TODO: fucking hack! @@ -105,6 +108,8 @@ impl JsonManager { let proud_skills: Vec = reader.read_json_list_game("ProudSkill"); + let avatar_skills: Vec = reader.read_json_list_game("AvatarSkill"); + return JsonManager { reader: reader, avatar_skill_depot: asd.into_iter().map(|a| (a.id, a)).collect(), @@ -137,6 +142,8 @@ impl JsonManager { avatars: avatars.into_iter().map(|a| (a.id, a)).collect(), proud_skills: proud_skills.into_iter().map(|ps| (ps.proud_skill_id, ps)).collect(), + + avatar_skills: avatar_skills.into_iter().map(|ass| (ass.id, ass)).collect(), }; } diff --git a/src/jsonmanager/mod.rs b/src/jsonmanager/mod.rs index ccbf8d2..5b015cd 100644 --- a/src/jsonmanager/mod.rs +++ b/src/jsonmanager/mod.rs @@ -4,6 +4,7 @@ pub use self::json_manager::JsonManager; mod proud_skill; mod avatar; +mod avatar_skill; mod avatar_skill_depot; mod entity_curve; mod monster; diff --git a/src/utils/avatar_builder.rs b/src/utils/avatar_builder.rs index dfa8d87..5798842 100644 --- a/src/utils/avatar_builder.rs +++ b/src/utils/avatar_builder.rs @@ -51,8 +51,16 @@ impl AvatarBuilder { .filter(|s| s.proud_skill_group_id != None) .filter(|s| s.need_avatar_promote_level == None || s.need_avatar_promote_level.unwrap() <= promote_level) .map(|s| s.proud_skill_group_id.unwrap()) - .map(|s| s * 100 + 1) // TODO: ugly hack! Fix it by reading ProudSkillExcelConfigData! + + .map(|s| { + let skill_ids: Vec = jm.proud_skills.values().filter(|ps| ps.proud_skill_group_id == s).map(|ps| ps.proud_skill_id).collect(); + skill_ids + }) + .flatten() .collect(); + /* + .map(|s| s * 100 + 1) // TODO: ugly hack! Fix it by reading ProudSkillExcelConfigData! + .collect();*/ // TODO: properly fill! let afi = build!(AvatarFetterInfo { @@ -63,10 +71,21 @@ impl AvatarBuilder { let egi = db.get_avatar_equip(a.guid).unwrap_or_else(|| panic!("Equip not found for avatar {}!", a.guid)); let egi = egi.into_iter().map(|g| g as u64).collect(); // FIXME - // TODO: ugly ugly hack! - let mut fuck = HashMap::new(); - fuck.insert(732, 3); - fuck.insert(739, 3); + /* + 1. Get all the skill IDs from AvatarSkillDepot entry + 2. For each skill, get corresponding entry from AvatarSkill collection + 3. For each AvatarSkill, filter out ones that have ProudSkillGroupId set + 4. Specify the level for those proud skills + */ + let proud_skill_extra = asd.skills.iter() + .map(|s| jm.avatar_skills.get(s)) + .filter(|ass| ass.is_some()) + .map(|ass| ass.unwrap()) + .filter(|ass| ass.proud_skill_group_id != None) + .map(|ass| (ass.proud_skill_group_id.unwrap(), 3)) // TODO: fetch level from the database! + .collect(); + + let avatar = &jm.avatars[&IdManager::get_avatar_id_by_char_id(a.character_id)]; let ai = build!(AvatarInfo { avatar_id: IdManager::get_avatar_id_by_char_id(a.character_id), @@ -81,15 +100,15 @@ impl AvatarBuilder { equip_guid_list: egi, inherent_proud_skill_list: ips, //vec![72101, 72201], skill_level_map: slm, - proud_skill_extra_level_map: fuck, //collection!{739 => 3, 732 => 3}, + proud_skill_extra_level_map: proud_skill_extra, //collection!{739 => 3, 732 => 3}, wearing_flycloak_id: 140001, // TODO: hack! life_state: 1, - excel_info: Some(build!(AvatarExcelInfo { // TODO: load values from config! - prefab_path_hash: IdManager::get_hash_by_prefix_suffix(50, 2568507538), - prefab_path_remote_hash: IdManager::get_hash_by_prefix_suffix(158, 3204428759), - controller_path_hash: IdManager::get_hash_by_prefix_suffix(154, 3376713903), - controller_path_remote_hash: IdManager::get_hash_by_prefix_suffix(228, 1479775384), - combat_config_hash: IdManager::get_hash_by_prefix_suffix(244, 4049143033), + excel_info: Some(build!(AvatarExcelInfo { + prefab_path_hash: IdManager::get_hash_by_prefix_suffix(avatar.prefab_path_hash_pre, avatar.prefab_path_hash_suffix), + prefab_path_remote_hash: IdManager::get_hash_by_prefix_suffix(avatar.prefab_path_remote_hash_pre, avatar.prefab_path_remote_hash_suffix), + controller_path_hash: IdManager::get_hash_by_prefix_suffix(avatar.controller_path_hash_pre, avatar.controller_path_hash_suffix), + controller_path_remote_hash: IdManager::get_hash_by_prefix_suffix(avatar.controller_path_remote_hash_pre, avatar.controller_path_remote_hash_suffix), + combat_config_hash: IdManager::get_hash_by_prefix_suffix(avatar.combat_config_hash_pre, avatar.combat_config_hash_suffix), })), }); return ai;