This commit is contained in:
Flerp
2025-11-04 17:19:09 -08:00
parent d42d6f7dbc
commit 760540f687
6 changed files with 120 additions and 5 deletions

42
src/Leech.cpp Normal file
View 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
View 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
View 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();
}