Adding functionality to the module (#9)

This commit is contained in:
Walter Pagani
2023-06-17 18:07:13 -03:00
committed by GitHub
parent f5e6661c3c
commit 2f67366bd3
7 changed files with 197 additions and 154 deletions

View File

@@ -1,8 +1,8 @@
[*] [*]
charset = utf-8 charset = utf-8
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
tab_width = 4 tab_width = 4
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
max_line_length = 80 max_line_length = 80

94
.gitignore vendored
View File

@@ -1,47 +1,47 @@
!.gitignore !.gitignore
# #
#Generic #Generic
# #
.directory .directory
.mailmap .mailmap
* .orig * .orig
* .rej * .rej
* .*~ * .*~
.hg / .hg /
*.kdev * *.kdev *
.DS_Store .DS_Store
CMakeLists.txt.user CMakeLists.txt.user
* .bak * .bak
* .patch * .patch
* .diff * .diff
* .REMOTE.* * .REMOTE.*
* .BACKUP.* * .BACKUP.*
* .BASE.* * .BASE.*
* .LOCAL.* * .LOCAL.*
# #
# IDE & other softwares # IDE & other softwares
# #
/ .settings/ / .settings/
/.externalToolBuilders/* /.externalToolBuilders/*
# exclude in all levels # exclude in all levels
nbproject/ nbproject/
.sync.ffs_db .sync.ffs_db
*.kate-swp *.kate-swp
# #
# Eclipse # Eclipse
# #
*.pydevproject *.pydevproject
.metadata .metadata
.gradle .gradle
tmp/ tmp/
*.tmp *.tmp
*.swp *.swp
*~.nib *~.nib
local.properties local.properties
.settings/ .settings/
.loadpath .loadpath
.project .project
.cproject .cproject

View File

@@ -1,26 +1,26 @@
# #
# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information # 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 # This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# #
# This program is distributed in the hope that it will be useful, but # 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 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# #
# User has manually chosen to ignore the git-tests, so throw them a warning. # 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. # This is done EACH compile so they can be alerted about the consequences.
# #
######################################## ########################################
# AoeLoot module configuration # AoeLoot module configuration
######################################## ########################################
# #
# AOELoot.Enable # AOELoot.Enable
# Description: Enables Module # Description: Enables Module
# Default: 0 - (Disabled) # Default: 0 - (Disabled)
# 1 - (Enabled) # 1 - (Enabled)
# #
AOELoot.Enable = 0 AOELoot.Enable = 0

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "AoeLoot.h"
#include "Log.h"
#include "Config.h"

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef _AOE_LOOT_H_
#define _AOE_LOOT_H_
#endif /* _AOE_LOOT_H_ */

View File

@@ -15,7 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "AoeLoot.h"
#include "Log.h" #include "Log.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "Config.h" #include "Config.h"
@@ -23,19 +22,104 @@
#include "Player.h" #include "Player.h"
#include "ScriptedGossip.h" #include "ScriptedGossip.h"
class AoeLoot_World : public WorldScript class AoeLoot_Player : public PlayerScript
{ {
public: 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<bool>("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<bool>("AOELoot.Enable", true);
if (player->GetGroup() || !creature || !_Enable)
return true;
float range = 30.0f;
uint32 gold = 0;
std::list<Creature*> 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<bool>("AOELoot.Enable", true);
Creature* creature = nullptr;
if (player->GetGroup() || !creature || !_Enable)
return;
float range = 30.0f;
uint32 gold = 0;
Loot* loot = nullptr;
std::list<Creature*> 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() void AddSC_AoeLoot()
{ {
new AoeLoot_World(); new AoeLoot_Player();
} }

View File

@@ -1,25 +1,25 @@
/* /*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information * 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 * 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 * 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 * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// From SC // From SC
void AddSC_AoeLoot(); void AddSC_AoeLoot();
// Add all // Add all
void Addmod_aoe_lootScripts() void Addmod_aoe_lootScripts()
{ {
AddSC_AoeLoot(); AddSC_AoeLoot();
} }