#include "precompile.h" #include "creature.h" #include "room.h" #include "skill.h" #include "human.h" #include "mt/Skill.h" void Creature::SelectSkillTargets(Skill* skill, const Position& target_pos, std::set& target_list) { switch (skill->meta->skill_target()) { case kST_All: { TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if (hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_Self: { target_list.insert(this); } break; case kST_FriendlyIncludeSelf: { target_list.insert(this); TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if ((hum == this || hum->team_id == team_id) && hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_FriendlyExcludeSelf: { TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if ((hum != this && hum->team_id == team_id) && hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_EnemySingle: { Entity* entity = room->GetEntityByUniId(skill_target_id_); if (entity && entity->IsEntityType(ET_Player)) { Human* hum = (Human*)entity; if (IsEnemy(hum)) { target_list.insert(hum); } } } break; case kST_EnemyGroup: { TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if ((hum->team_id != team_id) && hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_EnemyAndObject: { TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if ((hum->team_id != team_id) && hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_EnemyAndSelf: { TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { if ((hum == this || this->IsEnemy(hum)) && hum->GetPos().Distance2D2(target_pos) < skill->meta->skill_distance()) { target_list.insert(hum); } }); } break; case kST_SingleEnemyAndSelf: { Entity* entity = room->GetEntityByUniId(skill_target_id_); if (entity && entity->IsEntityType(ET_Player)) { Human* hum = (Human*)entity; if (IsEnemy(hum)) { target_list.insert(hum); } } target_list.insert(this); } break; case kST_SpecDir: { target_list.insert(this); } break; default: break; } }