require "Insurgent/InsurgentTraitDefinitions"

LoadoutMachinegunnerTrait = CreateInsurgentTrait()
LoadoutMachinegunnerTrait.name = "LoadoutMachinegunner"
LoadoutMachinegunnerTrait.insurgentExclusive = true
LoadoutMachinegunnerTrait.mutualExclusions = {"LoadoutRifleman", "LoadoutMarksman", "LoadoutAssault", "LoadoutRecon"}
LoadoutMachinegunnerTrait.description  = getText("UI_trait_LoadoutMachinegunnerDesc_FIREARMSB41_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.M60", {"Base.RedDot", "Base.Sling", "Base.RecoilPad"})
    InsurgentWeaponUtil.addMags(player, "Base.M60Mag", 2)
    InsurgentWeaponUtil.equipAndFullyLoadWeapon(player, weapon, "Base.M60Mag")
end

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