Advertisement
Guest User

CSWeapons.uc

a guest
Jul 9th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // CSWeapons.
  3. //=============================================================================
  4. class CSWeapons expands Weapon
  5.     Abstract;
  6.  
  7. Var(CSWeapons) Int Count, ClipCount, HitDamage, AltHitDamage;
  8. Var(CSWeapons) Float ShellCaseScale, FireRate, AltFireRate;
  9. Var(CSWeapons) Vector EjectOffset, TracerOffset;
  10. Var(CSWeapons) Sound ReloadSounds[4];
  11.  
  12. Replication
  13. {
  14.     Reliable If (Role == ROLE_Authority && bNetOwner)
  15.         ClipCount;
  16.     Reliable If (Role == ROLE_Authority)
  17.         ClientSetFOV, ClientSetMFlash, ClientResetFOV;
  18. }
  19.  
  20. Simulated Function SpawnShellCase( Vector X, Vector Y, Vector Z )
  21. {
  22.     local shellcase s;
  23.  
  24.     s = Spawn(class'ShellCase', Pawn(Owner), '', Owner.Location + CalcDrawOffset() + EjectOffset.X * X + EjectOffset.Y * Y + EjectOffset.Z * Z);
  25.     if ( s != None )
  26.     {
  27.         s.DrawScale = ShellCaseScale;
  28.         s.Eject(((FRand()*0.3+0.8) *X + (FRand()*0.3+0.4) *Y + (FRand()*0.3+1.0) * Z * 100));
  29.     }
  30. }
  31.  
  32. Simulated Function SpawnSniperShellCase()
  33. {
  34.     Local Vector X, Y, Z;
  35.     local shellcase s;
  36.  
  37.     GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
  38.     s = Spawn(class'ShellCase', Pawn(Owner), '', Owner.Location + CalcDrawOffset() + EjectOffset.X * X + EjectOffset.Y * Y + EjectOffset.Z * Z);
  39.     if ( s != None )
  40.     {
  41.         s.DrawScale = ShellCaseScale;
  42.         s.LightType = LT_None;
  43.         s.LightEffect = LE_None;
  44.         s.LightRadius = 0;
  45.         s.LightBrightness = 0;
  46.         s.LightHue = 0;
  47.         s.LightSaturation = 0;
  48.         s.Eject(((FRand()*0.3+0.8) *X + (FRand()*0.3+0.4) *Y + (FRand()*0.3+1.0) * Z * 100));
  49.     }
  50. }
  51.  
  52. function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
  53. {
  54.     SpawnShellCase( X,Y,Z );
  55.     if ( PlayerPawn(Owner)!=None )
  56.         PlayerPawn(Owner).ClientInstantFlash( -0.4, vect(650, 450, 190));
  57.     if (Other == Level)
  58.         Spawn(class'HeavyWallHitEffect',,, HitLocation+HitNormal*9, Rotator(HitNormal));
  59.     else if ( Other!=None && Other!=Self )
  60.     {
  61.         if ( Other.IsA('Pawn') && (HitLocation.Z - Other.Location.Z > 0.62 * Other.CollisionHeight)
  62.                 && (instigator.IsA('PlayerPawn') || (instigator.skill > 1))
  63.                 && (!Other.IsA('ScriptedPawn') || !ScriptedPawn(Other).bIsBoss) )
  64.             Other.TakeDamage(HitDamage * 1.35, Pawn(Owner), HitLocation, 35000 * X, 'decapitated');
  65.         else
  66.             Other.TakeDamage(HitDamage,  Pawn(Owner), HitLocation, 30000.0*X, 'shot');
  67.         if ( !Other.IsA('Pawn') && !Other.IsA('Carcass') )
  68.             spawn(class'SpriteSmokePuff',,,HitLocation+HitNormal*9);
  69.  
  70.         if ( Other.IsA('Brush') )
  71.             Spawn(class'HeavyWallHitEffect',,, HitLocation+HitNormal*9, Rotator(HitNormal));
  72.     }
  73. }
  74.  
  75. function TraceFire( float Accuracy )
  76. {
  77.     local vector HitLocation, HitNormal, StartTraceFire, StartTraceSpawn, EndTrace, X,Y,Z, AimDir;
  78.     local actor Other;
  79.  
  80.     Owner.MakeNoise(Pawn(Owner).SoundDampening);
  81.     GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
  82.     StartTraceFire = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z;
  83.     StartTraceSpawn = Owner.Location + CalcDrawOffset() + TracerOffset.X * X + TracerOffset.Y * Y + TracerOffset.Z * Z;
  84.     AdjustedAim = pawn(owner).AdjustAim(1000000, StartTraceFire, 2.75*AimError, False, False)
  85.     EndTrace = StartTraceFire + Accuracy * (FRand() - 0.5 )* Y * 1000
  86.         + Accuracy * (FRand() - 0.5 ) * Z * 1000;
  87.     AimDir = vector(AdjustedAim);
  88.     EndTrace += (10000 * AimDir);
  89.     Other = Pawn(Owner).TraceShot(HitLocation,HitNormal,EndTrace,StartTraceFire);
  90.  
  91.     Count++;
  92.     if ( Count == 4 )
  93.     {
  94.         Count = 0;
  95.         if ( VSize(HitLocation - StartTraceFire) > 250 )
  96.             Spawn(class'CSTracer',,, StartTraceSpawn + 96 * AimDir, rotator(EndTrace - StartTraceFire));
  97.     }
  98.     ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
  99. }
  100.  
  101. Simulated Function ClientSetFOV( Float NewFOV )
  102. {
  103.     PlayerPawn(Owner).FovAngle = NewFOV;
  104.     PlayerPawn(Owner).DesiredFov = NewFOV;
  105. }
  106.  
  107. Simulated Function ClientResetFOV()
  108. {
  109.     PlayerPawn(Owner).FOVAngle = PlayerPawn(Owner).DefaultFOV;
  110.     PlayerPawn(Owner).DesiredFov = PlayerPawn(Owner).DefaultFOV;
  111. }
  112.  
  113. Simulated Function ClientSetMFlash( Float FlashSOffset, Float FlashYOffset )
  114. {
  115.     FlashS = FlashSOffset;
  116.     FlashY = FlashYOffset;
  117. }
  118.  
  119. // Credit to whoever made this, can't remember who it was
  120. Simulated function WeaponKickback(Int WeaponKickback)
  121. {
  122.     Local Rotator ViewRotation;
  123.  
  124.     ViewRotation = Pawn(Owner).ViewRotation;
  125.  
  126.     ViewRotation.Pitch += WeaponKickback;
  127.     If ( ( ViewRotation.Pitch > 16384 ) && ( ViewRotation.Pitch < 32768 ) )
  128.         ViewRotation.Pitch = 16384;
  129.     Pawn(Owner).ClientSetRotation(ViewRotation);
  130. }
  131.  
  132. Function TweenDown();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement