mirror of
https://git.neonteam.dev/amizing/robinsr.git
synced 2025-03-12 03:28:30 -04:00
?
This commit is contained in:
parent
54db3b2408
commit
1e8e6f04c3
@ -24,7 +24,7 @@ pub async fn on_start_cocoon_stage_cs_req(
|
||||
if **avatar_id == 0 {
|
||||
continue;
|
||||
}
|
||||
if let Some(avatar) = player.avatars.get(&avatar_id) {
|
||||
if let Some(avatar) = player.avatars.get(avatar_id) {
|
||||
let (battle_avatar, techs) = avatar.to_battle_avatar_proto(
|
||||
i,
|
||||
player
|
||||
@ -47,7 +47,7 @@ pub async fn on_start_cocoon_stage_cs_req(
|
||||
// custom stats for avatars
|
||||
for stat in &player.battle_config.custom_stats {
|
||||
for avatar in &mut battle_info.battle_avatar_list {
|
||||
if avatar.relic_list.len() == 0 {
|
||||
if avatar.relic_list.is_empty() {
|
||||
avatar.relic_list.push(BattleRelic {
|
||||
id: 61011,
|
||||
main_affix_id: 1,
|
||||
@ -184,7 +184,7 @@ pub async fn on_mpemgbdkigg(session: &mut PlayerSession, request: &Mpemgbdkigg)
|
||||
if **avatar_id == 0 {
|
||||
continue;
|
||||
}
|
||||
if let Some(avatar) = player.avatars.get(&avatar_id) {
|
||||
if let Some(avatar) = player.avatars.get(avatar_id) {
|
||||
let (battle_avatar, techs) = avatar.to_battle_avatar_proto(
|
||||
i,
|
||||
player
|
||||
@ -207,7 +207,7 @@ pub async fn on_mpemgbdkigg(session: &mut PlayerSession, request: &Mpemgbdkigg)
|
||||
// custom stats for avatars
|
||||
for stat in &player.battle_config.custom_stats {
|
||||
for avatar in &mut battle_info.battle_avatar_list {
|
||||
if avatar.relic_list.len() == 0 {
|
||||
if avatar.relic_list.is_empty() {
|
||||
avatar.relic_list.push(BattleRelic {
|
||||
id: 61011,
|
||||
main_affix_id: 1,
|
||||
@ -317,7 +317,5 @@ pub async fn on_mpemgbdkigg(session: &mut PlayerSession, request: &Mpemgbdkigg)
|
||||
|
||||
resp.battle_info = Some(battle_info);
|
||||
|
||||
session.send(CMD_SCENE_CAST_SKILL_SC_RSP, resp).await?;
|
||||
|
||||
Ok(())
|
||||
session.send(CMD_SCENE_CAST_SKILL_SC_RSP, resp).await
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@ pub async fn on_get_all_lineup_data_cs_req(
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_GET_ALL_LINEUP_DATA_SC_RSP,
|
||||
@ -33,7 +32,7 @@ pub async fn on_get_cur_lineup_data_cs_req(
|
||||
_body: &GetCurLineupDataCsReq,
|
||||
) -> Result<()> {
|
||||
let player = tools::JsonData::load().await;
|
||||
let mut lineup = LineupInfo {
|
||||
let mut lineup = LineupInfo {
|
||||
extra_lineup_type: ExtraLineupType::LineupNone.into(),
|
||||
name: "Squad 1".to_string(),
|
||||
njjbfegnhjc: 5,
|
||||
@ -43,8 +42,8 @@ pub async fn on_get_cur_lineup_data_cs_req(
|
||||
|
||||
let avatar_ids = player
|
||||
.avatars
|
||||
.iter()
|
||||
.map(|(_, v)| v.avatar_id)
|
||||
.values()
|
||||
.map(|v| v.avatar_id)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut avatars = player
|
||||
@ -62,7 +61,6 @@ pub async fn on_get_cur_lineup_data_cs_req(
|
||||
|
||||
lineup.avatar_list.append(&mut avatars);
|
||||
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_GET_CUR_LINEUP_DATA_SC_RSP,
|
||||
@ -78,30 +76,31 @@ pub async fn on_join_lineup_cs_req(
|
||||
session: &mut PlayerSession,
|
||||
body: &JoinLineupCsReq,
|
||||
) -> Result<()> {
|
||||
|
||||
// update lineups
|
||||
// TODO: FIX THESE SHIT
|
||||
{
|
||||
let mut player = tools::JsonData::load().await;
|
||||
let mut player = tools::JsonData::load().await;
|
||||
let lineups = &mut player.lineups;
|
||||
lineups.insert(body.slot, if body.base_avatar_id > 8000 {
|
||||
player.main_character as u32
|
||||
} else {
|
||||
body.base_avatar_id
|
||||
});
|
||||
lineups.insert(
|
||||
body.slot,
|
||||
if body.base_avatar_id > 8000 {
|
||||
player.main_character as u32
|
||||
} else {
|
||||
body.base_avatar_id
|
||||
},
|
||||
);
|
||||
player.save_lineup().await;
|
||||
}
|
||||
|
||||
{
|
||||
let player = tools::JsonData::load().await;
|
||||
let player = tools::JsonData::load().await;
|
||||
|
||||
refresh_lineup(session,&player).await?;
|
||||
refresh_lineup(session, &player).await?;
|
||||
}
|
||||
|
||||
session.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
session
|
||||
.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn on_replace_lineup_cs_req(
|
||||
@ -109,14 +108,14 @@ pub async fn on_replace_lineup_cs_req(
|
||||
req: &ReplaceLineupCsReq,
|
||||
) -> Result<()> {
|
||||
{
|
||||
let mut player = tools::JsonData::load().await;
|
||||
let mut player = tools::JsonData::load().await;
|
||||
|
||||
let lineups = &mut player.lineups;
|
||||
for (slot, avatar_id) in &mut *lineups {
|
||||
if let Some(lineup) = req.jkifflmenfn.get(*slot as usize) {
|
||||
*avatar_id = if lineup.id > 8000 {
|
||||
player.main_character as u32
|
||||
} else {
|
||||
} else {
|
||||
lineup.id
|
||||
};
|
||||
} else {
|
||||
@ -127,35 +126,30 @@ pub async fn on_replace_lineup_cs_req(
|
||||
}
|
||||
|
||||
{
|
||||
let player = tools::JsonData::load().await;
|
||||
let player = tools::JsonData::load().await;
|
||||
|
||||
refresh_lineup(_session, &player).await?;
|
||||
}
|
||||
|
||||
_session.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
_session
|
||||
.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn on_quit_lineup_cs_req(
|
||||
_session: &mut PlayerSession,
|
||||
_: &QuitLineupCsReq,
|
||||
) -> Result<()> {
|
||||
_session.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
_session
|
||||
.send(CMD_JOIN_LINEUP_SC_RSP, JoinLineupScRsp::default())
|
||||
.await
|
||||
}
|
||||
|
||||
async fn refresh_lineup(
|
||||
sess: &mut PlayerSession,
|
||||
player: &JsonData
|
||||
) -> Result<()> {
|
||||
async fn refresh_lineup(sess: &mut PlayerSession, player: &JsonData) -> Result<()> {
|
||||
let lineup = LineupInfo {
|
||||
extra_lineup_type: ExtraLineupType::LineupNone.into(),
|
||||
name: "Squad 1".to_string(),
|
||||
avatar_list: AvatarJson::to_lineup_avatars(&player),
|
||||
avatar_list: AvatarJson::to_lineup_avatars(player),
|
||||
njjbfegnhjc: 5,
|
||||
bpkggopoppf: 5,
|
||||
..Default::default()
|
||||
@ -165,12 +159,10 @@ async fn refresh_lineup(
|
||||
CMD_SYNC_LINEUP_NOTIFY,
|
||||
SyncLineupNotify {
|
||||
lineup: Some(lineup),
|
||||
reason_list: vec![]
|
||||
reason_list: vec![],
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn on_change_lineup_leader_cs_req(
|
||||
|
||||
@ -20,7 +20,7 @@ pub async fn on_get_cur_scene_info_cs_req(
|
||||
_body: &GetCurSceneInfoCsReq,
|
||||
) -> Result<()> {
|
||||
let mut player = JsonData::load().await;
|
||||
let entry = player.scene.entry_id.clone();
|
||||
let entry = player.scene.entry_id;
|
||||
|
||||
let scene = load_scene(session, &mut player, entry, false, Option::<u32>::None).await;
|
||||
|
||||
@ -66,14 +66,14 @@ pub async fn on_lckgkdehclb(session: &mut PlayerSession, request: &Lckgkdehclb)
|
||||
.send(CMD_ENTER_SCENE_SC_RSP, Dummy::default())
|
||||
.await?;
|
||||
|
||||
let _ = load_scene(
|
||||
load_scene(
|
||||
session,
|
||||
&mut player,
|
||||
request.entry_id,
|
||||
true,
|
||||
Some(request.maplanefddc),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -107,16 +107,11 @@ pub async fn on_fkjoeabiioe(sesison: &mut PlayerSession, request: &Fkjoeabiioe)
|
||||
map_info.phicefeaigb.push(i)
|
||||
}
|
||||
|
||||
let group_config = GAME_RESOURCES
|
||||
.map_entrance
|
||||
.get(&entry_id)
|
||||
.map(|v| {
|
||||
GAME_RESOURCES
|
||||
.level_group
|
||||
.get(&format!("P{}_F{}", v.plane_id, v.floor_id))
|
||||
})
|
||||
.flatten();
|
||||
|
||||
let group_config = GAME_RESOURCES.map_entrance.get(entry_id).and_then(|v| {
|
||||
GAME_RESOURCES
|
||||
.level_group
|
||||
.get(&format!("P{}_F{}", v.plane_id, v.floor_id))
|
||||
});
|
||||
if let Some(level) = group_config {
|
||||
// add teleports
|
||||
for teleport in &level.teleports {
|
||||
@ -138,7 +133,7 @@ pub async fn on_fkjoeabiioe(sesison: &mut PlayerSession, request: &Fkjoeabiioe)
|
||||
} else {
|
||||
prop.state.clone() as u32
|
||||
},
|
||||
ifjocipnpgd: prop.id as u32,
|
||||
ifjocipnpgd: prop.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -205,9 +200,7 @@ pub async fn on_scene_entity_move_cs_req(
|
||||
player.save().await;
|
||||
session
|
||||
.send(CMD_SCENE_ENTITY_MOVE_SC_RSP, Dummy::default())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
.await
|
||||
}
|
||||
|
||||
pub type GetEnteredSceneCsReq = Dummy;
|
||||
@ -219,7 +212,7 @@ pub async fn on_get_entered_scene_cs_req(
|
||||
.map_entrance
|
||||
.iter()
|
||||
.filter(|(_, v)| {
|
||||
v.finish_main_mission_list.len() > 0 || v.finish_sub_mission_list.len() > 0
|
||||
!v.finish_main_mission_list.is_empty() || !v.finish_sub_mission_list.is_empty()
|
||||
})
|
||||
.map(|(_, v)| Lpllljogfeh {
|
||||
floor_id: v.floor_id,
|
||||
@ -235,8 +228,7 @@ pub async fn on_get_entered_scene_cs_req(
|
||||
retcode: 0,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
.await
|
||||
}
|
||||
|
||||
// getunlockteleportcsreq
|
||||
@ -272,8 +264,7 @@ async fn load_scene(
|
||||
let anchor = group_config
|
||||
.group_items
|
||||
.get(&teleport.anchor_group_id.unwrap_or_default())
|
||||
.map(|v| v.anchors.get(&teleport.anchor_id.unwrap_or_default()))
|
||||
.flatten();
|
||||
.and_then(|v| v.anchors.get(&teleport.anchor_id.unwrap_or_default()));
|
||||
if let Some(anchor) = anchor {
|
||||
position.x = (anchor.pos_x * 1000f64) as i32;
|
||||
position.y = (anchor.pos_y * 1000f64) as i32;
|
||||
@ -284,8 +275,8 @@ async fn load_scene(
|
||||
}
|
||||
|
||||
let mut scene_info = SceneInfo {
|
||||
floor_id: enterance.floor_id as u32,
|
||||
plane_id: enterance.plane_id as u32,
|
||||
floor_id: enterance.floor_id,
|
||||
plane_id: enterance.plane_id,
|
||||
entry_id,
|
||||
game_mode_type: plane.plane_type as u32,
|
||||
pbfgagecpcd: plane.world_id,
|
||||
@ -338,7 +329,7 @@ async fn load_scene(
|
||||
};
|
||||
|
||||
let entity_info = SceneEntityInfo {
|
||||
inst_id: prop.id as u32,
|
||||
inst_id: prop.id,
|
||||
group_id: prop.group_id,
|
||||
motion: Some(prop_position.to_motion()),
|
||||
prop: Some(ScenePropInfo {
|
||||
@ -355,13 +346,11 @@ async fn load_scene(
|
||||
|
||||
// Load NPCs
|
||||
for npc in &group.npcs {
|
||||
if loaded_npc.contains(&(npc.npcid as u32))
|
||||
|| json.avatars.contains_key(&(npc.npcid as u32))
|
||||
{
|
||||
if loaded_npc.contains(&(npc.npcid)) || json.avatars.contains_key(&(npc.npcid)) {
|
||||
continue;
|
||||
}
|
||||
npc_entity_id += 1;
|
||||
loaded_npc.push(npc.npcid as u32);
|
||||
loaded_npc.push(npc.npcid);
|
||||
|
||||
let npc_position = Position {
|
||||
x: (npc.pos_x * 1000f64) as i32,
|
||||
@ -371,12 +360,12 @@ async fn load_scene(
|
||||
};
|
||||
|
||||
let info = SceneEntityInfo {
|
||||
inst_id: npc.id as u32,
|
||||
inst_id: npc.id,
|
||||
group_id: npc.group_id,
|
||||
entity_id: npc_entity_id,
|
||||
motion: Some(npc_position.to_motion()),
|
||||
npc: Some(SceneNpcInfo {
|
||||
egeneneoadj: npc.npcid as u32,
|
||||
egeneneoadj: npc.npcid,
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
@ -396,14 +385,14 @@ async fn load_scene(
|
||||
};
|
||||
|
||||
let npc_monster = SceneNpcMonsterInfo {
|
||||
monster_id: monster.npcmonster_id as u32,
|
||||
event_id: monster.event_id as u32,
|
||||
monster_id: monster.npcmonster_id,
|
||||
event_id: monster.event_id,
|
||||
world_level: 6,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let info = SceneEntityInfo {
|
||||
inst_id: monster.id as u32,
|
||||
inst_id: monster.id,
|
||||
group_id: monster.group_id,
|
||||
entity_id: monster_entity_id,
|
||||
motion: Some(monster_position.to_motion()),
|
||||
@ -477,8 +466,8 @@ async fn load_scene(
|
||||
.await?;
|
||||
|
||||
json.scene.entry_id = entry_id;
|
||||
json.scene.floor_id = enterance.floor_id as u32;
|
||||
json.scene.plane_id = enterance.plane_id as u32;
|
||||
json.scene.floor_id = enterance.floor_id;
|
||||
json.scene.plane_id = enterance.plane_id;
|
||||
json.position.x = position.x;
|
||||
json.position.y = position.y;
|
||||
json.position.z = position.z;
|
||||
@ -486,5 +475,5 @@ async fn load_scene(
|
||||
json.save().await;
|
||||
}
|
||||
|
||||
return Ok(scene_info);
|
||||
Ok(scene_info)
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ pub struct AvatarData {
|
||||
pub skills: BTreeMap<u32, u32>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl AvatarJson {
|
||||
pub fn to_avatar_proto(&self, lightcone: Option<&Lightcone>, relics: Vec<&Relic>) -> Avatar {
|
||||
Avatar {
|
||||
@ -105,7 +104,7 @@ impl AvatarJson {
|
||||
for buff_id in &self.techniques {
|
||||
battle_buff.push(BattleBuff {
|
||||
wave_flag: 0xffffffff,
|
||||
owner_index: index as u32,
|
||||
owner_index: index,
|
||||
level: 1,
|
||||
id: *buff_id,
|
||||
..Default::default()
|
||||
@ -132,8 +131,8 @@ impl AvatarJson {
|
||||
pub fn to_lineup_avatars(player: &JsonData) -> Vec<LineupAvatar> {
|
||||
let avatar_ids = player
|
||||
.avatars
|
||||
.iter()
|
||||
.map(|(_, v)| &v.avatar_id)
|
||||
.values()
|
||||
.map(|v| &v.avatar_id)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
player
|
||||
@ -159,7 +158,7 @@ impl AvatarJson {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for (_, id) in lineups {
|
||||
for id in lineups.values() {
|
||||
if *id == 0 {
|
||||
continue;
|
||||
}
|
||||
@ -194,7 +193,6 @@ pub struct Lightcone {
|
||||
pub internal_uid: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Lightcone {
|
||||
pub fn to_equipment_proto(&self) -> Equipment {
|
||||
Equipment {
|
||||
@ -208,7 +206,6 @@ impl Lightcone {
|
||||
tid: self.item_id,
|
||||
// ?
|
||||
unique_id: 2000 + self.internal_uid,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +245,6 @@ pub struct SubAffix {
|
||||
pub step: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Relic {
|
||||
pub fn to_relic_proto(&self) -> proto::Relic {
|
||||
proto::Relic {
|
||||
@ -312,7 +308,6 @@ pub struct Monster {
|
||||
pub max_hp: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Monster {
|
||||
fn to_scene_monster_info(&self) -> SceneMonsterParam {
|
||||
SceneMonsterParam {
|
||||
@ -322,9 +317,9 @@ impl Monster {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_scene_monster_wave(wave_index: u32, monsters: &Vec<Self>) -> SceneMonsterWave {
|
||||
pub fn to_scene_monster_wave(wave_index: u32, monsters: &[Self]) -> SceneMonsterWave {
|
||||
let mut wave_index = wave_index;
|
||||
if wave_index <= 0 {
|
||||
if wave_index < 1 {
|
||||
wave_index += 1;
|
||||
}
|
||||
|
||||
@ -345,7 +340,7 @@ impl Monster {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_scene_monster_waves(monsters: &Vec<Vec<Self>>) -> Vec<SceneMonsterWave> {
|
||||
pub fn to_scene_monster_waves(monsters: &[Vec<Self>]) -> Vec<SceneMonsterWave> {
|
||||
monsters
|
||||
.iter()
|
||||
.enumerate()
|
||||
@ -386,15 +381,17 @@ impl Default for BattleConfig {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
pub enum BattleType {
|
||||
DEFAULT = 0,
|
||||
MOC = 1,
|
||||
#[serde(alias = "DEFAULT")]
|
||||
Default = 0,
|
||||
#[serde(alias = "MOC")]
|
||||
Moc = 1,
|
||||
PF = 2,
|
||||
SU = 3,
|
||||
}
|
||||
|
||||
impl Default for BattleType {
|
||||
fn default() -> Self {
|
||||
Self::DEFAULT
|
||||
Self::Default
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,7 +456,7 @@ pub struct Position {
|
||||
|
||||
impl Position {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
return self.x == 0 && self.y == 0 && self.z == 0;
|
||||
self.x == 0 && self.y == 0 && self.z == 0
|
||||
}
|
||||
|
||||
pub fn to_motion(&self) -> MotionInfo {
|
||||
@ -604,7 +601,7 @@ impl JsonData {
|
||||
}
|
||||
|
||||
async fn verify_lineup(&mut self) {
|
||||
if self.lineups.len() == 0 {
|
||||
if self.lineups.is_empty() {
|
||||
self.lineups = BTreeMap::<u32, u32>::from([(0, 8006), (1, 0), (2, 0), (3, 0)])
|
||||
} else if self.lineups.len() < 4 {
|
||||
for i in self.lineups.len()..4 {
|
||||
|
||||
@ -263,16 +263,16 @@ impl Default for PlaneType {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MazeProp {
|
||||
#[serde(rename = "ID")]
|
||||
pub id: i64,
|
||||
pub id: u32,
|
||||
#[serde(rename = "PropType")]
|
||||
pub prop_type: String,
|
||||
#[serde(rename = "PropStateList")]
|
||||
pub prop_state_list: Vec<PropState>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub enum PropState {
|
||||
Closed = 0,
|
||||
#[default] Closed = 0,
|
||||
Open = 1,
|
||||
Locked = 2,
|
||||
BridgeState1 = 3,
|
||||
@ -309,12 +309,6 @@ pub enum PropState {
|
||||
CustomState09 = 109,
|
||||
}
|
||||
|
||||
impl Default for PropState {
|
||||
fn default() -> Self {
|
||||
PropState::Closed
|
||||
}
|
||||
}
|
||||
|
||||
pub type IntMap<T> = HashMap<u32, T>;
|
||||
pub type StringMap<T> = HashMap<String, T>;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user