1
This commit is contained in:
parent
e6cc4105f1
commit
661d96be4d
@ -1104,6 +1104,7 @@ behaviac::EBTStatus HeroAgent::CoGetNextMobaModeRoadPoint()
|
||||
if (owner_->point_idx < road.size()) {
|
||||
++owner_->point_idx;
|
||||
} else {
|
||||
owner_->road_idx = rand() % owner_->room->GetMapMeta()->moba_path_points.size();
|
||||
owner_->point_idx = 0;
|
||||
owner_->path_dir = owner_->path_dir == 1 ? 0 : 1;
|
||||
}
|
||||
@ -1114,25 +1115,59 @@ behaviac::EBTStatus HeroAgent::CoGetNextMobaModeRoadPoint()
|
||||
out_point0 += dir * (float)a8::RandEx(0, 100);
|
||||
}
|
||||
if (owner_->GetPos().Distance2D2(out_point0) > 500) {
|
||||
std::vector<std::tuple<std::shared_ptr<mt::WorldObject>, int, int>> paths;
|
||||
int r = 0;
|
||||
for (auto& road : GetRoom()->GetMapMeta()->moba_path_points) {
|
||||
if (owner_->path_dir == 1) {
|
||||
int p = 0;
|
||||
for (auto itr = road.rbegin(); itr != road.rend(); ++itr) {
|
||||
auto& point = std::get<0>(*itr);
|
||||
if (point->pos.x < owner_->GetPos().GetX()) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 500) {
|
||||
paths.push_back(std::make_tuple
|
||||
(
|
||||
point,
|
||||
r,
|
||||
p
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
} else {
|
||||
int p = 0;
|
||||
for (auto itr = road.begin(); itr != road.end(); ++itr) {
|
||||
auto& point = std::get<0>(*itr);
|
||||
if (point->pos.x > owner_->GetPos().GetX()) {
|
||||
if (owner_->GetPos().Distance2D2(point->pos) < 500) {
|
||||
paths.push_back(std::make_tuple
|
||||
(
|
||||
point,
|
||||
r,
|
||||
p
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
}
|
||||
++r;
|
||||
}
|
||||
if (paths.empty()) {
|
||||
|
||||
} else {
|
||||
auto& path = paths.at(rand() % paths.size());
|
||||
owner_->road_idx = std::get<1>(path);
|
||||
owner_->point_idx = std::get<2>(path);
|
||||
if (owner_->path_dir == 1) {
|
||||
out_point0 = std::get<0>(road.at(road.size() - owner_->point_idx - 1))->pos;
|
||||
} else {
|
||||
out_point0 = std::get<0>(road.at(owner_->point_idx))->pos;
|
||||
out_point0 += dir * (float)a8::RandEx(0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return behaviac::BT_SUCCESS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user