//=============================================================================
// sgSupplier.
// * Revised by 7DS'Lust
//=============================================================================
class sgSupplier extends sgEquipmentSupplier;


function Supply(Pawn target)
{

    local int       numWeapons,
                    i;
    local Inventory inv;

if (bDisabledByEMP){return;}

    if ( !default.ClassesLoaded )
        LoadWeaponClasses();

    numWeapons = GetWeaponCount();

    for ( i = 0; i < numWeapons; i++ )
    {
        if ( default.WeaponClasses[i] == None )
            continue;

        inv = target.FindInventoryType(default.WeaponClasses[i]);
        if ( inv != None && Weapon(inv) != None &&
          Weapon(inv).AmmoType != None )
        {
            if ( Weapon(inv).AmmoType.AmmoAmount <
              Weapon(inv).PickupAmmoCount / 2 )
                Weapon(inv).AmmoType.AmmoAmount =
                  Weapon(inv).PickupAmmoCount / 2;
            else if ( FRand() < float(Weapon(inv).AmmoType.MaxAmmo) / 400 )
                Weapon(inv).AmmoType.AmmoAmount = FMin(
                  Weapon(inv).AmmoType.AmmoAmount + 1 +
                  int(FRand()*Grade/2*EquipRate),
                  Weapon(inv).AmmoType.MaxAmmo);
        }
    }

    inv = target.FindInventoryType(class'sgArmor');
    if ( inv == None )
    {
        inv = Spawn(class'sgArmor');
        if ( inv != None )
            inv.GiveTo(target);
    }
    if ( inv != None && FRand() < 0.1 + (Grade/15) && inv.Charge < 25 +
      Grade*25 )
        inv.Charge = FMin(inv.Charge + 1, 25 + grade * 25 );

    if ( FRand() < 0.2 )
        target.PlaySound(sound'SiegeUltimateRC7UB01Media.sgStockUp', SLOT_Misc,
          target.SoundDampening*2.5);
}

defaultproperties
{
    EquipRate=1.25
    AnnounceImmunity=True
    
    BuildingName="Supplier"
    BuildCost=300
    BuildTime=45.00
    MaxEnergy=2500.00
    Model=LodMesh'Botpack.ShockWavem'
    SkinRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.MotionAlarmSpriteT0'
    SkinBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.MotionAlarmSpriteT1'
    SkinGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.MotionAlarmSpriteT2'
    SkinYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.MotionAlarmSpriteT3'
    SpriteRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.ContainerSpriteTeam0'
    SpriteBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.ContainerSpriteTeam1'
    SpriteGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.ContainerSpriteTeam2'
    SpriteYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.ContainerSpriteTeam3'
    DSofMFX=2.00
    MFXrotX=(Pitch=5000,Yaw=5000,Roll=5000),
    MultiSkins(0)=Texture'SiegeUltimateRC7UB01Media.GFX.sgSupSpriteT0'
    MultiSkins(1)=Texture'SiegeUltimateRC7UB01Media.GFX.sgSupSpriteT1'
    MultiSkins(2)=Texture'SiegeUltimateRC7UB01Media.GFX.sgSupSpriteT2'
    MultiSkins(3)=Texture'SiegeUltimateRC7UB01Media.GFX.sgSupSpriteT3'
}
