From 245dbfafdb7e2f3b8f8c5901597cee2a004da4d9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 27 May 2021 14:39:16 +0800 Subject: [PATCH] 1 --- server/gameserver/buff.cc | 62 +++++++++++++++++++++++++++++ server/gameserver/buff.h | 1 + server/gameserver/constant.h | 12 ++++++ server/gameserver/constant_export.h | 1 + server/gameserver/creature.cc | 33 ++++++++++----- server/gameserver/creature.h | 1 + server/gameserver/metadata.cc | 4 ++ server/gameserver/metadata.h | 4 ++ 8 files changed, 109 insertions(+), 9 deletions(-) diff --git a/server/gameserver/buff.cc b/server/gameserver/buff.cc index c720b20..07b238f 100644 --- a/server/gameserver/buff.cc +++ b/server/gameserver/buff.cc @@ -330,3 +330,65 @@ void Buff::ProcSprint(Creature* caster) }); } } + +void Buff::ProcSeletTargetWithSelfPos(Creature* caster) +{ + std::vector targets; + owner->TraverseCreatures + ( + [this, &targets] (Creature* c, bool& stop) + { + switch (meta->int_param1) { + case kBST_All: + { + targets.push_back(c); + } + break; + case kBST_Self: + { + if (c == owner) { + targets.push_back(c); + } + } + break; + case kBST_FriendlyIncludeSelf: + { + if (c->team_id == owner->team_id) { + targets.push_back(c); + } + } + break; + case kBST_FriendlyExcludeSelf: + { + if (c->team_id == owner->team_id && c != owner) { + targets.push_back(c); + } + } + break; + case kBST_Enemy: + { + if (c->team_id != owner->team_id) { + targets.push_back(c); + } + } + break; + case kBST_EnemyAndSelf: + { + if (c->team_id != owner->team_id || c == owner) { + targets.push_back(c); + } + } + break; + default: + { + } + break; + } + } + ); + for (auto& target : targets) { + for (int buff_id : meta->param2_int_list) { + target->TryAddBuff(caster, buff_id); + } + } +} diff --git a/server/gameserver/buff.h b/server/gameserver/buff.h index c450e92..f2c6764 100644 --- a/server/gameserver/buff.h +++ b/server/gameserver/buff.h @@ -45,6 +45,7 @@ class Buff void ProcPassenger(Creature* caster); void ProcRemovePassenger(Creature* caster); void ProcSprint(Creature* caster); + void ProcSeletTargetWithSelfPos(Creature* caster); private: void InternalTimerAddBuff(Creature* caster); diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 970c762..714d41f 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -167,6 +167,18 @@ enum SkillTarget_e kST_SpecDir = 11 }; +enum BuffSelectTarget_e +{ + kBST_All = 0, + + kBST_Self = 1, + kBST_FriendlyIncludeSelf = 2, + kBST_FriendlyExcludeSelf = 3, + + kBST_Enemy = 5, + kBST_EnemyAndSelf = 6, +}; + enum VirtualWeapon_e { VW_SafeArea = 9000000, diff --git a/server/gameserver/constant_export.h b/server/gameserver/constant_export.h index 3249a1e..21763ee 100644 --- a/server/gameserver/constant_export.h +++ b/server/gameserver/constant_export.h @@ -54,6 +54,7 @@ enum BuffEffectType_e kBET_FlashMove = 37, //瞬间移动 kBET_Become = 38, //变身 kBET_ShotCharge = 39, //射击蓄力 + kBET_SelectTargetWithSelfPos = 39, //已自己坐标为中心范围内选取目标,并且批量添加buff kBET_FollowMaster = 49, //跟随主人 kBET_ThroughWall = 50, //穿墙 diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 725e213..cb60d7e 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -938,17 +938,22 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff) buff->ProcBecome(caster); } break; - case kBET_Driver: - { + case kBET_SelectTargetWithSelfPos: + { + buff->ProcSeletTargetWithSelfPos(caster); + } + break; + case kBET_Driver: + { buff->ProcDriver(caster); - } - break; - case kBET_Passenger: - { + } + break; + case kBET_Passenger: + { buff->ProcPassenger(caster); - } - break; - default: + } + break; + default: { } break; @@ -1136,6 +1141,13 @@ bool Creature::IsEnemy(Creature* target) } } +void Creature::TraverseCreatures(std::function func) +{ + room->grid_service->TraverseCreatures(room->GetRoomIdx(), + GetGridList(), + func); +} + void Creature::TraverseProperTargets(std::function func) { auto callback = @@ -1780,6 +1792,9 @@ void Creature::GetHitEnemys(std::set& enemys) void Creature::AddHp(float hp) { + if (dead) { + return; + } float old_health = GetHP(); ability.hp += hp; ability.hp = std::min(GetHP(), GetMaxHP()); diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 361b18d..03db0c0 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -134,6 +134,7 @@ class Creature : public MoveableEntity int GetActionType() { return action_type; } int GetActionTargetId() { return action_target_id; } + void TraverseCreatures(std::function func); void TraverseProperTargets(std::function func); void TraverseProperTargetsNoTeammate(std::function func); CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; }; diff --git a/server/gameserver/metadata.cc b/server/gameserver/metadata.cc index c7e0ec8..b837914 100644 --- a/server/gameserver/metadata.cc +++ b/server/gameserver/metadata.cc @@ -644,6 +644,10 @@ namespace MetaData param2 = a8::XValue(i->buff_param2()).GetDouble(); param3 = a8::XValue(i->buff_param3()).GetDouble(); param4 = a8::XValue(i->buff_param4()).GetDouble(); + int_param1 = a8::XValue(i->buff_param1()); + int_param2 = a8::XValue(i->buff_param2()); + int_param3 = a8::XValue(i->buff_param3()); + int_param4 = a8::XValue(i->buff_param4()); { std::vector strings; a8::Split(i->immune_buffeffect_list(), strings, '|'); diff --git a/server/gameserver/metadata.h b/server/gameserver/metadata.h index d4815d4..eb699c6 100755 --- a/server/gameserver/metadata.h +++ b/server/gameserver/metadata.h @@ -180,6 +180,10 @@ namespace MetaData float param2 = 0.0f; float param3 = 0.0f; float param4 = 0.0f; + int int_param1 = 0; + int int_param2 = 0; + int int_param3 = 0; + int int_param4 = 0; std::vector param1_int_list; std::vector param2_int_list; std::vector>>> batch_add_list;