This commit is contained in:
aozhiwei 2024-03-21 20:33:51 +08:00
commit 63e018441a
11 changed files with 274 additions and 1 deletions

View File

@ -135,6 +135,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMReportSpecShotHitPos); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMReportSpecShotHitPos);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchTarget); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchTarget);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMTeamCommand); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMTeamCommand);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMobaBattleData);
} }
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle, void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,

View File

@ -432,6 +432,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string killer_name, in
} }
} }
GetTrigger()->HpChg(); GetTrigger()->HpChg();
room->OnTeamPartChg(this);
} }
void Human::AddToNewObjects(Entity* entity) void Human::AddToNewObjects(Entity* entity)
@ -3553,6 +3554,7 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we
} }
} }
SendViewerUiMemberUpdate({GetUniId(), killer_id, real_killer_id}); SendViewerUiMemberUpdate({GetUniId(), killer_id, real_killer_id});
room->NotifyUiUpdate();
} }
int Human::GetTeamMode() int Human::GetTeamMode()
@ -3576,6 +3578,7 @@ void Human::CalcAssists(Human* target)
if (hum->room->GetFrameNo() - itr->second < if (hum->room->GetFrameNo() - itr->second <
SERVER_FRAME_RATE * assist_time) { SERVER_FRAME_RATE * assist_time) {
++hum->stats->assist; ++hum->stats->assist;
room->NotifyUiUpdate();
} }
} }
return true; return true;

View File

@ -17,6 +17,9 @@ namespace cs
class MFThrow; class MFThrow;
class MFSandTableFullMsg; class MFSandTableFullMsg;
class MFSandTablePartMsg; class MFSandTablePartMsg;
class MFMobaBattleDataMember;
class MFTeamPart;
class MFTeamMemberNew;
class SMGameOver; class SMGameOver;
class SMUpdate; class SMUpdate;
} }
@ -162,6 +165,9 @@ class Human : public Creature
virtual void OnExplosionHit(Explosion* explosion) override; virtual void OnExplosionHit(Explosion* explosion) override;
long long GetRealDeadFrameNo(Room* room); long long GetRealDeadFrameNo(Room* room);
void FillMFTeamData(Human* hum, cs::MFTeamData* team_data, bool is_game_over); void FillMFTeamData(Human* hum, cs::MFTeamData* team_data, bool is_game_over);
void FillMFMobaBattleDataMember(cs::MFMobaBattleDataMember* p);
void FillMFTeamPart(cs::MFTeamPart* p);
void FillMFTeamMemberNew(cs::MFTeamMemberNew* p);
void CarShot(const glm::vec3& target_dir); void CarShot(const glm::vec3& target_dir);
void BeKill(int killer_id, const std::string& killer_name, int weapon_id, void BeKill(int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name); int real_killer_id, const std::string& real_killer_name);

View File

