diff --git a/modules/mod-aoe-loot/.github/README.md b/modules/mod-aoe-loot/.github/README.md index 2388a39..17a4177 100644 --- a/modules/mod-aoe-loot/.github/README.md +++ b/modules/mod-aoe-loot/.github/README.md @@ -18,7 +18,7 @@ This module enables Area of Effect (AOE) looting functionality for AzerothCore, - **Configurable Range**: Server administrators can set the maximum distance for AOE loot collection - **Group Support**: Optional group looting with configurable settings - **Performance Optimized**: Limits number of corpses processed to maintain server stability -- **Smart Item Management**: +- **Smart Item Management**: - Automatic gold accumulation with overflow protection - Quest items sent directly to inventory - Maximum 15 items per loot window to prevent UI issues @@ -86,10 +86,10 @@ AOELoot.Enable = 1 # # AOELoot.Range # Description: Maximum distance (in yards) to collect loot from nearby corpses -# Default: 30.0 +# Default: 55.0 # Range: 5.0 - 100.0 -AOELoot.Range = 30.0 +AOELoot.Range = 55.0 # # AOELoot.Group @@ -160,7 +160,7 @@ The module can be controlled through configuration file settings (see Configurat | Option | Type | Default | Description | |--------|------|---------|-------------| | `AOELoot.Enable` | Boolean | 1 | Enable/disable module globally | -| `AOELoot.Range` | Float | 30.0 | Maximum loot collection radius (5.0 - 100.0) | +| `AOELoot.Range` | Float | 55.0 | Maximum loot collection radius (5.0 - 100.0) | | `AOELoot.Group` | Boolean | 1 | Allow AOE loot in groups | | `AOELoot.Message` | Boolean | 1 | Show login message | @@ -177,7 +177,7 @@ The module includes full multi-language support through AzerothCore's `acore_str To add additional language support, update the SQL file: ```sql -UPDATE `acore_string` SET +UPDATE `acore_string` SET `locale_frFR` = 'Votre traduction ici', `locale_deDE` = 'Ihre Übersetzung hier', `locale_ruRU` = 'Ваш перевод здесь' @@ -222,7 +222,7 @@ The module uses `acore_string` entries 50000-50007: **Solutions:** - Verify module is enabled: `AOELoot.Enable = 1` - Check if you disabled it personally: use `.aoeloot on` -- Ensure you're within range (default 30 yards) +- Ensure you're within range (default 55 yards) - If in group, check `AOELoot.Group` setting ### Issue: Corpses not disappearing diff --git a/modules/mod-aoe-loot/.github/README_ES.md b/modules/mod-aoe-loot/.github/README_ES.md index 0416492..d9453f5 100644 --- a/modules/mod-aoe-loot/.github/README_ES.md +++ b/modules/mod-aoe-loot/.github/README_ES.md @@ -18,7 +18,7 @@ Este módulo habilita la funcionalidad de saqueo en área (AOE) para AzerothCore - **Rango Configurable**: Los administradores del servidor pueden establecer la distancia máxima para la recolección de botín AOE - **Soporte de Grupo**: Saqueo en grupo opcional con configuración personalizable - **Optimizado para Rendimiento**: Limita el número de cadáveres procesados para mantener la estabilidad del servidor -- **Gestión Inteligente de Objetos**: +- **Gestión Inteligente de Objetos**: - Acumulación automática de oro con protección contra desbordamiento - Objetos de misión enviados directamente al inventario - Máximo de 15 objetos por ventana de botín para evitar problemas de interfaz @@ -86,10 +86,10 @@ AOELoot.Enable = 1 # # AOELoot.Range # Descripción: Distancia máxima (en yardas) para recolectar botín de cadáveres cercanos -# Por defecto: 30.0 +# Por defecto: 55.0 # Rango: 5.0 - 100.0 -AOELoot.Range = 30.0 +AOELoot.Range = 55.0 # # AOELoot.Group @@ -160,7 +160,7 @@ El módulo puede controlarse a través de la configuración del archivo (ver sec | Opción | Tipo | Por Defecto | Descripción | |--------|------|-------------|-------------| | `AOELoot.Enable` | Booleano | 1 | Habilitar/deshabilitar módulo globalmente | -| `AOELoot.Range` | Decimal | 30.0 | Radio máximo de recolección de botín (5.0 - 100.0) | +| `AOELoot.Range` | Decimal | 55.0 | Radio máximo de recolección de botín (5.0 - 100.0) | | `AOELoot.Group` | Booleano | 1 | Permitir saqueo AOE en grupos | | `AOELoot.Message` | Booleano | 1 | Mostrar mensaje de inicio de sesión | @@ -177,7 +177,7 @@ El módulo incluye soporte completo multi-idioma a través del sistema `acore_st Para agregar soporte de idiomas adicionales, actualiza el archivo SQL: ```sql -UPDATE `acore_string` SET +UPDATE `acore_string` SET `locale_frFR` = 'Votre traduction ici', `locale_deDE` = 'Ihre Übersetzung hier', `locale_ruRU` = 'Ваш перевод здесь' @@ -222,11 +222,11 @@ El módulo utiliza las entradas `acore_string` 50000-50007: **Soluciones:** - Verifica que el módulo esté habilitado: `AOELoot.Enable = 1` - Comprueba si lo desactivaste personalmente: usa `.aoeloot on` -- Asegúrate de estar dentro del rango (30 yardas por defecto) +- Asegúrate de estar dentro del rango (55 yardas por defecto) - Si estás en grupo, verifica la configuración `AOELoot.Group` ### Problema: Los cadáveres no desaparecen -**Solución:** +**Solución:** - Establece `Rate.Corpse.Decay.Looted = 0.01` en worldserver.conf ### Problema: Mensajes en idioma incorrecto diff --git a/modules/mod-aoe-loot/conf/mod_aoe_loot.conf.dist b/modules/mod-aoe-loot/conf/mod_aoe_loot.conf.dist index cb7abfc..6885992 100644 --- a/modules/mod-aoe-loot/conf/mod_aoe_loot.conf.dist +++ b/modules/mod-aoe-loot/conf/mod_aoe_loot.conf.dist @@ -18,36 +18,36 @@ ######################################## # # AOELoot.Enable -# Description: Enables Module -# Default: 0 - (Disabled) -# 1 - (Enabled) +# Description: Enables Module +# Default: 1 - (Enabled) +# 0 - (Disabled) # AOELoot.Enable = 1 # # AOELoot.Message -# Description: Enable message on login -# Default: 0 - (Disabled) -# 1 - (Enabled) +# Description: Enables area loot if the player is in a group +# Default: 1 - (Enabled) +# 0 - (Disabled) # AOELoot.Message = 1 # -# AOELoot.Range +# AOELoot.Range # Description: Maximum reach range search loot. # Default: 55.0 +# Range: 5.0 - 100.0 # AOELoot.Range = 55.0 # -# AOELoot.Group -# Description: Enables area loot if the player is in a group -# Default: 1 (Enabled) -# Possible values: 0 - (Disabled) -# 1 - (Enabled) +# AOELoot.Group +# Description: Enables area loot if the player is in a group +# Default: 1 - (Enabled) +# 0 - (Disabled) # AOELoot.Group = 1 diff --git a/modules/mod-aoe-loot/src/aoe_loot.cpp b/modules/mod-aoe-loot/src/aoe_loot.cpp index fd092fd..ef34e83 100644 --- a/modules/mod-aoe-loot/src/aoe_loot.cpp +++ b/modules/mod-aoe-loot/src/aoe_loot.cpp @@ -16,6 +16,7 @@ */ #include "aoe_loot.h" +#include "ObjectMgr.h" #include #include @@ -60,7 +61,7 @@ bool AOELootServer::CanPacketReceive(WorldSession* session, WorldPacket& packet) return true; // Get configured loot range - float range = sConfigMgr->GetOption("AOELoot.Range", 30.0f); + float range = sConfigMgr->GetOption("AOELoot.Range", 55.0f); // Limit range to reasonable values if (range < 5.0f) @@ -145,20 +146,69 @@ bool AOELootServer::CanPacketReceive(WorldSession* session, WorldPacket& packet) for (size_t i = 0; i < loot->items.size(); ++i) { // Check if there's still space - if ((mainLoot->items.size() + itemsToAdd.size() + mainLoot->quest_items.size() + questItemsToAdd.size()) >= 15) + if ((mainLoot->items.size() + itemsToAdd.size() + mainLoot->quest_items.size() + questItemsToAdd.size()) >= MAX_LOOT_ITEMS) break; itemsToAdd.push_back(loot->items[i]); } - // Collect quest items + // Collect quest items (only for active quests, limited to needed count) for (size_t i = 0; i < loot->quest_items.size(); ++i) { // Check if there's still space - if ((mainLoot->items.size() + itemsToAdd.size() + mainLoot->quest_items.size() + questItemsToAdd.size()) >= 15) + if ((mainLoot->items.size() + itemsToAdd.size() + mainLoot->quest_items.size() + questItemsToAdd.size()) >= MAX_LOOT_ITEMS) break; - questItemsToAdd.push_back(loot->quest_items[i]); + LootItem const& questItem = loot->quest_items[i]; + + // Skip items the player doesn't need for any active quest + if (!player->HasQuestForItem(questItem.itemid)) + continue; + + // Calculate how many the player still needs across all active quests + uint32 maxNeeded = 0; + for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) + { + uint32 questId = player->GetQuestSlotQuestId(slot); + if (!questId) + continue; + + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest) + continue; + + for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) + { + if (quest->RequiredItemId[j] == questItem.itemid && quest->RequiredItemCount[j] > maxNeeded) + maxNeeded = quest->RequiredItemCount[j]; + } + } + + if (maxNeeded == 0) + continue; + + // Count how many the player already has, plus pending adds + // and quest items already in the main loot window + uint32 ownedCount = player->GetItemCount(questItem.itemid, true); + for (auto const& pending : questItemsToAdd) + { + if (pending.itemid == questItem.itemid) + ownedCount += pending.count; + } + for (auto const& mainQuestItem : mainLoot->quest_items) + { + if (mainQuestItem.itemid == questItem.itemid) + ownedCount += mainQuestItem.count; + } + + if (ownedCount >= maxNeeded) + continue; + + uint32 stillNeeded = maxNeeded - ownedCount; + LootItem cappedItem = questItem; + cappedItem.count = std::min(static_cast(questItem.count), stillNeeded); + + questItemsToAdd.push_back(cappedItem); } // Clear source loot (but don't modify vector directly) @@ -176,13 +226,16 @@ bool AOELootServer::CanPacketReceive(WorldSession* session, WorldPacket& packet) // Add regular items for (const auto& item : itemsToAdd) { - if (mainLoot->items.size() < 15) + if (mainLoot->items.size() < MAX_LOOT_ITEMS) mainLoot->items.push_back(item); } - // Add quest items to player inventory + // Add quest items directly to player inventory for (const auto& item : questItemsToAdd) { + if (!player->HasQuestForItem(item.itemid)) + continue; + player->AddItem(item.itemid, item.count); }