public void RunFireEffects() { ActualAssert(ParentPlayer != null); if (CurrentWeapon.Kind == WeaponKind.PISTOL) { Sfx.PlaySfx(SfxCatagory.PISTOL_FIRE, 0, GlobalTransform.origin, 0); } else if (CurrentWeapon.Kind == WeaponKind.AK) { Sfx.PlaySfx(SfxCatagory.AK_FIRE, 0, GlobalTransform.origin, 0); } else if (CurrentWeapon.Kind == WeaponKind.SHOTGUN) { Sfx.PlaySfx(SfxCatagory.SHOTGUN_FIRE, 0, GlobalTransform.origin, 0); } float RecoilDampen = ((1 - CalcAdsDisplay()) + ParentPlayer.CrouchPercent) / 2f; ParentPlayer.CamAnimations.Add(new WeaponRecoil(CurrentWeapon.RecoilTime, CurrentWeapon.RecoilAmount, RecoilDampen)); int Index = TinkChooser.Choose(); Sfx.PlaySfxSpatially(SfxCatagory.CASING_TINK, Index, GlobalTransform.origin + new Vector3(0, -2, 0), 0); }
public void PerformHitscan() { ActualAssert(ParentPlayer != null); Vector3 Origin = ParentPlayer.Cam.GlobalTransform.origin; Vector3 Endpoint = Origin + new Vector3(0, 0, -Range) .Rotated(new Vector3(1, 0, 0), Deg2Rad(ParentPlayer.CamJoint.RotationDegrees.x + ParentPlayer.Cam.RotationDegrees.x)) .Rotated(new Vector3(0, 1, 0), Deg2Rad(ParentPlayer.RotationDegrees.y)); Vector3 BaseEndpoint = Endpoint; int PelletsLeft = CurrentWeapon.PelletCount; while (PelletsLeft > 0) { if (CurrentWeapon.Kind == WeaponKind.SHOTGUN) { const int DeviationDistance = 18; Endpoint = BaseEndpoint + new Vector3( Game.Rng.Next(DeviationDistance) * RandomSign(), Game.Rng.Next(DeviationDistance) * RandomSign(), Game.Rng.Next(DeviationDistance) * RandomSign() ); } var Exclude = new Godot.Collections.Array() { ParentPlayer }; PhysicsDirectSpaceState State = GetWorld().DirectSpaceState; Godot.Collections.Dictionary Results = State.IntersectRay(Origin, Endpoint, Exclude, 1 | 2); if (Results.Count > 0) { var Position = (Vector3)Results["position"]; var Normal = (Vector3)Results["normal"]; if (Results["collider"] is Hitbox Box) { int Damage = CurrentWeapon.BodyDamage; if (Box.Kind == HitboxKind.HEAD) { Damage = CurrentWeapon.HeadDamage; } Box.Damage(Damage); Sfx.PlaySfxSpatially(SfxCatagory.FLESH_HIT, 0, Position, 0); } else { Sfx.PlaySfxSpatially(SfxCatagory.BULLET_HIT, 0, Position, 0); } Particles.Spawn(Particle.PISTOL_IMPACT, Position, Normal); } PelletsLeft -= 1; } }
public override void _Process(float Delta) { if (Multiplayer.IsNetworkServer()) { CurrentDripTime -= Delta; if (CurrentDripTime <= 0) { CurrentDripTime = (float)(Game.Rng.NextDouble() * (MaxDripTime - MinDripTime) + MinDripTime); Sfx.PlaySfxSpatially(SfxCatagory.DRIP, DripChooser.Choose(), GlobalTransform.origin, 0); } } base._Process(Delta); }