## XIII
Class Magnum

source: C:\XIII\XIII\Classes\magnum.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Inventory
             |
             +--Engine.Weapon
                |
                +--XIII.XIIIWeapon
                   |
                   +--XIII.Magnum

Direct Known Subclasses:MagnumPlus

class Magnum
extends XIII.XIIIWeapon

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`bool` | `bAltFiring` to play altfiring anim whule using fire behaviour

States
ClientFiring, NormalFire

Function Summary
`simulated` | `AltFire(float Value)`
    //_____________________________________________________________________________
`void` | `Finish()`
    //_____________________________________________________________________________
    // Finish a sequence
`simulated` | `Fire(float Value)`
    //_____________________________________________________________________________
`string` | `GetAmmoText(out int)`
    //_____________________________________________________________________________
    // ELR Text to be displayed in HUD
`Name` | `GetBaseWeaponBone()`
    //_____________________________________________________________________________
`bool` | `HasAltAmmo()`
    //_____________________________________________________________________________
`simulated` | `PlayFiring()`
    //_____________________________________________________________________________
`float` | `RateSelf()`
    //_____________________________________________________________________________
    // FRD
`void` | `ServerAltFire()`
    //_____________________________________________________________________________
`void` | `ServerFire()`
    //_____________________________________________________________________________

State ClientFiring Function Summary

