Skip to content

Commit

Permalink
Add the default mark rti if bot is setup to ignore rti targets
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Nov 12, 2023
1 parent ee8ea87 commit 9378cd8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
6 changes: 3 additions & 3 deletions playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool syncWithMaster)

// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(newItemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > (int)sPlayerbotAIConfig.randomGearMaxDiff)
continue;

// filter tank weapons
Expand Down Expand Up @@ -1913,7 +1913,7 @@ void PlayerbotFactory::InitSecondEquipmentSet()

// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(itemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > (int)sPlayerbotAIConfig.randomGearMaxDiff)
continue;

if (!CanEquipItem(proto, desiredQuality))
Expand Down Expand Up @@ -3265,7 +3265,7 @@ void PlayerbotFactory::InitInventoryEquip()

// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(itemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > (int)sPlayerbotAIConfig.randomGearMaxDiff)
continue;

if ((proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_WEAPON) || (proto->Bonding == BIND_WHEN_PICKED_UP ||
Expand Down
7 changes: 7 additions & 0 deletions playerbot/strategy/actions/RtiAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ bool MarkRtiAction::Execute(Event& event)
if (!target) return false;

string rti = AI_VALUE(string, "rti");

// Add the default rti if the bot is setup to ignore rti targets
if (rti == "none")
{
rti = "skull";
}

int index = RtiTargetValue::GetRtiIndex(rti);
#ifndef MANGOSBOT_TWO
group->SetTargetIcon(index, target->GetObjectGuid());
Expand Down
29 changes: 28 additions & 1 deletion playerbot/strategy/triggers/RtiTriggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../Trigger.h"
#include "../../PlayerbotAIConfig.h"
#include "../../ServerFacade.h"
#include "../values/RtiTargetValue.h"

namespace ai
{
Expand All @@ -12,7 +13,33 @@ namespace ai

virtual bool IsActive()
{
return !AI_VALUE(Unit*, "rti target");
if (AI_VALUE(Unit*, "rti target"))
{
return false;
}
else
{
// Check for the default rti if the bot is setup to ignore rti targets
string rti = AI_VALUE(string, "rti");
if (rti == "none")
{
Group* group = bot->GetGroup();
if (group)
{
const ObjectGuid guid = group->GetTargetIcon(RtiTargetValue::GetRtiIndex("skull"));
if (!guid.IsEmpty())
{
Unit* unit = ai->GetUnit(ObjectGuid(guid));
if (unit && !sServerFacade.UnitIsDead(unit) && bot->IsWithinDistInMap(unit, sPlayerbotAIConfig.sightDistance, false))
{
return false;
}
}
}
}
}

return true;
}
};
}

0 comments on commit 9378cd8

Please sign in to comment.