@ -1014,6 +1014,63 @@ void Human::FillMFTeamData(Human* hum, cs::MFTeamData* team_data, bool is_game_o
} }
} }
void Human::FillMFMobaBattleDataMember(cs::MFMobaBattleDataMember* p)
{
p->set_team_id(GetTeam()->GetTeamId());
p->set_member_uniid(GetUniId());
p->set_name(name);
p->set_avatar_url(avatar_url);
p->set_hero_id(GetNetData()->GetHeroId());
p->set_head_frame(head_frame);
for (auto& inv : GetInventoryData()) {
p->add_inventory(inv.num);
}
p->set_kill_count(stats->kills);
p->set_dead_count(stats->dead_times);
p->set_assist_count(stats->assist);
p->set_main_skill_id(GetMainSkill()->GetSkillId());
p->set_main_skill_cd(GetMainSkill()->GetLeftTime());
p->set_main_skill_max_cd(GetMainSkill()->GetCd());
}
void Human::FillMFTeamPart(cs::MFTeamPart* p)
{
p->set_team_id(GetTeam()->GetTeamId());
p->set_obj_uniid(GetUniId());
TypeConvert::ToPb(GetPos(), p->mutable_pos());
TypeConvert::ToPb(GetAttackDir(), p->mutable_dir());
p->set_health(GetHP());
p->set_max_health(GetMaxHP());
p->set_disconnected(disconnected);
p->set_dead(dead);
p->set_downed(downed);
}
void Human::FillMFTeamMemberNew(cs::MFTeamMemberNew* p)
{
p->set_team_id(GetTeam()->GetTeamId());
p->set_obj_uniid(GetUniId());
TypeConvert::ToPb(GetPos(), p->mutable_pos());
TypeConvert::ToPb(GetAttackDir(), p->mutable_dir());
p->set_health(GetHP());
p->set_disconnected(disconnected);
p->set_dead(dead);
p->set_downed(downed);
p->set_name(name);
p->set_max_health(GetMaxHP());
p->set_hero_id(GetNetData()->GetHeroId());
p->set_level(GetNetData()->GetLevel());
p->set_hero_level(GetHeroLevel());
p->set_hero_exp(GetHeroExp());
p->set_hero_max_exp(GetHeroMaxExp());
p->set_main_skill_cd(GetMainSkill()->GetLeftTime());
p->set_main_skill_max_cd(GetMainSkill()->GetCd());
}
void Human::FillSMGameOver(cs::SMGameOver& msg) void Human::FillSMGameOver(cs::SMGameOver& msg)
{ {
if (room->GetVictoryTeam()) { if (room->GetVictoryTeam()) {
@ -1724,6 +1781,8 @@ void Human::SendUIUpdate()
cs::SMUiUpdate notifymsg; cs::SMUiUpdate notifymsg;
notifymsg.set_alive_count(room->AliveCount()); notifymsg.set_alive_count(room->AliveCount());
notifymsg.set_kill_count(stats->kills); notifymsg.set_kill_count(stats->kills);
notifymsg.set_dead_count(stats->dead_times);
notifymsg.set_assist_count(stats->assist);
room->FillSMUiUpdate(notifymsg); room->FillSMUiUpdate(notifymsg);
if (room->IsPveRoom()) { if (room->IsPveRoom()) {
notifymsg.set_score(stats->pve_rank_score); notifymsg.set_score(stats->pve_rank_score);
@ -2471,6 +2530,30 @@ void Team::FillSMGameOver(cs::SMGameOver& msg)
} }
} }
void Team::FillMFMobaBattleDataTeam(cs::MFMobaBattleDataTeam* p)
{
p->set_team_id(GetTeamId());
TraverseMembers
(
[p] (Human* hum) -> bool
{
hum->FillMFMobaBattleDataMember(p->add_members());
return true;
});
}
void Team::FillMFTeamFull(cs::MFTeamFull* p)
{
p->set_team_id(GetTeamId());
TraverseMembers
(
[p] (Human* hum) -> bool
{
hum->FillMFTeamMemberNew(p->add_members());
return true;
});
}
bool PBUtils::SupportSandTable(int proto_version) bool PBUtils::SupportSandTable(int proto_version)
{ {
return true; return true;
@ -2557,6 +2640,63 @@ void Room::NotifyKillList(const std::vector<int>& uniid_list)
}); });
} }
void Room::SendSMTeamFull(Human* hum)
{
if (!IsMobaModeRoom()) {
return;
}
cs::SMTeamFullNotify notify_msg;
std::vector<Team*> team_list = {GetMobaTeamA(), GetMobaTeamB()};
for (Team* team : team_list) {
team->FillMFTeamFull(notify_msg.add_team_list());
}
TraversePlayerList
(
[&notify_msg] (Player* hum) -> bool
{
#ifdef MYDEBUG1
a8::XPrintf("SMTeamFull:%s\n", {f8::PbToJson(&notify_msg)});
#endif
hum->SendNotifyMsg(notify_msg);
return true;
});
}
void Room::OnTeamPartChg(Human* hum)
{
if (!IsMobaModeRoom()) {
return;
}
if (team_part_chg_human_hash_.empty()) {
team_part_chg_human_hash_[hum->GetUniId()] = hum;
xtimer.SetTimeoutWpEx
(SERVER_FRAME_RATE * 0.5,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
cs::SMTeamPartNotify notify_msg;
for (auto& pair : team_part_chg_human_hash_) {
pair.second->FillMFTeamPart(notify_msg.add_members());
}
TraversePlayerList
(
[&notify_msg] (Player* hum) -> bool
{
#ifdef MYDEBUG1
a8::XPrintf("SMTeamPart:%s\n", {f8::PbToJson(&notify_msg)});
#endif
hum->SendNotifyMsg(notify_msg);
return true;
});
team_part_chg_human_hash_.clear();
}
},
&xtimer_attacher_);
} else {
team_part_chg_human_hash_[hum->GetUniId()] = hum;
}
}
int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg, int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
std::shared_ptr<CustomBattle> p) std::shared_ptr<CustomBattle> p)
{ {

View File

@ -1876,6 +1876,18 @@ void Player::_CMTeamCommand(f8::MsgHdr* hdr, const cs::CMTeamCommand& msg)
} }
} }
void Player::_CMMobaBattleData(f8::MsgHdr* hdr, const cs::CMMobaBattleData& msg)
{
if (room->IsMobaModeRoom()) {
cs::SMMobaBattleData rsp_msg;
std::vector<Team*> team_list = {room->GetMobaTeamA(), room->GetMobaTeamB()};
for (Team* team : team_list) {
team->FillMFMobaBattleDataTeam(rsp_msg.add_team_list());
}
SendNotifyMsg(rsp_msg);
}
}
void Player::SetShotHold(bool hold) void Player::SetShotHold(bool hold)
{ {
if (!hold && shot_hold) { if (!hold && shot_hold) {

View File

@ -30,6 +30,7 @@ namespace cs
class CMReportSpecShotHitPos; class CMReportSpecShotHitPos;
class CMWatchTarget; class CMWatchTarget;
class CMTeamCommand; class CMTeamCommand;
class CMMobaBattleData;
} }
class Room; class Room;
@ -147,6 +148,7 @@ class Player : public Human
void _CMReportSpecShotHitPos(f8::MsgHdr* hdr, const cs::CMReportSpecShotHitPos& msg); void _CMReportSpecShotHitPos(f8::MsgHdr* hdr, const cs::CMReportSpecShotHitPos& msg);
void _CMWatchTarget(f8::MsgHdr* hdr, const cs::CMWatchTarget& msg); void _CMWatchTarget(f8::MsgHdr* hdr, const cs::CMWatchTarget& msg);
void _CMTeamCommand(f8::MsgHdr* hdr, const cs::CMTeamCommand& msg); void _CMTeamCommand(f8::MsgHdr* hdr, const cs::CMTeamCommand& msg);
void _CMMobaBattleData(f8::MsgHdr* hdr, const cs::CMMobaBattleData& msg);
virtual void SetAttackDir(const glm::vec3& attack_dir) override; virtual void SetAttackDir(const glm::vec3& attack_dir) override;
void AsyncRequestWatchWar(bool send_rsp_msg); void AsyncRequestWatchWar(bool send_rsp_msg);

View File

@ -2997,6 +2997,7 @@ void Room::OnBattleStart()
return true; return true;
}); });
battle_starting_ = false; battle_starting_ = false;
SendSMTeamFull(nullptr);
} }
bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id) bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id)

