Skip to content

Commit

Permalink
Merge pull request #238 from nopeingeneer/idiot
Browse files Browse the repository at this point in the history
Взрывозащита сумок и немного фиксов
  • Loading branch information
PyotrIgn authored Dec 22, 2023
2 parents 8645327 + 18d219d commit 92674fa
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace Content.Server.Explosion.Components;

/// <summary>
/// Component that provides entities with explosion resistance.
/// Component that provides entities with explosion resistance.
/// By default this is applied when worn, but to solely protect the entity itself and
/// not the wearer use <c>worn: false</c>.
/// </summary>
/// <remarks>
/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
Expand All @@ -21,6 +23,20 @@ public sealed partial class ExplosionResistanceComponent : Component
[DataField("damageCoefficient")]
public float DamageCoefficient = 1;

/// <summary>
/// When true, resistances will be applied to the entity wearing this item.
/// When false, only this entity will get th resistance.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Worn = true;

/// <summary>
/// Examine string for explosion resistance.
/// Passed <c>value</c> from 0 to 100.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public LocId Examine = "explosion-resistance-coefficient-value";

/// <summary>
/// Modifiers specific to each explosion type for more customizability.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,13 @@ private DamageSpecifier GetDamage(EntityUid uid,
private void GetEntitiesToDamage(EntityUid uid, DamageSpecifier originalDamage, string prototype)
{
_toDamage.Clear();
_toDamage.Add((uid, GetDamage(uid, prototype, originalDamage)));

// don't raise BeforeExplodeEvent if the entity is completely immune to explosions
var thisDamage = GetDamage(uid, prototype, originalDamage);
if (!thisDamage.Any())
return;

_toDamage.Add((uid, thisDamage));

for (var i = 0; i < _toDamage.Count; i++)
{
Expand Down
9 changes: 5 additions & 4 deletions Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public override void Shutdown()
private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component,
InventoryRelayedEvent<GetExplosionResistanceEvent> args)
{
OnGetResistance(uid, component, ref args.Args);
if (component.Worn)
OnGetResistance(uid, component, ref args.Args);
}

private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args)
Expand Down Expand Up @@ -378,9 +379,9 @@ private void CameraShake(float range, MapCoordinates epicenter, float totalInten

private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
{
var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);

args.Msg.PushNewline();
args.Msg.AddMarkup(Loc.GetString("explosion-resistance-coefficient-value",
("value", MathF.Round((1f - component.DamageCoefficient) * 100, 1))
));
args.Msg.AddMarkup(Loc.GetString(component.Examine, ("value", value)));
}
}
4 changes: 0 additions & 4 deletions Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component,

private void OnExploded(Entity<EntityStorageComponent> ent, ref BeforeExplodeEvent args)
{
if (ent.Comp.ExplosionDamageCoefficient <= 0)
return;

args.Contents.AddRange(ent.Comp.Contents.ContainedEntities);
args.DamageCoefficient *= ent.Comp.ExplosionDamageCoefficient;
}

protected override void TakeGas(EntityUid uid, SharedEntityStorageComponent component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ public abstract partial class SharedEntityStorageComponent : Component
/// </summary>
[ViewVariables]
public Container Contents = default!;

/// <summary>
/// Multiplier for explosion damage that gets applied to contained entities.
/// </summary>
[DataField]
public float ExplosionDamageCoefficient = 1;
}

[Serializable, NetSerializable]
Expand Down
10 changes: 10 additions & 0 deletions Resources/Changelog/ChangelogADT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,20 @@ Entries:
id: 55642 #костыль отображения в Обновлениях
time: '2023-12-19T20:04:00.0000000+00:00'



- author: Петр Игнатьевич
changes:
- {message: Выживание убрано как доступная для выбора режима по опросу опция, type: Tweak}
- {message: Изменены веса режимов в Секрете - 30% предатели. 25% - ядерные. 15% - выживание. зомби и революция соответственно, type: Tweak}
- {message: Ядерным Оперативникам теперь можно лететь на станцию через 15 минут после объявления войны, type: Tweak}
id: 55643 #костыль отображения в Обновлениях
time: '2023-12-22T07:20:00.0000000+00:00'

- author: Nopeengener
changes:
- {message: Добавлена защита от взрывов сумкам синдиката и разгрузкам, type: Tweak}
- {message: Дуфель синдиката имеет больше места чем обычная сумка, type: Tweak}
- {message: Изменил шансы кастомного и обычного лута на экспедициях карго, type: Tweak}
id: 55643 #костыль отображения в Обновлениях
time: '2023-12-22T07:40:00.0000000+00:00'
1 change: 1 addition & 0 deletions Resources/Locale/en-US/explosions/explosion-resistance.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
explosion-resistance-coefficient-value = - [color=orange]Explosion[/color] damage reduced by [color=lightblue]{$value}%[/color].
explosion-resistance-contents-coefficient-value = - [color=orange]Explosion[/color] damage [color=white]to contents[/color] reduced by [color=lightblue]{$value}%[/color].
20 changes: 10 additions & 10 deletions Resources/Prototypes/Catalog/Fills/Crates/salvage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,29 @@
- type: StorageFill
contents:
- id: QuadraticCapacitorStockPart
prob: 0.1
amount: 3
- id: FemtoManipulatorStockPart
prob: 0.1
amount: 3
- id: BluespaceMatterBinStockPart
prob: 0.1
amount: 3
- id: SuperCapacitorStockPart
prob: 0.1
amount: 3
- id: PicoManipulatorStockPart
prob: 0.1
amount: 3
- id: SuperMatterBinStockPart
prob: 0.1
amount: 3

