Compare commits

...

2 commits

Author SHA1 Message Date
07348aed45 Weapons unlock & switching 2024-04-13 17:34:52 +03:00
8c1a42b9f4 Skins and flycloaks (wind gliders) switching & unlock 2024-04-12 22:41:43 +03:00
13 changed files with 11783 additions and 246 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,123 @@
[
{
"flycloakId": 140001,
"nameTextMapHash": 1227437700,
"descTextMapHash": 2963284368,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Glider_01/Flycloak_Normal_Glider_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Glider",
"materialId": 140001
},
{
"flycloakId": 140002,
"nameTextMapHash": 3679998556,
"descTextMapHash": 2439760640,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Starlit_01/Flycloak_Normal_Starlit_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Starlit",
"materialId": 140002
},
{
"flycloakId": 140003,
"nameTextMapHash": 1307041812,
"descTextMapHash": 251460624,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Psalmus_01/Flycloak_Normal_Psalmus_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Psalmus",
"materialId": 140003
},
{
"flycloakId": 140004,
"nameTextMapHash": 3265724196,
"descTextMapHash": 95448472,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Gale_01/Flycloak_Normal_Gale_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Gale",
"materialId": 140004
},
{
"flycloakId": 140005,
"nameTextMapHash": 1800191236,
"descTextMapHash": 397410296,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Megalith_01/Flycloak_Normal_Megalith_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Megalith",
"materialId": 140005
},
{
"flycloakId": 140006,
"nameTextMapHash": 790364508,
"descTextMapHash": 2419069352,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Nixavis_01/Flycloak_Normal_Nixavis_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Nixavis",
"materialId": 140006
},
{
"flycloakId": 140007,
"nameTextMapHash": 972574812,
"descTextMapHash": 3582594568,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Redcomet_01/Flycloak_Normal_Redcomet_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Redcomet",
"materialId": 140007,
"hide": true
},
{
"flycloakId": 140008,
"nameTextMapHash": 1047777100,
"descTextMapHash": 533901256,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Thunderclap_01/Flycloak_Normal_Thunderclap_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Thunderclap",
"materialId": 140008
},
{
"flycloakId": 140009,
"nameTextMapHash": 14389020,
"descTextMapHash": 3075333936,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Skald_01/Flycloak_Normal_Skald_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Skald",
"materialId": 140009,
"hide": true
},
{
"flycloakId": 140010,
"nameTextMapHash": 2488969468,
"descTextMapHash": 1899653016,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Ayus_01/Flycloak_Normal_Ayus_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Ayus",
"materialId": 140010
},
{
"flycloakId": 140011,
"nameTextMapHash": 2292890772,
"descTextMapHash": 681143304,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Asterceno_01/Flycloak_Normal_Asterceno_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Asterceno",
"materialId": 140011,
"hide": true
},
{
"flycloakId": 140012,
"nameTextMapHash": 180645420,
"descTextMapHash": 1161581424,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Iustitia_01/Flycloak_Normal_Iustitia_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Iustitia",
"materialId": 140012
},
{
"flycloakId": 140013,
"nameTextMapHash": 2462291164,
"descTextMapHash": 1830391744,
"prefabPath": "ART/System/Flycloak/Flycloak_Normal_Sternlied_01/Flycloak_Normal_Sternlied_01",
"jsonName": "Flycloak_Default_01",
"icon": "UI_Gacha_FlycloakIcon_Sternlied",
"materialId": 140013,
"hide": true
}
]

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,80 @@ pub struct AvatarExcelConfig {
pub lodpattern_name: String,
}
#[derive(Deserialize, Default)]
#[serde(default)]
#[serde(rename_all = "camelCase")]
pub struct AvatarCostumeExcelConfig {
pub skin_id: u32,
#[serde(rename = "indexID")]
pub index_id: u32,
pub name_text_map_hash: u64,
pub desc_text_map_hash: u64,
pub item_id: u32,
pub character_id: u32,
pub json_name: String,
pub prefab_path_hash: u64,
pub prefab_remote_path_hash: u64,
pub prefab_npc_path_hash: u64,
pub prefab_manekin_path_hash: u64,
pub quality: u32,
pub front_icon_name: String,
pub side_icon_name: String,
pub image_name_hash: u64,
}
#[derive(Deserialize, Default)]
#[serde(default)]
#[serde(rename_all = "camelCase")]
pub struct AvatarFlycloakExcelConfig {
pub flycloak_id: u32,
pub name_text_map_hash: u64,
pub desc_text_map_hash: u64,
pub prefab_path: String,
pub json_name: String,
pub icon: String,
pub material_id: u32,
}
#[derive(Deserialize, Default)]
#[serde(default)]
#[serde(rename_all = "camelCase")]
pub struct WeaponExcelConfig {
pub weapon_type: String,
pub rank_level: u32,
pub weapon_base_exp: u32,
pub skill_affix: Vec<u32>,
pub weapon_prop: Vec<WeaponProp>,
pub awaken_texture: String,
pub awaken_light_map_texture: String,
pub awaken_icon: String,
pub weapon_promote_id: u32,
pub story_id: u32,
pub awaken_costs: Vec<u32>,
pub gacha_card_name_hash: u64,
pub destroy_rule: String,
pub destroy_return_material: Vec<u32>,
pub destroy_return_material_count: Vec<u32>,
pub id: u32,
pub name_text_map_hash: u64,
pub desc_text_map_hash: u64,
pub icon: String,
pub item_type: String,
pub weight: u32,
pub rank: u32,
pub gadget_id: u32,
}
#[derive(Deserialize, Default)]
#[serde(default)]
#[serde(rename_all = "camelCase")]
pub struct WeaponProp {
pub prop_type: String,
pub init_value: f32,
#[serde(rename = "type")]
pub type_field: String,
}
#[derive(Deserialize, Default)]
#[serde(default)]
#[serde(rename_all = "camelCase")]