View File

@ -288,6 +288,8 @@ public:
void CreateAndroid(int android_num, std::shared_ptr<Team> team = nullptr); void CreateAndroid(int android_num, std::shared_ptr<Team> team = nullptr);
int GetFullLevelIdx() { return ++curr_full_level_idx_;} int GetFullLevelIdx() { return ++curr_full_level_idx_;}
std::shared_ptr<RoomOb> GetRoomOb(); std::shared_ptr<RoomOb> GetRoomOb();
void SendSMTeamFull(Human* hum);
void OnTeamPartChg(Human* hum);
private: private:
void ShuaAndroid(); void ShuaAndroid();
@ -400,6 +402,7 @@ private:
std::map<int, Human*> alive_human_hash_; std::map<int, Human*> alive_human_hash_;
std::map<int, Human*> alive_player_hash_; std::map<int, Human*> alive_player_hash_;
std::map<int, Human*> last_human_hash_; std::map<int, Human*> last_human_hash_;
std::map<int, Human*> team_part_chg_human_hash_;
std::map<int, std::shared_ptr<BornPoint>> born_point_hash_; std::map<int, std::shared_ptr<BornPoint>> born_point_hash_;
std::map<int, std::shared_ptr<a8::CommonCbProcEx>> task_hash_; std::map<int, std::shared_ptr<a8::CommonCbProcEx>> task_hash_;

