mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 02:20:00 +01:00
better movement
This commit is contained in:
parent
0c3b5805cf
commit
1aaa1f8507
@ -7,6 +7,7 @@
|
|||||||
#include "Formations.h"
|
#include "Formations.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
|
#include "SharedDefines.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
bool FollowAction::Execute(Event event)
|
bool FollowAction::Execute(Event event)
|
||||||
|
|||||||
@ -149,7 +149,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
// bot->Say("I'm falling", LANG_UNIVERSAL);
|
// bot->Say("I'm falling", LANG_UNIVERSAL);
|
||||||
// }
|
// }
|
||||||
float modified_z;
|
float modified_z;
|
||||||
for (float delta = 2.0f; delta <= 15.0f; delta++) {
|
float delta;
|
||||||
|
for (delta = -5.0f; delta <= 10.0f; delta++) {
|
||||||
modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
|
modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
|
||||||
PathGenerator gen(bot);
|
PathGenerator gen(bot);
|
||||||
gen.CalculatePath(x, y, modified_z);
|
gen.CalculatePath(x, y, modified_z);
|
||||||
@ -157,6 +158,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (delta > 10.0f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// z += 0.5f;
|
// z += 0.5f;
|
||||||
float distance = bot->GetDistance2d(x, y);
|
float distance = bot->GetDistance2d(x, y);
|
||||||
if (distance > sPlayerbotAIConfig->contactDistance)
|
if (distance > sPlayerbotAIConfig->contactDistance)
|
||||||
@ -173,12 +177,10 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
}
|
}
|
||||||
bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) &&
|
bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) &&
|
||||||
!bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater();
|
!bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater();
|
||||||
// char speak[100];
|
|
||||||
// sprintf(speak, "Move to : (%.2f, %.2f, %.2f), generatePath: %d", x, y, z, generatePath);
|
|
||||||
// bot->Say(speak, LANG_UNIVERSAL);
|
|
||||||
MotionMaster &mm = *bot->GetMotionMaster();
|
MotionMaster &mm = *bot->GetMotionMaster();
|
||||||
|
|
||||||
mm.Clear();
|
mm.Clear();
|
||||||
mm.MovePoint(mapId, x, y, z, generatePath);
|
mm.MovePoint(mapId, x, y, modified_z, generatePath);
|
||||||
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation());
|
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,8 +44,8 @@ WorldLocation ArrowFormation::GetLocationInternal()
|
|||||||
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
|
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
|
||||||
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
|
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
|
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z + 0.5f);
|
float ground = master->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
// master->UpdateGroundPositionZ(x, y, z);
|
// master->UpdateGroundPositionZ(x, y, z);
|
||||||
|
|||||||
@ -34,22 +34,22 @@ WorldLocation MoveAheadFormation::GetLocation()
|
|||||||
float y = loc.GetPositionY();
|
float y = loc.GetPositionY();
|
||||||
float z = loc.GetPositionZ();
|
float z = loc.GetPositionZ();
|
||||||
|
|
||||||
if (master->isMoving())
|
// if (master->isMoving())
|
||||||
{
|
// {
|
||||||
float ori = master->GetOrientation();
|
// float ori = master->GetOrientation();
|
||||||
float x1 = x + sPlayerbotAIConfig->tooCloseDistance * cos(ori);
|
// float x1 = x + sPlayerbotAIConfig->tooCloseDistance * cos(ori);
|
||||||
float y1 = y + sPlayerbotAIConfig->tooCloseDistance * sin(ori);
|
// float y1 = y + sPlayerbotAIConfig->tooCloseDistance * sin(ori);
|
||||||
float ground = master->GetMap()->GetHeight(x1, y1, z);
|
// float ground = master->GetMap()->GetHeight(x1, y1, z);
|
||||||
if (ground > INVALID_HEIGHT)
|
// if (ground > INVALID_HEIGHT)
|
||||||
{
|
// {
|
||||||
x = x1;
|
// x = x1;
|
||||||
y = y1;
|
// y = y1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z);
|
// float ground = master->GetMap()->GetHeight(x, y, z);
|
||||||
if (ground <= INVALID_HEIGHT)
|
// if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
// return Formation::NullLocation;
|
||||||
|
|
||||||
//z += CONTACT_DISTANCE;
|
//z += CONTACT_DISTANCE;
|
||||||
//bot->UpdateAllowedPositionZ(x, y, z);
|
//bot->UpdateAllowedPositionZ(x, y, z);
|
||||||
@ -88,7 +88,7 @@ class NearFormation : public MoveAheadFormation
|
|||||||
float x = master->GetPositionX() + cos(angle) * range;
|
float x = master->GetPositionX() + cos(angle) * range;
|
||||||
float y = master->GetPositionY() + sin(angle) * range;
|
float y = master->GetPositionY() + sin(angle) * range;
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z);
|
float ground = master->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class ChaosFormation : public MoveAheadFormation
|
|||||||
float x = master->GetPositionX() + cos(angle) * range + dx;
|
float x = master->GetPositionX() + cos(angle) * range + dx;
|
||||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z);
|
float ground = master->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ class CircleFormation : public MoveFormation
|
|||||||
float x = target->GetPositionX() + cos(angle) * range;
|
float x = target->GetPositionX() + cos(angle) * range;
|
||||||
float y = target->GetPositionY() + sin(angle) * range;
|
float y = target->GetPositionY() + sin(angle) * range;
|
||||||
float z = target->GetPositionZ();
|
float z = target->GetPositionZ();
|
||||||
float ground = target->GetMap()->GetHeight(x, y, z);
|
float ground = target->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ class FarFormation : public FollowFormation
|
|||||||
float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
||||||
float z = master->GetPositionZ();
|
float z = master->GetPositionZ();
|
||||||
|
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z);
|
float ground = master->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
{
|
{
|
||||||
float minDist = 0, minX = 0, minY = 0;
|
float minDist = 0, minX = 0, minY = 0;
|
||||||
@ -336,7 +336,7 @@ class FarFormation : public FollowFormation
|
|||||||
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
|
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
|
||||||
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
||||||
float dist = sServerFacade->GetDistance2d(bot, x, y);
|
float dist = sServerFacade->GetDistance2d(bot, x, y);
|
||||||
float ground = master->GetMap()->GetHeight(x, y, z);
|
float ground = master->GetMap()->GetHeight(x, y, z + 30.0f);
|
||||||
if (ground > INVALID_HEIGHT && (!minDist || minDist > dist))
|
if (ground > INVALID_HEIGHT && (!minDist || minDist > dist))
|
||||||
{
|
{
|
||||||
minDist = dist;
|
minDist = dist;
|
||||||
@ -613,7 +613,7 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float dif
|
|||||||
float lx = x + cos(angle) * radius;
|
float lx = x + cos(angle) * radius;
|
||||||
float ly = y + sin(angle) * radius;
|
float ly = y + sin(angle) * radius;
|
||||||
float lz = cz;
|
float lz = cz;
|
||||||
float ground = bot->GetMap()->GetHeight(lx, ly, lz);
|
float ground = bot->GetMap()->GetHeight(lx, ly, lz + 30.0f);
|
||||||
if (ground <= INVALID_HEIGHT)
|
if (ground <= INVALID_HEIGHT)
|
||||||
return Formation::NullLocation;
|
return Formation::NullLocation;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user