-----------------------------------------------------------------------------
--  File     : /mods/4DC_V0.8/hook/lua/Shield.lua
--
--  Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid, Domino
--
--  Summary  : Alows projectiles to ignore shields
--
--  Copyright © 2011 4DC_V0.8  All rights reserved.
-----------------------------------------------------------------------------
-- 
--  The following is required within the projectile blueprint for "Shield Piercing"
--    Categories = {
--        'PROJECTILE',
--        'SHIELDPIERCING',
--    }, 
-- 
-----------------------------------------------------------------------------
do
local oldUnit = Shield
Shield = Class(oldUnit) {
    -- Return true to process this collision, false to ignore it.
    OnCollisionCheck = function(self,other)
        if other:GetArmy() == -1 then
            return false
        end
        if EntityCategoryContains( categories.STRATEGIC, other ) and 
           EntityCategoryContains( categories.MISSILE, other ) then
            -- Allow strategic nuke missile to penetrate shields           
            return false
        elseif EntityCategoryContains( categories.PROJECTILE, other ) and
            EntityCategoryContains( categories.SHIELDPIERCING, other ) then
            -- Allow Shield Piercing Projectiles to ignore shields
            return false
        end
        if other:GetBlueprint().Physics.CollideFriendlyShield then
            -- Allow the projectile to impact normally
            return true
        end
        return IsEnemy(self:GetArmy(),other:GetArmy())
    end,
}
end    