Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry Pick Improvised Weaponry, DeltaV #1217

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;

namespace Content.Server.Explosion.EntitySystems;

public sealed partial class ExplosionSystem
{
[Dependency] private readonly FlammableSystem _flammableSystem = default!;

/// <summary>
/// Used to limit explosion processing time. See <see cref="MaxProcessingTime"/>.
/// </summary>
Expand Down Expand Up @@ -95,7 +99,7 @@ public override void Update(float frameTime)
{
// EXPLOSION TODO allow explosion spawning to be interrupted by time limit. In the meantime, ensure that
// there is at-least 1ms of time left before creating a new explosion
if (MathF.Max(MaxProcessingTime - 1, 0.1f) < Stopwatch.Elapsed.TotalMilliseconds)
if (MathF.Max(MaxProcessingTime - 1, 0.1f) < Stopwatch.Elapsed.TotalMilliseconds)
break;

if (!_explosionQueue.TryDequeue(out var queued))
Expand Down Expand Up @@ -129,11 +133,11 @@ public override void Update(float frameTime)
try
{
#endif
var processed = _activeExplosion.Process(tilesRemaining);
tilesRemaining -= processed;
var processed = _activeExplosion.Process(tilesRemaining);
tilesRemaining -= processed;

// has the explosion finished processing?
if (_activeExplosion.FinishedProcessing)
// has the explosion finished processing?
if (_activeExplosion.FinishedProcessing)
{
var comp = EnsureComp<TimedDespawnComponent>(_activeExplosion.VisualEnt);
comp.Lifetime = _cfg.GetCVar(CCVars.ExplosionPersistence);
Expand Down Expand Up @@ -202,7 +206,8 @@ internal bool ExplodeTile(BroadphaseComponent lookup,
DamageSpecifier damage,
MapCoordinates epicenter,
HashSet<EntityUid> processed,
string id)
string id,
float? fireStacks)
{
var size = grid.Comp.TileSize;
var gridBox = new Box2(tile * size, (tile + 1) * size);
Expand All @@ -221,7 +226,7 @@ internal bool ExplodeTile(BroadphaseComponent lookup,
// process those entities
foreach (var (uid, xform) in list)
{
ProcessEntity(uid, epicenter, damage, throwForce, id, xform);
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
}

// process anchored entities
Expand All @@ -231,7 +236,7 @@ internal bool ExplodeTile(BroadphaseComponent lookup,
foreach (var entity in _anchored)
{
processed.Add(entity);
ProcessEntity(entity, epicenter, damage, throwForce, id, null);
ProcessEntity(entity, epicenter, damage, throwForce, id, null, fireStacks);
}

// Walls and reinforced walls will break into girders. These girders will also be considered turf-blocking for
Expand Down Expand Up @@ -267,7 +272,7 @@ internal bool ExplodeTile(BroadphaseComponent lookup,
{
// Here we only throw, no dealing damage. Containers n such might drop their entities after being destroyed, but
// they should handle their own damage pass-through, with their own damage reduction calculation.
ProcessEntity(uid, epicenter, null, throwForce, id, xform);
ProcessEntity(uid, epicenter, null, throwForce, id, xform, null);
}

return !tileBlocked;
Expand Down Expand Up @@ -302,7 +307,8 @@ internal void ExplodeSpace(BroadphaseComponent lookup,
DamageSpecifier damage,
MapCoordinates epicenter,
HashSet<EntityUid> processed,
string id)
string id,
float? fireStacks)
{
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, new Vector2(DefaultTileSize, DefaultTileSize));
var worldBox = spaceMatrix.TransformBox(gridBox);
Expand All @@ -318,7 +324,7 @@ internal void ExplodeSpace(BroadphaseComponent lookup,
foreach (var (uid, xform) in state.Item1)
{
processed.Add(uid);
ProcessEntity(uid, epicenter, damage, throwForce, id, xform);
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
}

if (throwForce <= 0)
Expand All @@ -332,7 +338,7 @@ internal void ExplodeSpace(BroadphaseComponent lookup,

foreach (var (uid, xform) in list)
{
ProcessEntity(uid, epicenter, null, throwForce, id, xform);
ProcessEntity(uid, epicenter, null, throwForce, id, xform, fireStacks);
}
}

Expand Down Expand Up @@ -429,7 +435,8 @@ private void ProcessEntity(
DamageSpecifier? originalDamage,
float throwForce,
string id,
TransformComponent? xform)
TransformComponent? xform,
float? fireStacksOnIgnite)
{
if (originalDamage != null)
{
Expand All @@ -438,6 +445,17 @@ private void ProcessEntity(
{
// TODO EXPLOSIONS turn explosions into entities, and pass the the entity in as the damage origin.
_damageableSystem.TryChangeDamage(entity, damage, ignoreResistances: true);

}
}

// ignite
if (fireStacksOnIgnite != null)
{
if (_flammableQuery.TryGetComponent(uid, out var flammable))
{
flammable.FireStacks += fireStacksOnIgnite.Value;
_flammableSystem.Ignite(uid, uid, flammable);
}
}

Expand Down Expand Up @@ -706,14 +724,14 @@ private bool TryGetNextTileEnumerator()
{
_currentIntensity = _tileSetIntensity[CurrentIteration];

#if DEBUG
#if DEBUG
if (_expectedDamage != null)
{
// Check that explosion processing hasn't somehow accidentally mutated the damage set.
DebugTools.Assert(_expectedDamage.Equals(_currentDamage));
_expectedDamage = ExplosionType.DamagePerIntensity * _currentIntensity;
}
#endif
#endif

_currentDamage = ExplosionType.DamagePerIntensity * _currentIntensity;

Expand Down Expand Up @@ -812,7 +830,8 @@ public int Process(int processingTarget)
_currentDamage,
Epicenter,
ProcessedEntities,
ExplosionType.ID);
ExplosionType.ID,
ExplosionType.FireStacks);

// If the floor is not blocked by some dense object, damage the floor tiles.
if (canDamageFloor)
Expand All @@ -829,7 +848,8 @@ public int Process(int processingTarget)
_currentDamage,
Epicenter,
ProcessedEntities,
ExplosionType.ID);
ExplosionType.ID,
ExplosionType.FireStacks);
}

if (!MoveNext())
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public sealed partial class ExplosionSystem : EntitySystem
[Dependency] private readonly SharedMapSystem _map = default!;

private EntityQuery<TransformComponent> _transformQuery;
private EntityQuery<DamageableComponent> _damageQuery;
private EntityQuery<FlammableComponent> _flammableQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
private EntityQuery<ProjectileComponent> _projectileQuery;

Expand Down Expand Up @@ -104,7 +104,7 @@ public override void Initialize()
InitVisuals();

_transformQuery = GetEntityQuery<TransformComponent>();
_damageQuery = GetEntityQuery<DamageableComponent>();
_flammableQuery = GetEntityQuery<FlammableComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
_projectileQuery = GetEntityQuery<ProjectileComponent>();
}
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Explosion/ExplosionPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public sealed partial class ExplosionPrototype : IPrototype
[DataField("damagePerIntensity", required: true)]
public DamageSpecifier DamagePerIntensity = default!;

/// <summary>
/// Amount of firestacks to apply in addition to igniting.
/// </summary>
[DataField]
public float? FireStacks;

/// <summary>
/// This set of points, together with <see cref="_tileBreakIntensity"/> define a function that maps the
/// explosion intensity to a tile break chance via linear interpolation.
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/materials/materials.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ materials-bones = bone
materials-coal = coal
materials-bluespace = bluespace
materials-normality = normality
materials-gunpowder = gunpowder
# Ores
materials-raw-iron = raw iron
Expand Down
10 changes: 10 additions & 0 deletions Resources/Migrations/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,13 @@ ReinforcementRadioSyndicateMonkeyNukeops: ReinforcementRadioSyndicateAncestorNuk

# 2024-05-01
DrinkBottleGoldschlager: DrinkBottleGildlager

#2024-03-10
#ClothingBackpackFilledDetective: ClothingBackpackSecurityFilledDetective
#ClothingBackpackDuffelFilledDetective: ClothingBackpackDuffelSecurityFilledDetective
#ClothingBackpackSatchelFilledDetective: ClothingBackpackSatchelSecurityFilledDetective

# 2024-03-11
ImprovisedExplosive: FireBomb
ImprovisedExplosiveEmpty: FireBombEmpty
ImprovisedExplosiveFuel: FireBombFuel
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
- type: entity
parent: BaseItem
id: ModularBreech
name: modular breech
description: Loads the projectile and propellent into the chamber of the gun. Used in the creation of flintlock muskets.
components:
- type: Item
size: Small
- type: Sprite
sprite: DeltaV/Objects/Misc/modular_breech.rsi
state: base
- type: Construction
graph: ModularBreechGraph
node: modularbreech
- type: Tag
tags:
- Metal
- ModularBreech

- type: entity
parent: BaseItem
id: ModularTrigger
name: modular trigger
description: Makes gun go pew when activated. Used in the creation of guns.
components:
- type: Item
size: Small
- type: Sprite
sprite: DeltaV/Objects/Misc/modular_trigger.rsi
state: base
- type: Construction
graph: ModularTriggerGraph
node: modulartrigger
- type: Tag
tags:
- Metal
- ModularTrigger

- type: entity
parent: BaseItem
id: Bayonet
name: bayonet
description: Often placed on guns to go stabby stabby.
components:
- type: Item
size: Small
- type: Sprite
sprite: DeltaV/Objects/Misc/bayonet.rsi
state: base
- type: Construction
graph: BayonetGraph
node: bayonet
- type: Tag
tags:
- Metal
- Bayonet
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- type: entity
parent: BaseCartridge
id: CartridgeMusket
name: cartridge (musket)
description: A paper musket cartridge used to load a musket.
components:
- type: Tag
tags:
- Cartridge
- CartridgeMusket
- type: CartridgeAmmo
proto: BulletMusket
deleteOnSpawn: true
- type: Sprite
sprite: DeltaV/Objects/Weapons/Guns/Ammunition/Casings/musket_casing.rsi
state: base
- type: Construction
graph: CartridgeMusketGraph
node: musketcartridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- type: entity
id: BulletMusket
name: bullet (musket)
parent: BaseBullet
noSpawn: true
components:
- type: Projectile
damage:
types:
Piercing: 30 #4 shot kill for a musket
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,27 @@
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot

- type: entity
name: flintlock
suffix: "craftable"
parent: WeaponPistolFlintlock
id: WeaponPistolFlintlockCrafted
description: An old flintlock, feels like 1800s gang warfare. Uses musket cartridges.
components:
- type: BallisticAmmoProvider
whitelist:
tags:
- CartridgeMusket
capacity: 1
proto: CartridgeMusket
- type: Gun #Smoothbore
minAngle: 0
maxAngle: 30
fireRate: .125 #slow firerate
resetOnHandSelected: false #Dual Wielding Muskets
- type: Construction
graph: WeaponPistolFlintlockCraftedGraph
node: flintlock
- type: UseDelay
delay: 0 #Straight up doesn't work for guns
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,34 @@
sprite: DeltaV/Objects/Weapons/Guns/Rifles/carbinenogl.rsi
- type: Clothing
sprite: DeltaV/Objects/Weapons/Guns/Rifles/carbinenogl.rsi

- type: entity
name: musket
id: WeaponRifleMusket
parent: Musket
suffix: "craftable"
description: An old flintlock musket. Uses musket cartridges.
components:
- type: BallisticAmmoProvider
whitelist:
tags:
- CartridgeMusket
capacity: 1
proto: CartridgeMusket
- type: Sprite
sprite: DeltaV/Objects/Weapons/Guns/Rifles/musket.rsi
state: base
- type: Gun #Smoothbore
fireRate: .125
resetOnHandSelected: false
minAngle: 22
maxAngle: 43
- type: Wieldable
- type: GunWieldBonus
minAngle: -20
maxAngle: -40
- type: Construction
graph: WeaponRifleMusketGraph
node: musket
- type: UseDelay
delay: 0 #Straight up doesn't work for guns
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#In its own file and not musket.yml in case anyone ever wants to add more guns that use it.
- type: constructionGraph
id: BayonetGraph
start: start
graph:
- node: start
edges:
- to: bayonet
steps:
- material: Steel
amount: 1
doAfter: 4
- node: bayonet
entity: Bayonet
Loading
Loading