Skip to content

Commit

Permalink
Merge pull request #559 from Eagle0600/janiborg
Browse files Browse the repository at this point in the history
Add Mega Spray Bottle and Cleanade Launcher to Advanced Cleaning Module
  • Loading branch information
FoxxoTrystan authored Feb 18, 2025
2 parents bdd4816 + b6c98a8 commit ed670a7
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 25 deletions.
13 changes: 13 additions & 0 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Numerics;
using Content.Server.Cargo.Systems;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Interaction;
using Content.Server.Power.EntitySystems;
using Content.Server.Stunnable;
Expand All @@ -10,6 +11,7 @@
using Content.Shared.Damage.Systems;
using Content.Shared.Database;
using Content.Shared.Effects;
using Content.Shared.Explosion.Components;
using Content.Shared.Interaction.Components;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee;
Expand Down Expand Up @@ -39,6 +41,7 @@ public sealed partial class GunSystem : SharedGunSystem
[Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly ContestsSystem _contests = default!;
[Dependency] private readonly TriggerSystem _trigger = default!;

private const float DamagePitchVariation = 0.05f;
public const float GunClumsyChance = 0.5f;
Expand Down Expand Up @@ -287,6 +290,16 @@ private void ShootOrThrow(EntityUid uid, Vector2 mapDirection, Vector2 gunVeloci
Dirty(uid, targeted);
}

if (TryComp<OnUseTimerTriggerComponent>(uid, out var triggerComponent) && triggerComponent.StartOnShoot)
{
_trigger.HandleTimerTrigger(uid,
user,
triggerComponent.Delay,
triggerComponent.BeepInterval,
triggerComponent.InitialBeepDelay,
triggerComponent.BeepSound);
}

// Do a throw
if (!HasComp<ProjectileComponent>(uid))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public sealed partial class OnUseTimerTriggerComponent : Component
/// </summary>
[DataField] public bool StartOnStick;

/// <summary>
/// Should timer be started when it is shot from a gun.
/// </summary>
[DataField] public bool StartOnShoot = false;

/// <summary>
/// Allows changing the start-on-stick quality.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public sealed partial class BallisticAmmoProviderComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool MayTransfer;

/// <summary>
/// Does this entity load ammo it is used on directly?
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool LoadOnUse = false;

/// <summary>
/// DoAfter delay for filling a bullet into another ballistic ammo provider.
/// </summary>
Expand Down
64 changes: 42 additions & 22 deletions Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
Expand All @@ -14,6 +15,7 @@ namespace Content.Shared.Weapons.Ranged.Systems;
public abstract partial class SharedGunSystem
{
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;

protected virtual void InitializeBallistic()
{
Expand Down Expand Up @@ -41,44 +43,62 @@ private void OnBallisticUse(EntityUid uid, BallisticAmmoProviderComponent compon

private void OnBallisticInteractUsing(EntityUid uid, BallisticAmmoProviderComponent component, InteractUsingEvent args)
{
if (args.Handled || component.Whitelist?.IsValid(args.Used, EntityManager) != true)
return;

if (GetBallisticShots(component) >= component.Capacity)
if (args.Handled)
return;

component.Entities.Add(args.Used);
Containers.Insert(args.Used, component.Container);
// Not predicted so
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
args.Handled = true;
UpdateBallisticAppearance(uid, component);
Dirty(uid, component);
if (TryInsertAmmo(uid, component, args.Used))
{
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
args.Handled = true;
}
}

private void OnBallisticAfterInteract(EntityUid uid, BallisticAmmoProviderComponent component, AfterInteractEvent args)
{
if (args.Handled ||
!component.MayTransfer ||
!Timing.IsFirstTimePredicted ||
args.Target == null ||
args.Used == args.Target ||
Deleted(args.Target) ||
!TryComp<BallisticAmmoProviderComponent>(args.Target, out var targetComponent) ||
targetComponent.Whitelist == null)
Deleted(args.Target))
{
return;
}

args.Handled = true;
// Try to fill the target component with this.
if (component.MayTransfer &&
TryComp<BallisticAmmoProviderComponent>(args.Target, out var targetComponent) &&
targetComponent.Whitelist != null)
{
args.Handled = true;

_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.FillDelay, new AmmoFillDoAfterEvent(), used: uid, target: args.Target, eventTarget: uid)
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.FillDelay, new AmmoFillDoAfterEvent(), used: uid, target: args.Target, eventTarget: uid)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = false,
NeedHand = true
});
}
else if (component.LoadOnUse && TryInsertAmmo(uid, component, (EntityUid) args.Target))
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = false,
NeedHand = true
});
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
args.Handled = true;
}
}

private bool TryInsertAmmo(EntityUid uid, BallisticAmmoProviderComponent ammoProviderComponent, EntityUid ammo)
{
if (ammoProviderComponent.Whitelist != null && !_whitelist.IsValid(ammoProviderComponent.Whitelist, ammo)
|| GetBallisticShots(ammoProviderComponent) >= ammoProviderComponent.Capacity)
return false;

ammoProviderComponent.Entities.Add(ammo);
Containers.Insert(ammo, ammoProviderComponent.Container);
// Not predicted so
UpdateBallisticAppearance(uid, ammoProviderComponent);
Dirty(uid, ammoProviderComponent);

return true;
}

private void OnBallisticAmmoFillDoAfter(EntityUid uid, BallisticAmmoProviderComponent component, AmmoFillDoAfterEvent args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@
items:
- AdvMopItem
- HoloprojectorBorg
- SprayBottleSpaceCleaner
- MegaSprayBottleSpaceCleaner
- WeaponLauncherCleanadeBorg
- Dropper
- TrashBag

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Belt
- type: OnUseTimerTrigger
delay: 3.5
startOnShoot: true
- type: Damageable
damageContainer: Inorganic
- type: Destructible
Expand Down Expand Up @@ -404,6 +405,9 @@
reagents:
- ReagentId: SpaceCleaner
Quantity: 30
- type: Tag
tags:
- Cleanade

- type: entity
parent: SmokeGrenade
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- type: entity
id: MegaSprayBottleSpaceCleaner
parent: MegaSprayBottle
suffix: Space Cleaner
components:
- type: SolutionContainerManager
solutions:
spray:
maxVol: 250
reagents:
- ReagentId: SpaceCleaner
Quantity: 250
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
- type: entity
name: cleanade launcher
parent: [BaseWeaponLauncher, BaseGunWieldable]
id: WeaponLauncherCleanade
description: Only compatible with officially licensed Cleanades.
components:
- type: Sprite
sprite: Floof/Objects/Weapons/Guns/Launchers/cleanade.rsi
layers:
- state: icon
map: ["enum.GunVisualLayers.Base"]
- type: Clothing
sprite: Objects/Weapons/Guns/Launchers/china_lake.rsi
slots:
- Back
- suitStorage
- type: AmmoCounter
- type: Gun
fireRate: 1
projectileSpeed: 10
selectedMode: SemiAuto
availableModes:
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg
- type: BallisticAmmoProvider
whitelist:
tags:
- Cleanade
capacity: 2
proto: CleanerGrenade
soundInsert:
path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg

- type: entity
parent: WeaponLauncherCleanade
suffix: Borg
id: WeaponLauncherCleanadeBorg
categories: [ HideSpawnMenu ]
components:
- type: BallisticAmmoProvider
loadOnUse: true
whitelist:
tags:
- Cleanade
capacity: 2
proto: CleanerGrenade
soundInsert:
path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
7 changes: 5 additions & 2 deletions Resources/Prototypes/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1379,10 +1379,13 @@
id: BrassKnuckles

- type: Tag
id: WeaponDisabler
id: Cleanade

- type: Tag
id: ClothingHeadHelmetBasic

- type: Tag
id: Stunbaton

- type: Tag
id: ClothingHeadHelmetBasic
id: WeaponDisabler
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 1,
"license": "CC-BY-SA-4.0",
"copyright": "Taken/modified from cev-eris at https://github.com/discordia-space/CEV-Eris/pull/6042/commits/64916c98f4847acc4adf3a2416bf78c005fd7dd7, https://github.com/discordia-space/CEV-Eris/blob/master/icons/obj/guns/launcher/grenadelauncher.dmi, backpack sprite by Peptide, resprited for mail gun by erhardsteinhauer (discord), then resprited for cleanade launcher by Eagle0600 (discord and GitHub)",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "bolt-open"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "equipped-BELT",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
}
]
}

0 comments on commit ed670a7

Please sign in to comment.