diff --git a/Content.Client/IgnoredComponents.cs b/Content.Client/IgnoredComponents.cs index 87ec860cb6..0cb7efa887 100644 --- a/Content.Client/IgnoredComponents.cs +++ b/Content.Client/IgnoredComponents.cs @@ -217,6 +217,7 @@ "ConveyorAssembly", "TwoWayLever", "FirelockElectronics", + "ChemicalInjectionProjectile", "Machine", "MachinePart", "MachineFrame", diff --git a/Content.Server/GameObjects/Components/Projectiles/ChemicalInjectionProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ChemicalInjectionProjectileComponent.cs new file mode 100644 index 0000000000..bc4ede4b00 --- /dev/null +++ b/Content.Server/GameObjects/Components/Projectiles/ChemicalInjectionProjectileComponent.cs @@ -0,0 +1,55 @@ +using Content.Server.GameObjects.Components.Body.Circulatory; +using Content.Server.GameObjects.Components.Chemistry; +using Content.Shared.Chemistry; +using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; +using System; + +namespace Content.Server.GameObjects.Components.Projectiles +{ + [RegisterComponent] + public class ChemicalInjectionProjectileComponent : Component, ICollideBehavior + { + public override string Name => "ChemicalInjectionProjectile"; + + [ViewVariables] + private SolutionContainerComponent _solutionContainer; + + [ViewVariables(VVAccess.ReadWrite)] + public ReagentUnit TransferAmount { get; set; } + + [ViewVariables(VVAccess.ReadWrite)] + public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); } + private float _transferEfficiency; + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + serializer.DataField(this, x => x.TransferAmount, "transferAmount", ReagentUnit.New(1)); + serializer.DataField(ref _transferEfficiency, "transferEfficiency", 1f); + } + + public override void Initialize() + { + base.Initialize(); + _solutionContainer = Owner.EnsureComponent(); + } + + void ICollideBehavior.CollideWith(IEntity entity) + { + if (!entity.TryGetComponent(out var bloodstream)) + return; + + var solution = _solutionContainer.Solution; + var solRemoved = solution.SplitSolution(TransferAmount); + var solRemovedVol = solRemoved.TotalVolume; + + var solToInject = solRemoved.SplitSolution(solRemovedVol * TransferEfficiency); + + bloodstream.TryTransferSolution(solToInject); + } + } +} diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/cartridges.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/cartridges.yml index 715394c48f..78262f338e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/cartridges.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/cartridges.yml @@ -1,4 +1,4 @@ -- type: entity +- type: entity id: ShellShotgunBase name: shell (.50) parent: BaseItem @@ -87,3 +87,15 @@ - type: Ammo projectile: PelletShotgun projectilesFired: 6 + +- type: entity + id: ShellTranquilizer + name: shell (.50 tranquilizer) + parent: ShellShotgunBase + components: + - type: Sprite + sprite: Objects/Weapons/Guns/Ammunition/Casings/shotgun_shell_practice.rsi + - type: Ammo + projectile: PelletShotgunTranquilizer + projectilesFired: 1 + ammoSpread: 0 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/projectiles.yml index 238d47d201..d636b4ae77 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Shotgun/projectiles.yml @@ -1,4 +1,4 @@ -- type: entity +- type: entity id: PelletShotgunSlug name: pellet (.50 slug) abstract: true @@ -76,3 +76,24 @@ - type: Projectile damages: Blunt: 1 + +- type: entity + id: PelletShotgunTranquilizer + name: pellet (.50 tranquilizer) + abstract: true + parent: BulletBasePractice + components: + - type: Sprite + sprite: Objects/Weapons/Guns/Projectiles/buckshot.rsi + state: base + - type: Projectile + damages: + Blunt: 1 + - type: SolutionContainer + maxVol: 10 + contents: + reagents: + - ReagentId: chem.H2O + Quantity: 10 + caps: RemoveFrom + - type: ChemicalInjectionProjectile