Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SRGameRules extends GameRules;
  2.  
  3. var Pawn LastDamagePawn;
  4. var int LastDamage;
  5. var ServerPerksMut RegMut;
  6.  
  7. var() config int MessageHealthLimit, MessageMassLimit;
  8.  
  9. function PostBeginPlay()
  10. {
  11.     if( Level.Game.GameRulesModifiers==None )
  12.         Level.Game.GameRulesModifiers = Self;
  13.     else
  14.         Level.Game.GameRulesModifiers.AddGameRules(Self);
  15. }
  16.  
  17. function AddGameRules(GameRules GR)
  18. {
  19.     if ( GR!=Self )
  20.         Super.AddGameRules(GR);
  21. }
  22.  
  23. function ScoreKill(Controller Killer, Controller Killed)
  24. {
  25.     local Controller C;
  26.  
  27.     if( Killer.PlayerReplicationInfo!=None && Killer.Pawn!=None && Monster(Killer.Pawn)==None && Monster(Killed.Pawn)!=None )
  28.     {
  29.         if( Class'SRGameRules'.Default.MessageHealthLimit<=Killed.Pawn.Default.Health ||
  30.             Class'SRGameRules'.Default.MessageMassLimit<=Killed.Pawn.Default.Mass )
  31.         {
  32.         PlayerController(Killer).ClientMessage(string(SRPlayerReplicationInfo(Killer.PlayerReplicationInfo).bKFTwoKillMsg));
  33.             for( C=Level.ControllerList; C!=None; C=C.nextController )
  34.             {
  35.                 if( C.bIsPlayer && xPlayer(C)!=None )
  36.                 {
  37.                     if ((SRPlayerReplicationInfo(C.PlayerReplicationInfo) != None && SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKillMsg))
  38.                     {
  39.                         if (SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKFTwoKillMsg)
  40.                             xPlayer(C).ReceiveLocalizedMessage(Class'KF2StyledKillMessage',1,Killer.PlayerReplicationInfo,,Killed.Pawn.Class);
  41.                         else
  42.                             xPlayer(C).ReceiveLocalizedMessage(Class'KF2KillMessage',1,Killer.PlayerReplicationInfo,,Killed.Pawn.Class);
  43.                     }
  44.                 }
  45.             }
  46.         }
  47.         else if( xPlayer(Killer)!=None )
  48.         {
  49.             if ((SRPlayerReplicationInfo(Killer.PlayerReplicationInfo) != None && SRPlayerReplicationInfo(Killer.PlayerReplicationInfo).bKillMsg))
  50.             {
  51.                 if (SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKFTwoKillMsg)
  52.                     xPlayer(Killer).ReceiveLocalizedMessage(Class'KF2StyledKillMessage',,,,Killed.Pawn.Class);
  53.                 else
  54.                     xPlayer(Killer).ReceiveLocalizedMessage(Class'KF2KillMessage',,,,Killed.Pawn.Class);
  55.             }
  56.         }
  57.     }
  58.     Super.ScoreKill(Killer,Killed);
  59. }
  60.  
  61. function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)
  62. {
  63.     local ClientPerkRepLink R;
  64.     local SRCustomProgress S;
  65.     local KFPlayerReplicationInfo KFPRI;
  66.     local SRPlayerReplicationInfo SRPRI;
  67.  
  68.     if ( (NextGameRules != None) && NextGameRules.PreventDeath(Killed,Killer, damageType,HitLocation) )
  69.         return true;
  70.  
  71.     if( xPlayer(Killer)!=None && Killed.Controller!=None && Killed.Controller!=Killer )
  72.     {
  73.         R = FindStatsFor(Killer);
  74.         if( R!=None )
  75.             for( S=R.CustomLink; S!=None; S=S.NextLink )
  76.                 S.NotifyPlayerKill(Killed,damageType);
  77.     }
  78.     if( xPlayer(Killed.Controller)!=None && Killer!=None && Killer.Pawn!=None )
  79.     {
  80.         R = FindStatsFor(Killed.Controller);
  81.         if( R!=None )
  82.             for( S=R.CustomLink; S!=None; S=S.NextLink )
  83.                 S.NotifyPlayerKilled(Killer.Pawn,damageType);
  84.     }
  85.     if(damageType==None || Killer==None || Killed==None)
  86.     {
  87.         if ( NextGameRules != None)
  88.             return NextGameRules.PreventDeath(Killed,Killer,damageType,HitLocation);
  89.         return false;
  90.     }
  91.     if(Killed.IsA('KFMonster') && Killer.IsA('PlayerController'))
  92.     {
  93.         KFPRI=KFPlayerReplicationInfo(Killer.PlayerReplicationInfo);
  94.         SRPRI=SRPlayerReplicationInfo(Killer.PlayerReplicationInfo);
  95.         if ( (KFPRI.ClientVeteranSkill.default.PerkIndex == 12) && SRPRI.bHPRegen )
  96.         {
  97.             if ( Killer.Pawn.Health < 100)
  98.             {
  99.                 Killer.Pawn.Health=Min(Killer.Pawn.Health + RegMut.RegenValue, RegMut.RegenMax);
  100.             }
  101.         }
  102.     }
  103.     if ( NextGameRules != None)
  104.         return NextGameRules.PreventDeath(Killed,Killer, damageType,HitLocation);
  105.     return false;  
  106. }
  107.  
  108. static final function ClientPerkRepLink FindStatsFor( Controller C )
  109. {
  110.     local LinkedReplicationInfo L;
  111.  
  112.     if( C.PlayerReplicationInfo==None )
  113.         return None;
  114.     for( L=C.PlayerReplicationInfo.CustomReplicationInfo; L!=None; L=L.NextReplicationInfo )
  115.         if( ClientPerkRepLink(L)!=None )
  116.             return ClientPerkRepLink(L);
  117.     return None;
  118. }
  119.  
  120. function int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
  121. {
  122.     local float HeadShotCheckScale;
  123.     local byte DamTypeNum;
  124.     local KFPCServ PC;
  125.     local SRPlayerReplicationInfo SRPRI;
  126.     local PlayerController PCT;
  127.     local KFMonster KFM;   
  128.  
  129.     // forward call to next rules
  130.     if ( NextGameRules != None )
  131.         Damage = NextGameRules.NetDamage( OriginalDamage,Damage,injured,instigatedBy,HitLocation,Momentum,DamageType );
  132.      
  133.     if ( Damage == 0 )
  134.         return 0;
  135.  
  136.     //Damage on the left
  137.     if( Damage > 0 && Monster(injured) != None && instigatedBy != None && Monster(instigatedBy) == None && xPlayer(instigatedBy.Controller) != None )
  138.         xPlayer(instigatedBy.Controller).ReceiveLocalizedMessage(Class'KF2DamageMessage',Damage,,,injured.Class);  
  139.    
  140.         // show damage on the hud  
  141.     if ( instigatedBy != none && injured != none && KFPCServ(instigatedBy.Controller) != none && instigatedBy != injured)  {
  142.         PC = KFPCServ(instigatedBy.Controller);
  143.         if (SRPlayerReplicationInfo(instigatedBy.PlayerReplicationInfo) != none && SRPlayerReplicationInfo(instigatedBy.PlayerReplicationInfo).bShowDamage)
  144.         {
  145.             if ( class<KFWeaponDamageType>(damageType)!=none)
  146.             {
  147.                 if ( class<KFWeaponDamageType>(damageType).default.bDealBurningDamage )
  148.                     DamTypeNum = 2;
  149.                 else if ( class<KFWeaponDamageType>(damageType).default.bCheckForHeadShots ) {
  150.                     HeadShotCheckScale = 1.0;
  151.                     if ( class<DamTypeMelee>(damageType) != none )
  152.                         HeadShotCheckScale = 1.25;
  153.                     if ( injured.IsHeadShot(HitLocation, normal(Momentum), HeadShotCheckScale) )
  154.                         DamTypeNum = 1; // pawn can already be playing hit animation, so headshot detection may be wrong
  155.                 }  
  156.                 if ( HitLocation == vect(0, 0, 0) ) //DoT,
  157.                     HitLocation = injured.Location;                
  158.                 PC.ClientPlayerDamaged(Damage, HitLocation, DamTypeNum);  
  159.             }  
  160.         }
  161.  
  162.     }  
  163. //Damage in scoreboard 
  164.     KFM = KFMonster(injured);
  165.     if((KFM == none) || instigatedBy == none)
  166.     {
  167.         if(NextGameRules != none)
  168.         {
  169.             return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
  170.         }
  171.         return Damage;
  172.     }
  173.     if((((KFM != none) && instigatedBy.IsA('KFHumanPawn')) && instigatedBy.Controller.IsA('PlayerController')) && Damage > 0)
  174.     {
  175.         PCT = PlayerController(instigatedBy.Controller);
  176.         if(PCT != none)
  177.         {
  178.             SRPRI = SRPlayerReplicationInfo(PCT.PlayerReplicationInfo);
  179.         }
  180.         if((PCT == none) || SRPRI == none)
  181.         {
  182.             if(NextGameRules != none)
  183.             {
  184.                 return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
  185.             }
  186.             return Damage;
  187.         }
  188.         if(Damage > KFM.Health)
  189.         {
  190.             Damage = KFM.Health;
  191.         }
  192.         if(Damage > KFM.HeadHealth && KFM.bDecapitated && KFM.HeadHealth >= 0)
  193.         {
  194.             Damage = KFM.HeadHealth;
  195.         }
  196.         if(Damage < 0)
  197.         {
  198.             return Damage;
  199.         }
  200.         SRPRI.Damage += Damage;
  201.     }
  202.     if(NextGameRules != none)
  203.     {
  204.         return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
  205.     }  
  206.     return Damage;
  207. }
  208.  
  209. defaultproperties
  210. {
  211.      MessageHealthLimit=2500
  212.      MessageMassLimit=5000
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement