Add files via upload

This commit is contained in:
TerraByte
2025-03-30 05:45:55 -05:00
committed by GitHub
commit ebfe14cd9c
5 changed files with 179 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
########################################
# AoeLoot module configuration
########################################
#
# AOELoot.Enable
# Description: Enables Module
# Default: 0 - (Disabled)
# 1 - (Enabled)
#
AOELoot.Enable = 1
#
# AOELoot.Message
# Description: Enable message on login
# Default: 0 - (Disabled)
# 1 - (Enabled)
#
AOELoot.Message = 0
#
# AOELoot.Range
# Description: Maximum reach range search loot.
# Default: 55.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 = 1

View File

@@ -0,0 +1,5 @@
SET @ENTRY:=50000;
DELETE FROM `acore_string` WHERE `entry` IN (@ENTRY+0, @ENTRY+1);
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
(@ENTRY+0, 'This server is running the |cff4CFF00Loot aoe|r module.', '', '', '', '', '', 'Este servidor está ejecutando el módulo |cff4CFF00Loot aoe|r.', 'Este servidor está ejecutando el módulo |cff4CFF00Loot aoe|r.', ''),
(@ENTRY+1, '|cff4CFF00[Loot aoe]|r Your items has been mailed to you.', '', '', '', '', '', '|cff4CFF00[Loot aoe]|r Sus artículos le han sido enviados por correo.', '|cff4CFF00[Loot aoe]|r Sus artículos le han sido enviados por correo.', '');

View File

@@ -0,0 +1,89 @@
#include "aoe_loot.h"
#include "LootMgr.h"
#include "WorldSession.h" // Include for HandleAutostoreLootItemOpcode
#include "WorldPacket.h" // Include for WorldPacket
#include "Player.h"
#include "Chat.h"
#include "Creature.h"
void AOELootPlayer::OnPlayerLogin(Player* player)
{
if (sConfigMgr->GetOption<bool>("AOELoot.Enable", true))
{
if (sConfigMgr->GetOption<bool>("AOELoot.Message", true))
ChatHandler(player->GetSession()).PSendSysMessage(AOE_ACORE_STRING_MESSAGE);
}
}
bool AOELootServer::CanPacketReceive(WorldSession* session, WorldPacket& packet)
{
LOG_DEBUG("module.aoe_loot", "CanPacketReceive function called for opcode {}", packet.GetOpcode());
if (packet.GetOpcode() == CMSG_LOOT)
{
Player* player = session->GetPlayer();
if (!sConfigMgr->GetOption<bool>("AOELoot.Enable", true))
return true;
if (player->GetGroup() && !sConfigMgr->GetOption<bool>("AOELoot.Group", true))
return true;
float range = sConfigMgr->GetOption<float>("AOELoot.Range", 55.0);
std::list<Creature*> lootcreature;
player->GetDeadCreatureListInGrid(lootcreature, range);
ObjectGuid mainGuid;
packet >> mainGuid;
for (auto* creature : lootcreature)
{
if (!player->GetMap()->Instanceable() && !player->isAllowedToLoot(creature))
continue;
Loot* loot = &creature->loot;
LOG_DEBUG("module.aoe_loot", "Quest Items Size for {}: {}", creature->GetAIName(), loot->quest_items.size());
ChatHandler(player->GetSession()).PSendSysMessage(fmt::format("AOE Loot: Quest Items Size for {}: {}", creature->GetAIName(), loot->quest_items.size()));
// Process quest items
for (size_t i = 0; i < loot->quest_items.size(); ++i)
{
player->SetLootGUID(creature->GetGUID());
WorldPacket autostorePacket(CMSG_AUTOSTORE_LOOT_ITEM, 1);
autostorePacket << i; // Use the index i as the slot for this creature
session->HandleAutostoreLootItemOpcode(autostorePacket);
}
LOG_DEBUG("module.aoe_loot", "Regular Items Size for {}: {}", creature->GetAIName(), loot->items.size());
ChatHandler(player->GetSession()).PSendSysMessage(fmt::format("AOE Loot: Regular Items Size for {}: {}", creature->GetAIName(), loot->items.size()));
// Process regular items
for (size_t i = 0; i < loot->items.size(); ++i)
{
player->SetLootGUID(creature->GetGUID());
WorldPacket autostorePacket(CMSG_AUTOSTORE_LOOT_ITEM, 1);
autostorePacket << i; // Use the index i as the slot for this creature
session->HandleAutostoreLootItemOpcode(autostorePacket);
}
LOG_DEBUG("module.aoe_loot", "Gold Amount for {}: {}", creature->GetAIName(), loot->gold);
ChatHandler(player->GetSession()).PSendSysMessage(fmt::format("AOE Loot: Found {} gold on nearby corpse.", loot->gold));
if (creature->loot.gold > 0)
{
player->SetLootGUID(creature->GetGUID());
WorldPacket moneyPacket(CMSG_LOOT_MONEY, 0); // Create a dummy packet
session->HandleLootMoneyOpcode(moneyPacket);
}
if (!loot->empty())
{
creature->loot.clear();
creature->AllLootRemovedFromCorpse();
creature->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
}
}
return true;
}
return true;
}

View File

@@ -0,0 +1,38 @@
#ifndef MODULE_AOELOOT_H
#define MODULE_AOELOOT_H
#include "ScriptMgr.h"
#include "Config.h"
#include "Chat.h"
#include "Player.h"
#include "ScriptedGossip.h"
enum AoeLootString
{
AOE_ACORE_STRING_MESSAGE = 50000,
AOE_ITEM_IN_THE_MAIL
};
class AOELootPlayer : public PlayerScript
{
public:
AOELootPlayer() : PlayerScript("AOELootPlayer") { }
void OnPlayerLogin(Player* player) override;
};
class AOELootServer : public ServerScript
{
public:
AOELootServer() : ServerScript("AOELootServer") { }
bool CanPacketReceive(WorldSession* session, WorldPacket& packet) override;
};
void AddSC_AoeLoot()
{
new AOELootPlayer();
new AOELootServer();
}
#endif //MODULE_AOELOOT_H

View File

@@ -0,0 +1,9 @@
// From SC
void AddSC_AoeLoot();
// Add all
void Addmod_aoe_lootScripts()
{
AddSC_AoeLoot();
}