Fuck AI, trying it, myself
This commit is contained in:
parent
9b41773110
commit
c16d5ec8fc
@ -7,32 +7,32 @@
|
||||
class Leech_UnitScript : public UnitScript
|
||||
{
|
||||
public:
|
||||
Leech_UnitScript() : UnitScript("Leech_UnitScript") {}
|
||||
Leech_UnitScript() : UnitScript("Leech_UnitScript") { }
|
||||
|
||||
void OnDamage(Unit *attacker, Unit *victim, uint32 &damage) override
|
||||
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 (!player)
|
||||
return;
|
||||
|
||||
if (sConfigMgr->GetOption<bool>("Leech.DungeonsOnly", true) && !player->GetMap()->IsDungeon())
|
||||
return;
|
||||
uint32 requiredItem = sConfigMgr->GetOption<uint32>("Leech.RequiredItemId", 0u);
|
||||
if (requiredItem != 0)
|
||||
{
|
||||
if (!player->HasItemCount(requiredItem, 1, false))
|
||||
return;
|
||||
}
|
||||
|
||||
if (damage == 0)
|
||||
return;
|
||||
}
|
||||
Player* player = isPet ? attacker->GetOwner()->ToPlayer() : attacker->ToPlayer();
|
||||
|
||||
if (sConfigMgr->GetOption<bool>("Leech.DungeonsOnly", true) && !(player->GetMap()->IsDungeon()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 requiredItem = sConfigMgr->GetOption<uint32>("Leech.RequiredItemId", 0u);
|
||||
if (requiredItem != 0) && !(player->HasItemCount(requiredItem, 1, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto leechAmount = sConfigMgr->GetOption<float>("Leech.Amount", 0.05f);
|
||||
auto bp1 = static_cast<int32>(leechAmount * float(damage));
|
||||
@ -40,6 +40,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Add all scripts in one
|
||||
void AddSC_mod_leech()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user