diff --git a/server/gameserver/ingamevoice.cc b/server/gameserver/ingamevoice.cc index 21a92344..d417c709 100644 --- a/server/gameserver/ingamevoice.cc +++ b/server/gameserver/ingamevoice.cc @@ -3,6 +3,7 @@ #include "ingamevoice.h" #include "room.h" #include "human.h" +#include "team.h" InGameVoice::InGameVoice(Room* room) { @@ -26,6 +27,7 @@ void InGameVoice::UnInit() void InGameVoice::OnHumanBeKill(int killer_id, Human* deader) { + #if 0 if (killer_id == deader->GetUniId()) { return; } @@ -33,6 +35,7 @@ void InGameVoice::OnHumanBeKill(int killer_id, Human* deader) if (!killer) { return; } + personal_nodead_series_kills_.erase(killer_id); IncGlobalKills(); IncPersonalKills(killer_id); if (global_times_ == 1) { @@ -42,6 +45,24 @@ void InGameVoice::OnHumanBeKill(int killer_id, Human* deader) if (GetPersonalKills(killer_id) == 1) { room_->SendSelfInGameVoice(killer_id, 2); } + if (room_->GetFrameNo() - GetTeamBeKillLastTime(deader->GetTeam()->GetTeamId()) > SERVER_FRAME_RATE) { + room_->SendTeamInGameVoice(killer_id, 3, deader->GetTeam()->GetTeamId()); + room_->SendTeamInGameVoice(killer_id, 4, killer->GetTeam()->GetTeamId()); + } + UpdateTeamBeKillLastTime(GetTeamBeKillLastTime(deader->GetTeam()->GetTeamId())); + if (deader->GetTeam()->AllIsDead()) { + if (!room_->IsMobaModeRoom()) { + room_->SendTeamInGameVoice(killer_id, 5, deader->GetTeam()->GetTeamId()); + } + } + IncPersonalSeriesKills(killer_id); + if (GetPersonalSeriesKills(killer_id) > 1) { + room_->SendTeamInGameVoice(killer_id, GetPersonalSeriesKills(killer_id) - 1 + 6, killer->GetTeam()->GetTeamId()); + } + if (!killer->dead) { + IncPersonalNoDeadSeriesKills(killer_id); + } + #endif } void InGameVoice::IncGlobalKills() @@ -75,3 +96,55 @@ int InGameVoice::GetTeamBeKillLastTime(int team_id) auto itr = team_bekill_last_time_hash_.find(team_id); return itr != team_bekill_last_time_hash_.end() ? itr->second : 0; } + +void InGameVoice::IncPersonalSeriesKills(int killer_id) +{ + auto itr = personal_series_kills_.find(killer_id); + if (itr != personal_series_kills_.end()) { + ++itr->second; + } else { + personal_series_kills_[killer_id] = 1; + } + room_->xtimer.SetTimeoutWpEx + ( + SERVER_FRAME_RATE * 30, + [room = room_, killer_id] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + room->GetInGameVoice()->personal_series_kills_.erase(killer_id); + } + }, + &room_->xtimer_attacher_); +} + +int InGameVoice::GetPersonalSeriesKills(int killer_id) +{ + auto itr = personal_series_kills_.find(killer_id); + return itr != personal_series_kills_.end() ? itr->second : 0; +} + +void InGameVoice::IncPersonalNoDeadSeriesKills(int killer_id) +{ + auto itr = personal_nodead_series_kills_.find(killer_id); + if (itr != personal_nodead_series_kills_.end()) { + ++itr->second; + } else { + personal_nodead_series_kills_[killer_id] = 1; + } + room_->xtimer.SetTimeoutWpEx + ( + SERVER_FRAME_RATE * 30, + [room = room_, killer_id] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + room->GetInGameVoice()->personal_nodead_series_kills_.erase(killer_id); + } + }, + &room_->xtimer_attacher_); +} + +int InGameVoice::GetPersonalNoDeadSeriesKills(int killer_id) +{ + auto itr = personal_nodead_series_kills_.find(killer_id); + return itr != personal_nodead_series_kills_.end() ? itr->second : 0; +} diff --git a/server/gameserver/ingamevoice.h b/server/gameserver/ingamevoice.h index 4de87d7b..7e30e566 100644 --- a/server/gameserver/ingamevoice.h +++ b/server/gameserver/ingamevoice.h @@ -20,11 +20,17 @@ private: int GetPersonalKills(int obj_uniid); void UpdateTeamBeKillLastTime(int team_id); int GetTeamBeKillLastTime(int team_id); + void IncPersonalSeriesKills(int killer_id); + int GetPersonalSeriesKills(int killer_id); + void IncPersonalNoDeadSeriesKills(int killer_id); + int GetPersonalNoDeadSeriesKills(int killer_id); private: Room* room_ = nullptr; int global_times_ = 0; std::map personal_kills_; + std::map personal_series_kills_; + std::map personal_nodead_series_kills_; std::map team_bekill_last_time_hash_; }; diff --git a/server/gameserver/mt/Forward.h b/server/gameserver/mt/Forward.h index bd9e3c64..4e014954 100644 --- a/server/gameserver/mt/Forward.h +++ b/server/gameserver/mt/Forward.h @@ -41,6 +41,7 @@ namespace mt class Grasp; class GraspBuff; class BattleHeroGrow; + class InGameVoice; struct SkillPhase; } diff --git a/server/gameserver/mt/InGameVoice.cc b/server/gameserver/mt/InGameVoice.cc new file mode 100644 index 00000000..7a9a7413 --- /dev/null +++ b/server/gameserver/mt/InGameVoice.cc @@ -0,0 +1,19 @@ +#include "precompile.h" + +#include "mt/InGameVoice.h" + +IMPL_TABLE(mt::InGameVoice) + +namespace mt +{ + + void InGameVoice::Init1() + { + } + + void InGameVoice::Init2() + { + + } + +} diff --git a/server/gameserver/mt/InGameVoice.h b/server/gameserver/mt/InGameVoice.h new file mode 100644 index 00000000..f915020c --- /dev/null +++ b/server/gameserver/mt/InGameVoice.h @@ -0,0 +1,20 @@ +#pragma once + +#include "mt/macro.h" +#include "mtb/InGameVoice.h" + +namespace mt +{ + + DECLARE_ID_TABLE(InGameVoice, mtb::InGameVoice, + "ingameVoice@ingameVoice.json", + "id") + public: + + void Init1(); + void Init2(); + + private: + }; + +} diff --git a/server/gameserver/mt/MetaMgr.cc b/server/gameserver/mt/MetaMgr.cc index 54ec7ee0..908811ab 100644 --- a/server/gameserver/mt/MetaMgr.cc +++ b/server/gameserver/mt/MetaMgr.cc @@ -46,6 +46,7 @@ #include "mt/LootConfig.h" #include "mt/BattleHeroGrow.h" #include "mt/MobaRoom.h" +#include "mt/InGameVoice.h" #include "app.h" @@ -119,6 +120,7 @@ namespace mt RegMetaTable(res_path_); RegMetaTable(res_path_); RegMetaTable(res_path_); + RegMetaTable(res_path_); } void MetaMgr::Load() diff --git a/server/gameserver/mtb/InGameVoice.h b/server/gameserver/mtb/InGameVoice.h new file mode 100644 index 00000000..7cd7e16a --- /dev/null +++ b/server/gameserver/mtb/InGameVoice.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +namespace mtb +{ + + class InGameVoice + { + public: + + std::shared_ptr GetClass() const; + int event_type() const { return event_type_; }; + int moba_is_play() const { return moba_is_play_; }; + int sound_id() const { return sound_id_; }; + int cond() const { return cond_; }; + const std::string notify_object() const { return notify_object_; }; + int notify_fields() const { return notify_fields_; }; + + bool has_event_type() const { return __flags__.test(0);}; + bool has_moba_is_play() const { return __flags__.test(1);}; + bool has_sound_id() const { return __flags__.test(2);}; + bool has_cond() const { return __flags__.test(3);}; + bool has_notify_object() const { return __flags__.test(4);}; + bool has_notify_fields() const { return __flags__.test(5);}; + + protected: + + int event_type_ = 0; + int moba_is_play_ = 0; + int sound_id_ = 0; + int cond_ = 0; + std::string notify_object_; + int notify_fields_ = 0; + +public: + std::bitset<6> __flags__; + }; + +}; diff --git a/server/gameserver/mtb/mtb.all.cc b/server/gameserver/mtb/mtb.all.cc index 3d72f4b4..fcc5b6fc 100644 --- a/server/gameserver/mtb/mtb.all.cc +++ b/server/gameserver/mtb/mtb.all.cc @@ -5,6 +5,7 @@ #include "mtb/Attr.h" #include "mtb/Map.h" #include "mtb/MobaRoom.h" +#include "mtb/InGameVoice.h" #include "mtb/MapArea.h" #include "mtb/MapThing.h" #include "mtb/SafeArea.h" @@ -128,6 +129,21 @@ namespace mtb return meta_class; } + std::shared_ptr InGameVoice::GetClass() const + { + std::shared_ptr meta_class = nullptr; + if (!meta_class) { + meta_class = std::make_shared("InGameVoice", 6, 0); + meta_class->SetSimpleField(0, "event_type", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, event_type_)); + meta_class->SetSimpleField(1, "moba_is_play", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, moba_is_play_)); + meta_class->SetSimpleField(2, "sound_id", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, sound_id_)); + meta_class->SetSimpleField(3, "cond", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, cond_)); + meta_class->SetSimpleField(4, "notify_object", a8::reflect::ET_STRING, my_offsetof2(InGameVoice, notify_object_)); + meta_class->SetSimpleField(5, "notify_fields", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, notify_fields_)); + } + return meta_class; + } + std::shared_ptr MapArea::GetClass() const { std::shared_ptr meta_class = nullptr; diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 5afe8400..5fa84391 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2947,7 +2947,8 @@ void Room::SendTeamInGameVoice(int killer_uniid, int voice_id, int team_id) } -void Room::SendGlobalInGameVoice(int killer_uniid, int voice_id, int dead_uniid) +void Room::SendGlobalInGameVoice(int killer_uniid, int voice_id, int dead_uniid, + int exclude_uniid, int exclude_team_id) { } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index d3454646..951456aa 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -296,7 +296,8 @@ public: std::shared_ptr GetInGameVoice() { return ingame_voice_; } void SendSelfInGameVoice(int killer_uniid, int voice_id); void SendTeamInGameVoice(int killer_uniid, int voice_id, int team_id); - void SendGlobalInGameVoice(int killer_uniid, int voice_id, int dead_uniid); + void SendGlobalInGameVoice(int killer_uniid, int voice_id, int dead_uniid, + int exclude_uniid, int exclude_team_id); private: void ShuaAndroid(); diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index cf75e767..c63d43d3 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -610,3 +610,13 @@ bool Team::MemberHasOb() }); return has; } + +bool Team::AllIsDead() +{ + for (Human* hum : members_) { + if (!hum->dead) { + return false; + } + } + return true; +} diff --git a/server/gameserver/team.h b/server/gameserver/team.h index 99a6eda0..5d9ff1a1 100644 --- a/server/gameserver/team.h +++ b/server/gameserver/team.h @@ -64,6 +64,7 @@ class Team : public std::enable_shared_from_this bool MemberHasOb(); void FillMFMobaBattleDataTeam(cs::MFMobaBattleDataTeam* p); void FillMFTeamFull(cs::MFTeamFull* p); + bool AllIsDead(); private: int team_id_ = 0; diff --git a/server/tools/protobuild/mt.proto b/server/tools/protobuild/mt.proto index dd60a289..8fa6a033 100755 --- a/server/tools/protobuild/mt.proto +++ b/server/tools/protobuild/mt.proto @@ -58,6 +58,16 @@ message MobaRoom optional string batterys = 8; } +message InGameVoice +{ + optional int32 event_type = 1; + optional int32 moba_is_play = 2; + optional int32 sound_id = 3; + optional int32 cond = 4; + optional string notify_object = 5; + optional int32 notify_fields = 6; +} + message MapArea { optional int32 map_id = 1;