protected virtual void DoWeaponFireShotgun(Vector2 projStartPos, Vector2 direction) { const int SHOT_SPREAD = 2; var spreading = new[] { -0.185f, -0.070f, 0, 0.070f, 0.185f }; var msg = new MsgPacker((int)GameMessages.SV_EXTRAPROJECTILE); msg.AddInt(SHOT_SPREAD * 2 + 1); for (var i = -SHOT_SPREAD; i <= SHOT_SPREAD; i++) { var angle = Math.GetAngle(direction); angle += spreading[i + 2]; var v = 1 - System.Math.Abs(i) / (float)SHOT_SPREAD; var speed = Math.Mix(Tuning["ShotgunSpeeddiff"], 1f, v); var projectile = new Projectile(Weapon.SHOTGUN, Player.ClientId, projStartPos, new Vector2((float)System.Math.Cos(angle), (float)System.Math.Sin(angle)) * speed, (int)(Server.TickSpeed * Tuning["ShotgunLifetime"]), 1, false, 0, (Sound)(-1)); var snapObj = new SnapObj_Projectile(); projectile.FillInfo(snapObj); snapObj.FillMsgPacker(msg); } Server.SendMsg(msg, MsgFlags.NONE, Player.ClientId); GameContext.CreateSound(Position, Sound.SHOTGUN_FIRE); }
protected virtual void DoWeaponFireGun(Vector2 projStartPos, Vector2 direction) { var projectile = new Projectile(Weapon.GUN, Player.ClientId, projStartPos, direction, (int)(Server.TickSpeed * Tuning["GunLifetime"]), 1, false, 0f, (Sound)(-1)); var snapObj = new SnapObj_Projectile(); var msg = new MsgPacker((int)GameMessages.SV_EXTRAPROJECTILE); msg.AddInt(1); projectile.FillInfo(snapObj); snapObj.FillMsgPacker(msg); Server.SendMsg(msg, MsgFlags.NONE, Player.ClientId); GameContext.CreateSound(Position, Sound.GUN_FIRE); }