This commit is contained in:
aozhiwei 2024-03-29 17:25:37 +08:00
parent 8b122340f9
commit 5d9de283df
6 changed files with 53 additions and 10 deletions

View File

@ -5,6 +5,8 @@
#include "human.h"
#include "team.h"
#include "mt/InGameVoice.h"
InGameVoice::InGameVoice(Room* room)
{
room_ = room;
@ -27,7 +29,6 @@ void InGameVoice::UnInit()
void InGameVoice::OnHumanBeKill(int killer_id, Human* deader)
{
#if 0
if (killer_id == deader->GetUniId()) {
return;
}
@ -35,13 +36,20 @@ void InGameVoice::OnHumanBeKill(int killer_id, Human* deader)
if (!killer) {
return;
}
personal_nodead_series_kills_.erase(killer_id);
personal_nodead_series_kills_.erase(deader->GetUniId());
IncGlobalKills();
IncPersonalKills(killer_id);
if (global_times_ == 1) {
room_->SendGlobalInGameVoice(killer_id, 1, deader->GetUniId());
return;
{
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kGlobalKills,
[this] (const mt::InGameVoice* meta) -> bool
{
return true;
});
}
if (GetPersonalKills(killer_id) == 1) {
room_->SendSelfInGameVoice(killer_id, 2);
}
@ -62,7 +70,6 @@ void InGameVoice::OnHumanBeKill(int killer_id, Human* deader)
if (!killer->dead) {
IncPersonalNoDeadSeriesKills(killer_id);
}
#endif
}
void InGameVoice::IncGlobalKills()

View File

@ -59,6 +59,20 @@ namespace mt
if (series_kill_interval() > 0) {
s_series_kill_interval = series_kill_interval();
}
_cond_val = a8::XValue(cond());
if (!cond().empty()) {
switch (cond().at(0)) {
case '>':
{
}
break;
default:
{
_cond_type = InGameVoiceCondType_e::kEq;
}
break;
}
}
}
void InGameVoice::Init2()
@ -105,4 +119,14 @@ namespace mt
}
}
InGameVoiceCondType_e InGameVoice::CondType() const
{
return _cond_type;
}
int InGameVoice::CondVal() const
{
return _cond_val;
}
}

View File

@ -30,6 +30,13 @@ A8_DECLARE_ENUM(InGameVoiceNotifyObject_e,
kTeammateExcludeDead
);
A8_DECLARE_ENUM(InGameVoiceCondType_e,
kNone,
kEq,
kGT,
kGE
);
namespace mt
{
@ -43,11 +50,16 @@ namespace mt
void Init1();
void Init2();
InGameVoiceNotifyObject_e GetNotifyObject() const;
InGameVoiceCondType_e CondType() const;
int CondVal() const;
static void Traverse(bool is_moba_room, int event_type, std::function<bool (const InGameVoice*)> cb);
private:
InGameVoiceNotifyObject_e _notify_object;
InGameVoiceCondType_e _cond_type = InGameVoiceCondType_e::kNone;
int _cond_val = 0;
static std::map<int, std::vector<const InGameVoice*>> s_type_hash_;
};

View File

@ -13,7 +13,7 @@ namespace mtb
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 cond() const { return cond_; };
const std::string notify_object() const { return notify_object_; };
int notify_fields() const { return notify_fields_; };
int play_interval() const { return play_interval_; };
@ -35,7 +35,7 @@ namespace mtb
int event_type_ = 0;
int moba_is_play_ = 0;
int sound_id_ = 0;
int cond_ = 0;
std::string cond_;
std::string notify_object_;
int notify_fields_ = 0;
int play_interval_ = 0;

View File

@ -137,7 +137,7 @@ namespace mtb
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(3, "cond", a8::reflect::ET_STRING, 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_));
meta_class->SetSimpleField(6, "play_interval", a8::reflect::ET_INT32, my_offsetof2(InGameVoice, play_interval_));

View File

@ -63,7 +63,7 @@ message InGameVoice
optional int32 event_type = 1;
optional int32 moba_is_play = 2;
optional int32 sound_id = 3;
optional int32 cond = 4;
optional string cond = 4;
optional string notify_object = 5;
optional int32 notify_fields = 6;
optional int32 play_interval = 7;