forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* NeSMOTRET' * x2 * ewe chyt' chyt' u ya ymry * pochti!!! * Spriteri RABOTAT' * ChanceFix * DexRev * kto prochital tot sdox * microfix * ache) * hz * gnomaLoxGonaLust) * cheki * probel * probel2 * cheki * Update Resources/Locale/ru-RU/ss220/prototypes/entities/clothing/outerclothing/reactivearmor.ftl Co-authored-by: Ady4ik <[email protected]> * Update Resources/Prototypes/Catalog/Fills/Lockers/heads.yml Co-authored-by: Ady4ik <[email protected]> * fix typosti * NASRANO --------- Co-authored-by: Ady4ik <[email protected]>
- Loading branch information
Showing
19 changed files
with
354 additions
and
3 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
Content.Server/SS220/ReactiveTeleportArmor/ReactiveTeleportArmorComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.tx | ||
namespace Content.Server.SS220.ReactiveTeleportArmor | ||
{ | ||
/// <summary> | ||
/// Intermediate component to work with TeleportOnDamageComponent | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ReactiveTeleportArmorComponent : Component | ||
{ | ||
|
||
} | ||
} |
179 changes: 179 additions & 0 deletions
179
Content.Server/SS220/ReactiveTeleportArmor/ReactiveTeleportArmorSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
using Robust.Shared.Random; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Movement.Pulling.Systems; | ||
using Content.Shared.Movement.Pulling.Components; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Components; | ||
using Robust.Shared.Map.Components; | ||
using System.Numerics; | ||
using Content.Shared.Physics; | ||
using Robust.Shared.Collections; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Clothing.EntitySystems; | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Shared.Item; | ||
using Content.Shared.Item.ItemToggle; | ||
using Content.Shared.Item.ItemToggle.Components; | ||
using Content.Shared.Timing; | ||
using Timer = Robust.Shared.Timing.Timer; | ||
|
||
namespace Content.Server.SS220.ReactiveTeleportArmor | ||
{ | ||
internal class ReactiveTeleportArmorSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
[Dependency] private readonly SharedTransformSystem _xform = default!; | ||
[Dependency] private readonly PullingSystem _pullingSystem = default!; | ||
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!; | ||
[Dependency] private readonly SharedMapSystem _mapSystem = default!; | ||
[Dependency] private readonly ExplosionSystem _explosion = default!; | ||
[Dependency] private readonly SharedItemSystem _item = default!; | ||
[Dependency] private readonly ClothingSystem _clothing = default!; | ||
[Dependency] private readonly ItemToggleSystem _toggle = default!; | ||
|
||
private EntityQuery<PhysicsComponent> _physicsQuery; | ||
private HashSet<Entity<MapGridComponent>> _targetGrids = []; | ||
|
||
public override void Initialize() | ||
{ | ||
_physicsQuery = GetEntityQuery<PhysicsComponent>(); | ||
|
||
base.Initialize(); | ||
SubscribeLocalEvent<TeleportOnDamageComponent, DamageChangedEvent>(TeleporWhenDamaged); | ||
SubscribeLocalEvent<ReactiveTeleportArmorComponent, ClothingGotEquippedEvent>(OnEquip); | ||
SubscribeLocalEvent<ReactiveTeleportArmorComponent, ClothingGotUnequippedEvent>(OnUnequip); | ||
SubscribeLocalEvent<ReactiveTeleportArmorComponent, ItemToggledEvent>(ToggleDone); | ||
} | ||
|
||
private void OnEquip(Entity<ReactiveTeleportArmorComponent> ent, ref ClothingGotEquippedEvent args) | ||
{ | ||
EnsureComp<TeleportOnDamageComponent>(args.Wearer, out var comp); | ||
comp.SavedUid = ent; | ||
} | ||
|
||
private void OnUnequip(Entity<ReactiveTeleportArmorComponent> ent, ref ClothingGotUnequippedEvent args) | ||
{ | ||
RemComp<TeleportOnDamageComponent>(args.Wearer); | ||
} | ||
|
||
private void ToggleDone(Entity<ReactiveTeleportArmorComponent> ent, ref ItemToggledEvent args) | ||
{ | ||
var prefix = args.Activated ? "on" : null; | ||
_item.SetHeldPrefix(ent, prefix); | ||
_clothing.SetEquippedPrefix(ent, prefix); | ||
} | ||
|
||
|
||
private void TeleporWhenDamaged(Entity<TeleportOnDamageComponent> ent, ref DamageChangedEvent args) | ||
{ | ||
if (!TryComp<TeleportOnDamageComponent>(ent, out var armor)) | ||
return; | ||
|
||
var xform = Transform(ent.Owner); | ||
var targetCoords = SelectRandomTileInRange(xform, armor.TeleportRadius); | ||
|
||
if (!args.DamageIncreased || args.DamageDelta == null) | ||
return; | ||
///teleport entity if taken damage && coord = !null && armor is on && !cooldown | ||
if (args.DamageDelta.GetTotal() >= ent.Comp.WakeThreshold && targetCoords != null && _toggle.IsActivated(ent.Comp.SavedUid) && !ent.Comp.OnCoolDown) | ||
{ | ||
ent.Comp.OnCoolDown = true; | ||
|
||
// We need stop the user from being pulled so they don't just get "attached" with whoever is pulling them. | ||
// This can for example happen when the user is cuffed and being pulled. | ||
if (TryComp<PullableComponent>(ent.Owner, out var pull) && _pullingSystem.IsPulled(ent.Owner, pull)) | ||
_pullingSystem.TryStopPull(ent.Owner, pull); | ||
|
||
if (_random.Prob(ent.Comp.TeleportChance)) | ||
{ | ||
_xform.SetCoordinates(ent.Owner, targetCoords.Value); | ||
_audio.PlayPvs(armor.TeleportSound, ent.Owner); | ||
SelectRandomTileInRange(xform, armor.TeleportRadius); | ||
} | ||
else | ||
{ | ||
_explosion.TriggerExplosive(ent.Comp.SavedUid); | ||
} | ||
Timer.Spawn(ent.Comp.CoolDownTime, () => ent.Comp.OnCoolDown = false); | ||
} | ||
} | ||
|
||
private EntityCoordinates? SelectRandomTileInRange(TransformComponent userXform, float radius) | ||
{ | ||
var userCoords = userXform.Coordinates.ToMap(EntityManager, _xform); | ||
_targetGrids.Clear(); | ||
_lookupSystem.GetEntitiesInRange(userCoords, radius, _targetGrids); | ||
Entity<MapGridComponent>? targetGrid = null; | ||
|
||
if (_targetGrids.Count == 0) | ||
return null; | ||
|
||
// Give preference to the grid the entity is currently on. | ||
// This does not guarantee that if the probability fails that the owner's grid won't be picked. | ||
// In reality the probability is higher and depends on the number of grids. | ||
if (userXform.GridUid != null && TryComp<MapGridComponent>(userXform.GridUid, out var gridComp)) | ||
{ | ||
var userGrid = new Entity<MapGridComponent>(userXform.GridUid.Value, gridComp); | ||
if (_random.Prob(0.5f)) | ||
{ | ||
_targetGrids.Remove(userGrid); | ||
targetGrid = userGrid; | ||
} | ||
} | ||
|
||
if (targetGrid == null) | ||
targetGrid = _random.GetRandom().PickAndTake(_targetGrids); | ||
|
||
EntityCoordinates? targetCoords = null; | ||
|
||
var valid = false; | ||
|
||
var range = (float)Math.Sqrt(radius); | ||
var box = Box2.CenteredAround(userCoords.Position, new Vector2(range, range)); | ||
var tilesInRange = _mapSystem.GetTilesEnumerator(targetGrid.Value.Owner, targetGrid.Value.Comp, box, false); | ||
var tileList = new ValueList<Vector2i>(); | ||
|
||
while (tilesInRange.MoveNext(out var tile)) | ||
{ | ||
tileList.Add(tile.GridIndices); | ||
} | ||
|
||
while (tileList.Count != 0) | ||
{ | ||
var tile = tileList.RemoveSwap(_random.Next(tileList.Count)); | ||
valid = true; | ||
foreach (var entity in _mapSystem.GetAnchoredEntities(targetGrid.Value.Owner, targetGrid.Value.Comp, | ||
tile)) | ||
{ | ||
if (!_physicsQuery.TryGetComponent(entity, out var body)) | ||
continue; | ||
|
||
if (body.BodyType != BodyType.Static || | ||
!body.Hard || | ||
(body.CollisionLayer & (int)CollisionGroup.MobMask) == 0) | ||
continue; | ||
|
||
valid = false; | ||
break; | ||
} | ||
|
||
if (valid) | ||
{ | ||
targetCoords = new EntityCoordinates(targetGrid.Value.Owner, | ||
_mapSystem.TileCenterToVector(targetGrid.Value, tile)); | ||
break; | ||
} | ||
} | ||
|
||
if (!valid || _targetGrids.Count != 0) // if we don't do the check here then PickAndTake will blow up on an empty set. | ||
targetGrid = _random.GetRandom().PickAndTake(_targetGrids); | ||
|
||
return targetCoords; | ||
|
||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Content.Server/SS220/ReactiveTeleportArmor/TeleportOnDamageComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Robust.Shared.Audio; | ||
using Content.Shared.FixedPoint; | ||
|
||
namespace Content.Server.SS220.ReactiveTeleportArmor; | ||
|
||
/// <summary> | ||
/// Randomly teleports entity when damaged. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class TeleportOnDamageComponent : Component | ||
{ | ||
/// <summary> | ||
/// Up to how far to teleport the user | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float TeleportRadius = 50f; | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier TeleportSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg"); | ||
|
||
/// <summary> | ||
/// How much damage of any type it takes to wake this entity. | ||
/// </summary> | ||
[DataField] | ||
public FixedPoint2 WakeThreshold = FixedPoint2.New(4); | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float TeleportChance = .9f; | ||
|
||
/// <summary> | ||
/// Need if you want to interact with the entity that provided the TeleportOnDamageComponent. | ||
/// </summary> | ||
[ViewVariables] | ||
public EntityUid SavedUid; | ||
|
||
public bool OnCoolDown = false; | ||
|
||
[DataField] | ||
public TimeSpan CoolDownTime = TimeSpan.FromSeconds(10); | ||
} | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
Resources/Locale/ru-RU/ss220/clothing/OuterClothing/armor.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
ent-ClothingOuterArmorCentcomNavalCarapace = флотский панцирь | ||
.desc = Панцирь, который носят офицеры Командования флота. | ||
ent-ClothingOuterReactiveArmor = экспериментальная реактивная броня | ||
.desc = Новейший прототип брони, основанный на ядре аномалии. Ходят слухи, что учёные NT разрабатывают более стабильную и многозадачную версию. |
1 change: 1 addition & 0 deletions
1
Resources/Locale/ru-RU/ss220/clothing/components/reactivearnor-component.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
toggle-reactivearmor-verb-get-data-text = Переключить реактивную броню |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Resources/Locale/ru-RU/ss220/prototypes/entities/clothing/outerclothing/reactivearmor.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ent-ActionToggleReactiveArmor = Переключить реактивную броню | ||
.desc = Включает или выключает реактивную броню. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
Resources/Prototypes/SS220/Entities/Clothing/OuterClothing/reactive_armor_rd.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
- type: entity | ||
parent: [ClothingOuterBaseLarge, AllowSuitStorageClothing, BaseToggleClothing] | ||
id: ClothingOuterReactiveArmor | ||
name: experimental reactive armor | ||
description: The latest armor prototype based on the anomaly core. There are rumors that NT scientists are developing a more stable and multitasking version. | ||
components: | ||
- type: Sprite | ||
sprite: SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi | ||
layers: | ||
- state: icon | ||
map: [ "enum.ToggleVisuals.Layer" ] | ||
- type: Clothing | ||
sprite: SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi | ||
- type: Appearance | ||
- type: GenericVisualizer | ||
visuals: | ||
enum.ToggleVisuals.Toggled: | ||
enum.ToggleVisuals.Layer: | ||
True: {state: icon-on} | ||
False: {state: icon} | ||
- type: Armor | ||
modifiers: | ||
coefficients: | ||
Blunt: 0.5 | ||
Slash: 0.5 | ||
Piercing: 0.6 | ||
Heat: 0.5 | ||
Caustic: 0.9 | ||
- type: HeldSpeedModifier | ||
- type: ToggleClothing | ||
action: ActionToggleReactiveArmor | ||
- type: ToggleVerb | ||
text: toggle-reactivearmor-verb-get-data-text | ||
- type: GroupExamine | ||
- type: ReactiveTeleportArmor | ||
- type: Explosive | ||
explosionType: Default | ||
maxIntensity: 2 | ||
totalIntensity: 1.5 | ||
intensitySlope: 1 | ||
canCreateVacuum: false | ||
deleteAfterExplosion: false | ||
repeatable: true | ||
- type: Tag | ||
tags: | ||
- HighRiskItem | ||
|
||
- type: entity | ||
id: ActionToggleReactiveArmor | ||
name: Toggle Reactive armor | ||
description: Toggles the armor on and off. | ||
components: | ||
- type: InstantAction | ||
useDelay: 5 | ||
priority: -9 | ||
itemIconStyle: BigItem | ||
event: !type:ToggleActionEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+932 Bytes
...S220/Clothing/OuterClothing/Armor/reactive_armor.rsi/equipped-OUTERCLOTHING.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+539 Bytes
...rces/Textures/SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi/icon-on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+418 Bytes
Resources/Textures/SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+583 Bytes
.../Textures/SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi/inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+552 Bytes
...Textures/SS220/Clothing/OuterClothing/Armor/reactive_armor.rsi/inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.