Forked from https://github.com/ZhengPeiRu21/mod-leech
This commit is contained in:
parent
d42d6f7dbc
commit
760540f687
20
LICENSE
20
LICENSE
@ -1,9 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 AzerothCore
|
||||
Copyright (c) 2021 AzerothCore
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
# mod-leech
|
||||
|
||||
An AzerothCore module that heals players when dealing damage.
|
||||
|
||||
32
conf/leech.conf.dist
Normal file
32
conf/leech.conf.dist
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
#
|
||||
|
||||
[worldserver]
|
||||
|
||||
########################################
|
||||
# Leech Config
|
||||
########################################
|
||||
#
|
||||
# Leech.Enable
|
||||
# Description: Enable the module
|
||||
# Default: 0 - Disabled
|
||||
# 1 - Enabled
|
||||
#
|
||||
|
||||
Leech.Enable = 1
|
||||
#
|
||||
# Leech.DungeonsOnly
|
||||
# Description: Enable leeching only in content that would normally be group content (ie, dungeons and raids)
|
||||
# Default: 1 - Enabled
|
||||
# 0 - Disabled
|
||||
#
|
||||
|
||||
Leech.DungeonsOnly = 1
|
||||
#
|
||||
# Leech.Amount
|
||||
# Description: Amount of damage dealt that will be applied as a heal on the player. 0 is none, 0.5 is 50%, 1 is 100%, 2 is 200%, etc.
|
||||
# Default: 0.05 - 5%
|
||||
#
|
||||
|
||||
Leech.Amount = 0.05
|
||||
42
src/Leech.cpp
Normal file
42
src/Leech.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
#include "Leech.h"
|
||||
|
||||
class Leech_UnitScript : public UnitScript
|
||||
{
|
||||
public:
|
||||
Leech_UnitScript() : UnitScript("Leech_UnitScript") { }
|
||||
|
||||
void OnDamage(Unit* attacker, Unit* victim, uint32& damage) override
|
||||
{
|
||||
if (!sConfigMgr->GetOption<bool>("Leech.Enable", true) || !attacker)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool isPet = attacker->GetOwner() && attacker->GetOwner()->GetTypeId() == TYPEID_PLAYER;
|
||||
if (!isPet && attacker->GetTypeId() != TYPEID_PLAYER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Player* player = isPet ? attacker->GetOwner()->ToPlayer() : attacker->ToPlayer();
|
||||
|
||||
if (sConfigMgr->GetOption<bool>("Leech.DungeonsOnly", true) && !(player->GetMap()->IsDungeon()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto leechAmount = sConfigMgr->GetOption<float>("Leech.Amount", 0.05f);
|
||||
auto bp1 = static_cast<int32>(leechAmount * float(damage));
|
||||
player->CastCustomSpell(attacker, SPELL_HEAL, &bp1, nullptr, nullptr, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Add all scripts in one
|
||||
void AddSC_mod_leech()
|
||||
{
|
||||
new Leech_UnitScript();
|
||||
}
|
||||
15
src/Leech.h
Normal file
15
src/Leech.h
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#ifndef AZEROTHCORE_LEECH_H
|
||||
#define AZEROTHCORE_LEECH_H
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "Config.h"
|
||||
#include <map>
|
||||
|
||||
enum LeechSpells
|
||||
{
|
||||
SPELL_HEAL = 18984
|
||||
};
|
||||
|
||||
|
||||
#endif //AZEROTHCORE_LEECH_H
|
||||
14
src/Leech_loader.cpp
Normal file
14
src/Leech_loader.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
// From SC
|
||||
void AddSC_mod_leech();
|
||||
|
||||
// Add all
|
||||
// cf. the naming convention https://github.com/azerothcore/azerothcore-wotlk/blob/master/doc/changelog/master.md#how-to-upgrade-4
|
||||
// additionally replace all '-' in the module folder name with '_' here
|
||||
void Addmod_leechScripts()
|
||||
{
|
||||
AddSC_mod_leech();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user