Skip to content

Commit 068a4a8

Browse files
committed
Remove DistanceFromAttacker
1 parent 0879812 commit 068a4a8

File tree

6 files changed

+12
-22
lines changed

6 files changed

+12
-22
lines changed

.sbproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,14 @@
347347
},
348348
"LaunchConfigs": [
349349
{
350-
"Name": "My New Config",
350+
"Name": "Test",
351351
"GameIdent": "matt.ttt#local",
352-
"MapName": "facepunch.square",
353-
"MaxPlayers": 1,
352+
"MapName": "facepunch.flatgrass",
353+
"MaxPlayers": 64,
354354
"GameSettings": {},
355355
"Addons": "",
356356
"PreLaunchCommand": "",
357-
"PostLaunchCommand": ""
357+
"PostLaunchCommand": "ttt_preround_time 1; ttt_postround_time 1;"
358358
}
359359
]
360360
}

code/Items/Base/Weapon.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,8 @@ protected virtual void ShootBullet( float spread, float force, float damage, flo
255255
.WithAttacker( Owner )
256256
.WithWeapon( this );
257257

258-
if ( trace.Entity is Player player )
259-
{
260-
player.DistanceToAttacker = Vector3.DistanceBetween( Owner.Position, player.Position ).SourceUnitsToMeters();
261-
262-
if ( Info.IsSilenced || damageInfo.IsHeadshot() )
263-
damageInfo.Tags.Add( "silent" );
264-
}
258+
if ( trace.Entity is Player && (Info.IsSilenced || damageInfo.IsHeadshot()) )
259+
damageInfo.Tags.Add( "silent" );
265260

266261
trace.Entity.TakeDamage( damageInfo );
267262
}

code/Items/Equipment/DNA/DNAScanner.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using static TTT.TTTEvent;
56

67
namespace TTT;
78

@@ -212,8 +213,9 @@ protected override void OnActivate()
212213
{
213214
case Corpse corpse:
214215
{
216+
var distance = Vector3.DistanceBetween( corpse.Player.Position, corpse.Player.LastAttacker.Position ).SourceUnitsToMeters();
215217
SourceName = $"{corpse.Player.SteamName}'s corpse";
216-
TimeUntilDecayed = MathF.Pow( 0.74803f * corpse.Player.DistanceToAttacker, 2 ) + 100;
218+
TimeUntilDecayed = MathF.Pow( 0.74803f * distance, 2 ) + 100;
217219

218220
break;
219221
}

code/Items/Weapons/Knife.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ private void StabAttack( float range, float radius )
8080

8181
if ( trace.Entity is Player player )
8282
{
83-
player.DistanceToAttacker = 0;
84-
8583
PlaySound( FleshHit );
8684

8785
if ( Backstabs && IsBehindAndFacingTarget( player ) )

code/Player/Player.Damage.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public partial class Player
1212
[Net]
1313
public TimeSince TimeSinceDeath { get; private set; }
1414

15-
public float DistanceToAttacker { get; set; }
16-
1715
/// <summary>
1816
/// It's always better to use this than <see cref="Entity.LastAttackerWeapon"/>
1917
/// because the weapon may be invalid.
@@ -181,8 +179,7 @@ public void SendDamageInfo( To to )
181179
LastAttackerWeaponInfo,
182180
LastDamage.Damage,
183181
LastDamage.Tags?.ToArray(),
184-
LastDamage.Position,
185-
DistanceToAttacker
182+
LastDamage.Position
186183
);
187184
}
188185

@@ -221,7 +218,6 @@ private float GetBulletDamageMultipliers( DamageInfo info )
221218

222219
private void ResetDamageData()
223220
{
224-
DistanceToAttacker = 0;
225221
LastAttacker = null;
226222
LastAttackerWeapon = null;
227223
LastAttackerWeaponInfo = null;
@@ -235,7 +231,7 @@ public static void Deafen( float strength )
235231
}
236232

237233
[ClientRpc]
238-
private void SendDamageInfo( Entity a, Entity w, CarriableInfo wI, float d, string[] tags, Vector3 p, float dTA )
234+
private void SendDamageInfo( Entity a, Entity w, CarriableInfo wI, float d, string[] tags, Vector3 p)
239235
{
240236
var info = DamageInfo.Generic( 100f )
241237
.WithAttacker( a )
@@ -244,7 +240,6 @@ private void SendDamageInfo( Entity a, Entity w, CarriableInfo wI, float d, stri
244240

245241
info.Tags = new HashSet<string>( tags ?? Array.Empty<string>() );
246242

247-
DistanceToAttacker = dTA;
248243
LastAttacker = a;
249244
LastAttackerWeapon = w;
250245
LastAttackerWeaponInfo = wI;

code/UI/Player/RoleMenu/DNA/DNAMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public static void SetAutoScan( bool enabled )
3939

4040
protected override int BuildHash()
4141
{
42-
return HashCode.Combine( _dnaScanner?.IsCharging, _dnaScanner?.SlotText, _dnaScanner?.DNACollected?.HashCombine( d => d.Id ), _dnaScanner.SelectedId );
42+
return HashCode.Combine( _dnaScanner?.IsCharging, _dnaScanner?.SlotText, _dnaScanner?.DNACollected?.HashCombine( d => d.Id ), _dnaScanner?.SelectedId );
4343
}
4444
}

0 commit comments

Comments
 (0)