I want the weapon to fire without delay after every single shot. Like the code I'm posting, the gun fires after quite some delay , but is there a code I can insert in DeusExWeapon.u to make it fire after every single shot. Also, when a pawn fires it, the muzzle flash disappears. Whereas when the player fires it, it appears. I made a custom muzzle flash sprite and implemented it.
Code: Select all
//=============================================================================
// WeaponAutoRifle.
//=============================================================================
class WeaponAutoRifle extends GESWeapon;
var float mpRecoilStrength;
simulated state ClientFiring
{
Begin:
if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
{
if (!bAutomatic)
{
bFiring = False;
FinishAnim();
}
if (Owner != None)
{
if (Owner.IsA('DeusExPlayer'))
{
bFiring = False;
if (DeusExPlayer(Owner).bAutoReload)
{
bClientReadyToFire = False;
bInProcess = False;
if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
CycleAmmo();
ReloadAmmo();
GotoState('SimQuickFinish');
}
else
{
if (bHasMuzzleFlash)
EraseMuzzleFlashTexture();
IdleFunction();
GotoState('SimQuickFinish');
}
}
else if (Owner.IsA('ScriptedPawn'))
{
bFiring = False;
}
}
else
{
if (bHasMuzzleFlash)
EraseMuzzleFlashTexture();
IdleFunction();
GotoState('SimQuickFinish');
}
}
Sleep(GetSimShotTime());
if (bAutomatic)
{
SimGenerateBullet();
Goto('Begin');
}
bFiring = False;
if(Pawn(Owner)!=None)
{
if(Pawn(Owner).bFire==0)
{
FinishAnim();
}
}
bInProcess = False;
Done:
bInProcess = False;
bFiring = False;
SimFinish();
}
simulated function PlaySelectiveFiring()
{
local Pawn aPawn;
local float rnd;
local Name anim;
anim = 'Shoot';
if (DeusExPlayer(Owner) == DeusExPlayer(GetPlayerPawn()))
{
PlayAnim('Shoot',,0.00);
}
}
state NormalFire
{
function float GetShotTime()
{
local float mult, sTime;
if (ScriptedPawn(Owner) != None)
return ShotTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
else
{
// AugCombat decreases shot time
mult = 1.0;
if (bHandToHand && DeusExPlayer(Owner) != None)
{
mult = 1.0 / DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
if (mult == -1.0)
mult = 1.0;
}
sTime = ShotTime * mult;
return (sTime);
}
}
Begin:
if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
{
if (Owner != None)
{
if (Owner.IsA('DeusExPlayer'))
{
bFiring = False;
// should we autoreload?
if (DeusExPlayer(Owner).bAutoReload)
{
// auto switch ammo if we're out of ammo and
// we're not using the primary ammo
FinishAnim();
if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
CycleAmmo();
ReloadAmmo();
}
else
{
if (bHasMuzzleFlash)
EraseMuzzleFlashTexture();
GotoState('Idle');
}
}
else if (Owner.IsA('ScriptedPawn'))
{
bFiring = False;
ReloadAmmo();
}
}
else
{
if (bHasMuzzleFlash)
EraseMuzzleFlashTexture();
GotoState('Idle');
}
}
Sleep(GetShotTime());
bFiring = False;
if(Pawn(Owner)!=None)
{
if(Pawn(Owner).bFire==0)
{
FinishAnim();
}
}
ReadyToFire();
Done:
bFiring = False;
Finish();
}
#exec AUDIO IMPORT FILE="Sounds\ak47-1.wav" NAME="AK47Fire" Group="Weapons"
#exec AUDIO IMPORT FILE="Sounds\safety.wav" NAME="SafetyOff" Group="Weapons"
#exec AUDIO IMPORT FILE="Sounds\ak47_boltpull.wav" NAME="AK47BoltPull" Group="Weapons"
#exec AUDIO IMPORT FILE="Sounds\ak47_magin.wav" NAME="AK47MagIn" Group="Weapons"
#exec AUDIO IMPORT FILE="Sounds\ak47_magout.wav" NAME="AK47MagOut" Group="Weapons"
#exec AUDIO IMPORT FILE="Sounds\ak47_magtap.wav" NAME="AK47MagTap" Group="Weapons"
simulated function AK74MagOut()
{
Owner.PlaySound(Sound'MP5S.AK47MagOut', SLOT_None,,, 1024);
}
simulated function AK74MagIn()
{
Owner.PlaySound(Sound'MP5S.AK47MagIn', SLOT_None,,, 1024);
}
simulated function AK74MagTap()
{
Owner.PlaySound(Sound'MP5S.AK47MagTap', SLOT_None,,, 1024);
}
simulated function AK74BoltPull()
{
Owner.PlaySound(Sound'MP5S.AK47BoltPull', SLOT_None,,, 1024);
}
simulated function AK74BoltBack()
{
Owner.PlaySound(Sound'MP5S.DesertEagleUnlock', SLOT_None,,, 1024);
}
simulated function PreBeginPlay()
{
Super.PreBeginPlay();
// If this is a netgame, then override defaults
if ( Level.NetMode != NM_StandAlone )
{
HitDamage = mpHitDamage;
BaseAccuracy = mpBaseAccuracy;
ReloadTime = mpReloadTime;
AccurateRange = mpAccurateRange;
MaxRange = mpMaxRange;
ReloadCount = mpReloadCount;
// Tuned for advanced -> master skill system (Monte & Ricardo's number) client-side
recoilStrength = 0.75;
}
}