mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #435 from liyunfan1223/mount0804
Follow waypoints and mount
This commit is contained in:
@@ -18,31 +18,28 @@ bool CheckMountStateAction::Execute(Event event)
|
||||
AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true;
|
||||
bool enemy = AI_VALUE(Unit*, "enemy player target");
|
||||
// ignore grind target in BG or bots will dismount near any creature (eg: the rams in AV)
|
||||
bool dps = (AI_VALUE(Unit*, "dps target") || (!bot->InBattleground() && AI_VALUE(Unit*, "grind target")));
|
||||
bool dps = AI_VALUE(Unit*, "dps target");
|
||||
bool fartarget =
|
||||
(enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) ||
|
||||
(dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f));
|
||||
bool attackdistance = false;
|
||||
bool chasedistance = false;
|
||||
// bool chasedistance = false;
|
||||
float attack_distance = 35.0f;
|
||||
if (PlayerbotAI::IsMelee(bot))
|
||||
{
|
||||
attack_distance = 10.0f;
|
||||
attack_distance = 5.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
attack_distance = 40.0f;
|
||||
attack_distance = 30.0f;
|
||||
}
|
||||
if (enemy)
|
||||
attack_distance /= 2;
|
||||
|
||||
if (dps || enemy)
|
||||
{
|
||||
attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan(
|
||||
AI_VALUE2(float, "distance", "current target"), attack_distance);
|
||||
chasedistance =
|
||||
enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) &&
|
||||
AI_VALUE2(bool, "moving", "enemy player target");
|
||||
Unit* currentTarget = AI_VALUE(Unit*, "current target");
|
||||
attackdistance =
|
||||
(enemy || dps) && currentTarget &&
|
||||
sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance);
|
||||
}
|
||||
|
||||
if (bot->IsMounted() && attackdistance)
|
||||
|
||||
@@ -48,8 +48,8 @@ WorldLocation ArrowFormation::GetLocationInternal()
|
||||
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
|
||||
float z = master->GetPositionZ();
|
||||
|
||||
float ground = master->GetMapHeight(x, y, z + 30.0f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
// master->UpdateGroundPositionZ(x, y, z);
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
|
||||
@@ -89,12 +89,9 @@ public:
|
||||
float y = master->GetPositionY() + sin(angle) * range;
|
||||
float z = master->GetPositionZ();
|
||||
|
||||
float ground = master->GetMapHeight(x, y, z + 30.0f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
|
||||
// z += CONTACT_DISTANCE;
|
||||
// bot->UpdateAllowedPositionZ(x, y, z);
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
}
|
||||
|
||||
@@ -115,6 +112,16 @@ public:
|
||||
float range = sPlayerbotAIConfig->followDistance;
|
||||
float angle = GetFollowAngle();
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if (!lastChangeTime || now - lastChangeTime >= 3)
|
||||
{
|
||||
Player* master = botAI->GetGroupMaster();
|
||||
if (!master)
|
||||
return WorldLocation();
|
||||
|
||||
float range = sPlayerbotAIConfig->followDistance;
|
||||
float angle = GetFollowAngle();
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if (!lastChangeTime || now - lastChangeTime >= 3)
|
||||
{
|
||||
@@ -127,12 +134,20 @@ public:
|
||||
float x = master->GetPositionX() + cos(angle) * range + dx;
|
||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
float z = master->GetPositionZ();
|
||||
float ground = master->GetMapHeight(x, y, z + 30.0f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
// bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
// bot->GetPositionZ(), x, y, z);
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
}
|
||||
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
float x = master->GetPositionX() + cos(angle) * range + dx;
|
||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
float z = master->GetPositionZ();
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
}
|
||||
|
||||
@@ -184,13 +199,10 @@ public:
|
||||
float x = target->GetPositionX() + cos(angle) * range;
|
||||
float y = target->GetPositionY() + sin(angle) * range;
|
||||
float z = target->GetPositionZ();
|
||||
float ground = target->GetMapHeight(x, y, z + 30.0f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
return WorldLocation(bot->GetMapId(), x, y, z);
|
||||
}
|
||||
};
|
||||
@@ -350,16 +362,18 @@ public:
|
||||
|
||||
if (minDist)
|
||||
{
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(minX, minY, z);
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
return WorldLocation(bot->GetMapId(), minX, minY, z);
|
||||
}
|
||||
|
||||
return Formation::NullLocation;
|
||||
}
|
||||
|
||||
z += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
return Formation::NullLocation;
|
||||
return WorldLocation(bot->GetMapId(), x, y, z);
|
||||
}
|
||||
};
|
||||
@@ -618,12 +632,12 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float dif
|
||||
float lx = x + cos(angle) * radius;
|
||||
float ly = y + sin(angle) * radius;
|
||||
float lz = cz;
|
||||
float ground = bot->GetMapHeight(lx, ly, lz + 30.0f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
|
||||
Player* master = botAI->GetMaster();
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz))
|
||||
return Formation::NullLocation;
|
||||
|
||||
lz += CONTACT_DISTANCE;
|
||||
bot->UpdateAllowedPositionZ(lx, ly, lz);
|
||||
return WorldLocation(bot->GetMapId(), lx, ly, lz);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user