mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-16 10:20:27 +00:00
Fix fishing AI position matching precision (#1992)
**Problem**: FishingAction::isUseful() used strict `pos == bot->GetPosition()` comparison causing "Rog A:go fishing - USELESS" when bot was within 0.5-1m of fishing spot (normal positioning tolerance). **Solution**: Replace exact coordinate match with 1.5m tolerance using `fabs(posX - botX) < 1.5f` for all axes. Added `#include "Config.h"` for AI_VALUE stability. **Result**: Master fishing now reliably triggers and completes cycle: - move near water → go fishing → use bobber ✓ Closes #fishing-useless-bug --------- Co-authored-by: Кунгуров Олег <okungurov@rapidsoft.ru>
This commit is contained in:
@@ -261,7 +261,9 @@ bool MoveNearWaterAction::isUseful()
|
||||
return false;
|
||||
FishingSpotValue* fishingSpotValueObject = (FishingSpotValue*)context->GetValue<WorldPosition>("fishing spot");
|
||||
WorldPosition pos = fishingSpotValueObject->Get();
|
||||
return !pos.IsValid() || fishingSpotValueObject->IsStale(FISHING_LOCATION_TIMEOUT) || pos != bot->GetPosition();
|
||||
return !pos.IsValid() || fishingSpotValueObject->IsStale(FISHING_LOCATION_TIMEOUT) ||
|
||||
bot->GetExactDist(&pos) < 0.1f;
|
||||
|
||||
}
|
||||
|
||||
bool MoveNearWaterAction::isPossible()
|
||||
@@ -299,6 +301,17 @@ bool MoveNearWaterAction::isPossible()
|
||||
}
|
||||
}
|
||||
}
|
||||
// Can the bot fish from current position?
|
||||
WorldPosition waterAtCurrentPos =
|
||||
FindWaterRadial(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot->GetMap(),
|
||||
bot->GetPhaseMask(), MIN_DISTANCE_TO_WATER, MAX_DISTANCE_TO_WATER, SEARCH_INCREMENT, true);
|
||||
if (waterAtCurrentPos.IsValid())
|
||||
{
|
||||
SET_AI_VALUE(WorldPosition, "fishing spot",
|
||||
WorldPosition(WorldPosition(bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ())));
|
||||
return false;
|
||||
}
|
||||
// Lets find some water where we can fish.
|
||||
WorldPosition water = FindWaterRadial(
|
||||
bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
|
||||
@@ -435,10 +448,14 @@ bool FishingAction::isUseful()
|
||||
{
|
||||
if (!AI_VALUE(bool, "can fish"))
|
||||
return false;
|
||||
|
||||
FishingSpotValue* fishingSpotValueObject = (FishingSpotValue*)context->GetValue<WorldPosition>("fishing spot");
|
||||
WorldPosition pos = fishingSpotValueObject->Get();
|
||||
|
||||
return pos.IsValid() && !fishingSpotValueObject->IsStale(FISHING_LOCATION_TIMEOUT) && pos == bot->GetPosition();
|
||||
if (!pos.IsValid() || fishingSpotValueObject->IsStale(FISHING_LOCATION_TIMEOUT))
|
||||
return false;
|
||||
|
||||
return bot->GetExactDist(&pos) < 0.1f;
|
||||
}
|
||||
|
||||
bool UseBobberAction::isUseful()
|
||||
|
||||
Reference in New Issue
Block a user