This commit is contained in:
aozhiwei 2021-07-23 12:07:14 +00:00
parent f7f8dcbc57
commit 4876f68369
4 changed files with 40 additions and 1 deletions

View File

@ -507,5 +507,31 @@ void HeroAI::UpdateSweepMine()
RoomObstacle* HeroAI::FindObstacleTarget()
{
return nullptr;
Hero* myself = (Hero*)owner;
RoomObstacle* target = nullptr;
if (!myself->master.Get()) {
return nullptr;
}
for (auto& pair : myself->room->mine_objects) {
if (pair.second.Get() &&
!pair.second.Get()->IsDead(myself->room) &&
(pair.second.Get()->meta->sweep_tags & ai_meta->bits_param2) != 0) {
if (pair.second.Get()->GetTeamId(myself->room) == myself->master.Get()->team_id) {
continue;
}
if (target) {
if (myself->GetPos().ManhattanDistance(target->GetPos()) >
myself->GetPos().ManhattanDistance(pair.second.Get()->GetPos())) {
target = pair.second.Get();
}
} else {
target = pair.second.Get();
}
}
}
if (target && target->GetPos().Distance(myself->GetPos()) > ai_meta->int_param2) {
target = nullptr;
}
return target;
}

View File

@ -1170,6 +1170,14 @@ namespace MetaData
);
}
}
if (i->ai_kind() == kAI_MineSweeper) {
for (int n : int_list_param2) {
if (n <= 0 || n > 63) {
abort();
}
a8::SetBitFlag(bits_param2, n);
}
}
}
void AI::Init2()

View File

@ -317,6 +317,8 @@ namespace MetaData
std::set<int> int_set_param4;
std::set<int> int_set_param5;
long long bits_param2 = 0;
private:
std::tuple<int, int> random_move_idle_time_;
std::tuple<int, int> random_move_time_;

View File

@ -407,6 +407,9 @@ void RoomObstacle::Die(Room* room)
if (!IsDead(room)) {
Obstacle::Die(room);
DetachFromMaster();
if (meta->sweep_tags != 0) {
room->mine_objects.erase(GetUniId());
}
}
}