Skip to content

Commit

Permalink
ll ![gameobject] command to add GO to skip loot list, ll -[gameobject…
Browse files Browse the repository at this point in the history
…] to remove
  • Loading branch information
ike3 authored and celguar committed Dec 4, 2023
1 parent 0321abf commit b1a06c8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
3 changes: 3 additions & 0 deletions playerbot/LootObjectStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ void LootObject::Refresh(Player* bot, ObjectGuid guid)
return;

uint32 goId = go->GetGOInfo()->id;
set<uint32>& skipGoLootList = ai->GetAiObjectContext()->GetValue<set<uint32>& >("skip go loot list")->Get();
if (skipGoLootList.find(goId) != skipGoLootList.end()) return;

uint32 lockId = go->GetGOInfo()->GetLockId();
LockEntry const *lockInfo = sLockStore.LookupEntry(lockId);
if (!lockInfo)
Expand Down
54 changes: 48 additions & 6 deletions playerbot/strategy/actions/LootStrategyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bool LootStrategyAction::Execute(Event& event)
LootObjectStack* lootItems = AI_VALUE(LootObjectStack*, "available loot");
set<uint32>& alwaysLootItems = AI_VALUE(set<uint32>&, "always loot list");
set<uint32>& skipLootItems = AI_VALUE(set<uint32>&, "skip loot list");
set<uint32>& skipGoLootList = AI_VALUE(set<uint32>&, "skip go loot list");

if (strategy == "?")
{
Expand All @@ -28,6 +29,7 @@ bool LootStrategyAction::Execute(Event& event)

TellLootList(requester, "always loot list");
TellLootList(requester, "skip loot list");
TellGoList(requester, "skip go loot list");
}
else if (strategy == "clear")
{
Expand All @@ -39,8 +41,9 @@ bool LootStrategyAction::Execute(Event& event)
else
{
set<string> itemQualifiers = chat->parseItemQualifiers(strategy);
list<ObjectGuid> gos = chat->parseGameobjects(strategy);

if (itemQualifiers.size() == 0)
if (itemQualifiers.size() == 0 && gos.size() == 0)
{
SET_AI_VALUE(string, "loot strategy", strategy);

Expand Down Expand Up @@ -96,13 +99,34 @@ bool LootStrategyAction::Execute(Event& event)
alwaysLootItems.insert(itemid);
changes = true;
}
}

for (list<ObjectGuid>::iterator i = gos.begin(); i != gos.end(); ++i)
{
GameObject *go = ai->GetGameObject(*i);
if (!go) continue;
uint32 goId = go->GetGOInfo()->id;

if (changes)
if (remove || add)
{
TellLootList(requester, "always loot list");
TellLootList(requester, "skip loot list");
AI_VALUE(LootObjectStack*, "available loot")->Clear();
set<uint32>::iterator j = skipGoLootList.find(goId);
if (j != skipGoLootList.end()) skipGoLootList.erase(j);
changes = true;
}

if (ignore)
{
skipGoLootList.insert(goId);
changes = true;
}
}

if (changes)
{
TellLootList(requester, "always loot list");
TellLootList(requester, "skip loot list");
TellGoList(requester, "skip go loot list");
AI_VALUE(LootObjectStack*, "available loot")->Clear();
}
}

Expand All @@ -127,4 +151,22 @@ void LootStrategyAction::TellLootList(Player* requester, const string& name)
}

ai->TellPlayer(requester, out);
}
}

void LootStrategyAction::TellGoList(Player* requester, const string& name)
{
set<uint32>& skipGoItems = AI_VALUE(set<uint32>&, name);
ostringstream out;
out << "My " << name << ":";

for (set<uint32>::iterator i = skipGoItems.begin(); i != skipGoItems.end(); i++)
{
uint32 id = *i;
GameObjectInfo const *proto = sGOStorage.LookupEntry<GameObjectInfo>(id);
if (!proto)
continue;

out << " |cFFFFFF00|Hfound:" << 0 << ":" << id << ":" << "|h[" << proto->name << "]|h|r";
}
ai->TellPlayer(requester, out);
}
1 change: 1 addition & 0 deletions playerbot/strategy/actions/LootStrategyAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ namespace ai

private:
void TellLootList(Player* requester, const string& name);
void TellGoList(Player* requester, const string& name);
};
}
2 changes: 2 additions & 0 deletions playerbot/strategy/values/ValueContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace ai
creators["should loot object"] = &ValueContext::should_loot_object;
creators["always loot list"] = &ValueContext::always_loot_list;
creators["skip loot list"] = &ValueContext::skip_loot_list;
creators["skip go loot list"] = &ValueContext::skip_go_loot_list;
creators["loot strategy"] = &ValueContext::loot_strategy;
creators["active rolls"] = &ValueContext::active_rolls;
creators["last movement"] = &ValueContext::last_movement;
Expand Down Expand Up @@ -459,6 +460,7 @@ namespace ai
static UntypedValue* should_loot_object(PlayerbotAI* ai) { return new ShouldLootObject(ai); }
static UntypedValue* always_loot_list(PlayerbotAI* ai) { return new AlwaysLootListValue(ai, "always loot list"); }
static UntypedValue* skip_loot_list(PlayerbotAI* ai) { return new AlwaysLootListValue(ai, "skip loot list"); }
static UntypedValue* skip_go_loot_list(PlayerbotAI* ai) { return new AlwaysLootListValue(ai, "skip go loot list"); }
static UntypedValue* loot_strategy(PlayerbotAI* ai) { return new LootStrategyValue(ai); }
static UntypedValue* active_rolls(PlayerbotAI* ai) { return new ActiveRolls(ai); }

Expand Down

0 comments on commit b1a06c8

Please sign in to comment.