/*
 *  Author: Needles
 *  https://steamcommunity.com/profiles/76561198026257137/
 */

 printl("*** HANDLER/MILK");



local MilkHandler = class extends ::Handler.BaseHandler
{
    /*
        BASE CLASS
        self        =   The entity that the handler is assigned to
        activator   =   The entity that assigned the handler
        time        =   When this handler was assigned
    */

    function OnAdd()
    {
        local particleAttachment = ::Particle.Validate(self);
        if (particleAttachment != null)
            particleAttachment.AddEffect("peejar_drips_milk");
    }



    function OnRemove()
    {
        local particleAttachment = ::Particle.Validate(self);
            if (particleAttachment != null)
        particleAttachment.RemoveEffect("peejar_drips_milk");
    }



    function OnEvent_DamagePost(params)
    {
        if (params.const_entity != self)
            return;

        //  Heal attcker
        ::Players.HealPlayer(params.attacker, activator, params.damage * ::Const.WEAPON_MILK_HEAL_FACTOR);
    }
}

::Handler.RegisterHandler("milk", @() MilkHandler());