mirror of
https://github.com/azerothcore/mod-aoe-loot
synced 2025-11-29 21:38:16 +08:00
Adding functionality to the module (#9)
This commit is contained in:
@@ -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
|
||||
|
||||
94
.gitignore
vendored
94
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
@@ -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_ */
|
||||
@@ -15,7 +15,6 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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<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()
|
||||
{
|
||||
new AoeLoot_World();
|
||||
new AoeLoot_Player();
|
||||
}
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// From SC
|
||||
void AddSC_AoeLoot();
|
||||
|
||||
// Add all
|
||||
void Addmod_aoe_lootScripts()
|
||||
{
|
||||
AddSC_AoeLoot();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user