This commit is contained in:
aozhiwei 2023-03-10 11:10:04 +08:00
parent 9e040e8a7e
commit dbe014eec0
2 changed files with 8 additions and 40 deletions

View File

@ -2,6 +2,10 @@
#include <float.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/vec2.hpp>
#include "creature.h"
#include "room.h"
#include "skill.h"
@ -2419,11 +2423,9 @@ void Creature::UpdateMove()
if (!GetMovement()->IsFindPath()) {
GetMovement()->CalcTargetPos(mt::Param::s().move_step_len);
if (!GetMovement()->UpdatePosition()) {
#if 0
if (IsPlayer()) {
ShortFindPath();
}
#endif
}
}
}
@ -2937,11 +2939,7 @@ void Creature::ShortFindPath()
}
};
glm::vec3 last_pos = glm::vec3(0.0f, 0.0f, 0.0f);
int count = 0;
glm::vec3 start_pos = GetPos().ToGlmVec3() + GetMoveDir() * -1.0f * 2.0f;
#if 1
bool right_ok = false;
float right_distance = 0.0f;
glm::vec3 right_pos = glm::vec3(0.0f, 0.0f, 0.0f);
@ -2989,46 +2987,16 @@ void Creature::ShortFindPath()
}
glm::vec3 move_dir = finaly_pos - GetPos().ToGlmVec3();
GlmHelper::Normalize(move_dir);
glm::vec3 end_pos = start_pos + move_dir * GetSpeed() / 2.0f;
glm::vec3 end_pos = start_pos + move_dir * GetSpeed() / 1.0f;
glm::vec3 new_point = glm::vec3(0.0f, 0.0f, 0.0f);
bool ret = try_move(start_pos, end_pos, new_point);
if (ret) {
Global::Instance()->verify_set_pos = 1;
GetMutablePos().FromGlmVec3(last_pos);
GetMutablePos().FromGlmVec3(new_point);
Global::Instance()->verify_set_pos = 0;
}
}
#else
for (float angle = 1.0f; angle < 90.0f; angle += 1.0f) {
glm::vec3 move_dir = GetMoveDir();
GlmHelper::RotateY(move_dir, angle);
glm::vec3 end_pos = start_pos + move_dir * 80.0f;
glm::vec3 new_point = glm::vec3(0.0f, 0.0f, 0.0f);
bool ret = try_move(start_pos, end_pos, new_point);
if (ret) {
if (count <= 0) {
last_pos = new_point;
} else {
float curr_distance = GlmHelper::Norm(new_point - start_pos);
float curr_center_distance = GlmHelper::Norm(new_point - GetPos().ToGlmVec3());
float last_distance = GlmHelper::Norm(last_pos - start_pos);
float last_center_distance = GlmHelper::Norm(last_pos - GetPos().ToGlmVec3());
if (curr_distance > last_distance) {
if (std::fabs(curr_distance - GetSpeed())) {
}
} else {
}
Global::Instance()->verify_set_pos = 1;
GetMutablePos().FromGlmVec3(last_pos);
Global::Instance()->verify_set_pos = 0;
}
++count;
}
}
#endif
}
}

View File

@ -2916,12 +2916,12 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
void Human::LootInteraction(Loot* entity)
{
#ifdef DEBUG
#ifdef DEBUG1
a8::XPrintf("LootInteraction start %d:%d\n", {entity->GetUniId(), entity->item_id});
#endif
if (entity->pickuped ||
entity->count <= 0) {
#ifdef DEBUG
#ifdef DEBUG1
a8::XPrintf("LootInteraction error1 %d:%d\n", {entity->GetUniId(), entity->item_id});
#endif
return;