Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SRGameRules extends GameRules;
- var Pawn LastDamagePawn;
- var int LastDamage;
- var ServerPerksMut RegMut;
- var() config int MessageHealthLimit, MessageMassLimit;
- function PostBeginPlay()
- {
- if( Level.Game.GameRulesModifiers==None )
- Level.Game.GameRulesModifiers = Self;
- else
- Level.Game.GameRulesModifiers.AddGameRules(Self);
- }
- function AddGameRules(GameRules GR)
- {
- if ( GR!=Self )
- Super.AddGameRules(GR);
- }
- function ScoreKill(Controller Killer, Controller Killed)
- {
- local Controller C;
- if( Killer.PlayerReplicationInfo!=None && Killer.Pawn!=None && Monster(Killer.Pawn)==None && Monster(Killed.Pawn)!=None )
- {
- if( Class'SRGameRules'.Default.MessageHealthLimit<=Killed.Pawn.Default.Health ||
- Class'SRGameRules'.Default.MessageMassLimit<=Killed.Pawn.Default.Mass )
- {
- PlayerController(Killer).ClientMessage(string(SRPlayerReplicationInfo(Killer.PlayerReplicationInfo).bKFTwoKillMsg));
- for( C=Level.ControllerList; C!=None; C=C.nextController )
- {
- if( C.bIsPlayer && xPlayer(C)!=None )
- {
- if ((SRPlayerReplicationInfo(C.PlayerReplicationInfo) != None && SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKillMsg))
- {
- if (SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKFTwoKillMsg)
- xPlayer(C).ReceiveLocalizedMessage(Class'KF2StyledKillMessage',1,Killer.PlayerReplicationInfo,,Killed.Pawn.Class);
- else
- xPlayer(C).ReceiveLocalizedMessage(Class'KF2KillMessage',1,Killer.PlayerReplicationInfo,,Killed.Pawn.Class);
- }
- }
- }
- }
- else if( xPlayer(Killer)!=None )
- {
- if ((SRPlayerReplicationInfo(Killer.PlayerReplicationInfo) != None && SRPlayerReplicationInfo(Killer.PlayerReplicationInfo).bKillMsg))
- {
- if (SRPlayerReplicationInfo(C.PlayerReplicationInfo).bKFTwoKillMsg)
- xPlayer(Killer).ReceiveLocalizedMessage(Class'KF2StyledKillMessage',,,,Killed.Pawn.Class);
- else
- xPlayer(Killer).ReceiveLocalizedMessage(Class'KF2KillMessage',,,,Killed.Pawn.Class);
- }
- }
- }
- Super.ScoreKill(Killer,Killed);
- }
- function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)
- {
- local ClientPerkRepLink R;
- local SRCustomProgress S;
- local KFPlayerReplicationInfo KFPRI;
- local SRPlayerReplicationInfo SRPRI;
- if ( (NextGameRules != None) && NextGameRules.PreventDeath(Killed,Killer, damageType,HitLocation) )
- return true;
- if( xPlayer(Killer)!=None && Killed.Controller!=None && Killed.Controller!=Killer )
- {
- R = FindStatsFor(Killer);
- if( R!=None )
- for( S=R.CustomLink; S!=None; S=S.NextLink )
- S.NotifyPlayerKill(Killed,damageType);
- }
- if( xPlayer(Killed.Controller)!=None && Killer!=None && Killer.Pawn!=None )
- {
- R = FindStatsFor(Killed.Controller);
- if( R!=None )
- for( S=R.CustomLink; S!=None; S=S.NextLink )
- S.NotifyPlayerKilled(Killer.Pawn,damageType);
- }
- if(damageType==None || Killer==None || Killed==None)
- {
- if ( NextGameRules != None)
- return NextGameRules.PreventDeath(Killed,Killer,damageType,HitLocation);
- return false;
- }
- if(Killed.IsA('KFMonster') && Killer.IsA('PlayerController'))
- {
- KFPRI=KFPlayerReplicationInfo(Killer.PlayerReplicationInfo);
- SRPRI=SRPlayerReplicationInfo(Killer.PlayerReplicationInfo);
- if ( (KFPRI.ClientVeteranSkill.default.PerkIndex == 12) && SRPRI.bHPRegen )
- {
- if ( Killer.Pawn.Health < 100)
- {
- Killer.Pawn.Health=Min(Killer.Pawn.Health + RegMut.RegenValue, RegMut.RegenMax);
- }
- }
- }
- if ( NextGameRules != None)
- return NextGameRules.PreventDeath(Killed,Killer, damageType,HitLocation);
- return false;
- }
- static final function ClientPerkRepLink FindStatsFor( Controller C )
- {
- local LinkedReplicationInfo L;
- if( C.PlayerReplicationInfo==None )
- return None;
- for( L=C.PlayerReplicationInfo.CustomReplicationInfo; L!=None; L=L.NextReplicationInfo )
- if( ClientPerkRepLink(L)!=None )
- return ClientPerkRepLink(L);
- return None;
- }
- function int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
- {
- local float HeadShotCheckScale;
- local byte DamTypeNum;
- local KFPCServ PC;
- local SRPlayerReplicationInfo SRPRI;
- local PlayerController PCT;
- local KFMonster KFM;
- // forward call to next rules
- if ( NextGameRules != None )
- Damage = NextGameRules.NetDamage( OriginalDamage,Damage,injured,instigatedBy,HitLocation,Momentum,DamageType );
- if ( Damage == 0 )
- return 0;
- //Damage on the left
- if( Damage > 0 && Monster(injured) != None && instigatedBy != None && Monster(instigatedBy) == None && xPlayer(instigatedBy.Controller) != None )
- xPlayer(instigatedBy.Controller).ReceiveLocalizedMessage(Class'KF2DamageMessage',Damage,,,injured.Class);
- // show damage on the hud
- if ( instigatedBy != none && injured != none && KFPCServ(instigatedBy.Controller) != none && instigatedBy != injured) {
- PC = KFPCServ(instigatedBy.Controller);
- if (SRPlayerReplicationInfo(instigatedBy.PlayerReplicationInfo) != none && SRPlayerReplicationInfo(instigatedBy.PlayerReplicationInfo).bShowDamage)
- {
- if ( class<KFWeaponDamageType>(damageType)!=none)
- {
- if ( class<KFWeaponDamageType>(damageType).default.bDealBurningDamage )
- DamTypeNum = 2;
- else if ( class<KFWeaponDamageType>(damageType).default.bCheckForHeadShots ) {
- HeadShotCheckScale = 1.0;
- if ( class<DamTypeMelee>(damageType) != none )
- HeadShotCheckScale = 1.25;
- if ( injured.IsHeadShot(HitLocation, normal(Momentum), HeadShotCheckScale) )
- DamTypeNum = 1; // pawn can already be playing hit animation, so headshot detection may be wrong
- }
- if ( HitLocation == vect(0, 0, 0) ) //DoT,
- HitLocation = injured.Location;
- PC.ClientPlayerDamaged(Damage, HitLocation, DamTypeNum);
- }
- }
- }
- //Damage in scoreboard
- KFM = KFMonster(injured);
- if((KFM == none) || instigatedBy == none)
- {
- if(NextGameRules != none)
- {
- return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
- }
- return Damage;
- }
- if((((KFM != none) && instigatedBy.IsA('KFHumanPawn')) && instigatedBy.Controller.IsA('PlayerController')) && Damage > 0)
- {
- PCT = PlayerController(instigatedBy.Controller);
- if(PCT != none)
- {
- SRPRI = SRPlayerReplicationInfo(PCT.PlayerReplicationInfo);
- }
- if((PCT == none) || SRPRI == none)
- {
- if(NextGameRules != none)
- {
- return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
- }
- return Damage;
- }
- if(Damage > KFM.Health)
- {
- Damage = KFM.Health;
- }
- if(Damage > KFM.HeadHealth && KFM.bDecapitated && KFM.HeadHealth >= 0)
- {
- Damage = KFM.HeadHealth;
- }
- if(Damage < 0)
- {
- return Damage;
- }
- SRPRI.Damage += Damage;
- }
- if(NextGameRules != none)
- {
- return NextGameRules.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
- }
- return Damage;
- }
- defaultproperties
- {
- MessageHealthLimit=2500
- MessageMassLimit=5000
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement