rott/kf_sources/ScrnBalanceSrv/Classes/ScrnM4AssaultRifle.uc
2026-07-14 20:27:09 +07:00

120 lines
3.9 KiB
Ucode

class ScrnM4AssaultRifle extends M4AssaultRifle
config(user);
var name ReloadShortAnim;
var float ReloadShortRate;
var transient bool bShortReload;
exec function ReloadMeNow()
{
local float ReloadMulti;
if(!AllowReload())
return;
if ( bHasAimingMode && bAimingRifle )
{
FireMode[1].bIsFiring = False;
ZoomOut(false);
if( Role < ROLE_Authority)
ServerZoomOut(false);
}
if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
ReloadMulti = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.GetReloadSpeedModifier(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo), self);
else
ReloadMulti = 1.0;
bIsReloading = true;
ReloadTimer = Level.TimeSeconds;
bShortReload = MagAmmoRemaining > 0;
if ( bShortReload )
ReloadRate = default.ReloadShortRate / ReloadMulti;
else
ReloadRate = default.ReloadRate / ReloadMulti;
if( bHoldToReload )
{
NumLoadedThisReload = 0;
}
ClientReload();
Instigator.SetAnimAction(WeaponReloadAnim);
if ( Level.Game.NumPlayers > 1 && KFGameType(Level.Game).bWaveInProgress && KFPlayerController(Instigator.Controller) != none &&
Level.TimeSeconds - KFPlayerController(Instigator.Controller).LastReloadMessageTime > KFPlayerController(Instigator.Controller).ReloadMessageDelay )
{
KFPlayerController(Instigator.Controller).Speech('AUTO', 2, "");
KFPlayerController(Instigator.Controller).LastReloadMessageTime = Level.TimeSeconds;
}
}
simulated function ClientReload()
{
local float ReloadMulti;
if ( bHasAimingMode && bAimingRifle )
{
FireMode[1].bIsFiring = False;
ZoomOut(false);
if( Role < ROLE_Authority)
ServerZoomOut(false);
}
if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
ReloadMulti = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.GetReloadSpeedModifier(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo), self);
else
ReloadMulti = 1.0;
bIsReloading = true;
if (MagAmmoRemaining <= 0)
{
PlayAnim(ReloadAnim, ReloadAnimRate*ReloadMulti, 0.1);
}
else if (MagAmmoRemaining >= 1)
{
PlayAnim(ReloadShortAnim, ReloadAnimRate*ReloadMulti, 0.1);
}
}
function AddReloadedAmmo()
{
local int a;
UpdateMagCapacity(Instigator.PlayerReplicationInfo);
a = MagCapacity;
if ( bShortReload )
a++; // 1 bullet already bolted
if ( AmmoAmount(0) >= a )
MagAmmoRemaining = a;
else
MagAmmoRemaining = AmmoAmount(0);
// this seems redudant -- PooSH
// if( !bHoldToReload )
// {
// ClientForceKFAmmoUpdate(MagAmmoRemaining,AmmoAmount(0));
// }
if ( PlayerController(Instigator.Controller) != none && KFSteamStatsAndAchievements(PlayerController(Instigator.Controller).SteamStatsAndAchievements) != none )
{
KFSteamStatsAndAchievements(PlayerController(Instigator.Controller).SteamStatsAndAchievements).OnWeaponReloaded();
}
}
defaultproperties
{
ReloadShortAnim="Reload"
ReloadShortRate=1.900000
MagCapacity=32
ReloadRate=2.794846
ReloadAnimRate=1.300000
FireModeClass(0)=Class'ScrnBalanceSrv.ScrnM4Fire'
Description="A compact assault rifle. Damage could be better, but accuracy, fast reload and a lot of ammo makes it a good choise in a battle."
PickupClass=Class'ScrnBalanceSrv.ScrnM4Pickup'
PlayerViewPivot=(Pitch=28,Yaw=7)
ItemName="M4 SE"
}