#Conditional Hooks
$Application: FS2_Open

$On Gameplay Start:
[
    antihuman_var = mn.SEXPVariables["antihuman"]
    weaponlevel_var = mn.SEXPVariables["WeaponLevel"]
]

$On Weapon Collision:
[
    -- no need to process if this isn't the right mission or if we already switched
    if not antihuman_var:isValid() or not weaponlevel_var:isValid() or antihuman_var.Value ~= 0 then
        return
    end

    if not alpha_1 then
        alpha_1 = mn.Ships["Alpha 1"]
        alpha_2 = mn.Ships["Alpha 2"]
        alpha_3 = mn.Ships["Alpha 3"]
        alpha_4 = mn.Ships["Alpha 4"]
        friendly = mn.Teams["Friendly"]
    end

    weapon = hv.Object
    target = hv.Self
    hitter = weapon.Parent

    -- must be the player, and don't check the immediate wing
    if (hitter ~= alpha_1) or (target == alpha_2 or target == alpha_3 or target == alpha_4) then
        return
    end
    
    if (target:getBreedName() == "Ship") then
        -- see if we hit a friendly
        if target.Team == friendly then
            weaponlevel_var.Value = weaponlevel_var.Value + weapon.Class.Damage
        end
    end
]

#End
