Skip to content

Commit a51dbc8

Browse files
committed
adjust fp-search distance
1 parent 2f2e3a8 commit a51dbc8

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

game/game/gamescript.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ bool GameScript::wld_isfpavailable(std::shared_ptr<zenkit::INpc> self, std::stri
17001700
}
17011701

17021702
auto wp = world().findFreePoint(*findNpc(self.get()),name);
1703-
return wp != nullptr;
1703+
return wp!=nullptr;
17041704
}
17051705

17061706
bool GameScript::wld_isnextfpavailable(std::shared_ptr<zenkit::INpc> self, std::string_view name) {
@@ -2275,7 +2275,7 @@ bool GameScript::npc_isonfp(std::shared_ptr<zenkit::INpc> npcRef, std::string_vi
22752275
return false;
22762276

22772277
auto w = npc->currentWayPoint();
2278-
if(w==nullptr || !MoveAlgo::isClose(npc->position(),*w) || !w->checkName(val))
2278+
if(w==nullptr || !MoveAlgo::isClose(npc->position(),*w,MAX_AI_USE_DISTANCE) || !w->checkName(val))
22792279
return false;
22802280
return w->isFreePoint();
22812281
}

game/game/movealgo.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,14 @@ int32_t MoveAlgo::diveTime() const {
689689
}
690690

691691
bool MoveAlgo::isClose(const Tempest::Vec3& w, const WayPoint &p) {
692-
return isClose(w.x,w.y,w.z,p);
692+
float dist = closeToPointThreshold;
693+
if(p.useCounter()>1)
694+
dist += 100; // need
695+
return isClose(w,p,dist);
693696
}
694697

695-
bool MoveAlgo::isClose(float x, float y, float z, const WayPoint &p) {
696-
return isClose(x,y,z,p,closeToPointThreshold);
697-
}
698-
699-
bool MoveAlgo::isClose(float x, float /*y*/, float z, const WayPoint &p, float dist) {
700-
float len = p.qDistTo(x,p.pos.y,z);
698+
bool MoveAlgo::isClose(const Tempest::Vec3& w, const WayPoint& p, float dist) {
699+
float len = p.qDistTo(w.x,p.pos.y,w.z);
701700
return (len<dist*dist);
702701
}
703702

game/game/movealgo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class MoveAlgo final {
3535
};
3636

3737
static bool isClose(const Tempest::Vec3& w, const WayPoint& p);
38-
static bool isClose(float x,float y,float z,const WayPoint& p);
39-
static bool isClose(float x,float y,float z,const WayPoint& p,float dist);
38+
static bool isClose(const Tempest::Vec3& w, const WayPoint& p,float dist);
4039

4140
void load(Serialize& fin);
4241
void save(Serialize& fout) const;

game/world/objects/npc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ bool Npc::implGoTo(uint64_t dt) {
13971397
if(!mvAlgo.checkLastBounce())
13981398
dist = MoveAlgo::closeToPointThreshold*1.5f;
13991399
if(go2.wp!=nullptr && go2.wp->useCounter()>1)
1400-
dist += 100;
1400+
dist = float(MAX_AI_USE_DISTANCE);
14011401
}
14021402
return implGoTo(dt,dist);
14031403
}

0 commit comments

Comments
 (0)