1
This commit is contained in:
parent
8e8325000e
commit
4d1beae4fc
@ -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;
|
||||
}
|
||||
|
@ -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<int, int> personal_kills_;
|
||||
std::map<int, int> personal_series_kills_;
|
||||
std::map<int, int> personal_nodead_series_kills_;
|
||||
std::map<int, int> team_bekill_last_time_hash_;
|
||||
|
||||
};
|
||||
|
@ -41,6 +41,7 @@ namespace mt
|
||||
class Grasp;
|
||||
class GraspBuff;
|
||||
class BattleHeroGrow;
|
||||
class InGameVoice;
|
||||
|
||||
struct SkillPhase;
|
||||
}
|
||||
|
19
server/gameserver/mt/InGameVoice.cc
Normal file
19
server/gameserver/mt/InGameVoice.cc
Normal file
@ -0,0 +1,19 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "mt/InGameVoice.h"
|
||||
|
||||
IMPL_TABLE(mt::InGameVoice)
|
||||
|
||||
namespace mt
|
||||
{
|
||||
|
||||
void InGameVoice::Init1()
|
||||
{
|
||||
}
|
||||
|
||||
void InGameVoice::Init2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
20
server/gameserver/mt/InGameVoice.h
Normal file
20
server/gameserver/mt/InGameVoice.h
Normal file
@ -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:
|
||||
};
|
||||
|
||||
}
|
@ -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<Distribution>(res_path_);
|
||||
RegMetaTable<LootConfig>(res_path_);
|
||||
RegMetaTable<BattleHeroGrow>(res_path_);
|
||||
RegMetaTable<InGameVoice>(res_path_);
|
||||
}
|
||||
|
||||
void MetaMgr::Load()
|
||||
|
40
server/gameserver/mtb/InGameVoice.h
Normal file
40
server/gameserver/mtb/InGameVoice.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
|
||||
namespace mtb
|
||||
{
|
||||
|
||||
class InGameVoice
|
||||
{
|
||||
public:
|
||||
|
||||
std::shared_ptr<a8::reflect::Class> 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__;
|
||||
};
|
||||
|
||||
};
|
@ -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<a8::reflect::Class> InGameVoice::GetClass() const
|
||||
{
|
||||
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
|
||||
if (!meta_class) {
|
||||
meta_class = std::make_shared<a8::reflect::Class>("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<a8::reflect::Class> MapArea::GetClass() const
|
||||
{
|
||||
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -296,7 +296,8 @@ public:
|
||||
std::shared_ptr<InGameVoice> 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();
|
||||
|
@ -610,3 +610,13 @@ bool Team::MemberHasOb()
|
||||
});
|
||||
return has;
|
||||
}
|
||||
|
||||
bool Team::AllIsDead()
|
||||
{
|
||||
for (Human* hum : members_) {
|
||||
if (!hum->dead) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class Team : public std::enable_shared_from_this<Team>
|
||||
bool MemberHasOb();
|
||||
void FillMFMobaBattleDataTeam(cs::MFMobaBattleDataTeam* p);
|
||||
void FillMFTeamFull(cs::MFTeamFull* p);
|
||||
bool AllIsDead();
|
||||
|
||||
private:
|
||||
int team_id_ = 0;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user