feat(Core/CreatureAI): improve npc position during the combat (#3369)
+ tangent equation to find correct angle and distance when moving + implemented proper backward * Improved performance + random angle margin * chore: add tollerance calculation in instance * improved LOS checks with movements * implemented collisions using raycast (imported by TC) + improved collision detection for CanReachPositionAndGetCoords + improved collision check + set correct flags for the backward movement + first implementation of slope angle (to improve) Co-authored-by: Yehonal <yehonal.azeroth@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "DBCStores.h"
|
||||
#include "Log.h"
|
||||
#include "VMapDefinitions.h"
|
||||
#include "GridDefines.h"
|
||||
|
||||
using G3D::Vector3;
|
||||
|
||||
@@ -54,7 +55,7 @@ namespace VMAP
|
||||
Vector3 VMapManager2::convertPositionToInternalRep(float x, float y, float z) const
|
||||
{
|
||||
Vector3 pos;
|
||||
const float mid = 0.5f * 64.0f * 533.33333333f;
|
||||
const float mid = 0.5f * MAX_NUMBER_OF_GRIDS * SIZE_OF_GRIDS;
|
||||
pos.x = mid - x;
|
||||
pos.y = mid - y;
|
||||
pos.z = z;
|
||||
@@ -308,4 +309,4 @@ namespace VMAP
|
||||
return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
|
||||
}
|
||||
|
||||
} // namespace VMAP
|
||||
} // namespace VMAP
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
#ifndef _GEOMETRY_H
|
||||
#define _GEOMETRY_H
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
inline float getAngle(float startX, float startY, float destX, float destY)
|
||||
{
|
||||
auto dx = destX - startX;
|
||||
auto dy = destY - startY;
|
||||
|
||||
auto ang = atan2(dy, dx);
|
||||
ang = (ang >= 0) ? ang : 2 * M_PI + ang;
|
||||
return ang;
|
||||
}
|
||||
|
||||
inline float getSlopeAngle(float startX, float startY, float startZ, float destX, float destY, float destZ)
|
||||
{
|
||||
auto a = (startX * destX + startY * destY + startZ * destZ);
|
||||
auto b = sqrt(pow(startX,2.0f) + pow(startY,2.0f) + pow(startZ, 2.0f));
|
||||
auto c = sqrt(pow(destX,2.0f) + pow(destY,2.0f) + pow(destZ, 2.0f));
|
||||
|
||||
auto ang = acos(a / (b * c));
|
||||
|
||||
if (isnan(ang))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return ang;
|
||||
}
|
||||
|
||||
inline float getSlopeAngleAbs(float startX, float startY, float startZ, float destX, float destY, float destZ)
|
||||
{
|
||||
return abs(getSlopeAngle(startX, startY, startZ, destX, destY, destZ));
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user