- type: entity
parent: CrateGenericSteel
id: CratePartsT4
name: tier 4 parts crate
description: Contains 5 random tier 4 parts for upgrading machines.
description: Contains 18 random tier 4 parts for upgrading machines.
components:
- type: StorageFill
contents:
- id: QuadraticCapacitorStockPart
prob: 0.1
amount: 6
- id: FemtoManipulatorStockPart
prob: 0.1
amount: 6
- id: BluespaceMatterBinStockPart
prob: 0.1
amount: 6
4 changes: 3 additions & 1 deletion Resources/Prototypes/Entities/Clothing/Back/backpacks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- type: entity
parent: Clothing
parent: [Clothing, ContentsExplosionResistanceBase]
id: ClothingBackpack
name: backpack
description: You wear this on your back and put items into it.
Expand Down Expand Up @@ -27,6 +27,8 @@
# to prevent bag open/honk spam
- type: UseDelay
delay: 0.5
- type: ExplosionResistance
damageCoefficient: 0.9

- type: entity
parent: ClothingBackpack
Expand Down
8 changes: 8 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Back/duffel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
components:
- type: Sprite
sprite: Clothing/Back/Duffels/syndicate.rsi
- type: ExplosionResistance
damageCoefficient: 0.1
- type: Storage
maxItemSize: Huge
maxTotalWeight: 50
- type: ClothingSpeedModifier
walkModifier: 1
sprintModifier: 1

- type: entity
parent: ClothingBackpackDuffelSyndicate
Expand Down
6 changes: 4 additions & 2 deletions Resources/Prototypes/Entities/Clothing/Belt/belts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
sprite: Clothing/Belt/salvagewebbing.rsi

- type: entity
parent: ClothingBeltStorageBase
parent: [ClothingBeltStorageBase, ContentsExplosionResistanceBase]
id: ClothingBeltMilitaryWebbing
name: chest rig
description: A set of tactical webbing worn by Syndicate boarding parties.
Expand All @@ -522,9 +522,11 @@
sprite: Clothing/Belt/militarywebbing.rsi
- type: Clothing
sprite: Clothing/Belt/militarywebbing.rsi
- type: ExplosionResistance
damageCoefficient: 0.5

- type: entity
parent: ClothingBeltStorageBase
parent: ClothingBeltMilitaryWebbing
id: ClothingBeltMilitaryWebbingMed
name: medical chest rig
description: A set of tactical webbing worn by Gorlex Marauder medic operatives.
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Entities/Clothing/base_clothing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@
components:
- type: Geiger
attachedToSuit: true

# a piece of clothing that has explosion resistance *for its contents*, not the wearer
- type: entity
abstract: true
id: ContentsExplosionResistanceBase
components:
- type: ExplosionResistance
worn: true # only apply to the clothing itself and items inside, not the wearer
examine: explosion-resistance-contents-coefficient-value
# to show explosion resistance examine
- type: GroupExamine
- type: Armor
modifiers: {}
33 changes: 11 additions & 22 deletions Resources/Prototypes/Procedural/salvage_loot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
prob: 0.5
- proto: PowerCellAntiqueProto
cost: 5
prob: 0.25
prob: 0.35
- proto: ProtolatheMachineCircuitboard
- proto: RandomArtifactSpawner
cost: 2
Expand All @@ -69,52 +69,41 @@
cost: 2
prob: 0.5
- proto: ResearchAndDevelopmentServerMachineCircuitboard
cost: 5
cost: 2
prob: 0.5
- proto: ResearchDisk10000
prob: 0.75
- proto: ResearchDisk5000
prob: 0.5
- proto: RipleyHarness
cost: 3
prob: 0.5
- proto: RPED
- proto: SpaceCash1000
- proto: SpaceCash10000
cost: 10
- proto: SpaceCash2500
cost: 3
- proto: SpaceCash5000
cost: 5
- proto: TechnologyDiskRare
cost: 5
cost: 2
prob: 0.75
- proto: CrateScienceTopDisk
cost: 5
prob: 0.5
prob: 0.65
- proto: WeldingFuelTankHighCapacity
cost: 3
- proto: ADTWeaponWarhammer
cost: 5
prob: 0.1
prob: 0.3
- proto: CrateSyndicateSuperSurplusBundle
cost: 5
prob: 0.0001
prob: 0.01
- proto: CrateBerserk
cost: 5
prob: 0.055
prob: 0.35
- proto: Katana
cost: 5
prob: 0.25
prob: 0.45
- proto: CrateMaterialPlastic
cost: 5
cost: 1
prob: 1
- proto: CrateMaterialSteel
cost: 5
cost: 1
prob: 1
- proto: CargoTelepadMachineCircuitboard
cost: 5
prob: 0.1
prob: 0.3


# Mob loot table
Expand Down

0 comments on commit 92674fa

Please sign in to comment.