require "Insurgent/InsurgentTraitDefinitions"

LoadoutMachinegunnerTrait = CreateInsurgentTrait()
LoadoutMachinegunnerTrait.name = "LoadoutMachinegunner"
LoadoutMachinegunnerTrait.insurgentExclusive = true
LoadoutMachinegunnerTrait.mutualExclusions = {"LoadoutRifleman", "LoadoutMarksman", "LoadoutAssault", "LoadoutRecon"}
LoadoutMachinegunnerTrait.description  = getText("UI_trait_LoadoutMachinegunnerDesc_BRITA_VERSION")

function LoadoutMachinegunnerTrait.Create()
    local lMachinegunner = TraitFactory.addTrait("LoadoutMachinegunner", getText("UI_trait_LoadoutMachinegunner"), 6, LoadoutMachinegunnerTrait.description, false, false);
    lMachinegunner:addXPBoost(Perks.Strength, 1);
    return lMachinegunner;
end

function LoadoutMachinegunnerTrait.OnNewGame(player)
    if not player:HasTrait("LoadoutMachinegunner") then
        return
    end

    local weapon = InsurgentWeaponUtil.addWeapon(player, "Base.M249", {"Base.Sight_Aimpoint", "Base.Sling_3", "Base.Compensator", "Base.Bipod"})
    InsurgentWeaponUtil.addMags(player, "Base.556Belt", 2)
    InsurgentWeaponUtil.equipAndFullyLoadWeapon(player, weapon, "Base.556Belt")
end

function LoadoutMachinegunnerTrait.RegisterEvents()
    Events.OnNewGame.Add(LoadoutMachinegunnerTrait.OnNewGame)
end