Guest User

SG552

a guest
Jul 9th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SG552.
  3. //=============================================================================
  4. class SG552 expands CSWeapons;
  5.  
  6. Var Bool bIsZoomed;
  7.  
  8. Replication
  9. {
  10.     Reliable If (bNetOwner && Role == ROLE_Authority)
  11.         bIsZoomed;
  12. }
  13.  
  14. simulated function PostRender( canvas Canvas )
  15. {
  16. //  Super.PostRender(Canvas);
  17.     bOwnsCrosshair = !bIsZoomed;
  18.  
  19.     if(!bIsZoomed)
  20.     {
  21.         if ((Canvas.SizeX == 1920) && (Canvas.SizeY == 1080))
  22.             ClientSetMFlash(Default.FlashS, -0.11);
  23.         else
  24.             ClientSetMFlash(Default.FlashS, Default.FlashY);
  25.     }
  26.        
  27.     Else if (bIsZoomed)
  28.     {
  29.         if ((Canvas.SizeX == 1920) && (Canvas.SizeY == 1080))
  30.             ClientSetMFlash(-180, -0.17);
  31.         else
  32.             ClientSetMFlash(-180, -0.13);
  33.     }
  34. }
  35.  
  36. state NormalFire
  37. {
  38.     function AltFire(float F)
  39.     {
  40.         Global.AltFire(0);
  41.     }
  42. Begin:
  43.     if (bIsZoomed)
  44.         PlayAnim('Fire',AltFireRate, 0.04);
  45.     Else
  46.         PlayAnim('Fire',FireRate, 0.04);
  47.     FinishAnim();
  48.     if (ClipCount <= 5)
  49.         Owner.PlaySound(Misc1Sound, SLOT_None, 3.5*Pawn(Owner).SoundDampening);
  50.     if ( bChangeWeapon )   
  51.         GotoState('DownWeapon');
  52.     else if ( PlayerPawn(Owner) == None )
  53.         Super.Finish();
  54.     else if ( (AmmoType.AmmoAmount<=0) || (Pawn(Owner).Weapon != self) )
  55.         GotoState('Idle');
  56.     else if (ClipCount<=0)
  57.         GoToState('NewClip');
  58.     else if ( Pawn(Owner).bFire!=0 )
  59.         Global.Fire(0);
  60.     else if ( Pawn(Owner).bAltFire!=0 )
  61.         Global.AltFire(0);
  62.     GoToState('Idle');
  63. }
  64.  
  65. function Fire( float Value )
  66. {
  67.     if(ClipCount>0)
  68.     {  
  69.         bMuzzleFlash++;
  70.         GotoState('NormalFire');
  71.         AmmoType.UseAmmo(1);       
  72.         if ( PlayerPawn(Owner) != None )
  73.             PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
  74.         bPointing=True;
  75.         if (!bIsZoomed)
  76.             TraceFire(0.5);
  77.         if (bIsZoomed)
  78.             TraceFire(0.25);
  79.         Owner.PlaySound(FireSound);
  80.         ClipCount--;       
  81.         CheckVisibility();
  82.     }
  83.  
  84.     else if(ClipCount<=0)
  85.     {
  86.         GotoState('NewClip');
  87.     }
  88. }
  89.  
  90.  
  91.  
  92. Simulated state AltFiring
  93. {
  94.     function Timer()
  95.     {
  96.         if (Pawn(Owner).bAltFire == 0)
  97.         {
  98.             if (PlayerPawn(Owner) != None)
  99.                 ClientResetFOV();
  100.             SetTimer(0.0,False);
  101.             GoToState('Idle');
  102.         }
  103.     }
  104.  
  105. Begin:
  106.     if ( Owner.IsA('PlayerPawn'))
  107.     {
  108.         ClientSetFOV(50);
  109.         SetTimer(0.03,True);
  110.     }
  111.     else
  112.     {
  113.         Pawn(Owner).bFire = 1;
  114.         Pawn(Owner).bAltFire = 0;
  115.         Global.Fire(0);
  116.     }
  117. }  
  118.  
  119. Simulated function AltFire( float Value )
  120. {
  121.     if( PlayerPawn(Owner)==None )
  122.     {
  123.         Global.Fire(0);
  124.         return;
  125.     }
  126.     ClientSetFOV(50);
  127.     bIsZoomed = True;
  128.     SetTimer(0.03,true);
  129. }
  130.  
  131. Simulated function Timer()
  132. {
  133.     if( PlayerPawn(Owner)==None || Pawn(Owner).Weapon!=Self )
  134.         SetTimer(0.00,false);
  135.     else if( Pawn(Owner).bAltFire==0 )
  136.     {
  137.         ClientResetFOV();
  138.         bIsZoomed = False;
  139.         SetTimer(0,false);
  140.     }
  141. }
  142.  
  143. state NewClip
  144. {
  145.     ignores Fire, AltFire;
  146. Begin:
  147.     if (Owner.IsA('PlayerPawn'))
  148.     {
  149.         ClientResetFOV();
  150.         bOwnsCrossHair = True;
  151.         bIsZoomed = False;
  152.     }
  153.     PlayAnim('Reload',1.3,0.04);
  154.     If (AmmoType.AmmoAmount >= Default.Clipcount)
  155.         ClipCount = Default.Clipcount;
  156.     Else if (AmmoType.AmmoAmount < Default.Clipcount)
  157.         ClipCount = Ammotype.AmmoAmount;
  158.     Sleep(0.6);
  159.         Owner.PlaySound(ReloadSounds[0], SLOT_None, Pawn(Owner).SoundDampening * 1.0);
  160.     Sleep(0.9);                            
  161.         Owner.PlaySound(ReloadSounds[1], SLOT_None, Pawn(Owner).SoundDampening * 1.0);
  162.     Sleep(0.8);                                
  163.         Owner.PlaySound(ReloadSounds[2], SLOT_None, Pawn(Owner).SoundDampening * 1.0);
  164.     FinishAnim();                              
  165.     GotoState('Idle');
  166.     if ( bChangeWeapon )
  167.         GotoState('DownWeapon');
  168.     else if ( Pawn(Owner).bFire!=0 )
  169.         Global.Fire(0);
  170.     else if ( Pawn(Owner).bAltFire!=0 )
  171.         Global.AltFire(0);
  172.     else GotoState('Idle');
  173. }
  174.  
  175. function Finish()
  176. {
  177.     local Pawn PawnOwner;
  178.  
  179.     if ( bChangeWeapon )
  180.     {
  181.         GotoState('DownWeapon');
  182.         return;
  183.     }
  184.  
  185.     PawnOwner = Pawn(Owner);
  186.     if ( PlayerPawn(Owner) == None )
  187.     {
  188.         if ( (AmmoType != None) && (AmmoType.AmmoAmount<=0) )
  189.         {
  190.             PawnOwner.StopFiring();
  191.             PawnOwner.SwitchToBestWeapon();
  192.             if ( bChangeWeapon )
  193.                 GotoState('DownWeapon');
  194.         }
  195.         else if ( (PawnOwner.bFire != 0) && (FRand() < RefireRate) )
  196.             Global.Fire(0);
  197.         else
  198.         {
  199.             PawnOwner.StopFiring();
  200.             GotoState('Idle');
  201.         }
  202.         return;
  203.     }
  204.     if ( ((AmmoType != None) && (AmmoType.AmmoAmount<=0)) || (PawnOwner.Weapon != self) )
  205.         GotoState('Idle');
  206.     else if ( PawnOwner.bFire!=0 )
  207.         Global.Fire(0);
  208.     else GotoState('Idle');
  209. }
  210.  
  211.  
  212. state Idle
  213. {
  214. Begin:
  215.     if ( bChangeWeapon )
  216.     {
  217.         GotoState('DownWeapon');
  218.     }
  219.     bMuzzleFlash = 0;
  220.     bPointing=False;
  221.     if ( (AmmoType != None) && (AmmoType.AmmoAmount<=0) )
  222.         Pawn(Owner).SwitchToBestWeapon();  //Goto Weapon that has Ammo
  223.     if ( Pawn(Owner).bFire!=0 ) Fire(0.0);
  224.         Disable('AnimEnd');
  225.     SetTimer(1.5,True);
  226.     if (Pawn(Owner).bFire!=0 )
  227.         Global.Fire(0.0);
  228.     if (Pawn(Owner).bAltFire!=0 )
  229.         Global.AltFire(0.0);
  230.     if( PlayerPawn(Owner)!=None )
  231.     {
  232.         while( Pawn(Owner).bExtra1==0 )
  233.             Sleep(0.05);
  234.     }
  235.     else Sleep(3.f);
  236.     GotoState('NewClip');
  237. }
  238.  
  239. state Active
  240. {
  241.     function Fire(float F)
  242.     {
  243.     }
  244.  
  245.     function AltFire(float F)
  246.     {
  247.     }
  248.  
  249.     function bool PutDown()
  250.     {
  251.         if ( bWeaponUp || (AnimFrame < 0.75) )
  252.             GotoState('DownWeapon');
  253.         else
  254.             bChangeWeapon = true;
  255.         return True;
  256.     }
  257.  
  258.     function BeginState()
  259.     {
  260.         bChangeWeapon = false;
  261.         Super.BeginState();
  262.     }
  263.  
  264. Begin:
  265.     if ( bChangeWeapon )
  266.         GotoState('DownWeapon');
  267.     bWeaponUp = True;
  268.  
  269.     PlayAnim('Select',1.0,0.0);
  270.     Sleep(0.4);
  271.     Owner.PlaySound(SelectSound, SLOT_Misc, Pawn(Owner).SoundDampening);
  272.  
  273.     FinishAnim();
  274.     Finish();
  275. }
  276.  
  277. function BringUp()
  278. {
  279.     bIsZoomed = false;
  280.     Super.BringUp();
  281. }
  282.  
  283. Function PlaySelect();
  284.  
  285. Simulated State DownWeapon
  286. {
  287.     ignores Fire, AltFire;
  288.  
  289.     function BeginState()
  290.     {
  291.         if( PlayerPawn(Owner)!=None )
  292.             ClientResetFOV();
  293.             bIsZoomed = False;
  294.         bChangeWeapon = false;
  295.         bMuzzleFlash = 0;
  296.         SetTimer(0,false);
  297.     }
  298. }
Advertisement
Add Comment
Please, Sign In to add comment