From ad62d11326e3cae6f76fa2997724ff98cd8797c0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 10 Jul 2019 19:08:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8A=80=E8=83=BD=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E9=80=89=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 54 +++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 6801b61..97b0348 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1575,32 +1575,65 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set& ta switch (skill_meta->i->skill_target()) { case ST_All: { - + for (auto& cell : grid_list) { + for (Human* hum : cell->human_list) { + if (hum->pos.Distance(target_pos) < skill_meta->i->skill_distance()) { + target_list.insert(hum); + } + } + } } break; case ST_Self: { - + target_list.insert(this); } break; case ST_FriendlyIncludeSelf: { - + for (auto& cell : grid_list) { + for (Human* hum : cell->human_list) { + if ((hum == this || hum->team_id == team_id) || + hum->pos.Distance(target_pos) < skill_meta->i->skill_distance()) { + target_list.insert(hum); + } + } + } } break; case ST_FriendlyExcludeSelf: { - + for (auto& cell : grid_list) { + for (Human* hum : cell->human_list) { + if ((hum != this && hum->team_id == team_id) || + hum->pos.Distance(target_pos) < skill_meta->i->skill_distance()) { + target_list.insert(hum); + } + } + } } break; case ST_EnemySingle: { - + Entity* entity = room->GetEntityByUniId(skill_target_id); + if (entity && entity->entity_type == ET_Player) { + Human* hum = (Human*)entity; + if (hum->team_id != team_id) { + target_list.insert(hum); + } + } } break; case ST_EnemyGroup: { - + for (auto& cell : grid_list) { + for (Human* hum : cell->human_list) { + if ((hum->team_id != team_id) || + hum->pos.Distance(target_pos) < skill_meta->i->skill_distance()) { + target_list.insert(hum); + } + } + } } break; case ST_EnemyAndObject: @@ -1610,7 +1643,14 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set& ta break; case ST_EnemyAndSelf: { - + for (auto& cell : grid_list) { + for (Human* hum : cell->human_list) { + if ((hum == this || hum->team_id != team_id) || + hum->pos.Distance(target_pos) < skill_meta->i->skill_distance()) { + target_list.insert(hum); + } + } + } } break; }