Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SRHUDKillingFloor extends HUD_StoryMode
  2.     dependson(SRPlayerReplicationInfo);
  3.  
  4. ...
  5.  
  6. //NEW
  7. var Texture Noob_Crosshair;
  8. var() config bool bShowDamages;
  9.  
  10. struct DamageInfo
  11. {
  12.     var int Damage;
  13.     var float HitTime;
  14.     var Vector HitLocation;
  15.     var byte DamTypeNum;
  16.     var float RandX, RandY;
  17.     var color FontColor;
  18. };
  19.  
  20. const DAMAGEPOPUP_COUNT = 32;
  21. var DamageInfo DamagePopups[32];
  22. var int NextDamagePopupIndex;
  23. var() config byte DamagePopupFont;
  24. var() config float DamagePopupFadeOutTime;
  25.  
  26. ...
  27.  
  28. var() Material CrosshairTexture;
  29.  
  30. ...
  31.  
  32. simulated function DrawHud(Canvas C)
  33. {
  34. ...
  35.     if ( KFPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).bViewingMatineeCinematic )
  36.     {
  37.         PassStyle = STY_Alpha;
  38.         DrawCinematicHUD(C);
  39.     }
  40.     if ( bShowNotification )
  41.         DrawPopupNotification(C);
  42.        
  43.     if(((PlayerOwner != none) && SRPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo) != none) && SRPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).bShowDamage)
  44.     {
  45.         DrawDamage(C);
  46.     }
  47.    
  48.     if(((PlayerOwner != none) && SRPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo) != none) && SRPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).bUseNoobCross)
  49.     {
  50.         DrawNoobCrosshair(C);
  51.     }  
  52. }
  53.  
  54. ...
  55.  
  56. simulated function ShowDamage(int Damage, float HitTime, Vector HitLocation, byte DamTypeNum, bool Crit)
  57. {
  58.     local Color C;
  59.  
  60.     DamagePopups[NextDamagePopupIndex].Damage = Damage;
  61.     DamagePopups[NextDamagePopupIndex].HitTime = HitTime;
  62.     DamagePopups[NextDamagePopupIndex].DamTypeNum = DamTypeNum;
  63.     DamagePopups[NextDamagePopupIndex].HitLocation = HitLocation;
  64.     DamagePopups[NextDamagePopupIndex].RandX = 2.0 * FRand();
  65.     DamagePopups[NextDamagePopupIndex].RandY = 1.0 * FRand();
  66.     C.A = 255;
  67.    
  68.     if(DamTypeNum == 1)
  69.     {
  70.             C.R = 0;
  71.             C.G = 100;
  72.             C.B = 255;
  73.     }
  74.     if(DamTypeNum == 2)
  75.             {
  76.                 C.R = 206;
  77.                 C.G = 103;
  78.                 C.B = 0;
  79.             }
  80.                 if(Damage >= 500)
  81.                 {
  82.                     C.R = 0;
  83.                     C.G = 206;
  84.                     C.B = 0;
  85.                 }
  86.                     if(Damage >= 175)
  87.                     {
  88.                         C.R = 206;
  89.                         C.G = 206;
  90.                         C.B = 0;
  91.                     }
  92.                         if(Damage > 0)
  93.                         {
  94.                             C.R = 206;
  95.                             C.G = 64;
  96.                             C.B = 64;
  97.                         }
  98.                         else
  99.                         {
  100.                             C.R = 127;
  101.                             C.G = 127;
  102.                             C.B = 127;
  103.                         }
  104.     DamagePopups[NextDamagePopupIndex].FontColor = C;
  105.     if(++ NextDamagePopupIndex >= 32)
  106.     {
  107.         NextDamagePopupIndex = 0;
  108.     }
  109. }
  110.  
  111. simulated function DrawDamage(Canvas C)
  112. {
  113.     local int i;
  114.     local float TimeSinceHit;
  115.     local vector CameraLocation, CamDir;
  116.     local rotator CameraRotation;
  117.     local vector HBScreenPos;
  118.     local float TextWidth, TextHeight, x;
  119.  
  120.     C.GetCameraLocation(CameraLocation, CameraRotation);
  121.     CamDir = vector(CameraRotation);
  122.  
  123.     if ( C.ClipX <= 800 )
  124.         DamagePopupFont = 7;
  125.     else if ( C.ClipX <= 1024 )
  126.         DamagePopupFont = 6;
  127.     else if ( C.ClipX < 1400 )
  128.         DamagePopupFont = 5;
  129.     else if ( C.ClipX < 1700 )
  130.         DamagePopupFont = 4;
  131.     else
  132.         DamagePopupFont = 3;  
  133.        
  134.     C.Font = LoadFont(DamagePopupFont);
  135.  
  136.     for( i=0; i < 32; i++ )
  137.     {
  138. Log("Inside FOR Loop");
  139.         TimeSinceHit = Level.TimeSeconds - DamagePopups[i].HitTime;
  140. Log("Inside FOR Loop 1");
  141.         if(TimeSinceHit > DamagePopupFadeOutTime || (Normal(DamagePopups[i].HitLocation - CameraLocation) dot Normal(CamDir) < 0.1))
  142. Log("Inside FOR Loop 2");
  143.             //continue;
  144. Log("4");        
  145.         HBScreenPos = C.WorldToScreen(DamagePopups[i].HitLocation);    
  146.         C.StrLen(DamagePopups[i].damage, TextWidth, TextHeight);  
  147.         //draw just on the hit location
  148.         HBScreenPos.Y -= TextHeight/2;
  149.         HBScreenPos.X -= TextWidth/2;
  150. Log("5");        
  151.         //let numbers to fly up
  152.         HBScreenPos.Y -= TimeSinceHit * TextHeight * DamagePopups[i].RandY;
  153.         x = Sin(2*Pi * TimeSinceHit/DamagePopupFadeOutTime) * TextWidth * DamagePopups[i].RandX;
  154. Log("6");
  155.         // odd numbers start to flying to the right side, even - left
  156.         // So in situations of decapitaion player could see both damages
  157.         if ( i % 2 == 0)
  158.             x *= -1.0;
  159. Log("7");
  160.         HBScreenPos.X += x;          
  161. Log("8");
  162.         C.DrawColor = DamagePopups[i].FontColor;
  163.         C.DrawColor.A = 255 * cos(0.5*Pi * TimeSinceHit/DamagePopupFadeOutTime);
  164. Log("9");
  165.         C.SetPos( HBScreenPos.X, HBScreenPos.Y);
  166.         C.DrawText(DamagePopups[i].damage);
  167. Log("10");
  168.     }
  169. }
  170.  
  171. ...
  172.  
  173. defaultproperties
  174. {
  175.     // CROSSHAIR TEXTURE
  176.     Noob_Crosshair=Texture'Weps2.Throwing_KnifeV2_T.HL2Crosshair'
  177.     DamagePopupFadeOutTime=1.50
  178.     DamagePopupFont=4
  179.     bShowDamages=True
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement