Implement bangboo for battles (works in archive quests)

This commit is contained in:
xeon 2024-08-01 02:43:13 +03:00
parent 7d7bd76ae8
commit 220fbc42f0
7 changed files with 131 additions and 62 deletions

View file

@ -85,8 +85,13 @@ pub async fn on_begin_archive_battle_quest(
let quest_id = ArchiveBattleQuestID::new(req.quest_id).ok_or(Retcode::RetFail)?;
player.game_instance = GameInstance::Hollow(
HollowGame::create_archive_battle(quest_id, ELocalPlayType::ArchiveBattle, &req.avatars)
.map_err(LogicError::from)?,
HollowGame::create_archive_battle(
quest_id,
ELocalPlayType::ArchiveBattle,
&req.avatars,
req.buddy_id,
)
.map_err(LogicError::from)?,
);
let world_init_notify = player.game_instance.create_world_init_notify()?;

View file

@ -0,0 +1,25 @@
use std::collections::HashMap;
use proto::EquippedBuddyData;
use crate::logic::{BaseProperty, BuddyTeamType};
pub struct EquippedBuddyDataItem {
pub buddy_id: u32,
pub buddy_team: BuddyTeamType,
pub override_property_map: HashMap<BaseProperty, i32>,
}
impl EquippedBuddyDataItem {
pub fn to_client(&self) -> EquippedBuddyData {
EquippedBuddyData {
buddy_id: self.buddy_id,
r#type: self.buddy_team.to_protocol().into(),
mp_property_override_map: self
.override_property_map
.iter()
.map(|(prop, value)| (*prop as u32, *value))
.collect(),
}
}
}

View file

@ -1,4 +1,7 @@
mod avatar;
pub use avatar::InLevelAvatarDataItem;
mod buddy;
mod team;
pub use avatar::InLevelAvatarDataItem;
pub use buddy::EquippedBuddyDataItem;
pub use team::TeamDataItem;

View file

@ -1,13 +1,16 @@
use std::collections::HashMap;
use super::InLevelAvatarDataItem;
use crate::logic::BuddyTeamType;
use super::{EquippedBuddyDataItem, InLevelAvatarDataItem};
pub struct TeamDataItem {
pub avatar_member_list: Vec<InLevelAvatarDataItem>,
pub equipped_buddy_list: Vec<EquippedBuddyDataItem>,
}
impl TeamDataItem {
pub fn new(avatars: &[u32]) -> Self {
pub fn new(avatars: &[u32], buddy_id: u32) -> Self {
Self {
avatar_member_list: avatars
.iter()
@ -16,6 +19,13 @@ impl TeamDataItem {
mp_property_override: HashMap::new(),
})
.collect(),
equipped_buddy_list: (buddy_id != 0)
.then_some(vec![EquippedBuddyDataItem {
buddy_id,
buddy_team: BuddyTeamType::Assisting,
override_property_map: HashMap::new(),
}])
.unwrap_or_default(),
}
}
}

View file

@ -259,3 +259,22 @@ pub enum BaseProperty {
Luck = 5,
AllDamageResist = 43,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(i32)]
pub enum BuddyTeamType {
Unknown = 0,
Fighting = 1,
Assisting = 2,
}
impl BuddyTeamType {
pub fn to_protocol(&self) -> ::proto::BuddyTeamType {
match *self {
Self::Unknown => ::proto::BuddyTeamType::Unknown,
Self::Fighting => ::proto::BuddyTeamType::Fighting,
Self::Assisting => ::proto::BuddyTeamType::Assisting,
}
}
}

View file

@ -4,7 +4,7 @@ use proto::{DungeonInfo, DungeonItemData, FightSceneInfo, SceneInfo, WeatherPool
use thiserror::Error;
use crate::logic::{
battle::{InLevelAvatarDataItem, TeamDataItem},
battle::{EquippedBuddyDataItem, InLevelAvatarDataItem, TeamDataItem},
ELocalPlayType, ESceneType, TimePeriodType, WeatherType,
};
@ -38,7 +38,7 @@ impl HollowGame {
weather: WeatherType::SunShine,
start_timestamp: util::cur_timestamp() as i64,
play_type,
team_data: TeamDataItem::new(avatars),
team_data: TeamDataItem::new(avatars, 0),
})
}
@ -46,6 +46,7 @@ impl HollowGame {
archive_battle_quest_id: ArchiveBattleQuestID,
play_type: ELocalPlayType,
avatars: &[u32],
buddy_id: u32,
) -> Result<Self, HollowGameError> {
let template = archive_battle_quest_id.template();
@ -56,7 +57,7 @@ impl HollowGame {
weather: WeatherType::SunShine,
start_timestamp: util::cur_timestamp() as i64,
play_type,
team_data: TeamDataItem::new(avatars),
team_data: TeamDataItem::new(avatars, buddy_id),
})
}
}
@ -94,6 +95,12 @@ impl NapGameMode for HollowGame {
.iter()
.map(InLevelAvatarDataItem::to_client)
.collect(),
buddy_list: self
.team_data
.equipped_buddy_list
.iter()
.map(EquippedBuddyDataItem::to_client)
.collect(),
..Default::default()
})
}

