This commit is contained in:
aozhiwei 2022-11-29 18:44:40 +08:00
parent f354a90eca
commit 89aa344e9c
2 changed files with 32 additions and 1 deletions

View File

@ -39,6 +39,7 @@
#include "skillhelper.h" #include "skillhelper.h"
#include "shot.h" #include "shot.h"
#include "battledatacontext.h" #include "battledatacontext.h"
#include "mapinstance.h"
const int kReviveTimeAdd = 12; const int kReviveTimeAdd = 12;
const int kSkinNum = 4; const int kSkinNum = 4;
@ -3531,6 +3532,31 @@ void Human::OnLand()
if (IsPlayer()) { if (IsPlayer()) {
StartRefreshViewTimer(); StartRefreshViewTimer();
} }
#ifdef MAP3D
{
a8::Vec3 center;
center.x = GetPos().x / 10;
center.z = GetPos().y / 10;
a8::Vec3 point;
bool ok = room->map_instance->FindNearestPoint(center, 2, point);
if (!ok) {
abort();
}
a8::Vec2 new_pos;
new_pos.x = point.x * 10;
new_pos.y = point.z * 10;
SetPos(new_pos);
#ifdef DEBUG
a8::XPrintf("OnLoad ok:%d pos:%f,%f,%f\n",
{
ok ? 1 : 0,
point.x,
point.y,
point.z
});
#endif
}
#else
if (CheckCollision()) { if (CheckCollision()) {
a8::Vec2 old_pos = GetPos(); a8::Vec2 old_pos = GetPos();
std::vector<a8::Vec2> dirs; std::vector<a8::Vec2> dirs;
@ -3551,6 +3577,7 @@ void Human::OnLand()
} }
SetPos(old_pos); SetPos(old_pos);
} }
#endif
if (IsAndroid()) { if (IsAndroid()) {
int buff_uniid = MustBeAddBuff(this, int buff_uniid = MustBeAddBuff(this,
kPeaceModeBuffId kPeaceModeBuffId

View File

@ -730,7 +730,7 @@ bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec
filter.setIncludeFlags(0xffff); filter.setIncludeFlags(0xffff);
filter.setExcludeFlags(0); filter.setExcludeFlags(0);
const float extents[3] = {2.f, 4.f, 2.f}; const float extents[3] = {radius, radius, radius};
float nearestPt[3]; float nearestPt[3];
float pos[3]; float pos[3];
@ -740,7 +740,11 @@ bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec
navmesh_query_->findNearestPoly(pos, extents, &filter, &startRef, nearestPt); navmesh_query_->findNearestPoly(pos, extents, &filter, &startRef, nearestPt);
if (!startRef) { if (!startRef) {
return false;
} }
nearest_pt.x = nearestPt[0];
nearest_pt.y = nearestPt[1];
nearest_pt.z = nearestPt[2];
return true; return true;
} }