diff --git a/Classes/ST_ShockProj.uc b/Classes/ST_ShockProj.uc index 222a23c..2c8b8c0 100644 --- a/Classes/ST_ShockProj.uc +++ b/Classes/ST_ShockProj.uc @@ -1,6 +1,7 @@ class ST_ShockProj extends ShockProj; var ST_Mutator STM; +var WeaponSettingsRepl WSettings; // For ShockProjectileTakeDamage var float Health; @@ -8,24 +9,54 @@ var float Health; var PlayerPawn InstigatingPlayer; var vector ExtrapolationDelta; +simulated final function WeaponSettingsRepl FindWeaponSettings() { + local WeaponSettingsRepl S; + + foreach AllActors(class'WeaponSettingsRepl', S) + return S; + + return none; +} + +simulated final function WeaponSettingsRepl GetWeaponSettings() { + if (WSettings != none) + return WSettings; + + WSettings = FindWeaponSettings(); + return WSettings; +} + simulated function PostBeginPlay() { - if (ROLE == ROLE_Authority) { + if (Instigator != none && Instigator.Role == ROLE_Authority) { ForEach AllActors(Class'ST_Mutator', STM) break; // Find master :D - } - if (STM.WeaponSettings.ShockProjectileTakeDamage) { - Health = STM.WeaponSettings.ShockProjectileHealth; + + if (STM.WeaponSettings.ShockProjectileTakeDamage) { + Health = STM.WeaponSettings.ShockProjectileHealth; + } } Super.PostBeginPlay(); } simulated function PostNetBeginPlay() { local PlayerPawn In; + local ST_ShockRifle SR; + super.PostNetBeginPlay(); - In = PlayerPawn(Instigator); - if (In != none && Viewport(In.Player) != none) - InstigatingPlayer = In; + if (GetWeaponSettings().ShockProjectileCompensatePing) { + In = PlayerPawn(Instigator); + if (In != none && Viewport(In.Player) != none) + InstigatingPlayer = In; + + if (InstigatingPlayer != none) { + SR = ST_ShockRifle(InstigatingPlayer.Weapon); + if (SR != none && SR.LocalDummy != none && SR.LocalDummy.bDeleteMe == false) + SR.LocalDummy.Destroy(); + } + } else { + Disable('Tick'); + } } simulated event Tick(float Delta) { diff --git a/Classes/ST_ShockRifle.uc b/Classes/ST_ShockRifle.uc index e9a244c..964f465 100644 --- a/Classes/ST_ShockRifle.uc +++ b/Classes/ST_ShockRifle.uc @@ -7,9 +7,10 @@ class ST_ShockRifle extends ShockRifle; var ST_Mutator STM; - var WeaponSettingsRepl WSettings; +var ST_ShockProj LocalDummy; + simulated final function WeaponSettingsRepl FindWeaponSettings() { local WeaponSettingsRepl S; @@ -171,6 +172,52 @@ state ClientFiring { } } +state ClientAltFiring { + simulated function BeginState() { + local Pawn PawnOwner; + local vector X, Y, Z; + local vector Start; + + if (GetWeaponSettings().ShockProjectileCompensatePing == false) + return; + + PawnOwner = Pawn(Owner); + + GetAxes(PawnOwner.ViewRotation,X,Y,Z); + Start = Owner.Location + CalcDrawOffsetClient() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; + LocalDummy = ST_ShockProj(Spawn(AltProjectileClass,,, Start,PawnOwner.ViewRotation)); + LocalDummy.RemoteRole = ROLE_None; + LocalDummy.LifeSpan = 0.25; + LocalDummy.bCollideWorld = false; + LocalDummy.SetCollision(false, false, false); + } +} + +// compatibility between client and server logic +simulated function vector CalcDrawOffsetClient() { + local vector DrawOffset; + local Pawn PawnOwner; + local vector WeaponBob; + + DrawOffset = CalcDrawOffset(); + + if (Level.NetMode != NM_Client) + return DrawOffset; + + PawnOwner = Pawn(Owner); + + // correct for EyeHeight differences between server and client + DrawOffset -= (PawnOwner.EyeHeight * vect(0,0,1)); + DrawOffset += (PawnOwner.BaseEyeHeight * vect(0,0,1)); + + // remove WeaponBob, not applied on server + WeaponBob = BobDamping * PawnOwner.WalkBob; + WeaponBob.Z = (0.45 + 0.55 * BobDamping) * PawnOwner.WalkBob.Z; + DrawOffset -= WeaponBob; + + return DrawOffset; +} + defaultproperties { AltProjectileClass=Class'ST_ShockProj' } diff --git a/Classes/WeaponSettings.uc b/Classes/WeaponSettings.uc index 9a40398..f918350 100644 --- a/Classes/WeaponSettings.uc +++ b/Classes/WeaponSettings.uc @@ -103,6 +103,7 @@ var config float ShockProjectileHurtRadius; var config float ShockProjectileMomentum; var config bool ShockProjectileBlockBullets; var config bool ShockProjectileTakeDamage; +var config bool ShockProjectileCompensatePing; var config float ShockProjectileHealth; var config float ShockComboDamage; var config float ShockComboMomentum; @@ -257,6 +258,7 @@ defaultproperties ShockProjectileMomentum=1.0 ShockProjectileBlockBullets=True ShockProjectileTakeDamage=False + ShockProjectileCompensatePing=False ShockProjectileHealth=30 ShockComboDamage=165 ShockComboHurtRadius=250 diff --git a/Classes/WeaponSettingsRepl.uc b/Classes/WeaponSettingsRepl.uc index 831954d..0191e84 100644 --- a/Classes/WeaponSettingsRepl.uc +++ b/Classes/WeaponSettingsRepl.uc @@ -74,6 +74,7 @@ var float ShockProjectileHurtRadius; var float ShockProjectileMomentum; var bool ShockProjectileBlockBullets; var bool ShockProjectileTakeDamage; +var bool ShockProjectileCompensatePing; var float ShockProjectileHealth; var float ShockComboDamage; var float ShockComboMomentum; @@ -196,6 +197,7 @@ replication { ShockProjectileMomentum, ShockProjectileBlockBullets, ShockProjectileTakeDamage, + ShockProjectileCompensatePing, ShockProjectileHealth, ShockComboDamage, ShockComboMomentum, @@ -517,6 +519,7 @@ function InitFromWeaponSettings(WeaponSettings S) { ShockProjectileMomentum = S.ShockProjectileMomentum; ShockProjectileBlockBullets = S.ShockProjectileBlockBullets; ShockProjectileTakeDamage = S.ShockProjectileTakeDamage; + ShockProjectileCompensatePing = S.ShockProjectileCompensatePing; ShockProjectileHealth = S.ShockProjectileHealth; ShockComboDamage = S.ShockComboDamage; ShockComboMomentum = S.ShockComboMomentum; @@ -678,6 +681,7 @@ defaultproperties ShockProjectileMomentum=1.0 ShockProjectileBlockBullets=False ShockProjectileTakeDamage=False + ShockProjectileCompensatePing=False ShockProjectileHealth=30 ShockComboDamage=165 ShockComboHurtRadius=250