From 91ad7c571037e54f7e0bd5f2e20e7f22be9dab4a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 9 Apr 2021 19:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0buff=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/buff.cc | 12 ++++++++++++ server/gameserver/buff.h | 3 +++ server/gameserver/creature.cc | 10 ++++++---- server/gameserver/creature.h | 2 +- server/gameserver/human.cc | 2 +- server/tools/protobuild/metatable.proto | 2 ++ 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/server/gameserver/buff.cc b/server/gameserver/buff.cc index 471c73e..2b89e6f 100644 --- a/server/gameserver/buff.cc +++ b/server/gameserver/buff.cc @@ -137,3 +137,15 @@ void Buff::InternalTimerAddBuff(Creature* caster) break; } } + +void Buff::ProcSummonHero(Creature* caster) +{ + if (!caster->IsHuman()) { + return; + } +} + +bool Buff::NeedSync(Human* hum) +{ + return !meta->i->only_server() || !(meta->i->only_self() && owner == hum); +} diff --git a/server/gameserver/buff.h b/server/gameserver/buff.h index 1e04c9d..bcf9c29 100644 --- a/server/gameserver/buff.h +++ b/server/gameserver/buff.h @@ -15,6 +15,7 @@ namespace cs class MFBuff; } +class Human; class Creature; class Buff { @@ -28,11 +29,13 @@ class Buff int GetLeftTime(); int GetLastingTime(); + bool NeedSync(Human* hum); void FillMFBuff(cs::MFBuff* buff_pb); void ProcDelayAddBuff(Creature* caster); void ProcIntervalAddBuff(Creature* caster); void ProcBatchAddBuff(Creature* caster); + void ProcSummonHero(Creature* caster); private: void InternalTimerAddBuff(Creature* caster); diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index e0eab1c..ff52f0f 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -344,11 +344,13 @@ float Creature::GetBuffAttrRate(int attr_type) return 0; } -void Creature::FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list) +void Creature::FillBuffList(Human* hum, ::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list) { for (auto& itr : buff_list_) { - auto buff = pb_buff_list->Add(); - itr.FillMFBuff(buff); + if (itr.NeedSync(hum)) { + auto buff = pb_buff_list->Add(); + itr.FillMFBuff(buff); + } } } @@ -827,7 +829,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff) break; case kBET_SummonHero: { - + buff->ProcSummonHero(caster); } break; case kBET_Shield: diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index b9f17ca..e629482 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -69,7 +69,7 @@ class Creature : public MoveableEntity void ClearBuffList(); float GetBuffAttrAbs(int attr_id); float GetBuffAttrRate(int attr_id); - void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list); + void FillBuffList(Human* hum, ::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list); void FillSkillList(::google::protobuf::RepeatedPtrField< cs::MFSkill >* pb_skill_list); void TriggerBuff(Skill* skill, std::set& target_list, BuffTriggerType_e trigger_type); Skill* GetSkill(int skill_id); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c0ffbde..1471b60 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -203,7 +203,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data p->set_parachute(parachute); } FillBodyState(p->mutable_states()); - FillBuffList(p->mutable_buff_list()); + FillBuffList(hum, p->mutable_buff_list()); FillSkillList(p->mutable_skill_list()); if (dead) { p->set_killer_name(stats.killer_name); diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index c25ec34..b6c1cb7 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -213,6 +213,8 @@ message Buff optional float buff_valueup = 11; required string immune_buffeffect_list = 12; optional string post_remove_action = 13; + optional int32 only_server = 14; + optional int32 only_self = 15; } message Drop