## XIII
Class XIIIWeapon

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

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

Direct Known Subclasses:ArbaleteX3, Bazook, Beretta, DecoWeapon, Fists, FusilChasse, FusilPompe, FusilSnipe, Grenad, GrenadB, LHarpon, MiniUzi, TKnife, Arbalete, Kalash, M16, M60, Magnum, FlashBangBot, MPBomb, FlashBang

class XIIIWeapon
extends Engine.Weapon

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

Variables
`WeaponOno` | `MyWeaponOno` to not handle keep alt fire pressed (M60, Kalash).
`class` | `WeaponOnoClass` to not handle keep alt fire pressed (M60, Kalash).
`bool` | `bSpecialAltFire` to not handle keep alt fire pressed (M60, Kalash).

States
Idle, AltZooming, Zooming, MySlave, DownWeapon, GiveAmmo, Active, while, for, for, WaitForMasterDown, for, for, WaitForSlaveReload, for, for, WaitForSlaveDown, for, for, WaitForMasterReload, for, Reloading, ClientAltFiring, ClientFiring, NormalAltFire, NormalFire

Function Summary
`void` | `AltFeedBack()`
    //_____________________________________________________________________________
`void` | `AltFinish()`
    //_____________________________________________________________________________
    // Finish a sequence
`simulated` | `AltFire(float Value)`
    //_____________________________________________________________________________
`bool` | `AltNeedsToReload()`
    //_____________________________________________________________________________
`bool` | `CanReLoad()`
    //_____________________________________________________________________________
`void` | `CauseAltFire()`
    //_____________________________________________________________________________
`simulated` | `ClientAltFinish()`
    //_____________________________________________________________________________
`simulated` | `ClientFinish()`
    //_____________________________________________________________________________
`simulated` | `DrawTraceBullet(Canvas C, float XE, float YE)`
    //_____________________________________________________________________________
`simulated` | `DrawZoomedCrosshair(Canvas C)`
    //_____________________________________________________________________________
`void` | `FeedBack()`
    //_____________________________________________________________________________
`void` | `Finish()`
    //_____________________________________________________________________________
    // Finish a sequence
`simulated` | `Fire(float Value)`
    //_____________________________________________________________________________
    // 2350
`vector` | `GetAltFireStart(vector X, vector Y, vector Z)`
    //_____________________________________________________________________________
`string` | `GetAmmoText(out int)`
    //_____________________________________________________________________________
    // ELR Text to be displayed in HUD
`Name` | `GetBaseWeaponBone()`
    //_____________________________________________________________________________
`vector` | `GetFireStart(vector X, vector Y, vector Z)`
    //_____________________________________________________________________________
    simulated
`bool` | `HasScope()`
    //_____________________________________________________________________________
`bool` | `HasSilencer()`
    //_____________________________________________________________________________
`simulated` | `LocalAltFire()`
    //_____________________________________________________________________________
`simulated` | `LocalFire()`
    //_____________________________________________________________________________
`void` | `LoneAltFire()`
    //_____________________________________________________________________________
`void` | `LoneFire(float value)`
    //_____________________________________________________________________________
    // 2296
`bool` | `NeedsToReload()`
    //_____________________________________________________________________________
`void` | `NewWeaponNotify(Pawn Other)`
    //_____________________________________________________________________________
`Weapon` | `NextWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)`
    //_____________________________________________________________________________
`simulated` | `NotifyOwnerKilled(Controller Killer)`
    //_____________________________________________________________________________
`Weapon` | `PrevWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)`
    //_____________________________________________________________________________
`void` | `ProjectileAltFire()`
    //_____________________________________________________________________________
`void` | `ProjectileFire()`
    //_____________________________________________________________________________
`void` | `RealTraceAltFire(float Accuracy, float YOffset, float ZOffset)`
    //_____________________________________________________________________________
`void` | `RealTraceFire(float Accuracy, float YOffset, float ZOffset)`
    //_____________________________________________________________________________
    // 1228
`Weapon` | `RecommendWeapon(out float)`
    //_____________________________________________________________________________
`simulated` | `RumbleFX()`
    //_____________________________________________________________________________
`void` | `ServerAltFire()`
    //_____________________________________________________________________________
`void` | `ServerFire()`
    //_____________________________________________________________________________
`void` | `SetUpDual(Weapon Dual, Pawn other)`
    //_____________________________________________________________________________
`simulated` | `SetupMuzzleFlash()`
    //_____________________________________________________________________________
`simulated` | `SlaveBringUp()`
    //_____________________________________________________________________________
`void` | `StaticParseDynamicLoading(LevelInfo MyLI)`
    //_____________________________________________________________________________
`simulated` | `SwitchSlave(bool NewEnableSlave)`
    //_____________________________________________________________________________
`void` | `TraceAltFire(float Accuracy, float YOffset, float ZOffset)`
    //_____________________________________________________________________________
`void` | `TraceFire(float Accuracy, float YOffset, float ZOffset)`
    //_____________________________________________________________________________
    // 1236
`simulated` | `UnFire(float Value)`
    //_____________________________________________________________________________
`simulated` | `UpDatesilencer()`
    //_____________________________________________________________________________

State Idle Function Summary
`bool` | `PutDown()`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State AltZooming Function Summary

State Zooming Function Summary

State MySlave Function Summary

State DownWeapon Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`

State GiveAmmo Function Summary

State Active Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`

State while Function Summary

State for Function Summary

State for Function Summary

State WaitForMasterDown Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State for Function Summary

State for Function Summary

State WaitForSlaveReload Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State for Function Summary

State for Function Summary

State WaitForSlaveDown Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State for Function Summary

State for Function Summary

State WaitForMasterReload Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State for Function Summary

