From 5e1fcfc63ead8749aeb0b2c77b477d2762ba62d9 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:33:48 +0300 Subject: [PATCH] Major Tesla tweaks (#23235) * add ignore chance * twekas * add damaging and repairing * grounding rod undestructable by tesla --- .../Components/LightningTargetComponent.cs | 13 ++++ Content.Server/Lightning/LightningSystem.cs | 24 +++++-- .../Lightning/LightningTargetSystem.cs | 23 ++++--- .../Tesla/Components/TeslaCoilComponent.cs | 2 - .../Tesla/EntitySystem/TeslaCoilSystem.cs | 10 ++- .../Power/Generation/Tesla/coil.yml | 60 +++++++++++++++++- .../coil_cracks.rsi/DamageOverlay_16.png | Bin 0 -> 142 bytes .../coil_cracks.rsi/DamageOverlay_25.png | Bin 0 -> 151 bytes .../Tesla/coil_cracks.rsi/DamageOverlay_8.png | Bin 0 -> 133 bytes .../Tesla/coil_cracks.rsi/meta.json | 14 ++++ .../DamageOverlay_16.png | Bin 0 -> 169 bytes .../DamageOverlay_25.png | Bin 0 -> 189 bytes .../DamageOverlay_8.png | Bin 0 -> 137 bytes .../Tesla/groundingrod_cracks.rsi/meta.json | 14 ++++ 14 files changed, 135 insertions(+), 25 deletions(-) create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_16.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_25.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_8.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/meta.json create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_16.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_25.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_8.png create mode 100644 Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/meta.json diff --git a/Content.Server/Lightning/Components/LightningTargetComponent.cs b/Content.Server/Lightning/Components/LightningTargetComponent.cs index e85993562c..6d806b3fe7 100644 --- a/Content.Server/Lightning/Components/LightningTargetComponent.cs +++ b/Content.Server/Lightning/Components/LightningTargetComponent.cs @@ -1,5 +1,6 @@ using Content.Server.Tesla.EntitySystems; using Content.Shared.Explosion; +using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; namespace Content.Server.Lightning.Components; @@ -11,6 +12,12 @@ namespace Content.Server.Lightning.Components; [RegisterComponent, Access(typeof(LightningSystem), typeof(LightningTargetSystem))] public sealed partial class LightningTargetComponent : Component { + /// + /// The probability that this target will not be ignored by a lightning strike. This is necessary for Tesla's balance. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float HitProbability = 1f; + /// /// Priority level for selecting a lightning target. /// @@ -56,4 +63,10 @@ public sealed partial class LightningTargetComponent : Component /// [DataField, ViewVariables(VVAccess.ReadWrite)] public float MaxTileIntensity = 5f; + + /// + /// how much structural damage the object takes from a lightning strike + /// + [DataField] + public FixedPoint2 DamageFromLightning = 1; } diff --git a/Content.Server/Lightning/LightningSystem.cs b/Content.Server/Lightning/LightningSystem.cs index 00704df1e0..ae95a2a491 100644 --- a/Content.Server/Lightning/LightningSystem.cs +++ b/Content.Server/Lightning/LightningSystem.cs @@ -75,16 +75,26 @@ public sealed class LightningSystem : SharedLightningSystem var targets = _lookup.GetComponentsInRange(Transform(user).MapPosition, range).ToList(); _random.Shuffle(targets); targets.Sort((x, y) => y.Priority.CompareTo(x.Priority)); - var realCount = Math.Min(targets.Count, boltCount); - if (realCount <= 0) - return; - for (int i = 0; i < realCount; i++) + //var realCount = Math.Min(targets.Count, boltCount); + + int shootedCount = 0; + int count = -1; + while(shootedCount < boltCount) { - ShootLightning(user, targets[i].Owner, lightningPrototype); - if (arcDepth > 0) + count++; + + if (count >= targets.Count) { break; } + + var curTarget = targets[count]; + if (!_random.Prob(curTarget.HitProbability)) //Chance to ignore target + continue; + + ShootLightning(user, targets[count].Owner, lightningPrototype); + if (arcDepth - targets[count].LightningResistance > 0) { - ShootRandomLightnings(targets[i].Owner, range, 1, lightningPrototype, arcDepth - targets[i].LightningResistance); + ShootRandomLightnings(targets[count].Owner, range, 1, lightningPrototype, arcDepth - targets[count].LightningResistance); } + shootedCount++; } } } diff --git a/Content.Server/Lightning/LightningTargetSystem.cs b/Content.Server/Lightning/LightningTargetSystem.cs index f9e564a76a..ccaa74e9e2 100644 --- a/Content.Server/Lightning/LightningTargetSystem.cs +++ b/Content.Server/Lightning/LightningTargetSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Explosion.EntitySystems; using Content.Server.Lightning; using Content.Server.Lightning.Components; +using Content.Shared.Damage; namespace Content.Server.Tesla.EntitySystems; @@ -9,6 +10,7 @@ namespace Content.Server.Tesla.EntitySystems; /// public sealed class LightningTargetSystem : EntitySystem { + [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly ExplosionSystem _explosionSystem = default!; public override void Initialize() @@ -20,15 +22,18 @@ public sealed class LightningTargetSystem : EntitySystem private void OnHitByLightning(Entity uid, ref HitByLightningEvent args) { + DamageSpecifier damage = new(); + damage.DamageDict.Add("Structural", uid.Comp.DamageFromLightning); + _damageable.TryChangeDamage(uid, damage, true); - if (!uid.Comp.LightningExplode) - return; - - _explosionSystem.QueueExplosion( - Transform(uid).MapPosition, - uid.Comp.ExplosionPrototype, - uid.Comp.TotalIntensity, uid.Comp.Dropoff, - uid.Comp.MaxTileIntensity, - canCreateVacuum: false); + if (uid.Comp.LightningExplode) + { + _explosionSystem.QueueExplosion( + Transform(uid).MapPosition, + uid.Comp.ExplosionPrototype, + uid.Comp.TotalIntensity, uid.Comp.Dropoff, + uid.Comp.MaxTileIntensity, + canCreateVacuum: false); + } } } diff --git a/Content.Server/Tesla/Components/TeslaCoilComponent.cs b/Content.Server/Tesla/Components/TeslaCoilComponent.cs index 6effe8ca51..d9c7be6fe4 100644 --- a/Content.Server/Tesla/Components/TeslaCoilComponent.cs +++ b/Content.Server/Tesla/Components/TeslaCoilComponent.cs @@ -1,6 +1,4 @@ using Content.Server.Tesla.EntitySystems; -using Robust.Shared.Audio; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Server.Tesla.Components; diff --git a/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs b/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs index bf98d77406..4fd2f9b6ed 100644 --- a/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs +++ b/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs @@ -1,9 +1,7 @@ -using Content.Server.Popups; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Server.Tesla.Components; using Content.Server.Lightning; -using Robust.Shared.Timing; namespace Content.Server.Tesla.EntitySystems; @@ -24,9 +22,9 @@ public sealed class TeslaCoilSystem : EntitySystem //When struck by lightning, charge the internal battery private void OnHitByLightning(Entity coil, ref HitByLightningEvent args) { - if (!TryComp(coil, out var batteryComponent)) - return; - - _battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning); + if (TryComp(coil, out var batteryComponent)) + { + _battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning); + } } } diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Tesla/coil.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Tesla/coil.yml index 0813f49731..8d5621206d 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Tesla/coil.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Tesla/coil.yml @@ -61,9 +61,11 @@ - type: BatteryDischarger activeSupplyRate: 15000 - type: TeslaCoil - chargeFromLightning: 1000000 + chargeFromLightning: 500000 - type: LightningTarget priority: 4 + hitProbability: 0.5 + lightningResistance: 10 lightningExplode: false - type: PowerNetworkBattery maxSupply: 1000000 @@ -73,6 +75,33 @@ - type: Pullable - type: Clickable - type: InteractionOutline + - type: Damageable + damageContainer: StructuralInorganic + - type: ExaminableDamage + messages: WindowMessages + - type: Repairable + - type: DamageVisuals + thresholds: [8, 16, 25] + damageDivisor: 3.333 + trackAllDamage: true + damageOverlay: + sprite: Structures/Power/Generation/Tesla/coil_cracks.rsi + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 225 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 2 + max: 4 #- type: GuideHelp # To Do - add Tesla Guide - type: entity @@ -123,9 +152,38 @@ priority: 3 lightningResistance: 10 lightningExplode: false + damageFromLightning: 0 - type: Anchorable - type: Rotatable - type: Pullable - type: Clickable - type: InteractionOutline + - type: ExaminableDamage + messages: WindowMessages + - type: Repairable + - type: Damageable + damageContainer: StructuralInorganic + - type: DamageVisuals + thresholds: [8, 16, 25] + damageDivisor: 3.333 + trackAllDamage: true + damageOverlay: + sprite: Structures/Power/Generation/Tesla/groundingrod_cracks.rsi + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 300 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 2 + max: 4 #- type: GuideHelp # To Do - add Tesla Guide + diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_16.png b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_16.png new file mode 100644 index 0000000000000000000000000000000000000000..450cba08546343f1ff6c5185be6ffbf9a5879bca GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}9-c0aArY;~ z2@5FK1?q6`cP8hrQva7>s5G?T&8)z4*}Q$iB}i6|){j%S3om_$obiSyPN4ol{0ylB)2$R`C8zjqJdyx3oWax8&t;ucLK6VVtv0U! literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_8.png b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_8.png new file mode 100644 index 0000000000000000000000000000000000000000..9edd528a8beb8fe5fcadee8e8ddd34ddce13c975 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}_MR?|ArY-_ zFCOFts$y|W5_gi6`u*M~-prxHE^m3GZIdJegNDiRTeCi%uKpwc(dFqFVdQ&MBb@0429NHvj+t literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_25.png b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_25.png new file mode 100644 index 0000000000000000000000000000000000000000..836935bfd847d80c72c53e9535b225dcb3f7c6d3 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}<(@8%ArY-_ zrv!2xP~dUiJl9D4<=j2f*om80 zYt2XJIobP6Ty~dF@(PN5e<1r++7I!RZtfi>M|#%paAQ?kv^9*uK{GWXf6;cP>kPL0 mQcK<+7Sr~aq~dw#GsCeyTgfi5iF1KYVDNPHb6Mw<&;$U_@I?v$ literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_8.png b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_8.png new file mode 100644 index 0000000000000000000000000000000000000000..97f7d381c1f0091b835ce4db59ad096c035c823b GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}&YmugArY-_ zFFEou7;rdWJg4gRiZh<$rip+@+0Xa)wkUcqFeIG#_BTvU@bRb1yf^lRs(PL}Q&xBN j7;BhY&0l5)hGlYD7X>fReaz$tG>*a3)z4*}Q$iB}c*`xz literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/meta.json b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/meta.json new file mode 100644 index 0000000000..e9dc48878c --- /dev/null +++ b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "CC-BY-SA-3.0", + "copyright": "Created by TheShuEd (github) for Space Station 14", + "states": [ + {"name": "DamageOverlay_8", "directions": 1}, + {"name": "DamageOverlay_16", "directions": 1}, + {"name": "DamageOverlay_25", "directions": 1} + ] +} -- 2.51.2