mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-03 19:52:26 +00:00
A 'hack' and a 'fix' (bot movement changes)
This commit is contained in:
parent
1b2df18cea
commit
bf239f9691
120
zone/bot.cpp
120
zone/bot.cpp
@ -2164,7 +2164,7 @@ void Bot::AI_Process() {
|
|||||||
} else if(!IsRooted()) {
|
} else if(!IsRooted()) {
|
||||||
if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) {
|
if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) {
|
||||||
Log.Out(Logs::Detail, Logs::AI, "Returning to location prior to being summoned.");
|
Log.Out(Logs::Detail, Logs::AI, "Returning to location prior to being summoned.");
|
||||||
CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetRunspeed());
|
CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetBotRunspeed());
|
||||||
SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y));
|
SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2239,7 +2239,7 @@ void Bot::AI_Process() {
|
|||||||
if(IsMoving()) {
|
if(IsMoving()) {
|
||||||
SetHeading(0);
|
SetHeading(0);
|
||||||
SetRunAnimSpeed(0);
|
SetRunAnimSpeed(0);
|
||||||
SetCurrentSpeed(GetRunspeed());
|
SetCurrentSpeed(GetBotRunspeed());
|
||||||
if(moved)
|
if(moved)
|
||||||
SetCurrentSpeed(0);
|
SetCurrentSpeed(0);
|
||||||
}
|
}
|
||||||
@ -2250,17 +2250,17 @@ void Bot::AI_Process() {
|
|||||||
bool WaypointChanged, NodeReached;
|
bool WaypointChanged, NodeReached;
|
||||||
|
|
||||||
glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
|
glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
|
||||||
GetRunspeed(), WaypointChanged, NodeReached);
|
GetBotRunspeed(), WaypointChanged, NodeReached);
|
||||||
|
|
||||||
if (WaypointChanged)
|
if (WaypointChanged)
|
||||||
tar_ndx = 20;
|
tar_ndx = 20;
|
||||||
|
|
||||||
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed());
|
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetBotRunspeed());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mob* follow = entity_list.GetMob(GetFollowID());
|
Mob* follow = entity_list.GetMob(GetFollowID());
|
||||||
if (follow)
|
if (follow)
|
||||||
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetRunspeed());
|
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetBotRunspeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -2350,7 +2350,7 @@ void Bot::AI_Process() {
|
|||||||
float newZ = 0;
|
float newZ = 0;
|
||||||
FaceTarget(GetTarget());
|
FaceTarget(GetTarget());
|
||||||
if (PlotPositionAroundTarget(this, newX, newY, newZ)) {
|
if (PlotPositionAroundTarget(this, newX, newY, newZ)) {
|
||||||
CalculateNewPosition2(newX, newY, newZ, GetRunspeed());
|
CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2362,7 +2362,7 @@ void Bot::AI_Process() {
|
|||||||
float newY = 0;
|
float newY = 0;
|
||||||
float newZ = 0;
|
float newZ = 0;
|
||||||
if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ)) {
|
if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ)) {
|
||||||
CalculateNewPosition2(newX, newY, newZ, GetRunspeed());
|
CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2373,7 +2373,7 @@ void Bot::AI_Process() {
|
|||||||
float newY = 0;
|
float newY = 0;
|
||||||
float newZ = 0;
|
float newZ = 0;
|
||||||
if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ, false) && GetArchetype() != ARCHETYPE_CASTER) {
|
if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ, false) && GetArchetype() != ARCHETYPE_CASTER) {
|
||||||
CalculateNewPosition2(newX, newY, newZ, GetRunspeed());
|
CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2498,7 +2498,7 @@ void Bot::AI_Process() {
|
|||||||
if (AI_movement_timer->Check()) {
|
if (AI_movement_timer->Check()) {
|
||||||
if(!IsRooted()) {
|
if(!IsRooted()) {
|
||||||
Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName());
|
Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName());
|
||||||
CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed());
|
CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetBotRunspeed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2518,7 +2518,8 @@ void Bot::AI_Process() {
|
|||||||
else if(GetArchetype() == ARCHETYPE_CASTER)
|
else if(GetArchetype() == ARCHETYPE_CASTER)
|
||||||
BotMeditate(true);
|
BotMeditate(true);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
SetTarget(nullptr);
|
SetTarget(nullptr);
|
||||||
if (m_PlayerState & static_cast<uint32>(PlayerState::Aggressive))
|
if (m_PlayerState & static_cast<uint32>(PlayerState::Aggressive))
|
||||||
SendRemovePlayerState(PlayerState::Aggressive);
|
SendRemovePlayerState(PlayerState::Aggressive);
|
||||||
@ -2527,77 +2528,44 @@ void Bot::AI_Process() {
|
|||||||
if (!follow)
|
if (!follow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float cur_dist = DistanceSquared(m_Position, follow->GetPosition());
|
if (!IsMoving() && AI_think_timer->Check() && !spellend_timer.Enabled()) {
|
||||||
|
if (GetBotStance() != BotStancePassive) {
|
||||||
if (!IsMoving() && cur_dist <= GetFollowDistance()) {
|
if (!AI_IdleCastCheck() && !IsCasting() && GetClass() != BARD)
|
||||||
if (AI_think_timer->Check()) {
|
BotMeditate(true);
|
||||||
if (!spellend_timer.Enabled()) {
|
}
|
||||||
if (GetBotStance() != BotStancePassive) {
|
else {
|
||||||
if (!AI_IdleCastCheck() && !IsCasting() && GetClass() != BARD)
|
if (GetClass() != BARD)
|
||||||
BotMeditate(true);
|
BotMeditate(true);
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (GetClass() != BARD)
|
|
||||||
BotMeditate(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(AI_movement_timer->Check()) {
|
|
||||||
// Something is still wrong with bot the follow code...
|
if (AI_movement_timer->Check()) {
|
||||||
// Shows up really bad over long distances when movement bonuses are involved
|
float dist = DistanceSquared(m_Position, follow->GetPosition());
|
||||||
// The flip-side is that too much speed adversely affects node pathing...
|
int speed = GetBotRunspeed();
|
||||||
if (cur_dist > GetFollowDistance()) {
|
|
||||||
|
if (dist < GetFollowDistance() + BOT_FOLLOW_DISTANCE_WALK)
|
||||||
|
speed = GetBotWalkspeed();
|
||||||
|
|
||||||
|
SetRunAnimSpeed(0);
|
||||||
|
|
||||||
|
if (dist > GetFollowDistance()) {
|
||||||
if (RuleB(Bots, UsePathing) && zone->pathing) {
|
if (RuleB(Bots, UsePathing) && zone->pathing) {
|
||||||
if (cur_dist <= BOT_FOLLOW_DISTANCE_WALK) {
|
bool WaypointChanged, NodeReached;
|
||||||
bool WaypointChanged, NodeReached;
|
|
||||||
|
|
||||||
glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(),
|
glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(),
|
||||||
GetWalkspeed(), WaypointChanged, NodeReached);
|
speed, WaypointChanged, NodeReached);
|
||||||
|
|
||||||
if (WaypointChanged)
|
if (WaypointChanged)
|
||||||
tar_ndx = 20;
|
tar_ndx = 20;
|
||||||
|
|
||||||
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetWalkspeed());
|
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed);
|
||||||
}
|
|
||||||
else {
|
|
||||||
int speed = GetRunspeed();
|
|
||||||
if (cur_dist > BOT_FOLLOW_DISTANCE_CRITICAL)
|
|
||||||
speed = ((float)speed * 1.333f); // sprint mod (1/3 boost)
|
|
||||||
|
|
||||||
bool WaypointChanged, NodeReached;
|
|
||||||
|
|
||||||
glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(),
|
|
||||||
speed, WaypointChanged, NodeReached);
|
|
||||||
|
|
||||||
if (WaypointChanged)
|
|
||||||
tar_ndx = 20;
|
|
||||||
|
|
||||||
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (cur_dist <= BOT_FOLLOW_DISTANCE_WALK) {
|
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
|
||||||
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetWalkspeed());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int speed = GetRunspeed();
|
|
||||||
if (cur_dist > BOT_FOLLOW_DISTANCE_CRITICAL)
|
|
||||||
speed = ((float)speed * 1.333f); // sprint mod (1/3 boost)
|
|
||||||
|
|
||||||
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rest_timer.Enabled())
|
if (rest_timer.Enabled())
|
||||||
rest_timer.Disable();
|
rest_timer.Disable();
|
||||||
|
|
||||||
if (RuleB(Bots, UpdatePositionWithTimer)) { // this helps with rubber-banding effect
|
|
||||||
if (IsMoving())
|
|
||||||
SendPosUpdate();
|
|
||||||
//else
|
|
||||||
// SendPosition(); // enabled - no discernable difference..disabled - saves on no movement packets
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (moved) {
|
if (moved) {
|
||||||
@ -2605,13 +2573,9 @@ void Bot::AI_Process() {
|
|||||||
SetCurrentSpeed(0);
|
SetCurrentSpeed(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check())
|
|
||||||
AI_IdleCastCheck();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (IsMoving()) {
|
|
||||||
|
if (IsMoving()) {
|
||||||
if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check()) {
|
if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check()) {
|
||||||
AI_IdleCastCheck();
|
AI_IdleCastCheck();
|
||||||
}
|
}
|
||||||
@ -7074,10 +7038,6 @@ bool Bot::CanHeal() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) {
|
|
||||||
return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) {
|
Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) {
|
||||||
Bot* Result = 0;
|
Bot* Result = 0;
|
||||||
if(c) {
|
if(c) {
|
||||||
|
|||||||
@ -40,8 +40,7 @@
|
|||||||
|
|
||||||
#define BOT_FOLLOW_DISTANCE_DEFAULT 184 // as DSq value (~13.565 units)
|
#define BOT_FOLLOW_DISTANCE_DEFAULT 184 // as DSq value (~13.565 units)
|
||||||
#define BOT_FOLLOW_DISTANCE_DEFAULT_MAX 2500 // as DSq value (50 units)
|
#define BOT_FOLLOW_DISTANCE_DEFAULT_MAX 2500 // as DSq value (50 units)
|
||||||
#define BOT_FOLLOW_DISTANCE_WALK 400 // as DSq value (20 units)
|
#define BOT_FOLLOW_DISTANCE_WALK 1000 // as DSq value (~31.623 units)
|
||||||
#define BOT_FOLLOW_DISTANCE_CRITICAL 22500 // as DSq value (150 units)
|
|
||||||
|
|
||||||
extern WorldServer worldserver;
|
extern WorldServer worldserver;
|
||||||
|
|
||||||
@ -336,8 +335,9 @@ public:
|
|||||||
void Stand();
|
void Stand();
|
||||||
bool IsSitting();
|
bool IsSitting();
|
||||||
bool IsStanding();
|
bool IsStanding();
|
||||||
|
int GetBotWalkspeed() const { return (int)((float)_GetWalkSpeed() * 1.786f); } // 1.25 / 0.7 = 1.7857142857142857142857142857143
|
||||||
|
int GetBotRunspeed() const { return (int)((float)_GetRunSpeed() * 1.786f); }
|
||||||
bool IsBotCasterCombatRange(Mob *target);
|
bool IsBotCasterCombatRange(Mob *target);
|
||||||
bool CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ = true) ;
|
|
||||||
bool UseDiscipline(uint32 spell_id, uint32 target);
|
bool UseDiscipline(uint32 spell_id, uint32 target);
|
||||||
uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets);
|
uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets);
|
||||||
bool GetNeedsCured(Mob *tar);
|
bool GetNeedsCured(Mob *tar);
|
||||||
|
|||||||
19
zone/mob.cpp
19
zone/mob.cpp
@ -613,7 +613,11 @@ int Mob::_GetWalkSpeed() const {
|
|||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
//runspeed cap.
|
//runspeed cap.
|
||||||
|
#ifdef BOTS
|
||||||
|
if (IsClient() || IsBot())
|
||||||
|
#else
|
||||||
if(IsClient())
|
if(IsClient())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if(speed_mod > runspeedcap)
|
if(speed_mod > runspeedcap)
|
||||||
speed_mod = runspeedcap;
|
speed_mod = runspeedcap;
|
||||||
@ -672,7 +676,11 @@ int Mob::_GetRunSpeed() const {
|
|||||||
|
|
||||||
if (!has_horse && movemod != 0)
|
if (!has_horse && movemod != 0)
|
||||||
{
|
{
|
||||||
|
#ifdef BOTS
|
||||||
|
if (IsClient() || IsBot())
|
||||||
|
#else
|
||||||
if (IsClient())
|
if (IsClient())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
speed_mod += (speed_mod * movemod / 100);
|
speed_mod += (speed_mod * movemod / 100);
|
||||||
} else {
|
} else {
|
||||||
@ -701,7 +709,11 @@ int Mob::_GetRunSpeed() const {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
//runspeed cap.
|
//runspeed cap.
|
||||||
|
#ifdef BOTS
|
||||||
|
if (IsClient() || IsBot())
|
||||||
|
#else
|
||||||
if(IsClient())
|
if(IsClient())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if(speed_mod > runspeedcap)
|
if(speed_mod > runspeedcap)
|
||||||
speed_mod = runspeedcap;
|
speed_mod = runspeedcap;
|
||||||
@ -1458,10 +1470,15 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
|
|||||||
spu->padding0006 =7;
|
spu->padding0006 =7;
|
||||||
spu->padding0014 =0x7f;
|
spu->padding0014 =0x7f;
|
||||||
spu->padding0018 =0x5df27;
|
spu->padding0018 =0x5df27;
|
||||||
|
#ifdef BOTS
|
||||||
|
if (this->IsClient() || this->IsBot())
|
||||||
|
#else
|
||||||
if(this->IsClient())
|
if(this->IsClient())
|
||||||
|
#endif
|
||||||
spu->animation = animation;
|
spu->animation = animation;
|
||||||
else
|
else
|
||||||
spu->animation = pRunAnimSpeed;//animation;
|
spu->animation = pRunAnimSpeed;//animation;
|
||||||
|
|
||||||
spu->delta_heading = NewFloatToEQ13(m_Delta.w);
|
spu->delta_heading = NewFloatToEQ13(m_Delta.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -574,7 +574,11 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
|
|||||||
m_TargetV.z = z - nz;
|
m_TargetV.z = z - nz;
|
||||||
SetCurrentSpeed((int8)speed);
|
SetCurrentSpeed((int8)speed);
|
||||||
pRunAnimSpeed = speed;
|
pRunAnimSpeed = speed;
|
||||||
|
#ifdef BOTS
|
||||||
|
if(IsClient() || IsBot())
|
||||||
|
#else
|
||||||
if(IsClient())
|
if(IsClient())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
animation = speed / 2;
|
animation = speed / 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user