diff --git a/.editorconfig b/.editorconfig index b0597dd..eb64e2f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,8 +1,8 @@ -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -tab_width = 4 -insert_final_newline = true -trim_trailing_whitespace = true -max_line_length = 80 +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +tab_width = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 diff --git a/.gitignore b/.gitignore index be4c57d..4ba5dd3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,47 +1,47 @@ -!.gitignore - -# -#Generic -# -.directory -.mailmap -* .orig -* .rej -* .*~ -.hg / -*.kdev * -.DS_Store -CMakeLists.txt.user -* .bak -* .patch -* .diff -* .REMOTE.* -* .BACKUP.* -* .BASE.* -* .LOCAL.* - -# -# IDE & other softwares -# -/ .settings/ -/.externalToolBuilders/* -# exclude in all levels -nbproject/ -.sync.ffs_db -*.kate-swp - -# -# Eclipse -# -*.pydevproject -.metadata -.gradle -tmp/ -*.tmp -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.project -.cproject +!.gitignore + +# +#Generic +# +.directory +.mailmap +* .orig +* .rej +* .*~ +.hg / +*.kdev * +.DS_Store +CMakeLists.txt.user +* .bak +* .patch +* .diff +* .REMOTE.* +* .BACKUP.* +* .BASE.* +* .LOCAL.* + +# +# IDE & other softwares +# +/ .settings/ +/.externalToolBuilders/* +# exclude in all levels +nbproject/ +.sync.ffs_db +*.kate-swp + +# +# Eclipse +# +*.pydevproject +.metadata +.gradle +tmp/ +*.tmp +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.project +.cproject diff --git a/conf/AoeLoot.conf.dist b/conf/AoeLoot.conf.dist index 9a4700a..3d6117e 100644 --- a/conf/AoeLoot.conf.dist +++ b/conf/AoeLoot.conf.dist @@ -1,26 +1,26 @@ -# -# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# User has manually chosen to ignore the git-tests, so throw them a warning. -# This is done EACH compile so they can be alerted about the consequences. -# - -######################################## -# AoeLoot module configuration -######################################## -# -# AOELoot.Enable -# Description: Enables Module -# Default: 0 - (Disabled) -# 1 - (Enabled) -# - -AOELoot.Enable = 0 +# +# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# User has manually chosen to ignore the git-tests, so throw them a warning. +# This is done EACH compile so they can be alerted about the consequences. +# + +######################################## +# AoeLoot module configuration +######################################## +# +# AOELoot.Enable +# Description: Enables Module +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +AOELoot.Enable = 0 diff --git a/src/AoeLoot.cpp b/src/AoeLoot.cpp deleted file mode 100644 index a34ad80..0000000 --- a/src/AoeLoot.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "AoeLoot.h" -#include "Log.h" -#include "Config.h" diff --git a/src/AoeLoot.h b/src/AoeLoot.h deleted file mode 100644 index 1486e38..0000000 --- a/src/AoeLoot.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AOE_LOOT_H_ -#define _AOE_LOOT_H_ - -#endif /* _AOE_LOOT_H_ */ diff --git a/src/AoeLoot_SC.cpp b/src/AoeLoot_SC.cpp index 226790e..898f3c1 100644 --- a/src/AoeLoot_SC.cpp +++ b/src/AoeLoot_SC.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "AoeLoot.h" #include "Log.h" #include "ScriptMgr.h" #include "Config.h" @@ -23,19 +22,104 @@ #include "Player.h" #include "ScriptedGossip.h" -class AoeLoot_World : public WorldScript +class AoeLoot_Player : public PlayerScript { public: - AoeLoot_World() : WorldScript("AoeLoot_World") { } + AoeLoot_Player() : PlayerScript("AoeLoot_Player") { } - void OnAfterConfigLoad(bool /*reload*/) override + void OnLogin(Player* player) override { - // Add conigs options configiration + if (sConfigMgr->GetOption("AOELoot.Enable", false)) + { + ChatHandler(player->GetSession()).PSendSysMessage("This server is running the |cff4CFF00Loot aoe |r module."); + } + } + + bool CanSendErrorArleadyLooted(Player* /*player*/) override + { + return true; + } + + bool CanSendCreatureLoot(Creature* creature, Player* player) override + { + bool _Enable = sConfigMgr->GetOption("AOELoot.Enable", true); + + if (player->GetGroup() || !creature || !_Enable) + return true; + + float range = 30.0f; + uint32 gold = 0; + + std::list creaturedie; + player->GetDeadCreatureListInGrid(creaturedie, range); + + for (auto const& _creature : creaturedie) + { + auto loot = &_creature->loot; + gold += loot->gold; + loot->gold = 0; + + uint8 lootSlot = 0; + uint8 maxSlot = loot->GetMaxSlotInLootFor(player); + + for (uint32 i = 0; i < maxSlot; ++i) + { + if (LootItem* item = loot->LootItemInSlot(i, player)) + { + if (player->AddItem(item->itemid, item->count)) + { + player->SendNotifyLootItemRemoved(lootSlot); + player->SendLootRelease(player->GetLootGUID()); + } + else + { + player->SendItemRetrievalMail(item->itemid, item->count); + ChatHandler(player->GetSession()).SendSysMessage("Your items has been mailed to you."); + } + } + } + + loot->clear(); + + if (loot->isLooted() && loot->empty()) + { + _creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + } + + loot->gold = gold; + player->ModifyMoney(loot->gold); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold); + } + return true; + } + + void OnBeforeCreatureLootMoney(Player* player) override + { + bool _Enable = sConfigMgr->GetOption("AOELoot.Enable", true); + + Creature* creature = nullptr; + + if (player->GetGroup() || !creature || !_Enable) + return; + + float range = 30.0f; + uint32 gold = 0; + Loot* loot = nullptr; + std::list creaturedie; + player->GetDeadCreatureListInGrid(creaturedie, range); + + for (auto const& _creature : creaturedie) + { + loot = &_creature->loot; + gold += loot->gold; + loot->gold = 0; + } + + loot->gold = gold; } }; -// Group all custom scripts void AddSC_AoeLoot() { - new AoeLoot_World(); + new AoeLoot_Player(); } diff --git a/src/aoe_loot_loader.cpp b/src/aoe_loot_loader.cpp index 21c39e3..8d760fa 100644 --- a/src/aoe_loot_loader.cpp +++ b/src/aoe_loot_loader.cpp @@ -1,25 +1,25 @@ -/* - * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -// From SC -void AddSC_AoeLoot(); - -// Add all -void Addmod_aoe_lootScripts() -{ - AddSC_AoeLoot(); -} +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +// From SC +void AddSC_AoeLoot(); + +// Add all +void Addmod_aoe_lootScripts() +{ + AddSC_AoeLoot(); +}