From 01ef7a2d1bcf059777886b3792c4f57b04cefbc0 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 1 Jan 2023 00:59:38 -0500 Subject: [PATCH] Good artifact effects (#13223) --- .../ChargeBatteryArtifactComponent.cs | 14 ++ .../Components/SpawnArtifactComponent.cs | 27 +-- .../Systems/ChargeBatteryArtifactSystem.cs | 26 +++ .../Systems/RandomInstrumentArtifactSystem.cs | 4 +- .../Effects/Systems/SpawnArtifactSystem.cs | 40 +--- .../en-US/xenoarchaeology/artifact-hints.ftl | 1 + .../en-US/xenoarchaeology/misc-artifact.ftl | 3 +- .../Xenoarchaeology/item_artifacts.yml | 2 + .../Xenoarchaeology/structure_artifacts.yml | 8 + .../XenoArch/Effects/normal_effects.yml | 206 ++++++++++++++---- .../XenoArch/Effects/utility_effects.yml | 25 ++- 11 files changed, 253 insertions(+), 103 deletions(-) create mode 100644 Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChargeBatteryArtifactComponent.cs create mode 100644 Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChargeBatteryArtifactSystem.cs diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChargeBatteryArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChargeBatteryArtifactComponent.cs new file mode 100644 index 0000000000..cb2c226f6a --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChargeBatteryArtifactComponent.cs @@ -0,0 +1,14 @@ +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; + +/// +/// This is used for recharging all nearby batteries when activated +/// +[RegisterComponent] +public sealed class ChargeBatteryArtifactComponent : Component +{ + /// + /// The radius of entities that will be affected + /// + [DataField("radius")] + public float Radius = 15f; +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs index 4cf5a3d0a9..6c3689f626 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs @@ -1,6 +1,4 @@ -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; +using Content.Shared.Storage; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; @@ -11,18 +9,8 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; [RegisterComponent] public sealed class SpawnArtifactComponent : Component { - /// - /// The list of possible prototypes to spawn that it picks from. - /// - [DataField("possiblePrototypes", customTypeSerializer:typeof(PrototypeIdListSerializer))] - public List PossiblePrototypes = new(); - - /// - /// The prototype it selected to spawn. - /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer))] - public string? Prototype; + [DataField("spawns")] + public List? Spawns; /// /// The range around the artifact that it will spawn the entity @@ -34,12 +22,5 @@ public sealed class SpawnArtifactComponent : Component /// The maximum number of times the spawn will occur /// [DataField("maxSpawns")] - public int MaxSpawns = 20; - - /// - /// Whether or not the artifact spawns the same entity every time - /// or picks through the list each time. - /// - [DataField("consistentSpawn")] - public bool ConsistentSpawn = true; + public int MaxSpawns = 10; } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChargeBatteryArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChargeBatteryArtifactSystem.cs new file mode 100644 index 0000000000..3569a30c36 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChargeBatteryArtifactSystem.cs @@ -0,0 +1,26 @@ +using Content.Server.Power.Components; +using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; +using Content.Server.Xenoarchaeology.XenoArtifacts.Events; + +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; + +/// +/// This handles +/// +public sealed class ChargeBatteryArtifactSystem : EntitySystem +{ + [Dependency] private readonly EntityLookupSystem _lookup = default!; + /// + public override void Initialize() + { + SubscribeLocalEvent(OnActivated); + } + + private void OnActivated(EntityUid uid, ChargeBatteryArtifactComponent component, ArtifactActivatedEvent args) + { + foreach (var battery in _lookup.GetComponentsInRange(Transform(uid).MapPosition, component.Radius)) + { + battery.CurrentCharge = battery.MaxCharge; + } + } +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs index 25dc9e2ce1..8945b86795 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs @@ -17,9 +17,7 @@ public sealed class RandomInstrumentArtifactSystem : EntitySystem private void OnStartup(EntityUid uid, RandomInstrumentArtifactComponent component, ComponentStartup args) { - if (!TryComp(uid, out var instrument)) - return; - + var instrument = EnsureComp(uid); _instrument.SetInstrumentProgram(instrument, (byte) _random.Next(0, 127), 0); } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs index f8e5f16a77..1f260a1890 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs @@ -1,6 +1,6 @@ using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; -using Content.Shared.Hands.EntitySystems; +using Content.Shared.Storage; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; @@ -8,7 +8,6 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; public sealed class SpawnArtifactSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly ArtifactSystem _artifact = default!; public const string NodeDataSpawnAmount = "nodeDataSpawnAmount"; @@ -16,45 +15,28 @@ public sealed class SpawnArtifactSystem : EntitySystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnNodeEntered); SubscribeLocalEvent(OnActivate); } - private void OnNodeEntered(EntityUid uid, SpawnArtifactComponent component, ArtifactNodeEnteredEvent args) - { - if (component.PossiblePrototypes.Count == 0) - return; - - var proto = component.PossiblePrototypes[args.RandomSeed % component.PossiblePrototypes.Count]; - component.Prototype = proto; - } private void OnActivate(EntityUid uid, SpawnArtifactComponent component, ArtifactActivatedEvent args) { - if (component.Prototype == null) - return; - if (!_artifact.TryGetNodeData(uid, NodeDataSpawnAmount, out int amount)) amount = 0; if (amount >= component.MaxSpawns) return; - var toSpawn = component.Prototype; - if (!component.ConsistentSpawn) - toSpawn = _random.Pick(component.PossiblePrototypes); + if (component.Spawns is not {} spawns) + return; - // select spawn position near artifact var artifactCord = Transform(uid).MapPosition; - var dx = _random.NextFloat(-component.Range, component.Range); - var dy = _random.NextFloat(-component.Range, component.Range); - var spawnCord = artifactCord.Offset(new Vector2(dx, dy)); - - // spawn entity - var spawned = EntityManager.SpawnEntity(toSpawn, spawnCord); - _artifact.SetNodeData(uid, NodeDataSpawnAmount, amount+1); - - // if there is an user - try to put spawned item in their hands - // doesn't work for spawners - _handsSystem.PickupOrDrop(args.Activator, spawned); + foreach (var spawn in EntitySpawnCollection.GetSpawns(spawns, _random)) + { + var dx = _random.NextFloat(-component.Range, component.Range); + var dy = _random.NextFloat(-component.Range, component.Range); + var spawnCord = artifactCord.Offset(new Vector2(dx, dy)); + EntityManager.SpawnEntity(spawn, spawnCord); + } + _artifact.SetNodeData(uid, NodeDataSpawnAmount, amount + 1); } } diff --git a/Resources/Locale/en-US/xenoarchaeology/artifact-hints.ftl b/Resources/Locale/en-US/xenoarchaeology/artifact-hints.ftl index 7b97d5e9ec..e0a477ba30 100644 --- a/Resources/Locale/en-US/xenoarchaeology/artifact-hints.ftl +++ b/Resources/Locale/en-US/xenoarchaeology/artifact-hints.ftl @@ -15,6 +15,7 @@ artifact-effect-hint-multitool = Utility conglomerate artifact-effect-hint-storage = Internal chamber artifact-effect-hint-drill = Serrated rotator artifact-effect-hint-soap = Lubricated surface +artifact-effect-hint-communication = Long-distance communication # the triggers should be more obvious than the effects # gives people an idea of what to do: don't be too specific (i.e. no "welders") diff --git a/Resources/Locale/en-US/xenoarchaeology/misc-artifact.ftl b/Resources/Locale/en-US/xenoarchaeology/misc-artifact.ftl index 7e1ebc7a57..78b755a083 100644 --- a/Resources/Locale/en-US/xenoarchaeology/misc-artifact.ftl +++ b/Resources/Locale/en-US/xenoarchaeology/misc-artifact.ftl @@ -1,4 +1,5 @@ blink-artifact-popup = The artifact disappeared in an instant! foam-artifact-popup = Strange foam pours out of the artifact! -shuffle-artifact-popup = You feel yourself teleport instantly! \ No newline at end of file +shuffle-artifact-popup = You feel yourself teleport instantly! +charge-artifact-popup = You feel the air buzz with electricity. \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/item_artifacts.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/item_artifacts.yml index 23414f299f..3667613bdf 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/item_artifacts.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/item_artifacts.yml @@ -46,6 +46,8 @@ type: StorageBoundUserInterface - key: enum.TransferAmountUiKey.Key type: TransferAmountBoundUserInterface + - key: enum.InstrumentUiKey.Key + type: InstrumentBoundUserInterface - type: Appearance - type: StaticPrice price: 500 diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/structure_artifacts.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/structure_artifacts.yml index ff33084649..7a43b4b506 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/structure_artifacts.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/structure_artifacts.yml @@ -19,6 +19,14 @@ bodyType: Dynamic - type: Transform noRot: true + - type: UserInterface #needs to be here for certain effects + interfaces: + - key: enum.StorageUiKey.Key + type: StorageBoundUserInterface + - key: enum.TransferAmountUiKey.Key + type: TransferAmountBoundUserInterface + - key: enum.InstrumentUiKey.Key + type: InstrumentBoundUserInterface - type: Fixtures fixtures: - shape: diff --git a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml index 2f9d468dcc..5766de0cff 100644 --- a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml +++ b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml @@ -64,20 +64,37 @@ components: - type: SpawnArtifact maxSpawns: 10 - consistentSpawns: false - possiblePrototypes: - - FoodPacketSyndiTrash - - FoodPacketSemkiTrash - - FoodPacketBoritosTrash - - FoodPacketCheesieTrash - - FoodPacketChipsTrash - - FoodPacketChocolateTrash - - FoodPacketChowMeinTrash - - FoodPacketEnergyTrash - - FoodPacketPopcornTrash - - FoodPacketRaisinsTrash - - RandomInstruments - - ToySpawner + spawns: + - id: FoodPacketSyndiTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketSemkiTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketBoritosTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketCheesieTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketChipsTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketChocolateTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketEnergyTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketPopcornTrash + prob: 0.1 + orGroup: Trash + - id: FoodPacketRaisinsTrash + prob: 0.1 + orGroup: Trash + - id: ToySpawner + prob: 0.1 + orGroup: Trash - type: artifactEffect id: EffectLightFlicker @@ -102,8 +119,8 @@ components: - type: SpawnArtifact maxSpawns: 20 - possiblePrototypes: - - FoodBanana + spawns: + - id: FoodBanana - type: artifactEffect id: EffectCold @@ -145,8 +162,32 @@ components: - type: SpawnArtifact maxSpawns: 5 - possiblePrototypes: - - RandomInstruments + spawns: + - id: RandomInstruments + +- type: artifactEffect + id: EffectMonkeySpawn + targetDepth: 1 + effectHint: artifact-effect-hint-creation + components: + - type: SpawnArtifact + spawns: + - id: MobMonkey + orGroup: monkey + prob: 0.95 + - id: MobGorilla #harambe + orGroup: monkey + prob: 0.05 + +- type: artifactEffect + id: EffectChargeBatteries + targetDepth: 1 + effectHint: artifact-effect-hint-release + components: + - type: ChargeBatteryArtifact + - type: TelepathicArtifact + messages: + - charge-artifact-popup - type: artifactEffect id: EffectAngryCarpSpawn @@ -155,9 +196,30 @@ components: - type: SpawnArtifact maxSpawns: 5 - possiblePrototypes: - - MobCarpHolo - - MobCarpMagic + spawns: + - id: MobCarpHolo + orGroup: carp + - id: MobCarpMagic + orGroup: carp + +- type: artifactEffect + id: EffectCashSpawn + targetDepth: 2 + effectHint: artifact-effect-hint-creation + components: + - type: SpawnArtifact + maxSpawns: 10 + spawns: + - id: SpaceCash10 + maxAmount: 5 + prob: 0.75 + - id: SpaceCash100 + maxAmount: 2 + prob: 0.5 + - id: SpaceCash500 + prob: 0.25 + - id: SpaceCash1000 + prob: 0.1 - type: artifactEffect id: EffectRadiate @@ -202,6 +264,39 @@ components: - type: RandomTeleportArtifact +- type: artifactEffect + id: EffectFoamGood + targetDepth: 2 + effectHint: artifact-effect-hint-biochemical + components: + - type: FoamArtifact + spreadDuration: 0.5 + duration: 5 + reagents: + - Dermaline + - Arithrazine + - Spaceacillin + - Inaprovaline + - Kelotane + - Dexalin + - Omnizine + +- type: artifactEffect + id: EffectHealAll + targetDepth: 3 + effectHint: artifact-effect-hint-environment + components: + - type: DamageNearbyArtifact + damageChance: 0.75 + radius: 5 + whitelist: + components: + - MobState + damage: + groups: + Brute: -300 + Burn: -300 + - type: artifactEffect id: EffectMaterialSpawn targetDepth: 3 @@ -209,11 +304,13 @@ components: - type: SpawnArtifact maxSpawns: 5 - consistentSpawn: false - possiblePrototypes: - - SheetGlass - - SheetSteel - - SheetPlastic + spawns: + - id: SheetSteel + orGroup: materials + - id: SheetGlass + orGroup: materials + - id: SheetPlastic + orGroup: materials - type: artifactEffect id: EffectShuffle @@ -233,13 +330,22 @@ components: - type: SpawnArtifact maxSpawns: 10 - consistentSpawn: false - possiblePrototypes: - - SuperCapacitorStockPart - - PhasicScanningModuleStockPart - - PicoManipulatorStockPart - - UltraHighPowerMicroLaserStockPart - - SuperMatterBinStockPart + spawns: + - id: SuperCapacitorStockPart + prob: 0.3 + maxAmount: 2 + - id: PhasicScanningModuleStockPart + prob: 0.3 + maxAmount: 2 + - id: PicoManipulatorStockPart + prob: 0.3 + maxAmount: 2 + - id: UltraHighPowerMicroLaserStockPart + prob: 0.3 + maxAmount: 2 + - id: SuperMatterBinStockPart + prob: 0.3 + maxAmount: 2 - type: artifactEffect id: EffectDisease @@ -262,13 +368,19 @@ effectHint: artifact-effect-hint-creation components: - type: SpawnArtifact - maxSpawns: 15 - consistentSpawn: false - possiblePrototypes: - - SilverOre1 - - PlasmaOre1 - - GoldOre1 - - UraniumOre1 + spawns: + - id: SilverOre1 + prob: 0.3 + maxAmount: 3 + - id: PlasmaOre1 + prob: 0.3 + maxAmount: 3 + - id: GoldOre1 + prob: 0.3 + maxAmount: 3 + - id: UraniumOre1 + prob: 0.3 + maxAmount: 3 - type: artifactEffect id: EffectHeat @@ -306,6 +418,16 @@ components: - type: IgniteArtifact +- type: artifactEffect + id: EffectMitosis + targetDepth: 4 + effectHint: artifact-effect-hint-creation + components: + - type: SpawnArtifact + maxSpawns: 1 + spawns: + - id: RandomArtifactSpawner + - type: artifactEffect id: EffectSingulo targetDepth: 100 @@ -313,5 +435,5 @@ components: - type: SpawnArtifact maxSpawns: 1 - possiblePrototypes: - - Singularity + spawns: + - id: Singularity diff --git a/Resources/Prototypes/XenoArch/Effects/utility_effects.yml b/Resources/Prototypes/XenoArch/Effects/utility_effects.yml index a5099dcf49..f5170d08e4 100644 --- a/Resources/Prototypes/XenoArch/Effects/utility_effects.yml +++ b/Resources/Prototypes/XenoArch/Effects/utility_effects.yml @@ -1,5 +1,25 @@ # Utility effects permanently modify the entity in some way when triggered, and they generally make it 'useful' for some purpose, # like turning the artifact into a tool, or gun, or whatever. +- type: artifactEffect + id: EffectIntercom + targetDepth: 2 + effectHint: artifact-effect-hint-communication + permanentComponents: + - type: RadioMicrophone + powerRequired: false + listenRange: 3 + supportedChannels: + - Common + - CentCom + - Command + - Engineering + - Medical + - Science + - Security + - Service + - Supply + - Syndicate + - type: artifactEffect id: EffectRandomInstrument targetDepth: 2 @@ -7,14 +27,9 @@ permanentComponents: - type: Instrument - type: ActivatableUI - inHandsOnly: true singleUser: true verbText: verb-instrument-openui key: enum.InstrumentUiKey.Key - - type: UserInterface - interfaces: - - key: enum.InstrumentUiKey.Key - type: InstrumentBoundUserInterface - type: RandomInstrumentArtifact - type: artifactEffect