Added node pathing to the bot movement dilemma...

This commit is contained in:
Uleat
2017-02-25 03:48:02 -05:00
parent 5c6492bc0f
commit 7a6d5d46f4
7 changed files with 90 additions and 32 deletions
+64 -28
View File
@@ -77,7 +77,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, glm
SetShowHelm(true);
SetPauseAI(false);
rest_timer.Disable();
SetFollowDistance(BOT_DEFAULT_FOLLOW_DISTANCE);
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
// Do this once and only in this constructor
GenerateAppearance();
GenerateBaseStats();
@@ -151,7 +151,7 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
SetPauseAI(false);
rest_timer.Disable();
SetFollowDistance(BOT_DEFAULT_FOLLOW_DISTANCE);
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
strcpy(this->name, this->GetCleanName());
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
@@ -2065,6 +2065,8 @@ float Bot::GetMaxMeleeRangeToTarget(Mob* target) {
// AI Processing for the Bot object
void Bot::AI_Process() {
// TODO: Need to add root checks to all movement code
if (!IsAIControlled())
return;
if (GetPauseAI())
@@ -2229,13 +2231,23 @@ void Bot::AI_Process() {
return;
}
else if (!CheckLosFN(GetTarget())) {
if (!IsRooted()) {
if (RuleB(Bots, UsePathing) && zone->pathing) {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached);
if (WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed());
}
else {
Mob* follow = entity_list.GetMob(GetFollowID());
if (follow)
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetRunspeed());
return;
}
return;
}
@@ -2516,33 +2528,52 @@ void Bot::AI_Process() {
}
}
else if(AI_movement_timer->Check()) {
// something is wrong with bot movement spell bonuses - based on logging..
// ..this code won't need to be so complex once fixed...
int speed = GetRunspeed();
if (cur_dist < GetFollowDistance() + 2000) {
speed = GetWalkspeed();
}
else if (cur_dist >= GetFollowDistance() + 10000) { // 100
if (cur_dist >= 22500) { // 150
auto leader = follow;
while (leader->GetFollowID()) {
leader = entity_list.GetMob(leader->GetFollowID());
if (!leader || leader == this)
break;
if (leader->GetRunspeed() > speed)
speed = leader->GetRunspeed();
if (leader->IsClient())
break;
// Something is still wrong with bot following...
// Shows up really bad over long distances when movement bonuses are involved
if (cur_dist > GetFollowDistance()) {
if (RuleB(Bots, UsePathing) && zone->pathing) {
if (cur_dist <= GetFollowDistance() + BOT_FOLLOW_DISTANCE_WALK) {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(),
GetWalkspeed(), WaypointChanged, NodeReached);
if (WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetWalkspeed());
}
else {
int speed = GetRunspeed();
if (cur_dist > GetFollowDistance() + BOT_FOLLOW_DISTANCE_CRITICAL)
speed = ((float)speed * 1.25f); // sprint mod (1/4 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);
}
}
speed = (float)speed * (1.0f + ((float)speed * 0.03125f)); // 1/32 - special bot sprint mod
}
else {
if (cur_dist <= GetFollowDistance() + BOT_FOLLOW_DISTANCE_WALK) {
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetWalkspeed());
}
else {
int speed = GetRunspeed();
if (cur_dist > GetFollowDistance() + BOT_FOLLOW_DISTANCE_CRITICAL)
speed = ((float)speed * 1.25f); // sprint mod (1/4 boost)
if (cur_dist > GetFollowDistance()) {
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
}
}
if (rest_timer.Enabled())
rest_timer.Disable();
return;
}
else {
if (moved) {
@@ -2550,9 +2581,14 @@ void Bot::AI_Process() {
SetCurrentSpeed(0);
}
}
if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check())
AI_IdleCastCheck();
return;
}
else if (IsMoving()) {
if (GetBotStance() != BotStancePassive && GetClass() == BARD && !spellend_timer.Enabled() && AI_think_timer->Check()) {
if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check()) {
AI_IdleCastCheck();
}
}
+4 -1
View File
@@ -38,7 +38,10 @@
#include <sstream>
#define BOT_DEFAULT_FOLLOW_DISTANCE 184
#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_WALK 625 // as DSq value (25 units)
#define BOT_FOLLOW_DISTANCE_CRITICAL 22500 // as DSq value (150 units)
extern WorldServer worldserver;
+5 -1
View File
@@ -4550,7 +4550,7 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
}
const int ab_mask = ActionableBots::ABM_NoFilter;
uint32 bfd = BOT_DEFAULT_FOLLOW_DISTANCE;
uint32 bfd = BOT_FOLLOW_DISTANCE_DEFAULT;
bool set_flag = false;
int ab_arg = 2;
@@ -4561,6 +4561,10 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
}
bfd = atoi(sep->arg[2]);
if (bfd < 1)
bfd = 1;
if (bfd > BOT_FOLLOW_DISTANCE_DEFAULT_MAX)
bfd = BOT_FOLLOW_DISTANCE_DEFAULT_MAX;
set_flag = true;
ab_arg = 3;
}
+8 -2
View File
@@ -378,7 +378,13 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
loaded_bot = new Bot(bot_id, atoi(row[0]), atoi(row[1]), atof(row[14]), atoi(row[6]), tempNPCStruct);
if (loaded_bot) {
loaded_bot->SetShowHelm((atoi(row[43]) > 0 ? true : false));
loaded_bot->SetFollowDistance(atoi(row[44]));
uint32 bfd = atoi(row[44]);
if (bfd < 1)
bfd = 1;
if (bfd > BOT_FOLLOW_DISTANCE_DEFAULT_MAX)
bfd = BOT_FOLLOW_DISTANCE_DEFAULT_MAX;
loaded_bot->SetFollowDistance(bfd);
}
return true;
@@ -515,7 +521,7 @@ bool BotDatabase::SaveNewBot(Bot* bot_inst, uint32& bot_id)
bot_inst->GetPR(),
bot_inst->GetDR(),
bot_inst->GetCorrup(),
BOT_DEFAULT_FOLLOW_DISTANCE
BOT_FOLLOW_DISTANCE_DEFAULT
);
auto results = QueryDatabase(query);
if (!results.Success())