From dbe014eec0b400a995ac016e3521da47af3829e8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 10 Mar 2023 11:10:04 +0800 Subject: [PATCH] 1 --- server/gameserver/creature.cc | 44 +++++------------------------------ server/gameserver/human.cc | 4 ++-- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index b888f2d8..2cef030c 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -2,6 +2,10 @@ #include +#include +#include +#include + #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 } } diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 19c15d9a..8ff40bb7 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -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;