select_target.*

This commit is contained in:
aozhiwei 2021-03-19 16:40:57 +08:00
parent c5161158d7
commit 85024f9892
3 changed files with 128 additions and 120 deletions

View File

@ -284,126 +284,6 @@ Skill* Creature::GetPassiveSkill(int skill_id)
return itr != passive_skill_hash_.end() ? itr->second : nullptr;
}
void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std::set<Entity*>& target_list)
{
switch (skill->meta->i->skill_target()) {
case kST_All:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if (hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_Self:
{
target_list.insert(this);
}
break;
case kST_FriendlyIncludeSelf:
{
target_list.insert(this);
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum == this || hum->team_id == team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_FriendlyExcludeSelf:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum != this && hum->team_id == team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemySingle:
{
#if 0
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity;
if (IsEnemy(hum)) {
target_list.insert(hum);
}
}
#endif
}
break;
case kST_EnemyGroup:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum->team_id != team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemyAndObject:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum->team_id != team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemyAndSelf:
{
#if 0
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum == this || this->IsEnemy(hum)) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
#endif
}
break;
case kST_SingleEnemyAndSelf:
{
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity;
#if 0
if (IsEnemy(hum)) {
target_list.insert(hum);
}
#endif
}
target_list.insert(this);
}
break;
default:
break;
}
}
void Creature::TriggerBuff(Skill* skill, std::set<Entity*>& target_list, BuffTriggerType_e trigger_type)
{
for (Entity* entity : target_list) {

View File

@ -0,0 +1,127 @@
#include "precompile.h"
#include "creature.h"
#include "metamgr.h"
#include "room.h"
#include "skill.h"
#include "human.h"
void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std::set<Entity*>& target_list)
{
switch (skill->meta->i->skill_target()) {
case kST_All:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if (hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_Self:
{
target_list.insert(this);
}
break;
case kST_FriendlyIncludeSelf:
{
target_list.insert(this);
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum == this || hum->team_id == team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_FriendlyExcludeSelf:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum != this && hum->team_id == team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemySingle:
{
#if 0
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity;
if (IsEnemy(hum)) {
target_list.insert(hum);
}
}
#endif
}
break;
case kST_EnemyGroup:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum->team_id != team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemyAndObject:
{
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum->team_id != team_id) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
}
break;
case kST_EnemyAndSelf:
{
#if 0
TouchAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
if ((hum == this || this->IsEnemy(hum)) &&
hum->GetPos().Distance(target_pos) < skill->meta->i->skill_distance()) {
target_list.insert(hum);
}
});
#endif
}
break;
case kST_SingleEnemyAndSelf:
{
Entity* entity = room->GetEntityByUniId(skill_target_id_);
if (entity && entity->IsEntityType(ET_Player)) {
Human* hum = (Human*)entity;
#if 0
if (IsEnemy(hum)) {
target_list.insert(hum);
}
#endif
}
target_list.insert(this);
}
break;
default:
break;
}
}

View File

@ -0,0 +1 @@
#pragma once