Level 120: autohunt large targets, boss hit range, QUEST_INFO size
- QUEST_INFO: take the full packet size from the flags (server built it short) - Bosses get the huge-race 500 centre hit test, like AVA2 IsBoss() - Autohunt: defending reach as body size for large targets, walk straight at a body in reach when the planner finds no path, escalating skip for a target it keeps stalling on, new anchor after a teleport, immune skip only on an explicit 0-damage packet - ava2-dungeons README: hydra range notes, snow key stack note Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a1e7da68a4
commit
569afb1378
@@ -25,13 +25,22 @@ inline bool Segment(Point a, Point b, const Walkable& walkable) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// The point `body` short of goal on the way from p: a large target's own cells (a hydra on the
|
||||
// water) need not be walkable, only the line up to its edge.
|
||||
inline Point Toward(Point p, Point goal, float body) {
|
||||
const float d=Distance(p,goal);
|
||||
if (body<=0 || d<=0) return goal;
|
||||
if (d<=body) return p;
|
||||
return {goal.x+(p.x-goal.x)*body/d, goal.y+(p.y-goal.y)*body/d};
|
||||
}
|
||||
// Empty means unreachable within the loaded data/search budget, never permission to walk straight.
|
||||
inline std::vector<Point> FindPath(Point start, Point goal, float arrival, const Walkable& walkable,
|
||||
int budget=3500) {
|
||||
int budget=3500, float body=0.f) {
|
||||
if (!std::isfinite(start.x) || !std::isfinite(start.y) || !std::isfinite(goal.x) ||
|
||||
!std::isfinite(goal.y) || arrival < 0 || budget <= 0 || Distance(start,goal)>40000.f) return {};
|
||||
if (Distance(start,goal) <= arrival && Segment(start,goal,walkable)) return {start};
|
||||
if (Segment(start,goal,walkable)) return {goal};
|
||||
!std::isfinite(goal.y) || arrival < 0 || body < 0 || budget <= 0 || Distance(start,goal)>40000.f) return {};
|
||||
auto reaches=[&](Point p) { return Segment(p,Toward(p,goal,body),walkable); };
|
||||
if (Distance(start,goal) <= arrival && reaches(start)) return {start};
|
||||
if (reaches(start)) return {Toward(start,goal,body)};
|
||||
constexpr float cell=100.f;
|
||||
// Grid is relative to the exact starting position, so the first step cannot cross an unchecked edge.
|
||||
const int extent = int(std::ceil(Distance(start,goal)/cell))+25;
|
||||
@@ -61,8 +70,7 @@ inline std::vector<Point> FindPath(Point start, Point goal, float arrival, const
|
||||
--budget;
|
||||
const float cost=nodes[id].cost; // inserts below may rehash the map
|
||||
const Point p=point(e.x,e.y);
|
||||
if (Distance(p,goal)<=std::max(arrival,cell) &&
|
||||
Segment(p,goal,walkable)) { finish=id; break; }
|
||||
if (Distance(p,goal)<=std::max(arrival,cell) && reaches(p)) { finish=id; break; }
|
||||
for (int dy=-1;dy<=1;++dy) for (int dx=-1;dx<=1;++dx) {
|
||||
if (!dx && !dy) continue;
|
||||
const int x=e.x+dx,y=e.y+dy;
|
||||
@@ -82,7 +90,7 @@ inline std::vector<Point> FindPath(Point start, Point goal, float arrival, const
|
||||
reverse.push_back(point(id%width-extent,id/width-extent));
|
||||
std::reverse(reverse.begin(),reverse.end());
|
||||
if (reverse.empty()) reverse.push_back(start);
|
||||
if (Distance(reverse.back(),goal)>arrival) reverse.push_back(goal);
|
||||
if (Distance(reverse.back(),goal)>arrival) reverse.push_back(Toward(reverse.back(),goal,body));
|
||||
// Greedy line-of-sight smoothing, retaining every necessary turn.
|
||||
std::vector<Point> result;
|
||||
Point from=start;
|
||||
|
||||
Reference in New Issue
Block a user