View file

@ -20,6 +20,9 @@ lazy_static! {
pub struct ExcelCollection {
pub avatar_configs: Vec<AvatarExcelConfig>,
pub avatar_flycloak_configs: Vec<AvatarFlycloakExcelConfig>,
pub avatar_costume_configs: Vec<AvatarCostumeExcelConfig>,
pub weapon_configs: Vec<WeaponExcelConfig>,
pub open_state_configs: Vec<OpenStateConfig>,
}
@ -34,6 +37,18 @@ impl ExcelCollection {
"assets/ExcelBinOutput/AvatarExcelConfigData.json",
))
.unwrap(),
avatar_flycloak_configs: from_str(&load_asset(
"assets/ExcelBinOutput/AvatarFlycloakExcelConfigData.json",
))
.unwrap(),
avatar_costume_configs: from_str(&load_asset(
"assets/ExcelBinOutput/AvatarCostumeExcelConfigData.json",
))
.unwrap(),
weapon_configs: from_str(&load_asset(
"assets/ExcelBinOutput/WeaponExcelConfigData.json",
))
.unwrap(),
open_state_configs: from_str(&load_asset(
"assets/ExcelBinOutput/OpenStateConfigData.json",
))
@ -42,7 +57,7 @@ impl ExcelCollection {
}
pub fn table_count(&self) -> usize {
2
5
}
}

View file

