require "Insurgent/InsurgentTraitDefinitions"

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

function LoadoutMarksmanTrait.Create()
    local lMarksman = TraitFactory.addTrait("LoadoutMarksman", getText("UI_trait_LoadoutMarksman"), 4, LoadoutMarksmanTrait.description, false, false);
    lMarksman:addXPBoost(Perks.Aiming, 1);
    return lMarksman;
end

function LoadoutMarksmanTrait.OnNewGame(player)
    if not player:HasTrait("LoadoutMarksman") then
        return
    end

    local weapon = InsurgentWeaponUtil.addWeapon(player, "Base.AssaultRifle2", {"Base.x4Scope", "Base.Laser", "Base.RecoilPad"})
    InsurgentWeaponUtil.addMags(player, "Base.M14Clip", 8)
    InsurgentWeaponUtil.equipAndFullyLoadWeapon(player, weapon, "Base.M14Clip")
end

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