View File

@ -2,6 +2,8 @@
namespace cs namespace cs
{ {
class MFMobaBattleDataTeam;
class MFTeamFull;
class SMGameOver; class SMGameOver;
} }
@ -61,6 +63,8 @@ class Team : public std::enable_shared_from_this<Team>
int GetKillCount(); int GetKillCount();
long long GetLastKillFrameNo() { return last_kill_frameno_; } long long GetLastKillFrameNo() { return last_kill_frameno_; }
bool MemberHasOb(); bool MemberHasOb();
void FillMFMobaBattleDataTeam(cs::MFMobaBattleDataTeam* p);
void FillMFTeamFull(cs::MFTeamFull* p);
private: private:
int team_id_ = 0; int team_id_ = 0;

View File

@ -34,6 +34,7 @@ enum CMMessageId_e
_CMReportSpecShotHitPos = 240; _CMReportSpecShotHitPos = 240;
_CMWatchTarget = 241; _CMWatchTarget = 241;
_CMTeamCommand = 242; _CMTeamCommand = 242;
_CMMobaBattleData = 243;
} }
enum SMMessageId_e enum SMMessageId_e
@ -49,6 +50,7 @@ enum SMMessageId_e
_SMGetSettlementTeamList = 238; _SMGetSettlementTeamList = 238;
_SMWatchTarget = 241; _SMWatchTarget = 241;
_SMTeamComamnd = 242; _SMTeamComamnd = 242;
_SMMobaBattleData = 243;
_SMJoinedNotify = 103; _SMJoinedNotify = 103;
_SMMapInfo = 1002; _SMMapInfo = 1002;
@ -78,4 +80,6 @@ enum SMMessageId_e
_SMViewerUiNotify = 1029; _SMViewerUiNotify = 1029;
_SMViewerUiMemberUpdate = 1030; _SMViewerUiMemberUpdate = 1030;
_SMTeamCommandNotify = 1031; _SMTeamCommandNotify = 1031;
_SMTeamFullNotify = 1032;
_SMTeamPartNotify = 1033;
} }

View File