State NormalFire Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class Magnum extends XIIIWeapon;
    00005
    00006	var bool bAltFiring;  // to play altfiring anim whule using fire behaviour
    00007
    00008	//_____________________________________________________________________________
    00009	simulated function bool HasAltAmmo()
    00010	{ // because we can stun only if we have ammo (bAllowEmptyShot=false, must down weapon after last fire)
    00011	    return HasAmmo();
    00012	}
    00013
    00014	//_____________________________________________________________________________
    00015	// ELR Text to be displayed in HUD
    00016	simulated function string GetAmmoText(out int bDrawbulletIcon)
    00017	{
    00018	    local string AmmoText,AltAmmoText;
    00019
    00020	    bDrawbulletIcon = 1;
    00021
    00022	    // Setup ammotext
    00023	    AmmoText = ReLoadCount@"|"@(Ammotype.AmmoAmount-ReLoadCount);
    00024	    return AmmoText;
    00025	}
    00026
    00027	//_____________________________________________________________________________
    00028	simulated function Name GetBaseWeaponBone()
    00029	{
    00030	    return 'Magnum';
    00031	}
    00032
    00033	//_____________________________________________________________________________
    00034	// FRD
    00035	function float RateSelf()
    00036	{
    00037	   local float distance;
    00038
    00039	    if ( !HasAmmo() )
    00040	      return -2;
    00041	    if (instigator.controller.enemy!=none)
    00042	    {
    00043	      distance=Vsize(instigator.controller.enemy.location-instigator.location);
    00044	      if (distance>1766)
    00045	        return 0.31;
    00046	    }
    00047	    return AIRating;
    00048	}
    00049
    00050	//_____________________________________________________________________________
    00051	simulated function Fire( float Value )
    00052	{
    00053	    bAltFiring = false;
    00054	    Super.Fire(0.0);
    00055	}
    00056
    00057	//_____________________________________________________________________________
    00058	simulated function AltFire( float Value )
    00059	{
    00060	    if ( (XIIIPawn(Owner).LHand != none) && XIIIPawn(Owner).LHand.bActive )
    00061	      return;
    00062	    bAltFiring = true;
    00063	    Super.Fire(4.0);
    00064	}
    00065
    00066	//_____________________________________________________________________________
    00067	function ServerFire()
    00068	{
    00069	    bAltFiring = false;
    00070	    Super.ServerFire();
    00071	}
    00072
    00073	//_____________________________________________________________________________
    00074	function ServerAltFire()
    00075	{
    00076	    bAltFiring = true;
    00077	    Super.ServerFire();
    00078	}
    00079
    00080	//_____________________________________________________________________________
    00081	// Finish a sequence
    00082	function Finish()
    00083	{
    00084	    local bool bForce, bForceAlt;
    00085	    if ( DBWeap ) Log("> Finish called w/ bForceFire="$bForceFire@"& bForceReLoad="$bForceReLoad@"in state"@GetStateName());
    00086
    00087	    if ( HasAmmo() && (bAutoReload || !Level.bLonePlayer) && NeedsToReload() )
    00088	    {
    00089	      GotoState('Reloading');
    00090	      return;
    00091	    }
    00092
    00093	    bForce = bForceFire;
    00094	    bForceAlt = bForceAltFire;
    00095	    bForceFire = false;
    00096	    bForceAltFire = false;
    00097
    00098	    if ( bChangeWeapon )
    00099	    {
    00100	      GotoState('DownWeapon');
    00101	      return;
    00102	    }
    00103
    00104	    if ( (Instigator == None) || (Instigator.Controller == None) )
    00105	    {
    00106	      GotoState('');
    00107	      return;
    00108	    }
    00109
    00110	    if ( !Instigator.IsHumanControlled() )
    00111	    {
    00112	      if ( !HasAmmo() )
    00113	      {
    00114	        Instigator.Controller.SwitchToBestWeapon();
    00115	        if ( bChangeWeapon )
    00116	          GotoState('DownWeapon');
    00117	        else
    00118	          GotoState('Idle');
    00119	        return;
    00120	      }
    00121	      if ( NeedsToReload() )
    00122	      {
    00123	        GotoState('Reloading');
    00124	        return;
    00125	      }
    00126	      if ( Instigator.PressingFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) )
    00127	      {
    00128	        if ( Level.bLonePlayer )
    00129	          Global.LoneFire(0.0);
    00130	        else
    00131	          Global.ServerFire();
    00132	      }
    00133	      else if ( bAltFiring && Instigator.PressingAltFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) )
    00134	      {
    00135	        if ( Level.bLonePlayer )
    00136	          Global.LoneAltFire();
    00137	        else
    00138	          Global.ServerAltFire();
    00139	      }
    00140	      else
    00141	      {
    00142	        Instigator.Controller.StopFiring();
    00143	        GotoState('Idle');
    00144	      }
    00145	      return;
    00146	    }
    00147
    00148	    if ( !HasAmmo() && !HasAltAmmo() )
    00149	    {
    00150	//      Log("Finish, bAllowEmptyShot="$bAllowEmptyShot@"bLonePlayer=$"$Level.bLonePlayer);
    00151	      if ( !bAllowEmptyShot || !Level.bLonePlayer )
    00152	      {
    00153	        // if local player, switch weapon
    00154	        Instigator.Controller.SwitchToBestWeapon();
    00155	        if ( bChangeWeapon )
    00156	        {
    00157	          GotoState('DownWeapon');
    00158	          return;
    00159	        }
    00160	        else
    00161	          GotoState('Idle');
    00162	          return;
    00163	      }
    00164	    }
    00165	    if ( (Instigator.Weapon != self) || (!bUnderWaterWork && Pawn(Owner).HeadVolume.bWaterVolume)  )
    00166	      GotoState('Idle');
    00167	    else if ( (((StopFiringTime > Level.TimeSeconds) || Instigator.PressingFire()) && bAllowShot) || bForce )
    00168	    {
    00169	      if ( HasAmmo() && NeedsToReLoad() && CanReLoad() )
    00170	      {
    00171	//        Log("  in Finish Should send everybody to ReLoading there");
    00172	        GotoState('Reloading');
    00173	        ClientReLoad();
    00174	        return;
    00175	      }
    00176	      else if ( !CanReLoad() )
    00177	      {
    00178	        gotoState('Idle');
    00179	        return;
    00180	      }
    00181	      Global.ServerFire();
    00182	    }
    00183	    else if ( bAltFiring && bHaveAltFire && (bForceAlt || Instigator.PressingAltFire()) && bAllowShot )
    00184	    {
    00185	      if ( HasAmmo() && NeedsToReLoad() && CanReLoad() )
    00186	      {
    00187	//        Log("  in Finish Should send everybody to ReLoading there");
    00188	        GotoState('Reloading');
    00189	        ClientReLoad();
    00190	        return;
    00191	      }
    00192	      else if ( !CanReLoad() )
    00193	      {
    00194	        gotoState('Idle');
    00195	        return;
    00196	      }
    00197	      Global.ServerAltFire();
    00198	    }
    00199	    else
    00200	      GotoState('Idle');
    00201	}
    00202
    00203	//_____________________________________________________________________________
    00204	simulated state NormalFire
    00205	{
    00206	Begin:
    00207	  bAllowShot = bAltfiring;
    00208	  if ( DBWeap ) Log("  NormalFire Setting bAllowShot to"@bAllowShot);
    00209	}
    00210
    00211	//_____________________________________________________________________________
    00212	//Fire on the client side. This state is only entered on the network client of the player that is firing this weapon.
    00213	simulated state ClientFiring
    00214	{
    00215	Begin:
    00216	  bAllowShot = bAltfiring;
    00217	  if ( DBWeap ) Log("  ClientFiring Setting bAllowShot to"@bAllowShot);
    00218	}
    00219
    00220	//_____________________________________________________________________________
    00221	simulated function PlayFiring()
    00222	{
    00223	    if ( bAltFiring )
    00224	    {
    00225	      if ( HasAmmo() )
    00226	        PlayAnim(LoadedAltFiringAnim, 1.0);
    00227	      else
    00228	        PlayAnim(EmptyAltFiringAnim, 1.0);
    00229	      if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) )
    00230	        PlayFiringSound();
    00231
    00232	      if ( !HasAmmo() )
    00233	        return;
    00234
    00235	      IncrementFlashCount();
    00236	      if ( bDrawMuzzleflash )
    00237	        SetUpMuzzleFlash();
    00238	      return;
    00239
} 00240 // Log("PlayFiring call for"@self@"w/FiringMode="$FiringMode); 00241 if ( HasAmmo() ) 00242 PlayAnim(LoadedFiringAnim, 1.0); 00243 else 00244 PlayAnim(EmptyFiringAnim, 1.0); 00245 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 00246 PlayFiringSound(); 00247 00248 if ( !HasAmmo() ) 00249 return; 00250 00251 IncrementFlashCount(); 00252 if ( bDrawMuzzleflash ) 00253 SetUpMuzzleFlash(); 00254 } 00255 00256 // PickupClass=Class'XIII.magnumpick' 00257 // Icon=texture'XIIIMenu.MagnumIcon' 00258 00259 00260 defaultproperties 00261 { 00262 WeaponOnoClass=Class'XIDSpec.MagnumWeaponOno' 00263 bHaveAltFire=True 00264 bShouldGoThroughTraversable=True 00265 bHaveBoredSfx=True 00266 bDrawMuzzleFlash=True 00267 WHand=WHA_1HShot 00268 WeaponMode=WM_SemiAuto 00269 AmmoName=Class'XIII.c44Ammo' 00270 AltAmmoName=Class'XIII.c44Ammo' 00271 PickupAmmoCount=6 00272 ReloadCount=6 00273 MeshName="XIIIArmes.FpsMagnumM" 00274 FireOffset=(X=10.000000,Y=5.000000,Z=-3.000000) 00275 CrossHair=Texture'XIIIMenu.HUD.MireBeretta' 00276 TraceAccuracy=1.500000 00277 ShotTime=0.700000 00278 FiringMode="FM_1H" 00279 ReLoadNoise=0.000000 00280 LoadedAltFiringAnim="FireAlt" 00281 ViewFeedBack=(X=4.000000,Y=13.000000) 00282 RumbleFXNum=5 00283 FPMFRelativeLoc=(Y=18.000000,Z=6.000000) 00284 shaketime=4.000000 00285 ShakeVert=(Z=15.000000) 00286 ShakeSpeed=(X=500.000000,Y=500.000000,Z=500.000000) 00287 ShakeCycles=3.000000 00288 AIRating=0.550000 00289 TraceDist=100.000000 00290 hFireSound=Sound'XIIIsound.Guns__MagFire.MagFire__hMagFire' 00291 hReloadSound=Sound'XIIIsound.Guns__MagRel.MagRel__hMagRel' 00292 hNoAmmoSound=Sound'XIIIsound.Guns__MagDryFire.MagDryFire__hMagDry' 00293 hSelectWeaponSound=Sound'XIIIsound.Guns__MagSelWp.MagSelWp__hMagSelWp' 00294 hAltFireSound=Sound'XIIIsound.Guns__MagFire.MagFire__hMagFire' 00295 hActWaitSound=Sound'XIIIsound.Guns__MagWait.MagWait__hMagWait' 00296 MuzzleScale=0.750000 00297 FlashOffsetY=0.150000 00298 FlashOffsetX=0.150000 00299 InventoryGroup=3 00300 PickupClassName="XIII.magnumpick" 00301 PlayerViewOffset=(X=5.000000,Y=3.500000,Z=-4.000000) 00302 ThirdPersonRelativeLocation=(X=17.000000,Y=-2.500000,Z=5.000000) 00303 AttachmentClass=Class'XIII.MagnumAttach' 00304 ItemName="44 SPECIAL" 00305 DrawScale=0.300000 00306 }

End Source Code