State Reloading Function Summary
`bool` | `PutDown()`
`void` | `ServerAltFire()`
`void` | `ServerFire()`
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`
`void` | `ClientForceReload()`
`void` | `ServerForceReload()`

State ClientAltFiring Function Summary
`void` | `AltFire(float Value)`
`void` | `Fire(float Value)`

State ClientFiring Function Summary

State NormalAltFire Function Summary

State NormalFire Function Summary
`void` | `Timer()`

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class XIIIWeapon extends Weapon
    00005	  config
    00006	  abstract;
    00007
    00008	var bool bSpecialAltFire;     // to not handle keep alt fire pressed (M60, Kalash).
    00009
    00010	var Config class<WeaponOno> WeaponOnoClass;
    00011	var WeaponOno MyWeaponOno;
    00012
    00013	//_____________________________________________________________________________
    00014	Static function StaticParseDynamicLoading(LevelInfo MyLI)
    00015	{
    00016	    Super.StaticParseDynamicLoading(MyLI);
    00017
    00018	    if ( default.bUseSIlencer )
    00019	    {
    00020	      MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = class'XIII.BerettaSilencer';
    00021	      class'XIII.BerettaSilencer'.Static.StaticParseDynamicLoading(MyLI);
    00022	    }
    00023	}
    00024
    00025	//_____________________________________________________________________________
    00026	simulated event postbeginplay()
    00027	{
    00028	    super.postbeginplay();
    00029	//    log("===="@self@" (class"@Class$") PostBeginPlay, WeaponOnoClass="$WeaponOnoClass);
    00030	    if ( WeaponOnoClass != none )
    00031	      MyWeaponOno = Spawn(WeaponOnoClass, self);
    00032	}
    00033
    00034	//_____________________________________________________________________________
    00035	simulated event destroyed()
    00036	{
    00037	    Super.Destroyed();
    00038	    if ( MyWeaponOno != none )
    00039	      MyWeaponOno.Destroy();
    00040	}
    00041
    00042	//_____________________________________________________________________________
    00043	simulated event RenderOverlays( canvas Canvas )
    00044	{
    00045	    local rotator NewRot, R;
    00046	    local bool bPlayerOwner;
    00047	    local int Hand, PitchViewOffset;
    00048	    local  PlayerController PlayerOwner;
    00049
    00050	    if ( bDrawZoomedCrosshair )
    00051	    {
    00052	      DrawZoomedCrosshair(Canvas);
    00053	      if ( !bHidden )
    00054	      { // hide weapon in zoom but don't change bRendered to allow back when unzom
    00055	        bHidden = true;
    00056	        RefreshDisplaying();
    00057	      }
    00058	      return;
    00059	    }
    00060
    00061	    if ( Instigator == None )
    00062	      return;
    00063
    00064	    if ( bRendered && bHidden )
    00065	    {
    00066	      bHidden = false;
    00067	      RefreshDisplaying();
    00068	    }
    00069
    00070	    PlayerOwner = PlayerController(Instigator.Controller);
    00071
    00072	    if ( PlayerOwner != None )
    00073	    {
    00074	      bPlayerOwner = true;
    00075	      Hand = PlayerOwner.Handedness;
    00076	      if (  Hand == 2 )
    00077	        return;
    00078	    }
    00079
    00080	    if ( (FirstPersonMF == none) && bDrawMuzzleFlash && (MFTexture != none) && (Level.NetMode != NM_DedicatedServer) )
    00081	    {
    00082	      FirstPersonMF = spawn(FirstPersonMFClass, self);
    00083	      FirstPersonMF.Texture = MFTexture;
    00084	//        FirstPersonMF.SetDrawScale(MuzzleScale * MuzzleFlashSize / MFTexture.USize * 0.03);
    00085	      FirstPersonMF.SetDrawScale(MuzzleScale * 0.2); // no more scale because mesh instead of texture
    00086	      AttachToBone(FirstPersonMF,GetBaseWeaponBone());
    00087	      FirstPersonMF.SetRelativeLocation(FPMFRelativeLoc);
    00088	      FirstPersonMF.SetRelativeRotation(FPMFRelativeRot);
    00089	      FirstPersonMF.SetDrawType(DT_None);
    00090	    }
    00091
    00092	    if ( bDrawMuzzleFlash && (FirstPersonMF != none) )
    00093	    {
    00094	      FirstPersonMF.SetDrawType(DT_None); // use DrawType instead of bHidden because attached
    00095	      if ( bMuzzleFlash && !bZoomed && (MFTexture != None) )
    00096	      {
    00097	//          Log("Should muzzleflash");
    00098	        if ( !bSetFlashTime )
    00099	        {
    00100	          bSetFlashTime = true;
    00101	          FlashTime = Level.TimeSeconds + FlashLength;
    00102	        }
    00103	        else if ( FlashTime < Level.TimeSeconds )
    00104	          bMuzzleFlash = false;
    00105	        if ( bMuzzleFlash )
    00106	        {
    00107	          if ( !HasSilencer() )
    00108	          {
    00109	            FirstPersonMF.SetDrawType(FirstPersonMF.default.DrawType);
    00110	          }
    00111	          if ( AmmoType.bDrawTracingBullets && bTracebullets)
    00112	            DrawTraceBullet(Canvas, Canvas.ClipX * Hand * FlashOffsetX, Canvas.ClipY * FlashOffsetY);
    00113	        }
    00114	      }
    00115	      else
    00116	        bSetFlashTime = false;
    00117	    }
    00118
    00119	    SetLocation( Instigator.Location + Instigator.CalcDrawOffset(self) );
    00120
    00121	    // Handle view pitch change
    00122	    PitchViewOffset = Instigator.GetViewRotation().Pitch;
    00123	    if ( PitchViewOffset > 32767 )
    00124	      PitchViewOffset = PitchViewOffset - 65535;
    00125	    PitchViewOffset /= 35;
    00126
    00127	    NewRot = Instigator.GetViewRotation() + rot(1,0,0)*PitchViewOffset;
    00128	    if ( ShouldDrawCrosshair() )
    00129	      NewRot = rotator(vector(NewRot) * 4 + XIIIPlayerController(Instigator.Controller).ViewAdjustAim*(1.0-abs(XIIIPlayerController(Instigator.Controller).ViewAdjustAim.z)));
    00130
    00131	    // Handle fast turn visual offset
    00132	    R = Normalize(rot(0,1,0) * 350 * (PlayerController(Instigator.controller).PlayerInput.WeaponViewTurnAcc));
    00133	    NewRot += R;
    00134
    00135	    if ( Hand == 0 )
    00136	      newRot.Roll = 2 * Default.Rotation.Roll;
    00137	    else
    00138	      newRot.Roll = Default.Rotation.Roll * Hand;
    00139
    00140	    SetRotation(newRot);
    00141
    00142	    if ( Pawn(Owner).IsLocallyControlled() && (PlayerController(Pawn(Owner).Controller).DefaultFOV == PlayerController(Pawn(Owner).Controller).DesiredFOV) )
    00143	    {
    00144	      SetBase(Pawn(Owner).Controller);
    00145	      if ( (MySlave != none) && MySlave.bRendered && bEnableSlave )
    00146	        MySlave.RenderSlaveOverlays(Canvas);
    00147	    }
    00148	    if ( MyWeaponOno != none )
    00149	      MyWeaponOno.RenderOverlays(Canvas);
    00150	}
    00151
    00152	//_____________________________________________________________________________
    00153	// If this is called then just setup pos & render because primary weapon is already rendered
    00154	simulated event RenderSlaveOverlays( canvas Canvas )
    00155	{
    00156	    local bool bPlayerOwner;
    00157	    local int Hand;
    00158	    local  PlayerController PlayerOwner;
    00159
    00160	//    if ( DBDual ) Log(">> RenderSlaveOverlays PlayerViewOffset="$PlayerViewOffset);
    00161
    00162	    if ( bRendered && bHidden )
    00163	    {
    00164	      bHidden = false;
    00165	      RefreshDisplaying();
    00166	    }
    00167
    00168	    PlayerOwner = PlayerController(Instigator.Controller);
    00169
    00170	    if ( PlayerOwner != None )
    00171	    {
    00172	      bPlayerOwner = true;
    00173	      Hand = PlayerOwner.Handedness;
    00174	      if (  Hand == 2 )
    00175	        return;
    00176	    }
    00177
    00178	    if ( (FirstPersonMF == none) && bDrawMuzzleFlash && (MFTexture != none) && (Level.NetMode != NM_DedicatedServer) )
    00179	    {
    00180	      FirstPersonMF = spawn(FirstPersonMFClass, self);
    00181	      FirstPersonMF.Texture = MFTexture;
    00182	//        FirstPersonMF.SetDrawScale(MuzzleScale * MuzzleFlashSize / MFTexture.USize * 0.03);
    00183	      FirstPersonMF.SetDrawScale(MuzzleScale * 0.2); // no more scale because mesh instead of texture
    00184	      AttachToBone(FirstPersonMF,GetBaseWeaponBone());
    00185	      FirstPersonMF.SetRelativeLocation(FPMFRelativeLoc);
    00186	      FirstPersonMF.SetRelativeRotation(FPMFRelativeRot);
    00187	      FirstPersonMF.SetDrawType(DT_None);
    00188	    }
    00189
    00190	    if ( bDrawMuzzleFlash && ( FirstPersonMF != none) )
    00191
{ 00192 FirstPersonMF.SetDrawType(DT_None); // use DrawType instead of bHidden because attached 00193 if ( bMuzzleFlash && !bZoomed && (MFTexture != None) ) 00194 { 00195 if ( !bSetFlashTime ) 00196 { 00197 bSetFlashTime = true; 00198 FlashTime = Level.TimeSeconds + FlashLength; 00199 } 00200 else if ( FlashTime < Level.TimeSeconds ) 00201 bMuzzleFlash = false; 00202 if ( bMuzzleFlash ) 00203 { 00204 if ( !HasSilencer() ) 00205 FirstPersonMF.SetDrawType(FirstPersonMF.default.DrawType); 00206 if ( AmmoType.bDrawTracingBullets && bTracebullets) 00207 DrawTraceBullet(Canvas, -Canvas.ClipX * Hand * FlashOffsetX, Canvas.ClipY * FlashOffsetY); 00208 } 00209 } 00210 else 00211 bSetFlashTime = false; 00212 } 00213 00214 SetLocation( Instigator.Location + Instigator.CalcDrawOffset(self) ); 00215 SetRotation(SlaveOf.Rotation); 00216 SetBase(Pawn(Owner).Controller); 00217 } 00218 00219 //_____________________________________________________________________________ 00220 simulated function DrawZoomedCrosshair(Canvas C) 00221 { 00222 local float XSize, YSize; 00223 local float fDrawScale; 00224 local float fZoomFactor; 00225 local string sZoomFactor; 00226 local float fZoomStability; 00227 00228 fDrawScale = C.ClipX/640.0; 00229 00230 // ::TODO:: FIX this on ps2 for on-line ? 00231 // if ( (Level.Game != none) && (XIIIGameInfo(Level.Game).Plateforme == PF_PS2) ) 00232 fDrawScale *= 256 / ZCrossHair.USize; // on PS2 the texture is only 128x128 so scale it 00233 // fDrawScale *= 2; // on PS2 the texture is only 128x128 so scale it 00234 00235 fZoomStability = XIIIPlayerController(Pawn(owner).Controller).fSniperPrecision * 2.0 / 3.0; 00236 fZoomFactor = PlayerController(Pawn(owner).Controller).DefaultFOV / PlayerController(Pawn(owner).controller).FOVAngle; 00237 sZoomFactor = "zoom x"$int(fZoomFactor)$"."$int( (fZoomFactor-int(fZoomFactor))*100 ); 00238 00239 XSize = ZCrossHair.USize*fDrawScale; 00240 00241 C.Style = ERenderStyle.STY_Alpha; 00242 C.SetDrawColor(255,0,0,255); 00243 C.SetPos(0.50 * C.ClipX - ZCrosshairDot.USize/2.0, 0.50 * C.ClipY - ZCrosshairDot.VSize/2.0); 00244 C.DrawIcon(ZCrosshairDot, 1.0); 00245 00246 C.SetDrawColor(255,255,255,255); 00247 C.SetPos(0.50 * C.ClipX-0.5 - XSize, 0.50 * C.ClipY-0.5 - XSize); 00248 C.DrawTile(ZCrossHair, XSize, XSize, 0, 0,-ZCrossHair.USize, ZCrossHair.VSize); 00249 C.DrawTile(ZCrossHair, XSize, XSize, 0, 0,ZCrossHair.USize, ZCrossHair.VSize); 00250 C.SetPos(0.50 * C.ClipX-0.5 - XSize, 0.50 * C.ClipY-0.5); 00251 C.DrawTile(ZCrossHair, XSize, XSize, 0, 0,-ZCrossHair.USize, -ZCrossHair.VSize); 00252 C.DrawTile(ZCrossHair, XSize, XSize, 0, 0,ZCrossHair.USize, -ZCrossHair.VSize); 00253 00254 // screen cover w/ a part of the ZCrosshair texture 00255 YSize=0.5*C.ClipY - XSize; 00256 XSize=0.5*C.ClipX - XSize; 00257 // Left Part 00258 C.SetPos(0, 0); 00259 C.DrawTile(ZCrossHair, XSize-0.5, C.ClipY, 230, 2, 16, 16); 00260 // Up part 00261 C.SetPos(XSize-0.5, 0); 00262 C.DrawTile(ZCrossHair, C.ClipX - XSize*2.0, YSize-0.5, 230, 2, 16, 16); 00263 // Right Part 00264 C.SetPos(C.ClipX - XSize-0.5, 0); 00265 C.DrawTile(ZCrossHair, XSize+0.5, C.ClipY, 230, 2, 16, 16); 00266 //Down Part 00267 C.SetPos(XSize-0.5, C.ClipY - YSize-0.5); 00268 C.DrawTile(ZCrossHair, C.CLipX - XSize*2.0, YSize+0.5, 230, 2, 16, 16); 00269 00270 // Zoom Level Display 00271 C.Font=C.smallfont; //font'XIIIFonts.XIIIConsoleFont'; 00272 C.bCenter = false; 00273 C.SetPos(XSize + 10.0, C.ClipY/2.0 - 20.0); 00274 C.SetDrawColor(65,186,212,255); 00275 C.DrawText(sZoomFactor); 00276 bDrawZoomedCrosshair = false; 00277 00278 // Stability display 00279 if ( Level.bLonePlayer && (fZoomStability > 0.0) ) 00280 { 00281 C.SetPos(C.ClipX*0.5 + ZCrossHair.USize*fDrawScale+1, C.ClipY*0.5 - 8.0*fZoomFactor*fZoomStability+1); 00282 // C.SetDrawColor(65,186,212,255); 00283 C.DrawTile(StabilityTex, 8, 8.0*fZoomFactor*2.0*fZoomStability, 0, 0, StabilityTex.USize, StabilityTex.VSize); 00284 } 00285 } 00286 00287 //_____________________________________________________________________________ 00288 // ELR Text to be displayed in HUD 00289 simulated function string GetAmmoText(out int bDrawbulletIcon) 00290 { 00291 local string AmmoText,AltAmmoText; 00292 00293 if ( AmmoType == none ) 00294 return ""; 00295 00296 bDrawbulletIcon = 1; 00297 00298 if ( MySlave != none ) 00299 { 00300 AmmoText = MySlave.ReLoadCount$"/"$ReloadCount@"|"@(Ammotype.AmmoAmount-ReLoadCount-MySlave.ReloadCount); 00301 return AmmoText; 00302 } 00303 // Setup ammotext 00304 if ( default.ReLoadCount > 0 ) 00305 AmmoText = ReLoadCount@"|"@(Ammotype.AmmoAmount-ReLoadCount); 00306 else if ( (WHand == WHA_Fist) || (WHand == WHA_Deco) ) 00307 { 00308 AmmoText = ItemName; 00309 bDrawbulletIcon = 0; 00310 } 00311 else 00312 AmmoText = string(Ammotype.AmmoAmount); 00313 if ( AmmoType.bDisplayNameInHUD ) 00314 { 00315 AmmoText = "("$AmmoType.ItemName$")"@AmmoText; 00316 } 00317 00318 // Setup ammotext 00319 if ( bHaveAltFire && !bMeleeWeapon && (AltAmmoType != none) ) 00320 { 00321 if ( default.AltReLoadCount > 0 ) 00322 AltAmmoText = AltReLoadCount$"/"$(AltAmmoType.AmmoAmount-AltReLoadCount); 00323 else 00324 AltAmmoText = string(AltAmmotype.AmmoAmount); 00325 00326 if ( AltAmmoType.bDisplayNameInHUD ) 00327 AmmoText = AmmoText@"|"@AltAmmoText; 00328 else 00329 AmmoText = AltAmmoText@AmmoText; 00330 } 00331 return AmmoText; 00332 } 00333 00334 //_____________________________________________________________________________ 00335 simulated function DrawTraceBullet(Canvas C, float XE, float YE) 00336 { 00337 C.SetPos(C.ClipX/2.0 + RandRange(-TraceAccuracy*2,TraceAccuracy*2), C.ClipY/2.0 + RandRange(-TraceAccuracy*2,TraceAccuracy*2)); 00338 C.Style = ERenderStyle.STY_Translucent; 00339 C.DrawColor = C.Static.MakeColor(255,200,100,200); 00340 C.DrawTile(Ammotype.TBTexture, XE, YE, 0,0, Ammotype.TBTexture.USize, Ammotype.TBTexture.VSize); 00341 } 00342 00343 //_____________________________________________________________________________ 00344 simulated function Weapon RecommendWeapon( out float rating ) 00345 { 00346 local Weapon Recommended; 00347 local float oldRating; 00348 00349 if ( 00350 !Instigator.IsPlayerPawn() 00351 || (XIIIPlayerPawn(Instigator) == none) 00352 || (XIIIPlayerPawn(Instigator).LHand == none) 00353 || !XIIIPlayerPawn(Instigator).LHand.bActive 00354 ) 00355 return Super.RecommendWeapon(rating); 00356 00357 if ( Pawn(Owner).bHaveOnlyOneHandFree && (WHand == WHA_2HShot) ) 00358 rating = -100.0; 00359 00360 if ( inventory != None ) 00361 { 00362 Recommended = inventory.RecommendWeapon(oldRating); 00363 if ( (Recommended != None) && (oldRating > rating) ) 00364 { 00365 rating = oldRating; 00366 return Recommended; 00367 } 00368 } 00369 return self; 00370 } 00371 00372 //_____________________________________________________________________________ 00373 function NewWeaponNotify(Pawn Other) 00374 { 00375 if ( !Level.bLonePlayer ) 00376 return; 00377 if ( (Other.Controller == none) || (XIIIPlayerController(Other.Controller) == none) ) 00378 return; 00379 // now we can inform that a new weapon has been acquired 00380 XIIIBaseHud(XIIIPlayerController(Other.Controller).MyHud).NotifyNewWeapon(self.Class); 00381 } 00382 00383 //_____________________________________________________________________________ 00384 simulated function NotifyOwnerKilled(controller Killer) 00385 { 00386 bRendered = false; 00387 bHidden = true; 00388 Refreshdisplaying(); 00389 } 00390 00391 //_____________________________________________________________________________ 00392 event Timer2() 00393 { 00394 switch (NextSlaveState) 00395 { 00396 Case 'BringUp': 00397 if ( (XIIIPawn(Owner).LHand != none) && XIIIPawn(Owner).LHand.bActive ) 00398 { 00399 SlaveOf.bEnableSlave = false; 00400 return; 00401 } 00402 bRendered = true; 00403 // bHidden = false; 00404 // RefreshDisplaying(); 00405 BringUp(); 00406 break; 00407 Case 'Fire': 00408 Fire(0.0); 00409 break; 00410 } 00411 } 00412 00413 //_____________________________________________________________________________ 00414 function SetUpDual(Weapon Dual, Pawn other) 00415 { 00416 local vector tV; 00417 // inventory Giveto 00418 Instigator = Other; 00419 // we must add the inventory but just after dual & before it's ammo. 00420 Other.InsertInventory( Self, Dual ); // OLD = Other.AddInventory( Self ); 00421 GotoState(''); 00422 00423 bCanThrow = false; // can't throw weapon if dual else pb when in hand 00424 dual.bCanThrow = false; 00425 00426 // Weapon Giveto 00427 bTossedOut = false; 00428 Instigator = Other; 00429 GiveAmmo(Other); 00430 if ( (AmmoType != None) && Level.Game.bInventorySetUp ) 00431 AmmoType.AddAmmo(ReLoadCount); // For dual need to give the ReloadCount to be sure we do have them in inventory 00432 ClientWeaponSet(true); 00433 00434 // Dual setup 00435 Dual.bHaveSlave = true; 00436 Dual.MySlave = self; 00437 if ( (XIIIPawn(Owner).LHand != none) && XIIIPawn(Owner).LHand.bActive ) 00438 Dual.bEnableSlave = false; 00439 else 00440 Dual.bEnableSlave = true; 00441 SlaveOf = Dual; 00442 Dual.WHand = WHA_1HShot; // Leave as 1HShoot but must deactivate the SlaveBringUp if LeftHand is there. 00443 bIsSlave = true; 00444 if ( Silencer != none ) 00445 Silencer.Destroy(); 00446 bCanHaveSlave = false; 00447 PlayerViewOffset.y *= -1; 00448 PlayerViewOffset.X -= 1; 00449 FireOffset.y *= -1; 00450 // FlashOffsetX *= -1; 00451 tV = Dual.default.DrawScale3D; 00452 tV.x *= -1.0; 00453 SetDrawScale3D(tV); 00454 00455 bRendered = false; 00456 bHidden = true; 00457 RefreshDisplaying(); 00458 if ( Other.Weapon == Dual ) 00459 { 00460 SlaveBringUp(); 00461 } 00462 } 00463 00464 //_____________________________________________________________________________ 00465 simulated function SlaveBringUp() 00466 { 00467 if ( (XIIIPawn(Owner).LHand != none) && XIIIPawn(Owner).LHand.bActive ) 00468 { 00469 SlaveOf.bEnableSlave = false; 00470 return; 00471 } 00472 NextSlaveState = 'BringUp'; 00473 SetTimer2(0.2 + fRand()*0.2, false); 00474 } 00475 00476 //_____________________________________________________________________________ 00477 simulated function RumbleFX() 00478 { 00479 if ( (Instigator != none) && Instigator.IsHumanControlled() && Instigator.IsLocallyControlled() ) 00480 if( XIIIPlayerController(Instigator.Controller) != none ) 00481 XIIIPlayerController(Instigator.Controller).RumbleFX(RumbleFXNum); 00482 } 00483 00484 //_____________________________________________________________________________ 00485 simulated function bool HasSilencer() 00486 { 00487 return ( bUseSilencer && !bIsSlave && (Pawn(Owner).FindInventoryKind('Silencer') != none) ); 00488 } 00489 00490 //_____________________________________________________________________________ 00491 simulated function Name GetBaseWeaponBone() 00492 { 00493 return ''; 00494 } 00495 00496 //_____________________________________________________________________________ 00497 simulated function UpDatesilencer() 00498 { 00499 if ( (Level.Game == none) || !Level.Game.bInventorySetup ) 00500 return; 00501 if ( HasSilencer() ) 00502 { 00503 // MFTexture = SilencedMuzzleFlash; // ::TODO:: Change muzzleflash texture there 00504 if ( Silencer == None ) 00505 { 00506 Silencer = spawn(class'BerettaSilencer',self); 00507 AttachToBone(Silencer,GetBaseWeaponBone()); 00508 } 00509 } 00510 } 00511 00512 //_____________________________________________________________________________ 00513 simulated function Weapon PrevWeapon(Weapon CurrentChoice, Weapon CurrentWeapon) 00514 { 00515 if ( Level.bLonePlayer && XIIIPawn(Owner).LHand.bActive && (WHand == WHA_2HShot) ) 00516 { 00517 if ( Inventory == None ) 00518 return CurrentChoice; 00519 else 00520 return Inventory.PrevWeapon(CurrentChoice,CurrentWeapon); 00521 } 00522 else 00523 return Super.PrevWeapon(CurrentChoice, CurrentWeapon); 00524 } 00525 //_____________________________________________________________________________ 00526 simulated function Weapon NextWeapon(Weapon CurrentChoice, Weapon CurrentWeapon) 00527 { 00528 if ( Level.bLonePlayer && XIIIPawn(Owner).LHand.bActive && (WHand == WHA_2HShot) ) 00529 { 00530 if ( Inventory == None ) 00531 return CurrentChoice; 00532 else 00533 return Inventory.NextWeapon(CurrentChoice,CurrentWeapon); 00534 } 00535 else 00536 return Super.NextWeapon(CurrentChoice, CurrentWeapon); 00537 } 00538 00539 //_____________________________________________________________________________ 00540 simulated function bool HasScope() 00541 { 00542 return bHaveScope; 00543 } 00544 00545 //_____________________________________________________________________________ 00546 function FeedBack() 00547 { 00548 // Log("FeedBack call for "$self); 00549 if ( Instigator.IsPlayerPawn() && (Level.GetPlateforme() != 1) && (Level.GetPlateforme() != 3) ) 00550 XIIIPlayerController(Instigator.controller).ClientViewFeedBackSetUp(Self.Class, bIsSlave); 00551 } 00552 00553 //_____________________________________________________________________________ 00554 function AltFeedBack() 00555 { 00556 // Log("AltFeedBack call for "$self); 00557 if ( Instigator.IsPlayerPawn() && (Level.GetPlateforme() != 1) && (Level.GetPlateforme() != 3) ) 00558 XIIIPlayerController(Instigator.controller).ClientViewAltFeedBackSetUp(Self.Class, bIsSlave); 00559 } 00560 00561 /* 00562 //_____________________________________________________________________________ 00563 simulated function vector GetFireStart(vector X, vector Y, vector Z) 00564 { 00565 if ( bZoomed ) 00566 return (Instigator.Location + Instigator.EyePosition() + FireOffset.X * X); 00567 else 00568 return (Instigator.Location + Instigator.EyePosition() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z); 00569 } 00570 */ 00571 00572 //_____________________________________________________________________________ 00573 simulated function vector GetAltFireStart(vector X, vector Y, vector Z) 00574 { 00575 if ( bZoomed ) 00576 return (Instigator.Location + Instigator.EyePosition() + AltFireOffset.X * X); 00577 else 00578 return (Instigator.Location + Instigator.EyePosition() + AltFireOffset.X * X + AltFireOffset.Y * Y + AltFireOffset.Z * Z); 00579 } 00580 00581 //_____________________________________________________________________________ 00582 function ProjectileFire() 00583 { 00584 local Vector Start, X,Y,Z; 00585 00586 // log("ProjectileFire"); 00587 00588 if ( XIIIProjectilesAmmo(AmmoType).fThrowDelay > 0 ) 00589 SetTimer(XIIIProjectilesAmmo(AmmoType).fThrowDelay, false); 00590 else 00591 { 00592 MakeNoise(FireNoise); 00593 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 00594 Start = GetFireStart(X,Y,Z); 00595 if ( ShouldDrawCrosshair() ) 00596 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); 00597 else 00598 { 00599 if ( Instigator.controller != none ) 00600 { 00601 if ( Instigator.IsPlayerPawn() ) 00602 AdjustedAim = Instigator.controller.rotation; 00603 else 00604 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); 00605 } 00606 else 00607 AdjustedAim = Instigator.rotation; 00608 } 00609 // if ( (Default.ReloadCount != 0) && (ReLoadCount > 0) || ((Default.ReloadCount == 0) && (AmmoType.AmmoAmount > 0)) ) 00610 FeedBack(); 00611 AmmoType.SpawnProjectile(Start,AdjustedAim); 00612 } 00613 } 00614 00615 //_____________________________________________________________________________ 00616 function ProjectileAltFire() 00617 { 00618 local Vector Start, X,Y,Z; 00619 00620 // log("ProjectileFire"); 00621 00622 if ( XIIIProjectilesAmmo(AltAmmoType).fThrowDelay > 0 ) 00623 SetTimer(XIIIProjectilesAmmo(AltAmmoType).fThrowDelay, false); 00624 else 00625 { 00626 MakeNoise(AltFireNoise); 00627 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 00628 Start = GetAltFireStart(X,Y,Z); 00629 if ( ShouldDrawCrosshair() ) 00630 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); // ELR BIG BUG CAN'T HAVE AUTOAIM FOR ALT AMMOS (ANYWAY NOT BUG BECAUSE NOT COMPATIBLE) 00631 // AdjustedAim = Instigator.AdjustAim(AltAmmoType, Start, 0); // ELR BIG BUG CAN'T HAVE AUTOAIM FOR ALT AMMOS (ANYWAY NOT BUG BECAUSE NOT COMPATIBLE) 00632 else 00633 { 00634 if ( Instigator.controller != none ) 00635 { 00636 if ( Instigator.IsPlayerPawn() ) 00637 AdjustedAim = Instigator.controller.rotation; 00638 else 00639 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); 00640 // AdjustedAim = Instigator.AdjustAim(AltAmmoType, Start, 0); 00641 } 00642 else 00643 AdjustedAim = Instigator.rotation; 00644 } 00645 // if ( (Default.AltReloadCount != 0) && (AltReLoadCount > 0) || ((Default.AltReloadCount == 0) && (AltAmmoType.AmmoAmount > 0)) ) 00646 AltFeedBack(); 00647 AltAmmoType.SpawnProjectile(Start,AdjustedAim); 00648 } 00649 } 00650 00651 //_____________________________________________________________________________ 00652 // 1236µs 00653 function TraceFire( float Accuracy, float YOffset, float ZOffset ) 00654 { 00655 if ( AmmoType.fFireDelay > 0 ) 00656 SetTimer(AmmoType.fFireDelay, false); 00657 else 00658 RealTraceFire(Accuracy, YOffset, ZOffset); 00659 } 00660 00661 //_____________________________________________________________________________ 00662 // 1228µs 00663 function RealTraceFire( float Accuracy, float YOffset, float ZOffset ) 00664 { 00665 local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z, wHitLocation; 00666 local actor Other, wOther; 00667 local Material HitMat; 00668 local Vector vWaterDir; 00669 00670 if ( DBWeap ) Log(" # RealTracefire call for "$self); 00671 00672 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 00673 if ( WHand == WHA_Fist ) 00674 { 00675 StartTrace = Instigator.Location + Instigator.EyePosition(); // don't use GetFireStart because we don't want to change the target detection w/ diff weapons. 00676 AdjustedAim = Instigator.AdjustAim(AmmoType, StartTrace, 0); 00677 EndTrace = StartTrace + 100*vector(AdjustedAim); 00678 // EndTrace = StartTrace + 100*X; 00679 } 00680 else 00681 if ( WHand == WHA_Deco ) 00682 { 00683 StartTrace = Instigator.Location + Instigator.EyePosition(); // don't use GetFireStart because we don't want to change the target detection w/ diff weapons. 00684 AdjustedAim = Instigator.AdjustAim(AmmoType, StartTrace, 0); 00685 EndTrace = StartTrace + 150*vector(AdjustedAim); 00686 // EndTrace = StartTrace + 150*X; 00687 } 00688 else 00689 { 00690 StartTrace = GetFireStart(X,Y,Z); 00691 if ( ShouldDrawCrosshair() || !Pawn(Owner).IsPlayerPawn() ) 00692 AdjustedAim = Instigator.AdjustAim(AmmoType, StartTrace, 0); 00693 else 00694 { 00695 if ( Instigator.controller != none ) 00696 AdjustedAim = Instigator.controller.rotation; 00697 else 00698 AdjustedAim = Instigator.rotation; 00699 } 00700 X = vector(AdjustedAim); 00701 EndTrace = StartTrace + (TraceDist * X); 00702 EndTrace += vRand() * fRand() * (Accuracy/100.0) * TraceDist; 00703 } 00704 00705 if ( AmmoType.bHandToHand ) 00706 Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True, vect(0,0,0), HitMat, TRACETYPE_RequestBones); 00707 else 00708 Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True, vect(0,0,0), HitMat, TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon|TRACETYPE_RequestBones); 00709 00710 if ( Other != none ) 00711 { 00712 wOther = IntersectWaterPlane(StartTrace, HitLocation, wHitLocation); 00713 if ( wOther != none ) 00714 { 00715 vWaterDir = wHitLocation - StartTrace; 00716 vWaterDir.Z = abs(vWaterDir.z) * 8.0; 00717 WRE = PhysicsVolume(wOther).BeingHitByBullets(wHitLocation+vect(0,0,1), rotator(vWaterDir cross Y), AmmoType.HitSoundType); 00718 } 00719 } 00720 else 00721 { 00722 wOther = IntersectWaterPlane(StartTrace, EndTrace, wHitLocation); 00723 if ( wOther != none ) 00724 { 00725 vWaterDir = wHitLocation - StartTrace; 00726 vWaterDir.Z = abs(vWaterDir.z) * 8.0; 00727 WRE = PhysicsVolume(wOther).BeingHitByBullets(wHitLocation+vect(0,0,1), rotator(vWaterDir cross Y), AmmoType.HitSoundType); 00728 } 00729 } 00730 00731 // Fire noises 00732 if ( WHand == WHA_Fist ) 00733 { 00734 if ( Other != none ) 00735 MakeNoise(FireNoise); 00736 } 00737 else if ( HasSilencer() ) 00738 MakeNoise(FireNoise/8.33); 00739 else 00740 MakeNoise(FireNoise); 00741 00742 if ( WeaponAttachment(ThirdPersonActor) != None ) 00743 WeaponAttachment(ThirdPersonActor).iBTrailDist = vSize(hitLocation-StartTrace); 00744 00745 if ( XIIIPawn(Other) != none ) 00746 XIIIPawn(Other).LastBoneHit = GetLastTraceBone(); 00747 // Log("GetLastTraceBone="$GetLastTraceBone()); 00748 00749 if ( WHand == WHA_Fist ) 00750 { // Can break anything if icon is there even if little too far from fists (debug of breaking horizontal panel while underwater) 00751 if ( Pawn(Owner).IsLocallyControlled() && XIIIPlayerController(Pawn(Owner).Controller).MyInteraction.bCanBreak ) 00752 Other = XIIIPlayerController(Pawn(Owner).Controller).MyInteraction.TargetActor; 00753 } 00754 00755 if ( bShouldGoThroughTraversable && XIIIMover(Other)!=none && XIIIMover(Other).bTraversable ) 00756 { 00757 // Log("bTraversable, 1rst HitMat="$HitMat); 00758 if ( HitMat != none ) 00759 AmmoType.PlayImpactSound(HitMat.HitSound); 00760 FeedBack(); 00761 AmmoType.ProcessTraceHit(self, Other, HitLocation, HitNormal, X,Y,Z); // 875µs 00762 // Log("Shooting a bTraversableMover, health left :"@XIIIMover(Other).Health); 00763 if ( XIIIMover(Other).Health<=0 ) 00764 { 00765 Other = trace(HitLocation,HitNormal,EndTrace,HitLocation + normal(EndTrace - StartTrace) * 32,True, vect(0,0,0), HitMat, TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon|TRACETYPE_RequestBones); 00766 // Log("Next Target after btraversable :"@other@"hitMat="$HitMat); 00767 if ( XIIIPawn(Other) != none ) 00768 XIIIPawn(Other).LastBoneHit = GetLastTraceBone(); 00769 if ( HitMat != none ) 00770 AmmoType.PlayImpactSound(HitMat.Hitsound); 00771 AmmoType.AmmoAmount++; 00772 AmmoType.ProcessTraceHit(self, Other, HitLocation, HitNormal, X,Y,Z); // 875µs 00773 } 00774 } 00775 else 00776 { 00777 if ( HitMat != none ) 00778 AmmoType.PlayImpactSound(HitMat.HitSound); 00779 FeedBack(); 00780 00781 AmmoType.ProcessTraceHit(self, Other, HitLocation, HitNormal, X,Y,Z); // 875µs 00782 } 00783 } 00784 00785 //_____________________________________________________________________________ 00786 function TraceAltFire( float Accuracy, float YOffset, float ZOffset ) 00787 { 00788 if ( AltAmmoType.fFireDelay > 0 ) 00789 SetTimer(AltAmmoType.fFireDelay, false); 00790 else 00791 RealTraceAltFire(Accuracy, YOffset, ZOffset); 00792 } 00793 00794 //_____________________________________________________________________________ 00795 function RealTraceAltFire( float Accuracy, float YOffset, float ZOffset ) 00796 { 00797 local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z; 00798 local actor Other; 00799 local Material HitMat; 00800 00801 // log("RealTraceAltFire w/accuracy="$Accuracy@"AltTraceDist="$AltTraceDist); 00802 00803 if ( HasSilencer() ) 00804 MakeNoise(AltFireNoise/8.33); 00805 else 00806 MakeNoise(AltFireNoise); 00807 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 00808 if ( WHand == WHA_Fist ) 00809 { 00810 StartTrace = Instigator.Location + Instigator.EyePosition(); // don't use GetFireStart because we don't want to change the target detection w/ diff weapons. 00811 AdjustedAim = Instigator.AdjustAim(AltAmmoType, StartTrace, 0); 00812 EndTrace = StartTrace + 100*vector(AdjustedAim); 00813 } 00814 else 00815 if ( WHand == WHA_Deco ) 00816 { 00817 StartTrace = Instigator.Location + Instigator.EyePosition(); // don't use GetFireStart because we don't want to change the target detection w/ diff weapons. 00818 AdjustedAim = Instigator.AdjustAim(AltAmmoType, StartTrace, 0); 00819 EndTrace = StartTrace + 150*vector(AdjustedAim); 00820 } 00821 else 00822 { 00823 StartTrace = GetAltFireStart(X,Y,Z)+16*X; 00824 if ( ShouldDrawCrosshair() || !Pawn(Owner).IsPlayerPawn() ) 00825 AdjustedAim = Instigator.AdjustAim(AltAmmoType, StartTrace, 0); 00826 else 00827 { 00828 if ( Instigator.controller != none ) 00829 AdjustedAim = Instigator.controller.rotation; 00830 else 00831 AdjustedAim = Instigator.rotation; 00832 } 00833 X = vector(AdjustedAim); 00834 EndTrace = StartTrace + (AltTraceDist * X); 00835 EndTrace += vRand() * fRand() * (Accuracy/100.0) * AltTraceDist; 00836 } 00837 if ( AltAmmoType.bHandToHand ) 00838 Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True, vect(0,0,0), HitMat, TRACETYPE_RequestBones); 00839 else 00840 Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True, vect(0,0,0), HitMat, TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon|TRACETYPE_RequestBones); 00841 if ( WeaponAttachment(ThirdPersonActor) != None ) 00842 { 00843 WeaponAttachment(ThirdPersonActor).iBTrailDist = vSize(hitLocation-StartTrace); 00844 } 00845 if ( XIIIPawn(Other) != none ) 00846 XIIIPawn(Other).LastBoneHit = GetLastTraceBone(); 00847 if ((XIIIMover(other)!=none) && (XIIIMover(Other).bTraversable && bShouldGoThroughTraversable) ) 00848 { 00849 Other = trace(HitLocation,HitNormal,EndTrace,HitLocation + normal(HitLocation - StartTrace) * 32,True, vect(0,0,0), HitMat, TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon); 00850 00851 if ( HitMat != none ) 00852 AltAmmoType.PlayImpactSound(HitMat.HitSound); 00853 // else if ( TerrainInfo(Other) != none ) 00854 // AltAmmoType.PlayImpactSound(TerrainInfo(Other).HitSound); 00855 00856 // if ( (Default.AltReloadCount != 0) && (AltReLoadCount > 0) || ((Default.ReloadCount == 0) && (AltAmmoType.AmmoAmount > 0)) ) 00857 AltFeedBack(); 00858 AltAmmoType.ProcessTraceHit(self, Other, HitLocation, HitNormal, X,Y,Z); 00859 } 00860 else 00861 { 00862 // log("RealTraceAltFire hit"@other@"HitMat="$HitMat@""); 00863 if ( HitMat != none ) 00864 AltAmmoType.PlayImpactSound(HitMat.HitSound); 00865 // else if ( TerrainInfo(Other) != none ) 00866 // AltAmmoType.PlayImpactSound(TerrainInfo(Other).HitSound); 00867 // if ( (Default.AltReloadCount != 0) && (AltReLoadCount > 0) || ((Default.AltReloadCount == 0) && (AltAmmoType.AmmoAmount > 0)) ) 00868 AltFeedBack(); 00869 AltAmmoType.ProcessTraceHit(self, Other, HitLocation, HitNormal, X,Y,Z); 00870 } 00871 } 00872 00873 //_____________________________________________________________________________ 00874 simulated function UnFire( float Value ); 00875 00876 //_____________________________________________________________________________ 00877 simulated function SwitchSlave(bool NewEnableSlave) 00878 { 00879 if ( bChangeWeapon || !bHaveSlave ) // only switch slave if not going down. 00880 return; 00881 00882 if ( DBDual ) Log("SWITCHSLAVE Call for"@self@"NewEnableSlave="$NewEnableSlave); 00883 bEnableSlave = NewEnableSlave; 00884 00885 if ( !bEnableSlave ) 00886 { // Put slave down 00887 MySlave.PutDown(); 00888 MySlave.NextSlaveState = 'DownWeapon'; 00889 MySlave.SetTimer2(0.05, false); 00890 } 00891 else 00892 { // bring up slave 00893 MySlave.SlaveBringUp(); 00894 } 00895 00896 } 00897 00898 //_____________________________________________________________________________ 00899 // 2350 µs 00900 simulated function Fire( float Value ) 00901 { 00902 // a fire w/ param 1 should mean IA firing. 00903 // a fire w/ param 2 should mean ignore water test. 00904 // a fire w/ param 4 should mean ignore test on controller bFire. 00905 if ( DBWeap ) Log(" Fire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@" HasAmmo="$HasAmmo()@"Value="$Value); 00906 00907 if ( (MySlave != none) && bEnableSlave ) 00908 MySlave.SlaveFire(); 00909 00910 if ( (Value != 2.0) && !bUnderWaterWork && Pawn(Owner).HeadVolume.bWaterVolume ) 00911 return; 00912 00913 if ( !HasAmmo() ) // 11µs 00914 bEmptyShot=true; 00915 00916 if ( NeedsToReload() && HasAmmo() ) 00917 { // This should happen for both Server and client 00918 if ( CanReLoad() ) 00919 { 00920 GotoState('Reloading'); 00921 ServerReLoad(); 00922 } 00923 return; 00924 } 00925 00926 if ( Level.bLonePlayer ) 00927 { 00928 LoneFire(Value); // 2296µs 00929 return; 00930 } 00931 00932 if ( Value == 4.0 ) // Magnum specific cheat to allow same ammo use for fire/altfire 00933 ServerAltFire(); 00934 else 00935 ServerFire(); 00936 00937 // ELR do the client part of the script, server done in ServerFire called above. 00938 // if ( (Role < ROLE_Authority) && (HasAmmo() || bEmptyShot) && ((Instigator.controller.bFire != 0) || bIsSlave) ) 00939 if ( (Role < ROLE_Authority) && (HasAmmo() || bEmptyShot) && ((Instigator.controller.bFire != 0) || (Value == 4.0)) ) 00940 { 00941 if ( !bMeleeWeapon && HasAmmo() ) 00942 ReloadCount--; 00943 LocalFire(); 00944 GotoState('ClientFiring'); 00945 } 00946 } 00947 00948 //_____________________________________________________________________________ 00949 // 2296µs 00950 function LoneFire(float value) 00951 { 00952 if ( DBWeap ) Log(" LoneFire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@"bEmptyShot="$bEmptyShot@"State="$GetStateName()); 00953 00954 /* should be useless 00955 if ( AmmoType == None ) 00956 { // ammocheck 00957 // log("WARNING "$self$" HAS NO AMMO!!!"); 00958 GiveAmmo(Instigator); 00959 } 00960 */ 00961 Instigator.Controller.NotifyFiring(); 00962 00963 // if ( (HasAmmo() || bEmptyShot) && ((Instigator.controller.bFire != 0) || bIsSlave) ) 00964 if ( (HasAmmo() || bEmptyShot) && ((Instigator.controller.bFire != 0) || (Value == 4.0)) ) 00965 { 00966 GotoState('NormalFire'); 00967 if ( !bMeleeWeapon && HasAmmo() ) 00968 ReloadCount--; 00969 LocalFire(); // 822µs 00970 if ( AmmoType.bInstantHit ) 00971 { 00972 if ( HasAmmo() ) 00973 TraceFire(fVarAccuracy,0,0); // 1236µs 00974 } 00975 else 00976 ProjectileFire(); 00977 } 00978 else 00979 GotoState('Idle'); 00980 } 00981 00982 //_____________________________________________________________________________ 00983 function ServerFire() 00984 { 00985 if ( DBWeap ) Log(" ServerFire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@"bEmptyShot="$bEmptyShot@" HasAmmo="$HasAmmo()); 00986 00987 if ( AmmoType == None ) 00988 { // ammocheck 00989 // log("WARNING "$self$" HAS NO AMMO!!!"); 00990 GiveAmmo(Instigator); 00991 } 00992 Instigator.Controller.NotifyFiring(); 00993 00994 if ( (HasAmmo() || bEmptyShot) ) 00995 { 00996 GotoState('NormalFire'); 00997 if ( !bMeleeWeapon && HasAmmo() ) 00998 ReloadCount--; 00999 LocalFire(); 01000 if ( AmmoType.bInstantHit ) 01001 { 01002 if ( HasAmmo() ) 01003 TraceFire(fVarAccuracy,0,0); 01004 } 01005 else 01006 ProjectileFire(); 01007 } 01008 else 01009 GotoState('Idle'); 01010 } 01011 01012 //_____________________________________________________________________________ 01013 simulated function LocalFire() 01014 { 01015 local PlayerController P; 01016 01017 if ( DBWeap ) Log(" Localfire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@" HasAmmo="$HasAmmo()); 01018 01019 // bPointing = true; 01020 if ( HasAmmo() ) 01021 { 01022 if ( (Instigator != None) && Instigator.IsLocallyControlled() ) 01023 { 01024 P = PlayerController(Instigator.Controller); 01025 if (P!=None) 01026 P.ShakeView(ShakeTime, ShakeMag, ShakeVert, 120000, ShakeSpeed, ShakeCycles); // 50µs 01027 } 01028 } 01029 01030 if ( MyWeaponOno != none ) 01031 MyWeaponOno.FirePrimaryWeapon(); 01032 01033 PlayFiring(); // 738 µs 01034 01035 // ELR Try to avoid this client flickering ammo amount left. 01036 if ( (Level.NetMode == NM_Client) && (default.ReloadCount > 0 ) && ((XIIIBulletsAmmo(AmmoType) == none) || !XIIIBulletsAmmo(AmmoType).bInfiniteAmmo) ) 01037 { 01038 if ( AmmoType.AmmoAmount > 0 ) 01039 AmmoType.AmmoAmount --; 01040 } 01041 01042 } 01043 01044 //_____________________________________________________________________________ 01045 function CauseAltFire() 01046 { 01047 if ( Level.bLonePlayer ) 01048 Global.LoneAltFire(); 01049 else 01050 Global.ServerAltFire(); 01051 } 01052 01053 //_____________________________________________________________________________ 01054 simulated function AltFire( float Value ) 01055 { 01056 // Log(" AltFire call for"@self@"w/ ReLoadCount="$AltReLoadCount@" AmmoAmount="$AltAmmoType.AmmoAmount); 01057 if ( !bHaveAltFire ) 01058 return; 01059 if ( !bUnderWaterWork && Pawn(Owner).HeadVolume.bWaterVolume ) 01060 return; 01061 01062 if ( AltAmmoType == None ) 01063 { // ammocheck 01064 // log("WARNING "$self$" HAS NO AMMO!!!"); 01065 GiveAltAmmo(Instigator); 01066 } 01067 01068 bAltEmptyShot = !HasAltAmmo(); 01069 /* 01070 if ( !HasAltAmmo() ) 01071 { 01072 // if ( bAltEmptyShot ) 01073 // return; 01074 // else 01075 bAltEmptyShot=true; 01076 } 01077 */ 01078 01079 if ( AltNeedsToReload() && HasAltAmmo() ) 01080 { // This should happen for both Server and client 01081 // Log(" in Fire Should send everybody to ReLoading there"); 01082 if ( CanReLoad() ) 01083 { 01084 GotoState('Reloading'); 01085 ServerReLoad(); 01086 return; 01087 } 01088 else 01089 return; 01090 } 01091 01092 if ( Level.bLonePlayer ) 01093 { 01094 LoneAltFire(); 01095 return; 01096 } 01097 01098 ServerAltFire(); 01099 // ELR do the client part of the script, server done in ServerFire called above. 01100 if ( (Role < ROLE_Authority) && (HasAltAmmo() || bAltEmptyShot) && (Instigator.controller.bAltFire != 0) ) 01101 { 01102 if ( !bMeleeWeapon && HasAltAmmo() ) 01103 AltReloadCount--; 01104 LocalAltFire(); 01105 GotoState('ClientAltFiring'); 01106 } 01107 } 01108 01109 01110 //_____________________________________________________________________________ 01111 function LoneAltFire() 01112 { 01113 // Log(" LoneFire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@"bAltEmptyShot="$bAltEmptyShot@"State="$GetStateName()); 01114 01115 if ( AltAmmoType == None ) 01116 { // ammocheck 01117 // log("WARNING "$self$" HAS NO AMMO!!!"); 01118 GiveAltAmmo(Instigator); 01119 } 01120 Instigator.Controller.NotifyFiring(); 01121 01122 if ( (HasAltAmmo() || bAltEmptyShot) && (Instigator.controller.bAltFire != 0) ) 01123 { 01124 GotoState('NormalAltFire'); 01125 if ( !bMeleeWeapon && HasAltAmmo() ) 01126 AltReloadCount--; 01127 LocalAltFire(); 01128 if ( AltAmmoType.bInstantHit ) 01129 TraceAltFire(fVarAccuracy,0,0); 01130 else 01131 ProjectileAltFire(); 01132 } 01133 else 01134 GotoState('Idle'); 01135 } 01136 01137 //_____________________________________________________________________________ 01138 function ServerAltFire() 01139 { 01140 // Log(" ServerFire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@"bAltEmptyShot="$bAltEmptyShot); 01141 01142 if ( AltAmmoType == None ) 01143 { // ammocheck 01144 // log("WARNING "$self$" HAS NO AMMO!!!"); 01145 GiveAltAmmo(Instigator); 01146 } 01147 Instigator.Controller.NotifyFiring(); 01148 01149 if ( (HasAltAmmo() || bAltEmptyShot) ) 01150 { 01151 GotoState('NormalAltFire'); 01152 if ( !bMeleeWeapon && HasAltAmmo() ) 01153 AltReloadCount--; 01154 LocalAltFire(); 01155 if ( AltAmmoType.bInstantHit ) 01156 TraceAltFire(fVarAccuracy,0,0); 01157 else 01158 ProjectileAltFire(); 01159 } 01160 else 01161 GotoState('Idle'); 01162 } 01163 01164 01165 //_____________________________________________________________________________ 01166 simulated function LocalAltFire() 01167 { 01168 local PlayerController P; 01169 01170 if ( DBWeap ) Log(" LocalAltFire call for"@self@"w/ AltReLoadCount="$AltReLoadCount@" AltAmmoAmount="$AltAmmoType.AmmoAmount@"Ono="$MyWeaponOno); 01171 01172 // bPointing = true; 01173 if ( HasAltAmmo() ) 01174 { 01175 if ( (Instigator != None) && Instigator.IsLocallyControlled() ) 01176 { 01177 P = PlayerController(Instigator.Controller); 01178 if ( P!=None ) 01179 P.ShakeView(AltShakeTime, AltShakeMag, AltShakeVert, 120000, AltShakeSpeed, AltShakeCycles); 01180 } 01181 } 01182 01183 if ( MyWeaponOno != none ) 01184 MyWeaponOno.FirePrimaryWeaponAlt(); 01185 01186 PlayAltFiring(); 01187 } 01188 01189 //_____________________________________________________________________________ 01190 simulated function bool NeedsToReload() 01191 { 01192 if ( DBWeap ) Log(" NeedsToReLoad call bForceReload="$bForceReload@" result="@( bForceReload || (Default.ReloadCount > 0) && (ReloadCount == 0) )); 01193 return ( bForceReload || (Default.ReloadCount > 0) && (ReloadCount == 0) ); 01194 } 01195 01196 //_____________________________________________________________________________ 01197 simulated function bool AltNeedsToReload() 01198 { 01199 if ( DBWeap ) Log(" AltNeedsToReLoad call bForceReload="$bForceReload@" result="@( bForceReload || (Default.AltReloadCount > 0) && (AltReloadCount == 0) )); 01200 return ( bForceReload || (Default.AltReloadCount > 0) && (AltReloadCount == 0) ); 01201 } 01202 01203 //_____________________________________________________________________________ 01204 simulated function bool CanReLoad() 01205 { 01206 if ( (XIIIPawn(Owner).LHand!= none) && (XIIIPawn(Owner).LHand.pOnShoulder != none) ) 01207 return false; 01208 return true; 01209 } 01210 01211 //_____________________________________________________________________________ 01212 // Finish a sequence 01213 function Finish() 01214 { 01215 local bool bForce, bForceAlt; 01216 if ( DBWeap ) Log("> Finish called w/ bForceFire="$bForceFire@"& bForceReLoad="$bForceReLoad@"in state"@GetStateName()); 01217 01218 if ( HasAmmo() && (bAutoReload || !Level.bLonePlayer) && NeedsToReload() ) 01219 { 01220 GotoState('Reloading'); 01221 return; 01222 } 01223 01224 bForce = bForceFire; 01225 bForceAlt = bForceAltFire; 01226 bForceFire = false; 01227 bForceAltFire = false; 01228 01229 if ( bChangeWeapon ) 01230 { 01231 GotoState('DownWeapon'); 01232 return; 01233 } 01234 01235 if ( (Instigator == None) || (Instigator.Controller == None) ) 01236 { 01237 GotoState(''); 01238 return; 01239 } 01240 01241 if ( !Instigator.IsHumanControlled() ) 01242 { 01243 if ( !HasAmmo() ) 01244 { 01245 Instigator.Controller.SwitchToBestWeapon(); 01246 if ( bChangeWeapon ) 01247 GotoState('DownWeapon'); 01248 else 01249 GotoState('Idle'); 01250 return; 01251 } 01252 if ( NeedsToReload() ) 01253 { 01254 GotoState('Reloading'); 01255 return; 01256 } 01257 if ( Instigator.PressingFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) ) 01258 { 01259 if ( Level.bLonePlayer ) 01260 Global.LoneFire(0.0); 01261 else 01262 Global.ServerFire(); 01263 } 01264 else if ( !bSpecialAltFire && Instigator.PressingAltFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) ) 01265 CauseAltFire(); 01266 else 01267 { 01268 Instigator.Controller.StopFiring(); 01269 GotoState('Idle'); 01270 } 01271 return; 01272 } 01273 01274 if ( !HasAmmo() && !HasAltAmmo() ) 01275 { 01276 // Log("Finish, bAllowEmptyShot="$bAllowEmptyShot@"bLonePlayer=$"$Level.bLonePlayer); 01277 if ( !bAllowEmptyShot || !Level.bLonePlayer ) 01278 { 01279 // if local player, switch weapon 01280 Instigator.Controller.SwitchToBestWeapon(); 01281 if ( bChangeWeapon ) 01282 { 01283 GotoState('DownWeapon'); 01284 return; 01285 } 01286 else 01287 GotoState('Idle'); 01288 return; 01289 } 01290 } 01291 if ( (Instigator.Weapon != self) || (!bUnderWaterWork && Pawn(Owner).HeadVolume.bWaterVolume) ) 01292 GotoState('Idle'); 01293 else if ( (((StopFiringTime > Level.TimeSeconds) || Instigator.PressingFire()) && bAllowShot) || bForce ) 01294 { 01295 if ( HasAmmo() && NeedsToReLoad() && CanReLoad() ) 01296 { 01297 // Log(" in Finish Should send everybody to ReLoading there"); 01298 GotoState('Reloading'); 01299 ClientReLoad(); 01300 return; 01301 } 01302 else if ( !CanReLoad() ) 01303 { 01304 gotoState('Idle'); 01305 return; 01306 } 01307 Global.ServerFire(); 01308 } 01309 else if ( !bSpecialAltFire && bHaveAltFire && (bForceAlt || Instigator.PressingAltFire()) && bAllowShot ) 01310 CauseAltFire(); 01311 else 01312 GotoState('Idle'); 01313 } 01314 01315 //_____________________________________________________________________________ 01316 // Finish a sequence 01317 function AltFinish() 01318 { 01319 local bool bForce, bForceAlt; 01320 if ( DBWeap ) Log("> AltFinish called w/ bForceAltFire="$bForceAltFire@"& bForceReLoad="$bForceReLoad); 01321 01322 if ( HasAltAmmo() && (bAutoReload || !Level.bLonePlayer) && AltNeedsToReload() ) 01323 { 01324 GotoState('Reloading'); 01325 return; 01326 } 01327 01328 bForce = bForceFire; 01329 bForceAlt = bForceAltFire; 01330 bForceFire = false; 01331 bForceAltFire = false; 01332 01333 if ( bChangeWeapon ) 01334 { 01335 GotoState('DownWeapon'); 01336 return; 01337 } 01338 01339 if ( (Instigator == None) || (Instigator.Controller == None) ) 01340 { 01341 GotoState(''); 01342 return; 01343 } 01344 01345 if ( !Instigator.IsHumanControlled() ) 01346 { 01347 if ( !HasAltAmmo() ) 01348 { 01349 Instigator.Controller.SwitchToBestWeapon(); 01350 if ( bChangeWeapon ) 01351 GotoState('DownWeapon'); 01352 else 01353 GotoState('Idle'); 01354 return; 01355 } 01356 if ( AltNeedsToReload() ) 01357 { 01358 GotoState('Reloading'); 01359 return; 01360 } 01361 if ( Instigator.PressingFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) ) 01362 { 01363 if ( Level.bLonePlayer ) 01364 Global.LoneFire(0.0); 01365 else 01366 Global.ServerFire(); 01367 } 01368 else if ( !bSpecialAltFire && bHaveAltFire && Instigator.PressingAltFire() && (bUnderWaterWork || !Pawn(Owner).HeadVolume.bWaterVolume) ) 01369 CauseAltFire(); 01370 else 01371 { 01372 Instigator.Controller.StopFiring(); 01373 GotoState('Idle'); 01374 } 01375 return; 01376 } 01377 01378 if ( !HasAmmo() && !HasAltAmmo() ) 01379 { 01380 if ( !bAllowEmptyShot || !Level.bLonePlayer ) 01381 { 01382 // if local player, switch weapon 01383 Instigator.Controller.SwitchToBestWeapon(); 01384 if ( bChangeWeapon ) 01385 { 01386 GotoState('DownWeapon'); 01387 return; 01388 } 01389 else 01390 GotoState('Idle'); 01391 return; 01392 } 01393 } 01394 if ( (Instigator.Weapon != self) || (!bUnderWaterWork && Pawn(Owner).HeadVolume.bWaterVolume) ) 01395 GotoState('Idle'); 01396 else if ( (((StopFiringTime > Level.TimeSeconds) || Instigator.PressingFire()) && bAllowShot) || bForce ) 01397 { 01398 if ( HasAmmo() && NeedsToReLoad() && CanReLoad() ) 01399 { 01400 // Log(" in AltFinish Should send everybody to ReLoading there"); 01401 GotoState('Reloading'); 01402 ClientReLoad(); 01403 return; 01404 } 01405 else if ( !CanReLoad() ) 01406 { 01407 gotoState('Idle'); 01408 return; 01409 } 01410 Global.ServerFire(); 01411 } 01412 else if ( !bSpecialAltFire && bHaveAltFire && (bForceAlt || Instigator.PressingAltFire()) && bAllowShot ) 01413 { 01414 if ( HasAltAmmo() && AltNeedsToReLoad() && CanReLoad() ) 01415 { 01416 // Log(" in AltFinish Should send everybody to ReLoading there"); 01417 GotoState('Reloading'); 01418 ClientReLoad(); 01419 return; 01420 } 01421 else if ( !CanReLoad() ) 01422 { 01423 gotoState('Idle'); 01424 return; 01425 } 01426 CauseAltFire(); 01427 } 01428 else 01429 GotoState('Idle'); 01430 } 01431 01432 //_____________________________________________________________________________ 01433 simulated function ClientFinish() 01434 { 01435 if ( DBWeap ) Log("> ClientFinish called HasAmmo="$HasAmmo()@"bAllowShot="$bAllowShot); 01436 01437 if ( HasAmmo() && (bAutoReload || !Level.bLonePlayer) && NeedsToReload() ) 01438 { 01439 GotoState('Reloading'); 01440 return; 01441 } 01442 01443 if ( (Instigator == None) || (Instigator.Controller == None) ) 01444 { 01445 GotoState(''); 01446 return; 01447 } 01448 if ( HasAmmo() && NeedsToReLoad() && Instigator.PressingFire() ) 01449 { 01450 // Log(" in ClientFinish goto reloading"); 01451 GotoState('Reloading'); 01452 ServerReLoad(); 01453 return; 01454 } 01455 if ( !HasAmmo() && !HasAltAmmo() ) 01456 { 01457 if ( !bAllowEmptyShot || !Level.bLonePlayer ) 01458 { 01459 Instigator.Controller.SwitchToBestWeapon(); 01460 if ( !bChangeWeapon ) 01461 { 01462 PlayIdleAnim(); 01463 GotoState('Idle'); 01464 return; 01465 } 01466 } 01467 else 01468 { 01469 PlayIdleAnim(); 01470 GotoState('Idle'); 01471 return; 01472 } 01473 } 01474 if ( bChangeWeapon ) 01475 GotoState('DownWeapon'); 01476 else if ( Instigator.PressingFire() && bAllowShot ) 01477 Global.Fire(0); 01478 else 01479 { 01480 if ( !bSpecialAltFire && bHaveAltFire && Instigator.PressingAltFire() && bAllowShot ) 01481 Global.AltFire(0); 01482 else 01483 { 01484 PlayIdleAnim(); 01485 GotoState('Idle'); 01486 } 01487 } 01488 } 01489 01490 //_____________________________________________________________________________ 01491 simulated function ClientAltFinish() 01492 { 01493 if ( DBWeap ) Log("> ClientAltFinish called"); 01494 01495 if ( HasAltAmmo() && (bAutoReload || !Level.bLonePlayer) && AltNeedsToReload() ) 01496 { 01497 GotoState('Reloading'); 01498 return; 01499 } 01500 01501 if ( (Instigator == None) || (Instigator.Controller == None) ) 01502 { 01503 GotoState(''); 01504 return; 01505 } 01506 if ( !bSpecialAltFire && bHaveAltFire && HasAltAmmo() && AltNeedsToReLoad() && Instigator.PressingAltFire() ) 01507 { 01508 // Log(" in ClientAltFinish goto reloading"); 01509 GotoState('Reloading'); 01510 ServerReLoad(); 01511 return; 01512 } 01513 if ( !HasAmmo() && !HasAltAmmo() ) 01514 { 01515 if ( !bAllowEmptyShot || !Level.bLonePlayer ) 01516 { 01517 Instigator.Controller.SwitchToBestWeapon(); 01518 if ( !bChangeWeapon ) 01519 { 01520 PlayIdleAnim(); 01521 GotoState('Idle'); 01522 return; 01523 } 01524 } 01525 else 01526 { 01527 PlayIdleAnim(); 01528 GotoState('Idle'); 01529 return; 01530 } 01531 } 01532 if ( bChangeWeapon ) 01533 GotoState('DownWeapon'); 01534 else if ( Instigator.PressingFire() && bAllowShot ) 01535 Global.Fire(0); 01536 else 01537 { 01538 if ( !bSpecialAltFire && bHaveAltFire && Instigator.PressingAltFire() && bAllowShot ) 01539 Global.AltFire(0); 01540 else 01541 { 01542 PlayIdleAnim(); 01543 GotoState('Idle'); 01544 } 01545 } 01546 } 01547 01548 //_____________________________________________________________________________ 01549 simulated function SetupMuzzleFlash() 01550 { 01551 if ( bZoomed ) 01552 return; 01553 bMuzzleFlash = true; 01554 // No use in trying to turn if DrawType = DT_Sprite... trying using third person models 01555 if ( FirstPersonMF != none ) 01556 { 01557 FPMFRelativeRot.Roll = Rand(2500)-1250; 01558 FirstPersonMF.SetRelativeRotation(FPMFRelativeRot); 01559 } 01560 bSetFlashTime = false; 01561 fTraceBulletCount += AmmoType.fTraceFrequency * RandRange(0.7, 1.3); 01562 if ( fTraceBulletCount >= 1.0 ) 01563 { 01564 bTracebullets = true; 01565 fTraceBulletCount = 0.0; 01566 } 01567 else 01568 bTracebullets = false; 01569 } 01570 01571 //_____________________________________________________________________________ 01572 state NormalFire 01573 { 01574 event BeginState() 01575 { 01576 // Log("> #NormalFire BeginState"); 01577 // if ( Instigator.IsPlayerPawn() && (XIIIWeaponAttachment(ThirdPersonActor) != none) && XIIIWeaponAttachment(ThirdPersonActor).bSpawnShells ) 01578 // Instigator.PlayRolloffSound(hShellsSound, self, 1); 01579 } 01580 01581 simulated function Zoom() 01582 { 01583 // Log("ZOOM NORMALFIRE call for"@self); 01584 if ( bZoomed ) 01585 { 01586 PlayerController(Instigator.Controller).ToggleZoom(); 01587 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 01588 Instigator.PlayRolloffSound(hZoomSound, self, 1); 01589 bZoomed = false; 01590 iAltZoomLevel = 0; 01591 return; 01592 } 01593 // SwitchSlave(!bEnableSlave); 01594 } 01595 01596 event AnimEnd(int Channel) 01597 { 01598 if ( (fVarAccuracy < TraceAccuracy) && bRapidFire ) 01599 fVarAccuracy = fMin(TraceAccuracy, fVarAccuracy + TraceAccuracy/5.0); 01600 else 01601 fVarAccuracy = TraceAccuracy; 01602 Finish(); 01603 } 01604 01605 event EndState() 01606 { 01607 // if ( Instigator.IsPlayerPawn() && (XIIIWeaponAttachment(ThirdPersonActor) != none) && XIIIWeaponAttachment(ThirdPersonActor).bSpawnShells ) 01608 // Instigator.PlayRolloffSound(hShellsSound, self, 0); 01609 StopFiringTime = Level.TimeSeconds; 01610 } 01611 01612 function Timer() 01613 { 01614 local Vector Start, X,Y,Z; 01615 01616 if ( !AmmoType.bInstantHit ) 01617 { 01618 MakeNoise(FireNoise); 01619 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 01620 Start = GetFireStart(X,Y,Z); 01621 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); 01622 // if ( (Default.ReloadCount != 0) && (ReLoadCount > 0) || ((Default.ReloadCount == 0) && HasAmmo()) ) 01623 FeedBack(); 01624 AmmoType.SpawnProjectile(Start,AdjustedAim); 01625 } 01626 else 01627 { 01628 RealTraceFire(fVarAccuracy,0,0); 01629 } 01630 } 01631 Begin: 01632 if ( WeaponMode == WM_SemiAuto ) 01633 bAllowShot = false; 01634 else if ( WeaponMode == WM_Burst ) 01635 { 01636 iBurstCount ++; 01637 if ( iBurstCount > 2 ) 01638 { 01639 bAllowShot = false; 01640 iBurstCount = 0; 01641 } 01642 else 01643 bAllowShot = true; 01644 } 01645 else 01646 bAllowShot = true; 01647 } 01648 01649 //_____________________________________________________________________________ 01650 state NormalAltFire 01651 { 01652 event BeginState() 01653 { 01654 // Log("> NormalAltFire BeginState"); 01655 // if ( Instigator.IsPlayerPawn() && (XIIIWeaponAttachment(ThirdPersonActor) != none) && XIIIWeaponAttachment(ThirdPersonActor).bSpawnShells ) 01656 // Instigator.PlayRolloffSound(hShellsSound, self, 1); 01657 } 01658 01659 simulated function Zoom() 01660 { 01661 // Log("ZOOM NORMALALTFIRE call for"@self); 01662 if ( bZoomed ) 01663 { 01664 PlayerController(Instigator.Controller).ToggleZoom(); 01665 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 01666 Instigator.PlayRolloffSound(hZoomSound, self, 1); 01667 bZoomed = false; 01668 iAltZoomLevel = 0; 01669 return; 01670 } 01671 } 01672 01673 event AnimEnd(int Channel) 01674 { 01675 if ( (fVarAccuracy < TraceAccuracy) && bRapidFire ) 01676 fVarAccuracy = fMin(TraceAccuracy, fVarAccuracy + TraceAccuracy/5.0); 01677 else 01678 fVarAccuracy = TraceAccuracy; 01679 AltFinish(); 01680 } 01681 01682 event EndState() 01683 { 01684 // if ( Instigator.IsPlayerPawn() && (XIIIWeaponAttachment(ThirdPersonActor) != none) && XIIIWeaponAttachment(ThirdPersonActor).bSpawnShells ) 01685 // Instigator.PlayRolloffSound(hShellsSound, self, 0); 01686 StopFiringTime = Level.TimeSeconds; 01687 } 01688 01689 event Timer() 01690 { 01691 local Vector Start, X,Y,Z; 01692 01693 if ( !AltAmmoType.bInstantHit ) 01694 { 01695 MakeNoise(AltFireNoise); 01696 GetAxes(Instigator.GetViewRotation(),X,Y,Z); 01697 Start = GetAltFireStart(X,Y,Z); 01698 AdjustedAim = Instigator.AdjustAim(AmmoType, Start, 0); 01699 // AdjustedAim = Instigator.AdjustAim(AltAmmoType, Start, 0); 01700 // if ( (Default.AltReloadCount != 0) && (AltReLoadCount > 0) || ((Default.AltReloadCount == 0) && (AltAmmoType.AmmoAmount > 0)) ) 01701 AltFeedBack(); 01702 AltAmmoType.SpawnProjectile(Start,AdjustedAim); 01703 } 01704 else 01705 { 01706 RealTraceAltFire(fVarAccuracy,0,0); 01707 } 01708 } 01709 01710 Begin: 01711 if ( WeaponMode == WM_SemiAuto ) 01712 bAllowShot = false; 01713 else if ( WeaponMode == WM_Burst ) 01714 { 01715 iBurstCount ++; 01716 if ( iBurstCount > 2 ) 01717 { 01718 bAllowShot = false; 01719 iBurstCount = 0; 01720 } 01721 else 01722 bAllowShot = true; 01723 } 01724 else 01725 bAllowShot = true; 01726 } 01727 01728 //_____________________________________________________________________________ 01729 //Fire on the client side. This state is only entered on the network client of the player that is firing this weapon. 01730 state ClientFiring 01731 { 01732 Begin: 01733 if ( WeaponMode == WM_SemiAuto ) 01734 bAllowShot = false; 01735 else if ( WeaponMode == WM_Burst ) 01736 { 01737 iBurstCount ++; 01738 if ( iBurstCount > 2 ) 01739 { 01740 bAllowShot = false; 01741 iBurstCount = 0; 01742 } 01743 else 01744 bAllowShot = true; 01745 } 01746 else 01747 bAllowShot = true; 01748 } 01749 01750 01751 //_____________________________________________________________________________ 01752 //Fire on the client side. This state is only entered on the network client of the player that is firing this weapon. 01753 state ClientAltFiring 01754 { 01755 function Fire( float Value ) {} 01756 function AltFire( float Value ) {} 01757 01758 simulated event AnimEnd(int Channel) 01759 { 01760 ClientAltFinish(); 01761 } 01762 01763 simulated event EndState() 01764 { 01765 AmbientSound = None; 01766 if ( RepeatFire() && !bPendingDelete ) 01767 ServerStopFiring(); 01768 } 01769 01770 simulated event BeginState() 01771 { 01772 // Log("> ClientFiring BeginState"); 01773 } 01774 Begin: 01775 if ( WeaponMode == WM_SemiAuto ) 01776 bAllowShot = false; 01777 else if ( WeaponMode == WM_Burst ) 01778 { 01779 iBurstCount ++; 01780 if ( iBurstCount > 2 ) 01781 { 01782 bAllowShot = false; 01783 iBurstCount = 0; 01784 } 01785 else 01786 bAllowShot = true; 01787 } 01788 else 01789 bAllowShot = true; 01790 } 01791 01792 //_____________________________________________________________________________ 01793 state Reloading 01794 { 01795 function ServerForceReload() {} 01796 function ClientForceReload() {} 01797 function Fire( float Value ) {} 01798 function AltFire( float Value ) {} 01799 01800 function ServerFire() 01801 { 01802 bForceFire = true; 01803 } 01804 01805 function ServerAltFire() 01806 { 01807 bForceAltFire = true; 01808 } 01809 01810 simulated function bool PutDown() 01811 { 01812 bChangeWeapon = true; 01813 return True; 01814 } 01815 01816 simulated event BeginState() 01817 { 01818 // Log("> ReLoading BeginState"); 01819 if ( DBDual ) Log(">> Reloading BeginState for "$self); 01820 if ( bZoomed ) 01821 { 01822 bZoomed=false; 01823 PlayerController(Instigator.Controller).ToggleZoom(); 01824 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 01825 Instigator.PlayRolloffSound(hZoomSound, self, 1); 01826 iAltZoomLevel = 0; 01827 } 01828 01829 bEmptyShot=false; 01830 bAltEmptyShot=false; 01831 01832 if ( (MySlave != none) && !MySlave.IsInState('WaitForMasterReload') && bEnableSlave ) 01833 { 01834 MySlave.GotoState('WaitForMasterReload'); 01835 GotoState('WaitForSlaveDown'); 01836 return; 01837 } 01838 if ( (SlaveOf != none) && !SlaveOf.IsInState('WaitForSlaveReload') ) 01839 { 01840 SlaveOf.GotoState('WaitForSlaveReload'); 01841 GotoState('WaitForMasterDown'); 01842 return; 01843 } 01844 01845 if ( !bForceReload ) 01846 { 01847 if ( Role < ROLE_Authority ) 01848 ServerForceReload(); 01849 else 01850 ClientForceReload(); 01851 } 01852 bForceReload = false; 01853 01854 if ( MyWeaponOno != none ) 01855 MyWeaponOno.ReloadPrimaryWeapon(); 01856 01857 PlayReloading(); 01858 IncrementReloadClientCount(); 01859 /* 01860 if ( XIIIWeaponAttachment(ThirdPersonActor) != None ) 01861 XIIIWeaponAttachment(ThirdPersonActor).ThirdPersonReLoad(); 01862 */ 01863 } 01864 01865 simulated event AnimEnd(int Channel) 01866 { 01867 if ( MySlave != none ) 01868 { 01869 ReloadCount = Min(Default.ReloadCount, AmmoType.AmmoAmount); 01870 MySlave.ReloadCount = Min(Default.ReloadCount, AmmoType.AmmoAmount - ReloadCount); 01871 } 01872 else if ( SlaveOf != none ) 01873 { 01874 SlaveOf.ReloadCount = Min(Default.ReloadCount, AmmoType.AmmoAmount); 01875 ReloadCount = Min(Default.ReloadCount, AmmoType.AmmoAmount - SlaveOf.ReloadCount); 01876 } 01877 else 01878 ReloadCount = Min(Default.ReloadCount, AmmoType.AmmoAmount); 01879 01880 if ( bHaveAltFire && (AltAmmoType != none) ) 01881 AltReloadCount = Min(Default.AltReloadCount, AltAmmoType.AmmoAmount); 01882 if ( Role < ROLE_Authority ) 01883 ClientFinish(); 01884 else 01885 Finish(); 01886 if ( (MySlave != none) && bEnableSlave )// && MySlave.IsInState('WaitForMasterReload') ) 01887 { 01888 MySlave.BringUp(); 01889 } 01890 if ( (SlaveOf != none) ) //&& SlaveOf.IsInState('WaitForSlaveReload') ) 01891 SlaveOf.BringUpNoSlave(); 01892 } 01893 } 01894 01895 //_____________________________________________________________________________ 01896 state WaitForMasterReload 01897 { 01898 function ServerForceReload() {} 01899 function ClientForceReload() {} 01900 function Fire( float Value ) {} 01901 function AltFire( float Value ) {} 01902 event Timer2(); 01903 01904 function ServerFire() 01905 { 01906 bForceFire = true; 01907 } 01908 01909 function ServerAltFire() 01910 { 01911 bForceAltFire = true; 01912 } 01913 01914 simulated function bool PutDown() 01915 { 01916 bChangeWeapon = true; 01917 return True; 01918 } 01919 event BeginState() 01920 { 01921 if ( DBDual ) Log(">> WaitForMasterReload BeginState for "$self); 01922 PlayAnim('Down', 2.0); 01923 } 01924 event AnimEnd(int channel) 01925 { 01926 if ( DBDual ) Log(">> WaitForMasterReload AnimEnd for "$self); 01927 SlaveOf.GotoState('Reloading'); 01928 } 01929 event EndState() 01930 { 01931 if ( DBDual ) Log(" > WaitForMasterReload EndState for "$self); 01932 Finish(); 01933 } 01934 } 01935 01936 state WaitForSlaveDown 01937 { 01938 function ServerForceReload() {} 01939 function ClientForceReload() {} 01940 function Fire( float Value ) {} 01941 function AltFire( float Value ) {} 01942 01943 function ServerFire() 01944 { 01945 bForceFire = true; 01946 } 01947 01948 function ServerAltFire() 01949 { 01950 bForceAltFire = true; 01951 } 01952 01953 simulated function bool PutDown() 01954 { 01955 bChangeWeapon = true; 01956 return True; 01957 } 01958 event BeginState() 01959 { 01960 if ( DBDual ) Log(">> WaitForSlaveDown BeginState for "$self); 01961 } 01962 event EndState() 01963 { 01964 if ( DBDual ) Log(" > WaitForSlaveDown EndState for "$self); 01965 } 01966 } 01967 01968 //_____________________________________________________________________________ 01969 state WaitForSlaveReload 01970 { 01971 function ServerForceReload() {} 01972 function ClientForceReload() {} 01973 function Fire( float Value ) {} 01974 function AltFire( float Value ) {} 01975 01976 function ServerFire() 01977 { 01978 bForceFire = true; 01979 } 01980 01981 function ServerAltFire() 01982 { 01983 bForceAltFire = true; 01984 } 01985 01986 simulated function bool PutDown() 01987 { 01988 bChangeWeapon = true; 01989 return True; 01990 } 01991 event BeginState() 01992 { 01993 if ( DBDual ) Log(">> WaitForSlaveReload BeginState for "$self); 01994 PlayAnim('Down', 2.0); 01995 } 01996 event AnimEnd(int channel) 01997 { 01998 if ( DBDual ) Log(">> WaitForSlaveReload AnimEnd for "$self); 01999 MySlave.GotoState('Reloading'); 02000 } 02001 event EndState() 02002 { 02003 if ( DBDual ) Log(" > WaitForSlaveReload EndState for "$self); 02004 Finish(); 02005 } 02006 } 02007 02008 state WaitForMasterDown 02009 { 02010 function ServerForceReload() {} 02011 function ClientForceReload() {} 02012 function Fire( float Value ) {} 02013 function AltFire( float Value ) {} 02014 02015 function ServerFire() 02016 { 02017 bForceFire = true; 02018 } 02019 02020 function ServerAltFire() 02021 { 02022 bForceAltFire = true; 02023 } 02024 02025 simulated function bool PutDown() 02026 { 02027 bChangeWeapon = true; 02028 return True; 02029 } 02030 event BeginState() 02031 { 02032 if ( DBDual ) Log(">> WaitForMasterDown BeginState for "$self); 02033 } 02034 event EndState() 02035 { 02036 if ( DBDual ) Log(" > WaitForMasterDown EndState for "$self); 02037 } 02038 } 02039 02040 //_____________________________________________________________________________ 02041 /* Bring newly active weapon up. 02042 The weapon will remain in this state while its selection animation is being played (as well as any postselect animation). 02043 While in this state, the weapon cannot be fired. 02044 */ 02045 state Active 02046 { 02047 simulated function BringUp() { bRendered = true; } 02048 function Fire( float Value ) {} 02049 function AltFire( float Value ) {} 02050 02051 function ServerFire() 02052 { 02053 bForceFire = true; 02054 } 02055 02056 function ServerAltFire() 02057 { 02058 bForceAltFire = true; 02059 } 02060 02061 simulated function bool PutDown() 02062 { 02063 local name anim; 02064 local float frame,rate; 02065 02066 if ( DBWeap ) 02067 Log(self@"Active PutDown bIsSlave="$bIsSlave@"MySlave="$MySlave); 02068 02069 GetAnimParams(0,anim,frame,rate); 02070 bChangeWeapon = true; 02071 02072 if ( bIsSlave ) 02073 { // immediate order ? 02074 gotoState('DownWeapon'); 02075 return true; 02076 } 02077 if ( bHaveSlave ) 02078 { 02079 MySlave.PutDown(); 02080 MySlave.NextSlaveState = 'DownWeapon'; 02081 MySlave.SetTimer2(0.05, false); 02082 } 02083 return True; 02084 } 02085 02086 simulated event BeginState() 02087 { 02088 if ( DBWeap ) 02089 Log(self@"Active BeginState"); 02090 Instigator = Pawn(Owner); 02091 bForceFire = false; 02092 bForceAltFire = false; 02093 bChangeWeapon = false; 02094 bZoomed = false; 02095 bMuzzleFlash = false; 02096 bTracebullets = false; 02097 UpDateSilencer(); 02098 if ( Instigator.IsLocallyControlled() ) 02099 { 02100 // Log(Level.TimeSeconds@"Activate BeginState, bRendered goes true"); 02101 SetLocation( Instigator.Location + Instigator.CalcDrawOffset(self) ); 02102 SetBase(Instigator.Controller); 02103 bRendered = true; 02104 // bHidden = false; 02105 // RefreshDisplaying(); 02106 } 02107 if ( Default.ReLoadCount > 0 ) // ELR DBUG of the use of single ammotype for different weapons 02108 { 02109 if ( AmmoType == none ) // Multiplayer on-line for client's default weapon ?! 02110 { 02111 Log("Active Beginstate GiveAmmo because AmmoType none"); 02112 GiveAmmo(Instigator); 02113 } 02114 02115 else if ( MySlave != none ) 02116 ReloadCount = Min(ReloadCount, AmmoType.AmmoAmount - MySlave.ReloadCount); 02117 else if ( SlaveOf != none ) 02118 ReloadCount = Min(ReloadCount, AmmoType.AmmoAmount - SlaveOf.ReloadCount); 02119 else 02120 ReloadCount = Min(ReloadCount, AmmoType.AmmoAmount); 02121 } 02122 XIIIPawn(Owner).SetFiringMode(FiringMode); 02123 } 02124 02125 simulated event EndState() 02126 { 02127 bForceFire = false; 02128 bForceAltFire = false; 02129 } 02130 02131 simulated event AnimEnd(int Channel) 02132 { 02133 if ( DBWeap ) 02134 Log(self@"Active AnimEnd"); 02135 if ( WeaponMode == WM_SemiAuto ) 02136 bAllowShot = false; 02137 if ( bChangeWeapon ) 02138 { 02139 GotoState('DownWeapon'); 02140 return; 02141 } 02142 if ( Owner == None ) 02143 { 02144 // log(self$" no owner"); 02145 // Global.AnimEnd(0); 02146 GotoState(''); 02147 } 02148 else 02149 { 02150 if ( Role == ROLE_Authority ) 02151 Finish(); 02152 else 02153 ClientFinish(); 02154 } 02155 } 02156 } 02157 02158 //_____________________________________________________________________________ 02159 State DownWeapon 02160 { 02161 function Fire( float Value ) {} 02162 function AltFire( float Value ) {} 02163 function ServerFire() {} 02164 function ServerAltFire() {} 02165 02166 simulated function bool PutDown() 02167 { 02168 return true; //just keep putting it down 02169 } 02170 02171 simulated event AnimEnd(int Channel) 02172 { 02173 if ( bHeavyWeapon ) 02174 XIIIPawn(Owner).SetGroundSpeed(1.0); 02175 if ( !bIsSlave ) 02176 Pawn(Owner).ChangedWeapon(); 02177 if ( (Pawn(Owner).Weapon != self) || (Pawn(Owner).IsPlayerPawn() && !XIIIPlayerController(Pawn(Owner).Controller).bWeaponMode) ) 02178 { 02179 bRendered = false; 02180 bHidden = true; 02181 RefreshDisplaying(); 02182 if ( MySlave != none ) 02183 { 02184 MySlave.bRendered = false; 02185 MySlave.bHidden = true; 02186 MySlave.RefreshDisplaying(); 02187 } 02188 } 02189 } 02190 02191 simulated event BeginState() 02192 { 02193 if ( DBWeap ) 02194 Log(self@"DownWeapon BeginState MySlave="$MySlave); 02195 if ( FirstPersonMF != none ) 02196 { 02197 FirstPersonMF.Destroy(); 02198 FirstPersonMF = none; 02199 } 02200 bChangeWeapon = false; 02201 bMuzzleFlash = false; 02202 if ( bZoomed ) 02203 { 02204 bZoomed=false; 02205 PlayerController(Instigator.Controller).ToggleZoom(); 02206 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02207 Instigator.PlayRolloffSound(hZoomSound, self, 1); 02208 iAltZoomLevel = 0; 02209 } 02210 02211 TweenDown(); 02212 if ( XIIIWeaponAttachment(ThirdPersonActor) != None ) 02213 XIIIWeaponAttachment(ThirdPersonActor).ThirdPersonSwitchWeapon(); 02214 if ( MySlave != none ) 02215 { 02216 MySlave.PutDown(); 02217 MySlave.NextSlaveState = 'DownWeapon'; 02218 MySlave.SetTimer2(0.05, false); 02219 } 02220 } 02221 } 02222 02223 //_____________________________________________________________________________ 02224 state Zooming 02225 { 02226 simulated event Tick(float DeltaTime) 02227 { 02228 if ( !Instigator.PressingAltFire() ) 02229 { 02230 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02231 Instigator.PlayRolloffSound(hZoomSound, self, 2); 02232 if ( Instigator.IsLocallyControlled() ) 02233 PlayerController(Instigator.Controller).StopZoom(); 02234 SetTimer(0.0,False); 02235 bZoomed=true; 02236 GoToState('Idle'); 02237 } 02238 else if (PlayerController(Instigator.Controller).FovAngle < ScopeFov) 02239 { 02240 if ( Instigator.IsLocallyControlled() ) 02241 { 02242 PlayerController(Instigator.Controller).StopZoom(); 02243 PlayerController(Instigator.Controller).SetFov(ScopeFov); 02244 } 02245 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02246 Instigator.PlayRolloffSound(hZoomSound, self, 2); 02247 SetTimer(0.0,False); 02248 bZoomed=true; 02249 GoToState('Idle'); 02250 } 02251 } 02252 02253 simulated event BeginState() 02254 { 02255 if ( Instigator.IsHumanControlled() ) 02256 { 02257 if ( Instigator.IsLocallyControlled() ) 02258 { 02259 if ( bZoomed ) 02260 { 02261 // Log(self$"ToggleZoom"); 02262 PlayerController(Instigator.Controller).ToggleZoom(); 02263 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02264 Instigator.PlayRolloffSound(hZoomSound, self, 1); 02265 gotoState('Idle'); 02266 } 02267 else 02268 { 02269 PlayerController(Instigator.Controller).StartZoom(); 02270 PlayerController(Instigator.Controller).ZoomLevel = 0.3; 02271 PlayerController(Instigator.Controller).SetFov(FClamp(90.0 - (0.3 * 88.0), 1, 170)); 02272 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02273 Instigator.PlayRolloffSound(hZoomSound, self, 0); 02274 // Log(self$"StartZoom, ZoomLevel="$PlayerController(Instigator.Controller).ZoomLevel); 02275 } 02276 bZoomed = false; 02277 } 02278 } 02279 else 02280 { 02281 Instigator.Controller.bFire = 1; 02282 Instigator.Controller.bAltFire = 0; 02283 Global.Fire(0); 02284 } 02285 } 02286 } 02287 02288 //_____________________________________________________________________________ 02289 state AltZooming 02290 { 02291 simulated event Tick(float DeltaTime) 02292 { 02293 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02294 Instigator.PlayRolloffSound(hZoomSound, self, 2); 02295 SetTimer(0.0,False); 02296 bZoomed = true; 02297 if (PlayerController(Instigator.Controller).FovAngle < ScopeFov) 02298 PlayerController(Instigator.Controller).SetFov(ScopeFov); 02299 GoToState('Idle'); 02300 } 02301 02302 simulated event BeginState() 02303 { 02304 if ( Instigator.IsHumanControlled() ) 02305 { 02306 if ( Instigator.IsLocallyControlled() ) 02307 { 02308 iAltZoomLevel ++; 02309 if ( bZoomed && (iAltZoomLevel>Default.iAltZoomLevel) ) 02310 { 02311 // Log(self$"ToggleZoom"); 02312 PlayerController(Instigator.Controller).ToggleZoom(); 02313 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02314 Instigator.PlayRolloffSound(hZoomSound, self, 1); 02315 iAltZoomLevel = 0; 02316 gotoState('Idle'); 02317 } 02318 else 02319 { 02320 PlayerController(Instigator.Controller).ZoomLevel = fAltZoomValue[iAltZoomLevel-1]; 02321 PlayerController(Instigator.Controller).SetFov(FClamp(90.0 - (PlayerController(Instigator.Controller).ZoomLevel * 88.0), 1, 170)); 02322 if ( Instigator.IsLocallyControlled() || (Level.NetMode == NM_StandAlone) ) 02323 Instigator.PlayRolloffSound(hZoomSound, self, 0); 02324 // Log(self$"StartZoom, ZoomLevel="$PlayerController(Instigator.Controller).ZoomLevel); 02325 } 02326 bZoomed=false; 02327 } 02328 } 02329 else 02330 { 02331 Instigator.Controller.bFire = 1; 02332 Instigator.Controller.bAltFire = 0; 02333 Global.Fire(0); 02334 } 02335 } 02336 } 02337 02338 //_____________________________________________________________________________ 02339 state Idle 02340 { 02341 simulated function ForceReload() 02342 { // ELR check here that we have enough ammo to reload 02343 // Log(" ForceReload Call in Idle"); 02344 if ( (ReLoadCount < AmmoType.AmmoAmount) && (Default.ReLoadCount > 0) && (Default.ReLoadCount != ReLoadCount) && CanReLoad() ) 02345 { 02346 if ( bHaveSlave ) // ELR Reset Slave reload count to zero before reloading to avoid bug w/ primary empty & dual full 02347 MySlave.ReloadCount = 0; 02348 02349 ServerForceReload(); 02350 if ( HasAmmo() ) 02351 GotoState('Reloading'); 02352 } 02353 else if ( bHaveAltFire && (AltAmmoType != none) ) 02354 { 02355 if ( (AltReLoadCount < AltAmmoType.AmmoAmount) && (Default.AltReLoadCount > 0) && (Default.AltReLoadCount != AltReLoadCount) && CanReLoad() ) 02356 { 02357 ServerForceReload(); 02358 if ( HasAltAmmo() ) 02359 GotoState('Reloading'); 02360 } 02361 } 02362 } 02363 02364 function ServerForceReload() 02365 { 02366 // Log(" ServerForceReload Call in Idle"); 02367 if ( HasAmmo() || HasAltAmmo() ) 02368 GotoState('Reloading'); 02369 } 02370 function ClientForceReload() 02371 { 02372 // Log(" ClientForceReload Call in Idle"); 02373 if ( HasAmmo() || HasAltAmmo() ) 02374 GotoState('Reloading'); 02375 } 02376 02377 simulated event AnimEnd(int Channel) 02378 { 02379 // log("AnimEnd received for "@self@"in state"@GetStateName()@"animsequence="@AnimSequence); 02380 if ( bHaveBoredSfx && (Owner != none) && Pawn(Owner).IsPlayerPawn() ) 02381 { 02382 if ( Pawn(Owner).Velocity == vect(0,0,0) ) 02383 { 02384 iBoredCount ++; 02385 } 02386 } 02387 if ( bRapidfire ) 02388 fVarAccuracy = fMax(TraceAccuracy/3.0, fVarAccuracy - TraceAccuracy/6.0); 02389 else 02390 fVarAccuracy = TraceAccuracy; 02391 PlayIdleAnim(); 02392 // Log(self$"Playing Idle, fVarAccuracy="$fVarAccuracy); 02393 } 02394 02395 simulated function bool PutDown() 02396 { 02397 GotoState('DownWeapon'); 02398 return True; 02399 } 02400 simulated function Zoom() 02401 { 02402 // Log("ZOOM IDLE call for"@self); 02403 if ( HasScope() ) 02404 { 02405 if ( XIIIPlayerController(Pawn(Owner).controller).bAltZoomingSystem ) 02406 GotoState('AltZooming'); 02407 else 02408 GotoState('Zooming'); 02409 return; 02410 } 02411 SwitchSlave(!bEnableSlave); 02412 } 02413 simulated event BeginState() 02414 { 02415 PlayIdleAnim(); 02416 iBoredCount = 0; 02417 } 02418 Begin: 02419 if ( !Instigator.PressingFire() ) 02420 bAllowShot=true; 02421 if ( WeaponMode == WM_SemiAuto ) 02422 bAllowShot = false; 02423 if ( Instigator.PressingFire() && bAllowShot) Fire(0.0); 02424 if ( bHaveAltFire && Instigator.PressingAltFire() ) AltFire(0.0); 02425 } 02426 02427 // CrossHair=Texture'XIIIMenu.MireCouteau' 02428 // Icon=texture'XIIIMenu.FistsIcon' 02429 // hShellsSound=Sound'XIIIsound.Guns__Shells.Shells__hShellsFall' 02430 02431 02432 defaultproperties 02433 { 02434 bAllowEmptyShot=True 02435 bAllowShot=True 02436 ScopeFOV=10.000000 02437 FireNoise=2.624000 02438 ReLoadNoise=0.157000 02439 AltFireNoise=0.157000 02440 StabilityTex=Texture'XIIIMenu.HUD.fondialog' 02441 FirstPersonMFClass=Class'XIII.FirstPersonMuzzleFlash' 02442 FPMFRelativeRot=(Yaw=16384) 02443 FlashLength=0.030000 02444 MuzzleFlashSize=128.000000 02445 MFTexture=Texture'XIIIMenu.SFX.MuzzleFlash1' 02446 BobDamping=0.900000 02447 AttachmentClass=Class'XIII.XIIIWeaponAttachment' 02448 bDelayDisplay=True 02449 bSpecialDelayFov=True 02450 }

End Source Code