@ -739,6 +739,49 @@ message MFTeamData
repeated MFSkin skin = 39; //id repeated MFSkin skin = 39; //id
} }
//-
message MFTeamMemberNew
{
optional int32 team_id = 1; //Id
optional int32 obj_uniid = 2; //id
optional MFVec3 pos = 3; //
optional MFVec3 dir = 4; //
optional float health = 5; //
optional bool disconnected = 6 [default = false]; //线
optional bool dead = 7 [default = false]; //
optional bool downed = 8 [default = false]; //
optional string name = 9; //
optional float max_health = 10; //
optional int32 hero_id = 20 [default = 0]; //id
optional int32 level = 21 [default = 0]; //
optional int32 hero_level = 22; //hero等级
optional int32 hero_exp = 23; //hero经验
optional int32 hero_max_exp = 24; //hero max经验
optional int32 main_skill_cd = 25 [default = 0]; //cd时间
optional int32 main_skill_max_cd = 26 [default = 0]; //cd上限时间
}
//-
message MFTeamFull
{
optional int32 team_id = 1; //Id
repeated MFTeamMemberNew members = 2; //
}
//-
message MFTeamPart
{
optional int32 team_id = 1; //Id
optional int32 obj_uniid = 2; //id
optional MFVec3 pos = 3; //
optional MFVec3 dir = 4; //
optional float health = 5; //
optional float max_health = 6; //
optional bool disconnected = 7 [default = false]; //线
optional bool dead = 8 [default = false]; //
optional bool downed = 9 [default = false]; //
}
// //
message MFTeamDataNew message MFTeamDataNew
{ {
@ -1403,7 +1446,6 @@ message MFMobaTeamMember
optional int32 head_frame = 10; // optional int32 head_frame = 10; //
optional int32 obj_uniid = 11; //id optional int32 obj_uniid = 11; //id
} }
//moba队伍 //moba队伍
message MFMobaTeam message MFMobaTeam
{ {
@ -1432,6 +1474,33 @@ message MFViewerTeam
repeated MFViewTeamMember members = 2; // repeated MFViewTeamMember members = 2; //
} }
//moba战斗数据-
message MFMobaBattleDataMember
{
optional int32 team_id = 1; //id
optional int32 member_uniid = 2; //uniid
optional string name = 3; //
optional string avatar_url = 4; //
optional int32 hero_id = 5; //id
optional int32 head_frame = 6; //
repeated int32 inventory = 11; //()
optional int32 kill_count = 12; //
optional int32 dead_count = 13; //()
optional int32 assist_count = 14; //
optional int32 main_skill_id = 30; //id
optional int32 main_skill_cd = 31; //cd()
optional int32 main_skill_max_cd = 32 [default = 0]; //cd上限时间
}
//moba战斗数据-
message MFMobaBattleDataTeam
{
optional int32 team_id = 1; //id
repeated MFMobaBattleDataMember members = 2; //
}
//end mfmsg //end mfmsg
// //
@ -1736,6 +1805,16 @@ message CMTeamCommand
optional string custom_command = 2; //(json格式,) optional string custom_command = 2; //(json格式,)
} }
//moba战斗数据
message CMMobaBattleData
{
}
message SMMobaBattleData
{
repeated MFMobaBattleDataTeam team_list = 1; //(team_id是否等于自己队伍)
}
// //
message SMJoinedNotify message SMJoinedNotify
{ {
@ -1928,6 +2007,8 @@ message SMUiUpdate
optional int32 alive_count = 1; // optional int32 alive_count = 1; //
optional int32 kill_count = 2; // optional int32 kill_count = 2; //
repeated MFMapCarInfo car_list = 3; // repeated MFMapCarInfo car_list = 3; //
optional int32 dead_count = 4; //()
optional int32 assist_count = 5; //
//pve模式有意义 //pve模式有意义
optional int32 score = 10; // optional int32 score = 10; //
@ -2034,3 +2115,19 @@ message SMTeamCommandNotify
optional int32 sender_id = 1; // optional int32 sender_id = 1; //
optional string custom_command = 2; //(json格式客户端自定义) optional string custom_command = 2; //(json格式客户端自定义)
} }
//-
/*
()线
SMUpdate.team_data该队伍关系不会在发生改变(SMUpdate.team_data是会发生队伍的变更)
*/
message SMTeamFullNotify
{
repeated MFTeamFull team_list = 1; //
}
//-
message SMTeamPartNotify
{
repeated MFTeamPart members = 1; //
}