[performance] Added additional circle of life, 600 yards (#655)

This commit is contained in:
bash
2024-10-29 23:32:16 +01:00
committed by 姜耀
parent d246cdd511
commit 436774a7af
2 changed files with 42 additions and 35 deletions

View File

@@ -4124,10 +4124,6 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
if (!WorldPosition(bot).isOverworld())
return ActivePiorityType::IN_INSTANCE;
//VISIBLE_FOR_PLAYER
if (HasPlayerNearby(sPlayerbotAIConfig->reactDistance))
return ActivePiorityType::VISIBLE_FOR_PLAYER;
//IN_COMBAT
if (activityType != OUT_OF_PARTY_ACTIVITY && activityType != PACKET_ACTIVITY)
{
@@ -4136,9 +4132,15 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
return ActivePiorityType::IN_COMBAT;
}
//NEARBY_PLAYER
// IN_REACT_DISTANCE
if (HasPlayerNearby(sPlayerbotAIConfig->reactDistance))
return ActivePiorityType::IN_REACT_DISTANCE;
// NEARBY_PLAYER acitivity based on yards.
if (HasPlayerNearby(300.f))
return ActivePiorityType::NEARBY_PLAYER;
return ActivePiorityType::NEARBY_PLAYER_300;
if (HasPlayerNearby(600.f))
return ActivePiorityType::NEARBY_PLAYER_600;
//if (sPlayerbotAIConfig->IsFreeAltBot(bot) || HasStrategy("travel once", BotState::BOT_STATE_NON_COMBAT))
// return ActivePiorityType::IS_ALWAYS_ACTIVE;
@@ -4205,7 +4207,7 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
}
}
// IN_ACTIVE_AREA
// IN_VERY_ACTIVE_AREA
if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY)
{
if (HasManyPlayersNearby(20, sPlayerbotAIConfig->sightDistance))
@@ -4226,7 +4228,10 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
if (activityType == PACKET_ACTIVITY)
return true;
uint32 botActiveAlonePerc = sPlayerbotAIConfig->botActiveAlone > 100 ? 100 : sPlayerbotAIConfig->botActiveAlone;
uint32 mod = botActiveAlonePerc;
ActivePiorityType type = GetPriorityType(activityType);
switch (type)
{
case ActivePiorityType::HAS_REAL_PLAYER_MASTER:
@@ -4234,8 +4239,8 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
case ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER:
case ActivePiorityType::IN_INSTANCE:
case ActivePiorityType::IN_COMBAT:
case ActivePiorityType::NEARBY_PLAYER:
case ActivePiorityType::VISIBLE_FOR_PLAYER:
case ActivePiorityType::IN_REACT_DISTANCE:
case ActivePiorityType::NEARBY_PLAYER_300:
case ActivePiorityType::IS_ALWAYS_ACTIVE:
return true;
break;
@@ -4260,11 +4265,6 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
// active at all times. The default is 10%. With 0.1% of all bots going active
// or inactive each minute.
if (sPlayerbotAIConfig->botActiveAlone <= 0) return false;
// Normalize the configured botActiveAlone value, and set as default mod.
uint32 botActiveAlonePerc = sPlayerbotAIConfig->botActiveAlone > 100 ? 100 : sPlayerbotAIConfig->botActiveAlone;
uint32 mod = botActiveAlonePerc;
if (sPlayerbotAIConfig->botActiveAloneSmartScale &&
bot->GetLevel() >= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMinLevel &&
bot->GetLevel() <= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMaxLevel)
@@ -4302,23 +4302,28 @@ uint32 PlayerbotAI::SmartScaleActivity(ActivePiorityType type, uint32 botActiveA
case ActivePiorityType::IN_BG_QUEUE:
case ActivePiorityType::IN_LFG:
if (maxDiff > 100) return 80;
if (maxDiff > 50) return 90;
if (maxDiff > 100) return 90;
break;
case ActivePiorityType::NEARBY_PLAYER_600:
if (maxDiff > 100) return 50;
if (maxDiff > 50) return 75;
break;
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
case ActivePiorityType::IN_ACTIVE_MAP:
if (maxDiff > 200) return 25;
if (maxDiff > 200) return 30;
if (maxDiff > 100) return 50;
if (maxDiff > 50) return 80;
break;
case ActivePiorityType::IN_VERY_ACTIVE_AREA: // Many bots nearby. Do not do heavy area checks.
if (maxDiff > 50) return 75;
break;
case ActivePiorityType::IN_VERY_ACTIVE_AREA:
case ActivePiorityType::IN_NOT_ACTIVE_MAP:
if (maxDiff > 100) return 25;
if (maxDiff > 100) return 30;
if (maxDiff > 50) return 50;
break;
case ActivePiorityType::IN_EMPTY_SERVER:
return 25;
return 30;
default:
if (maxDiff > 200) return 25;
if (maxDiff > 200) return 30;
if (maxDiff > 100) return 50;
break;
}

View File

@@ -247,19 +247,21 @@ enum class ActivePiorityType : uint8
HAS_REAL_PLAYER_MASTER = 1,
IN_GROUP_WITH_REAL_PLAYER = 2,
IN_INSTANCE = 3,
VISIBLE_FOR_PLAYER = 4,
IS_ALWAYS_ACTIVE = 5,
IN_COMBAT = 6,
IN_BG_QUEUE = 7,
IN_LFG = 8,
NEARBY_PLAYER = 9,
PLAYER_FRIEND = 10,
PLAYER_GUILD = 11,
IN_VERY_ACTIVE_AREA = 12,
IN_ACTIVE_MAP = 13,
IN_NOT_ACTIVE_MAP = 14,
IN_EMPTY_SERVER = 15,
ALLOWED_PARTY_ACTIVITY = 16,
IS_ALWAYS_ACTIVE = 4,
IN_COMBAT = 5,
IN_BG_QUEUE = 6,
IN_LFG = 7,
IN_REACT_DISTANCE = 8,
NEARBY_PLAYER_300 = 9,
NEARBY_PLAYER_600 = 10,
NEARBY_PLAYER_900 = 11,
PLAYER_FRIEND = 12,
PLAYER_GUILD = 13,
IN_VERY_ACTIVE_AREA = 14,
IN_ACTIVE_MAP = 15,
IN_NOT_ACTIVE_MAP = 16,
IN_EMPTY_SERVER = 17,
ALLOWED_PARTY_ACTIVITY = 18,
DEFAULT
};