
--Revamp of the unstable robots! using lua for more consistent triggery
function unstablesetup(_, activator)
    local hastriggered = false

    --Preventing lethal that prevents triggering
    --THIS one over here deals with damage that has been done (which is why its POST) The IF THEN statement below will trigger once the damage is received and changed to what the if then statement is written
    activator:AddCallback(ON_DAMAGE_RECEIVED_POST, function(_, damageInfo)
        local health = activator.m_iHealth
        --//
        if  health <= 3 and hastriggered == false then --if the health is fatal then do below
            activator.m_iHealth = 1
            activator:AddCond(71,10,nil) -- Stuns the enemy
            -- activator:AddCond(5,1,nil) -- no longer needed due to the PRE section
            hastriggered = true --this will now switch us to the PRE SECTIONS
            return true
        end
    end)
    activator:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(activator, damageInfo) --The PRE section will basically nullify incoming damage!
        if hastriggered == true then
            activator:AddCond(71,10,nil) -- Stuns the enemy
            damageInfo.Damage = 0 -- turn all incoming damage to zero
            damageInfo.DamageType = DMG_GENERIC -- will make sure that the bot doesnt flitch when attacked
            activator.m_iHealth = 1 --Setting health as always 1 (Fixes Black-Box Soldiers from suddenly regenerating health during the ticking phase; causing the trigger not to happen)
            return true
        end
    end)
    activator:AddCallback(ON_DEATH, function()
        activator:RemoveAllCallbacks()
    end)
      activator:AddCallback(ON_SPAWN, function()
        activator:RemoveAllCallbacks()
    end)
end

--Overall i am a dumbass and also thank you to T_TFGatebot_Engineer for the crashcourse about .lua!
--my own combo pyro creations

--Idea: The pyro switches like crazy cuz he do be like that