]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Major Tesla tweaks (#23235)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Mon, 1 Jan 2024 07:33:48 +0000 (10:33 +0300)
committerGitHub <noreply@github.com>
Mon, 1 Jan 2024 07:33:48 +0000 (23:33 -0800)
* add ignore chance

* twekas

* add damaging and repairing

* grounding rod undestructable by tesla

14 files changed:
Content.Server/Lightning/Components/LightningTargetComponent.cs
Content.Server/Lightning/LightningSystem.cs
Content.Server/Lightning/LightningTargetSystem.cs
Content.Server/Tesla/Components/TeslaCoilComponent.cs
Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs
Resources/Prototypes/Entities/Structures/Power/Generation/Tesla/coil.yml
Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_16.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_25.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_8.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_16.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_25.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_8.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/meta.json [new file with mode: 0644]

index e85993562cee8a25089339fc7b897629b1a4bdcf..6d806b3fe7ee2272a2e231e132225dcfe897417c 100644 (file)
@@ -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
 {
+    /// <summary>
+    /// The probability that this target will not be ignored by a lightning strike. This is necessary for Tesla's balance.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public float HitProbability = 1f;
+
     /// <summary>
     /// Priority level for selecting a lightning target. 
     /// </summary>
@@ -56,4 +63,10 @@ public sealed partial class LightningTargetComponent : Component
     /// </summary>
     [DataField, ViewVariables(VVAccess.ReadWrite)]
     public float MaxTileIntensity = 5f;
+
+    /// <summary>
+    /// how much structural damage the object takes from a lightning strike
+    /// </summary>
+    [DataField]
+    public FixedPoint2 DamageFromLightning = 1;
 }
index 00704df1e03b9d03dfe953e4249acd0af5eedfaf..ae95a2a491d819ce6636e294b0abd31be30e933a 100644 (file)
@@ -75,16 +75,26 @@ public sealed class LightningSystem : SharedLightningSystem
         var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(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++;
         }
     }
 }
index f9e564a76a20cd7e7ee5a668e4079fbcbfaa41fe..ccaa74e9e262c8d91d554837e717c609e4639559 100644 (file)
@@ -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;
 /// </summary>
 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<LightningTargetComponent> 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);
+        }
     }
 }
index 6effe8ca517127d1dc6ab03171bf77763d81fde8..d9c7be6fe4d8c930e2741dfca98f3341a4f1b5b1 100644 (file)
@@ -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;
 
index bf98d77406fa3882fc39e329e84845ef33038ce7..4fd2f9b6ed041cc8cc9a42152c9a1cbf5de01bb9 100644 (file)
@@ -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<TeslaCoilComponent> coil, ref HitByLightningEvent args)
     {
-        if (!TryComp<BatteryComponent>(coil, out var batteryComponent))
-            return;
-
-        _battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning);
+        if (TryComp<BatteryComponent>(coil, out var batteryComponent))
+        {
+            _battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning);
+        }
     }
 }
index 0813f49731f65fb4d1e53d91a95c4ef1bb3d443c..8d5621206dbb0e6f8ecf8cd4697b040603285ec0 100644 (file)
   - 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
   - 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
     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 (file)
index 0000000..450cba0
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_16.png differ
diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_25.png b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_25.png
new file mode 100644 (file)
index 0000000..8cc1493
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_25.png differ
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 (file)
index 0000000..9edd528
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/DamageOverlay_8.png differ
diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/meta.json b/Resources/Textures/Structures/Power/Generation/Tesla/coil_cracks.rsi/meta.json
new file mode 100644 (file)
index 0000000..e9dc488
--- /dev/null
@@ -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}
+  ]
+}
diff --git a/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_16.png b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_16.png
new file mode 100644 (file)
index 0000000..3eadb94
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_16.png differ
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 (file)
index 0000000..836935b
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_25.png differ
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 (file)
index 0000000..97f7d38
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Tesla/groundingrod_cracks.rsi/DamageOverlay_8.png differ
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 (file)
index 0000000..e9dc488
--- /dev/null
@@ -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}
+  ]
+}