custom_weaponry
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| custom_weaponry [2023/06/12 10:49] – frank_lee_smith | custom_weaponry [2023/08/21 23:12] (current) – frank_lee_smith | ||
|---|---|---|---|
| Line 96: | Line 96: | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | Smoke Grenade Code | ||
| + | |||
| + | <code csharp> | ||
| + | |||
| + | using Editor; | ||
| + | using Sandbox; | ||
| + | namespace TerrorTown; | ||
| + | |||
| + | [Library( " | ||
| + | [Title( "Smoke Grenade" | ||
| + | [EditorModel( " | ||
| + | public class SmokeGrenade : Throwable, IGrenade, IRandomGrenade | ||
| + | { | ||
| + | public override string ViewModelPath => " | ||
| + | public override string WorldModelPath => " | ||
| + | public override void Throw() | ||
| + | { | ||
| + | if ( Game.IsServer ) | ||
| + | { | ||
| + | var Nade = new SmokeGrenadeThrown(); | ||
| + | Nade.SetModel( WorldModelPath ); | ||
| + | Nade.SetupPhysicsFromModel( PhysicsMotionType.Dynamic ); | ||
| + | Nade.Position = Owner.AimRay.Position + (Owner.AimRay.Forward * 24) + (Vector3.Down * 5); | ||
| + | Nade.PhysicsBody.Velocity = (Owner.AimRay.Forward * 900) + (Owner.AimRay.Forward.EulerAngles.ToRotation().Up * 80); | ||
| + | Nade.PhysicsBody.Velocity += Owner.Velocity * 1f; | ||
| + | Nade.PhysicsBody.AngularVelocity = Vector3.Random * 20; | ||
| + | Nade.TimeOffset = TimeSinceClicked.Relative; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | public class SmokeGrenadeThrown : BasePhysics | ||
| + | { | ||
| + | public float TimeOffset; | ||
| + | public override void Spawn() | ||
| + | { | ||
| + | base.Spawn(); | ||
| + | SetModel( " | ||
| + | SetupPhysicsFromModel( PhysicsMotionType.Dynamic ); | ||
| + | TimeSinceSpawned = 0; | ||
| + | } | ||
| + | TimeSince TimeSinceSpawned; | ||
| + | Particles Particle; | ||
| + | [GameEvent.Tick.Server] | ||
| + | void tick() | ||
| + | { | ||
| + | if ( TimeSinceSpawned > (5 - TimeOffset) ) | ||
| + | { | ||
| + | if ( Particle == null ) | ||
| + | { | ||
| + | Particle = Particles.Create( " | ||
| + | ParticleCleanupSystem.RegisterForCleanup( Particle ); | ||
| + | } | ||
| + | } | ||
| + | if ( TimeSinceSpawned > (65 - TimeOffset) ) | ||
| + | { | ||
| + | Particle.Destroy(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| </ | </ | ||
custom_weaponry.1686566963.txt.gz · Last modified: 2023/06/12 10:49 by frank_lee_smith