@ -1,7 +1,11 @@
use proto::*;
use super::*;
use crate::{data, game::AvatarData, util};
use crate::{
data,
game::{AvatarData, WeaponData},
util,
};
pub struct SceneAvatar {
data: AvatarData,
@ -25,6 +29,14 @@ impl SceneAvatar {
self.data.clone()
}
pub fn update_data(&mut self, data: &AvatarData) {
self.data = AvatarData {
properties: self.data.properties.clone(),
fight_properties: self.data.fight_properties.clone(),
..data.clone()
};
}
pub fn avatar_guid(&self) -> u64 {
self.data.guid
}
@ -49,6 +61,10 @@ impl SceneAvatar {
}
}
pub fn change_weapon(&mut self, weapon: WeaponData) {
self.weapon = SceneWeapon::new(self.weapon.get_entity_id(), weapon);
}
pub fn ability_control_block(&self) -> AbilityControlBlock {
let mut control_block = AbilityControlBlock::default();
@ -132,6 +148,7 @@ impl Entity for SceneAvatar {
skill_depot_id: self.data.skill_depot_id,
weapon: Some(self.weapon.scene_weapon_info()),
team_resonance_list: vec![10301],
costume_id: self.data.costume_id,
wearing_flycloak_id: self.data.wearing_flycloak_id,
born_time: self.data.born_time,
excel_info: Some(AvatarExcelInfo::default()),

View file

@ -7,6 +7,7 @@ pub struct PlayerInfo {
pub uid: u32,
pub guid_manager: GUIDManager,
pub avatars: Vec<AvatarData>,
pub weapons: Vec<WeaponData>,
}
#[derive(Clone)]
@ -15,6 +16,7 @@ pub struct AvatarData {
pub avatar_id: u32,
pub skill_depot_id: u32,
pub wearing_flycloak_id: u32,
pub costume_id: u32,
pub born_time: u32,
pub weapon: WeaponData,
pub properties: Vec<PropValue>,
@ -34,6 +36,7 @@ impl PlayerInfo {
uid: 1337,
guid_manager: GUIDManager::new(),
avatars: Vec::new(),
weapons: Vec::new(),
}
}
@ -41,22 +44,34 @@ impl PlayerInfo {
self.guid_manager.next()
}
pub fn unlock_all_weapons(&mut self) {
self.weapons
.extend(EXCEL_COLLECTION.weapon_configs.iter().map(|w| WeaponData {
weapon_id: w.id,
guid: self.guid_manager.next(),
}));
}
pub fn unlock_all_avatars(&mut self) {
for config in EXCEL_COLLECTION
.avatar_configs
.iter()
.filter(|c| !DISABLED_AVATAR_LIST.contains(&c.id))
{
let weapon = WeaponData {
weapon_id: config.initial_weapon,
guid: self.next_guid(),
};
self.weapons.push(weapon.clone());
let mut data = AvatarData {
guid: self.next_guid(),
avatar_id: config.id,
skill_depot_id: config.skill_depot_id,
wearing_flycloak_id: 140001,
costume_id: 0,
born_time: util::cur_timestamp() as u32,
weapon: WeaponData {
guid: self.next_guid(),
weapon_id: config.initial_weapon,
},
weapon,
properties: Vec::new(),
fight_properties: Vec::new(),
};
@ -154,6 +169,22 @@ impl AvatarData {
}
}
impl From<WeaponData> for Item {
fn from(value: WeaponData) -> Self {
Self {
item_id: value.weapon_id,
guid: value.guid,
detail: Some(item::Detail::Equip(Equip {
is_locked: false,
detail: Some(equip::Detail::Weapon(Weapon {
level: 1,
..Default::default()
})),
})),
}
}
}
impl From<AvatarData> for AvatarInfo {
fn from(value: AvatarData) -> Self {
Self {
@ -161,6 +192,7 @@ impl From<AvatarData> for AvatarInfo {
avatar_id: value.avatar_id,
skill_depot_id: value.skill_depot_id,
wearing_flycloak_id: value.wearing_flycloak_id,
costume_id: value.costume_id,
born_time: value.born_time,
life_state: 1,
avatar_type: 1,

View file

@ -38,6 +38,7 @@ pub async fn on_get_player_token_req(
pub async fn on_player_login_req(session: &PlayerSession, _body: &PlayerLoginReq) -> Result<()> {
session.player_info_mut().unlock_all_avatars();
session.player_info_mut().unlock_all_weapons();
let props = [
(PROP_PLAYER_LEVEL, 5),
@ -83,11 +84,28 @@ pub async fn on_player_login_req(session: &PlayerSession, _body: &PlayerLoginReq
.await?;
let player_info = session.player_info();
let player_store_notify = PlayerStoreNotify {
weight_limit: 30000,
store_type: StoreType::StorePack.into(),
item_list: player_info
.weapons
.clone()
.into_iter()
.map(Item::from)
.collect(),
};
session
.send(PLAYER_STORE_NOTIFY, player_store_notify)
.await?;
let avatar_data_notify = AvatarDataNotify {
avatar_list: player_info
.avatars
.iter()
.map(|a| Into::<AvatarInfo>::into(a.clone()))
.clone()
.into_iter()
.map(AvatarInfo::from)
.collect(),
cur_avatar_team_id: 1,
choose_avatar_guid: 228,
@ -105,6 +123,16 @@ pub async fn on_player_login_req(session: &PlayerSession, _body: &PlayerLoginReq
team_name: String::from("LogicTeam"),
},
)]),
owned_costume_list: EXCEL_COLLECTION
.avatar_costume_configs
.iter()
.map(|a| a.skin_id)
.collect(),
owned_flycloak_list: EXCEL_COLLECTION
.avatar_flycloak_configs
.iter()
.map(|a| a.flycloak_id)
.collect(),
..Default::default()
};

View file

@ -1,7 +1,7 @@
use std::collections::HashMap;
use super::*;
use crate::game::entity::Entity;
use crate::game::entity::{Entity, SceneWeapon};
pub async fn on_change_avatar_req(session: &PlayerSession, body: &ChangeAvatarReq) -> Result<()> {
let mut scene = session.context.scene.borrow_mut();
@ -33,6 +33,176 @@ pub async fn on_change_avatar_req(session: &PlayerSession, body: &ChangeAvatarRe
.await
}
pub async fn on_avatar_change_costume_req(
session: &PlayerSession,
body: &AvatarChangeCostumeReq,
) -> Result<()> {
let mut player = session.player_info_mut();
let Some(avatar) = player
.avatars
.iter_mut()
.find(|a| a.guid == body.avatar_guid)
else {
return session
.send(
AVATAR_CHANGE_COSTUME_RSP,
AvatarChangeCostumeRsp {
retcode: -1,
..Default::default()
},
)
.await;
};
avatar.costume_id = body.costume_id;
let mut scene = session.context.scene.borrow_mut();
if let Some(avatar_entity) = scene
.avatars
.iter_mut()
.find(|a| a.avatar_guid() == body.avatar_guid)
{
avatar_entity.update_data(avatar);
session
.send(
AVATAR_CHANGE_COSTUME_NOTIFY,
AvatarChangeCostumeNotify {
entity_info: Some(avatar_entity.info()),
},
)
.await?;
}
session
.send(
AVATAR_CHANGE_COSTUME_RSP,
AvatarChangeCostumeRsp {
avatar_guid: body.avatar_guid,
costume_id: body.costume_id,
retcode: 0,
},
)
.await
}
pub async fn on_avatar_wear_flycloak_req(
session: &PlayerSession,
body: &AvatarWearFlycloakReq,
) -> Result<()> {
let mut player = session.player_info_mut();
let Some(avatar) = player
.avatars
.iter_mut()
.find(|a| a.guid == body.avatar_guid)
else {
return session
.send(
AVATAR_WEAR_FLYCLOAK_RSP,
AvatarWearFlycloakRsp {
retcode: -1,
..Default::default()
},
)
.await;
};
avatar.wearing_flycloak_id = body.flycloak_id;
let mut scene = session.context.scene.borrow_mut();
if let Some(avatar_entity) = scene
.avatars
.iter_mut()
.find(|a| a.avatar_guid() == body.avatar_guid)
{
avatar_entity.update_data(avatar);
}
session
.send(
AVATAR_FLYCLOAK_CHANGE_NOTIFY,
AvatarFlycloakChangeNotify {
avatar_guid: body.avatar_guid,
flycloak_id: body.flycloak_id,
},
)
.await?;
session
.send(
AVATAR_WEAR_FLYCLOAK_RSP,
AvatarWearFlycloakRsp {
retcode: 0,
avatar_guid: body.avatar_guid,
flycloak_id: body.flycloak_id,
},
)
.await
}
pub async fn on_wear_equip_req(session: &PlayerSession, body: &WearEquipReq) -> Result<()> {
let mut player = session.player_info_mut();
let weapon = player
.weapons
.iter()
.find(|w| w.guid == body.equip_guid)
.map(|w| w.clone());
let avatar = player
.avatars
.iter_mut()
.find(|a| a.guid == body.avatar_guid);
let (Some(weapon), Some(avatar)) = (weapon, avatar) else {
return session
.send(
WEAR_EQUIP_RSP,
WearEquipRsp {
retcode: -1,
..Default::default()
},
)
.await;
};
avatar.weapon = weapon;
session
.send(
AVATAR_EQUIP_CHANGE_NOTIFY,
AvatarEquipChangeNotify {
avatar_guid: body.avatar_guid,
equip_guid: body.equip_guid,
item_id: avatar.weapon.weapon_id,
equip_type: 6,
weapon: Some(SceneWeapon::new(0, avatar.weapon.clone()).scene_weapon_info()),
reliquary: None,
},
)
.await?;
let mut scene = session.context.scene.borrow_mut();
if let Some(avatar_entity) = scene
.avatars
.iter_mut()
.find(|a| a.avatar_guid() == body.avatar_guid)
{
avatar_entity.update_data(&avatar);
avatar_entity.change_weapon(avatar.weapon.clone());
}
session
.send(
WEAR_EQUIP_RSP,
WearEquipRsp {
retcode: 0,
equip_guid: body.equip_guid,
avatar_guid: body.avatar_guid,
},
)
.await
}
pub async fn on_set_up_avatar_team_req(
session: &PlayerSession,
body: &SetUpAvatarTeamReq,

View file

@ -138,4 +138,7 @@ trait_handler! {
EvtAvatarStandUpNotify 8549;
MarkMapReq 7802;
GetSceneAreaReq 5114;
AvatarChangeCostumeReq 24368;
AvatarWearFlycloakReq 27466;
WearEquipReq 21829;
}

View file

@ -37,10 +37,7 @@ pub fn xor(bytes: &mut [u8], key: &[u8]) {
}
pub fn hash_str(value: &str) -> u32 {
let mut hash = 0;
value
.chars()
.for_each(|c| hash = (((c as u64) + 131 * hash as u64) & 0xFFFFFFFF) as u32);
hash
value.chars().fold(0, |hash, c| {
(((c as u64) + 131 * hash as u64) & 0xFFFFFFFF) as u32
})
}

File diff suppressed because it is too large Load diff

View file

@ -23,3 +23,10 @@ pub const EVT_AVATAR_SIT_DOWN_RSP: u16 = 29232;
pub const EVT_AVATAR_STAND_UP_NOTIFY: u16 = 8549;
pub const MARK_MAP_RSP: u16 = 25569;
pub const GET_SCENE_AREA_RSP: u16 = 22648;
pub const AVATAR_CHANGE_COSTUME_RSP: u16 = 21748;
pub const AVATAR_CHANGE_COSTUME_NOTIFY: u16 = 8370;
pub const AVATAR_WEAR_FLYCLOAK_RSP: u16 = 25960;
pub const AVATAR_FLYCLOAK_CHANGE_NOTIFY: u16 = 23818;
pub const PLAYER_STORE_NOTIFY: u16 = 20155;
pub const WEAR_EQUIP_RSP: u16 = 9831;
pub const AVATAR_EQUIP_CHANGE_NOTIFY: u16 = 9280;