View file

@ -2270,7 +2270,7 @@ pub struct PlayerSyncScNotify {
#[prost(message, optional, tag = "12")]
pub gchokpdeeci: ::core::option::Option<Mbhjjoafcmc>,
#[prost(message, optional, tag = "13")]
pub kplhefeipee: ::core::option::Option<Onacbnhpicf>,
pub buddy: ::core::option::Option<BuddySync>,
#[prost(message, optional, tag = "14")]
pub mobpkchjfai: ::core::option::Option<Phnapedndek>,
#[prost(message, optional, tag = "15")]
@ -2406,7 +2406,7 @@ pub struct Khhjipglbll {
pub bcbcjioepod: u32,
#[xor(2704)]
#[prost(uint32, tag = "1")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(uint32, repeated, tag = "11")]
pub avatars: ::prost::alloc::vec::Vec<u32>,
#[xor(9370)]
@ -2760,7 +2760,7 @@ pub struct Iedkhplmbab {
pub struct StartTrialFightingMissionCsReq {
#[xor(15246)]
#[prost(uint32, tag = "1")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(3842)]
#[prost(uint32, tag = "11")]
pub quest_id: u32,
@ -2800,8 +2800,8 @@ pub struct Eoaebmjlfjc {
pub struct EquippedBuddyData {
#[xor(8856)]
#[prost(uint32, tag = "9")]
pub buddy: u32,
#[prost(enumeration = "Hneekphmejf", tag = "6")]
pub buddy_id: u32,
#[prost(enumeration = "BuddyTeamType", tag = "6")]
pub r#type: i32,
#[prost(map = "uint32, int32", tag = "10")]
pub mp_property_override_map: ::std::collections::HashMap<u32, i32>,
@ -5916,7 +5916,7 @@ pub struct Lpjpfoaehlg {
pub lbmgeignmef: u32,
#[xor(2510)]
#[prost(uint32, tag = "8")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -7859,7 +7859,7 @@ pub struct LogBattleStatistics {
#[prost(message, optional, tag = "13")]
pub ncfafdpojjh: ::core::option::Option<Bacignlfind>,
#[prost(message, repeated, tag = "14")]
pub lmailahlomk: ::prost::alloc::vec::Vec<Jaokcopjeip>,
pub buddy_list: ::prost::alloc::vec::Vec<Jaokcopjeip>,
#[prost(uint32, tag = "15")]
pub mlagnchinll: u32,
#[prost(message, optional, tag = "17")]
@ -8695,7 +8695,7 @@ pub struct BeginArchiveBattleQuestCsReq {
pub quest_id: u32,
#[xor(1830)]
#[prost(uint32, tag = "11")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(bool, tag = "1")]
pub is_story: bool,
#[prost(uint32, repeated, tag = "2")]
@ -9176,7 +9176,7 @@ pub struct Bijjamapnjm {
pub struct Bffgkjikbhp {
#[xor(3555)]
#[prost(uint32, tag = "14")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(10954)]
#[prost(uint32, tag = "1")]
pub lbmgeignmef: u32,
@ -9395,7 +9395,7 @@ pub struct Kmkbpddeaoe {
pub struct Bhmhgadoncc {
#[xor(5509)]
#[prost(uint32, tag = "14")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(10314)]
#[prost(int32, tag = "12")]
pub nledmfjbmmo: i32,
@ -10824,7 +10824,7 @@ pub struct Gccdaofpapp {
pub struct Ihilkekkdmh {
#[xor(10553)]
#[prost(uint32, tag = "13")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(13840)]
#[prost(int32, tag = "1")]
pub retcode: i32,
@ -12833,7 +12833,7 @@ pub struct Okkjjhonnik {
pub ajichmhgblg: u32,
#[xor(1870)]
#[prost(uint32, tag = "7")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -16216,7 +16216,7 @@ pub struct Feanepokfam {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Onlmpmgcdle {
#[prost(message, repeated, tag = "13")]
pub lmailahlomk: ::prost::alloc::vec::Vec<EquippedBuddyData>,
pub buddy_list: ::prost::alloc::vec::Vec<EquippedBuddyData>,
}
#[derive(proto_gen::CmdID)]
#[cmdid(5211)]
@ -16488,7 +16488,7 @@ pub struct DungeonItemData {
#[prost(message, repeated, tag = "6")]
pub dldfgemogip: ::prost::alloc::vec::Vec<Ljcocgillfb>,
#[prost(message, repeated, tag = "14")]
pub lmailahlomk: ::prost::alloc::vec::Vec<BuddyInfo>,
pub buddy_list: ::prost::alloc::vec::Vec<BuddyInfo>,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -17052,7 +17052,7 @@ pub struct Fkibbohbdin {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Onacbnhpicf {
pub struct BuddySync {
#[prost(uint32, repeated, tag = "1")]
pub kghfhlopgjb: ::prost::alloc::vec::Vec<u32>,
#[prost(uint32, repeated, tag = "9")]
@ -17066,7 +17066,7 @@ pub struct Onacbnhpicf {
#[prost(uint32, tag = "3")]
pub lpfeinagkha: u32,
#[prost(message, repeated, tag = "2")]
pub lmailahlomk: ::prost::alloc::vec::Vec<BuddyInfo>,
pub buddy_list: ::prost::alloc::vec::Vec<BuddyInfo>,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -17266,7 +17266,7 @@ pub struct Ilehibpgief {
pub struct Fjppbkgebcl {
#[xor(7354)]
#[prost(uint32, tag = "8")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -17992,7 +17992,7 @@ pub mod gbcnocdacgf {
#[prost(message, tag = "12")]
Summonee(super::Endadpkgkid),
#[prost(message, tag = "13")]
Buddy(super::Ecjcmfjjgdp),
BuddyId(super::Ecjcmfjjgdp),
#[prost(message, tag = "14")]
DropItem(super::Mfbjkggafmo),
#[prost(message, tag = "15")]
@ -20840,7 +20840,7 @@ pub struct Ghgbhljlmde {
pub bikhplpcalp: ::std::collections::HashMap<u32, u32>,
#[xor(4986)]
#[prost(uint32, tag = "6")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(1495)]
#[prost(uint32, tag = "5")]
pub ihgcjhffkdf: u32,
@ -20969,8 +20969,8 @@ pub struct Acobofkfjgj {
pub struct Oidkngmaipi {
#[xor(8441)]
#[prost(uint32, tag = "14")]
pub buddy: u32,
#[prost(enumeration = "Hneekphmejf", tag = "7")]
pub buddy_id: u32,
#[prost(enumeration = "BuddyTeamType", tag = "7")]
pub ddogpdoomde: i32,
}
#[derive(proto_gen::CmdID)]
@ -21192,7 +21192,7 @@ pub struct Labghjgfhhh {
pub lbmgeignmef: u32,
#[xor(13505)]
#[prost(uint32, tag = "4")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -21227,7 +21227,7 @@ pub struct Gmgoddaldob {
#[prost(uint32, tag = "1")]
pub pmnjlmekmbc: u32,
#[prost(uint32, tag = "2")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(bool, tag = "3")]
pub majldghlkab: bool,
#[prost(bytes = "vec", tag = "4")]
@ -21748,7 +21748,7 @@ pub struct GetBuddyDataScRsp {
#[prost(uint32, tag = "12")]
pub lpfeinagkha: u32,
#[prost(message, repeated, tag = "5")]
pub lmailahlomk: ::prost::alloc::vec::Vec<BuddyInfo>,
pub buddy_list: ::prost::alloc::vec::Vec<BuddyInfo>,
#[prost(uint32, repeated, tag = "10")]
pub kghfhlopgjb: ::prost::alloc::vec::Vec<u32>,
}
@ -22137,7 +22137,7 @@ pub struct Kakpeoaekgb {
pub struct Mbchikbhcmp {
#[xor(8473)]
#[prost(uint32, tag = "10")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(bool, tag = "6")]
pub aobemkmdkgo: bool,
#[prost(message, repeated, tag = "14")]
@ -22404,7 +22404,7 @@ pub struct Aecgodfnpao {
pub lbmgeignmef: u32,
#[xor(7503)]
#[prost(uint32, tag = "12")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -22612,7 +22612,7 @@ pub struct Ghojoimpnad {
pub ndcnfidonje: u32,
#[xor(8060)]
#[prost(uint32, tag = "2")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(15324)]
#[prost(uint32, tag = "1")]
pub lbmgeignmef: u32,
@ -24257,7 +24257,7 @@ pub struct Enaagloodio {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Ecjcmfjjgdp {
#[prost(int32, tag = "1")]
pub buddy: i32,
pub buddy_id: i32,
#[prost(int32, repeated, tag = "2")]
pub jpncidefiba: ::prost::alloc::vec::Vec<i32>,
#[prost(message, optional, tag = "3")]
@ -25751,7 +25751,7 @@ pub struct DungeonInfo {
#[prost(message, optional, tag = "3")]
pub ncfafdpojjh: ::core::option::Option<Kalfjemiaaa>,
#[prost(message, optional, tag = "8")]
pub kplhefeipee: ::core::option::Option<EquippedBuddyData>,
pub buddy: ::core::option::Option<EquippedBuddyData>,
#[prost(bool, tag = "1724")]
pub gjhgpapkmod: bool,
#[prost(bool, tag = "1109")]
@ -25769,7 +25769,7 @@ pub struct DungeonInfo {
#[prost(map = "uint32, int32", tag = "7")]
pub njfikojmpcm: ::std::collections::HashMap<u32, i32>,
#[prost(message, repeated, tag = "1395")]
pub lmailahlomk: ::prost::alloc::vec::Vec<EquippedBuddyData>,
pub buddy_list: ::prost::alloc::vec::Vec<EquippedBuddyData>,
#[prost(message, optional, tag = "2")]
pub dungeon_item_data: ::core::option::Option<DungeonItemData>,
#[prost(message, optional, tag = "5")]
@ -27252,7 +27252,7 @@ pub struct Aicalelcmii {
pub kplhkiofbah: bool,
#[xor(3343)]
#[prost(uint32, tag = "7")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(4100)]
@ -28678,7 +28678,7 @@ pub struct Bkkmkacnhne {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Dpijpabbknc {
#[prost(message, optional, tag = "1")]
pub buddy: ::core::option::Option<StringEntry>,
pub buddy_id: ::core::option::Option<StringEntry>,
#[prost(enumeration = "Afnpekehlge", tag = "2")]
pub ddogpdoomde: i32,
}
@ -29634,7 +29634,7 @@ pub struct Jlgmobeofhe {
pub jipabmjagbi: u32,
#[xor(12923)]
#[prost(uint32, tag = "4")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(11558)]
#[prost(uint32, tag = "14")]
pub pmnjlmekmbc: u32,
@ -30207,7 +30207,7 @@ pub struct Dlenhbdpddl {
#[prost(uint32, tag = "5")]
pub uid: u32,
#[prost(message, repeated, tag = "7")]
pub lmailahlomk: ::prost::alloc::vec::Vec<Fjppbkgebcl>,
pub buddy_list: ::prost::alloc::vec::Vec<Fjppbkgebcl>,
}
#[derive(proto_gen::CmdID)]
#[cmdid(1394)]
@ -30566,7 +30566,7 @@ pub struct Jcfdccfejcg {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Jaokcopjeip {
#[prost(int32, tag = "1")]
pub buddy: i32,
pub buddy_id: i32,
#[prost(int64, tag = "2")]
pub cjehpadgajn: i64,
#[prost(int32, tag = "3")]
@ -32158,7 +32158,7 @@ pub struct Hphfnebchnb {
pub struct Hoeafbihgpd {
#[xor(1739)]
#[prost(uint32, tag = "3")]
pub buddy: u32,
pub buddy_id: u32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(3238)]
@ -33225,7 +33225,7 @@ pub struct Gkegfnbpiok {
pub star: u32,
#[xor(15011)]
#[prost(uint32, tag = "3")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(810)]
#[prost(uint32, tag = "5")]
pub exp: u32,
@ -33399,7 +33399,7 @@ pub struct Jcincgmdflc {
pub olcifcglpdd: ::prost::alloc::vec::Vec<u32>,
#[xor(3275)]
#[prost(uint32, tag = "11")]
pub buddy: u32,
pub buddy_id: u32,
#[xor(10845)]
#[prost(uint32, tag = "13")]
pub quest_id: u32,
@ -33777,7 +33777,7 @@ pub struct Jhinopamaoa {
pub avatars: ::prost::alloc::vec::Vec<u32>,
#[xor(6842)]
#[prost(uint32, tag = "14")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(uint32, repeated, tag = "3")]
pub obpdhglkbgk: ::prost::alloc::vec::Vec<u32>,
#[xor(8158)]
@ -34490,7 +34490,7 @@ pub struct Jiflifhgkhk {
pub is_story: bool,
#[xor(7590)]
#[prost(uint32, tag = "5")]
pub buddy: u32,
pub buddy_id: u32,
#[prost(bool, tag = "14")]
pub jcflmpbcojd: bool,
}
@ -48346,32 +48346,32 @@ impl DungeonContentDropPoolType {
#[derive(proto_gen::XorFields)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Hneekphmejf {
Jhlmmfkphgb = 0,
Kjppindjool = 1,
Ehemncmjnkg = 2,
Lddkjjhcikb = 3,
pub enum BuddyTeamType {
None = 0,
Unknown = 1,
Fighting = 2,
Assisting = 3,
}
impl Hneekphmejf {
impl BuddyTeamType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Hneekphmejf::Jhlmmfkphgb => "HNEEKPHMEJF_JHLMMFKPHGB",
Hneekphmejf::Kjppindjool => "HNEEKPHMEJF_KJPPINDJOOL",
Hneekphmejf::Ehemncmjnkg => "HNEEKPHMEJF_EHEMNCMJNKG",
Hneekphmejf::Lddkjjhcikb => "HNEEKPHMEJF_LDDKJJHCIKB",
BuddyTeamType::None => "BUDDY_TEAM_TYPE_NONE",
BuddyTeamType::Unknown => "BUDDY_TEAM_TYPE_UNKNOWN",
BuddyTeamType::Fighting => "BUDDY_TEAM_TYPE_FIGHTING",
BuddyTeamType::Assisting => "BUDDY_TEAM_TYPE_ASSISTING",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"HNEEKPHMEJF_JHLMMFKPHGB" => Some(Self::Jhlmmfkphgb),
"HNEEKPHMEJF_KJPPINDJOOL" => Some(Self::Kjppindjool),
"HNEEKPHMEJF_EHEMNCMJNKG" => Some(Self::Ehemncmjnkg),
"HNEEKPHMEJF_LDDKJJHCIKB" => Some(Self::Lddkjjhcikb),
"BUDDY_TEAM_TYPE_NONE" => Some(Self::None),
"BUDDY_TEAM_TYPE_UNKNOWN" => Some(Self::Unknown),
"BUDDY_TEAM_TYPE_FIGHTING" => Some(Self::Fighting),
"BUDDY_TEAM_TYPE_ASSISTING" => Some(Self::Assisting),
_ => None,
}
}