Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Система пробивания препятствий пулями #26

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Content.Server/Projectiles/ProjectileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Effects;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared._CorvaxNext.Penetration;
using Content.Shared.Camera;
using Content.Shared.Damage;
using Content.Shared.Database;
Expand All @@ -18,9 +19,14 @@ public sealed class ProjectileSystem : SharedProjectileSystem
[Dependency] private readonly GunSystem _guns = default!;
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;

private EntityQuery<PenetratableComponent> _penetratableQuery;

private Random _random = new();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему не IRobustRandom, который предоставляется нам через зависимости в IoC


public override void Initialize()
{
base.Initialize();
_penetratableQuery = GetEntityQuery<PenetratableComponent>();
SubscribeLocalEvent<ProjectileComponent, StartCollideEvent>(OnStartCollide);
}

Expand Down Expand Up @@ -67,9 +73,19 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St
_sharedCameraRecoil.KickCamera(target, direction);
}

component.DamagedEntity = true;
// Corvax-Next-Penetration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо открыть и закрыть подобный комментарий, для удобства

if (component.PenetrationScore > 0
&& _penetratableQuery.TryGetComponent(target, out var penetratable)
&& _random.Next(component.PenetrationScore + penetratable.StoppingPower) >= penetratable.StoppingPower)
{
component.DamagedEntity = component.PenetrationScore < penetratable.StoppingPower;

component.PenetrationScore -= penetratable.StoppingPower;
}
else
component.DamagedEntity = true;

if (component.DeleteOnCollide)
if (component.DeleteOnCollide && component.DamagedEntity)
QueueDel(uid);

if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform))
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Projectiles/ProjectileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ public sealed partial class ProjectileComponent : Component
/// </summary>
[DataField]
public bool DamagedEntity;

// Corvax-Next-Penetration
[DataField]
public int PenetrationScore;
}
10 changes: 10 additions & 0 deletions Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared._CorvaxNext.Penetration;

[RegisterComponent, NetworkedComponent]
public sealed partial class PenetratableComponent : Component
{
[DataField]
public int StoppingPower;
}
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
components:
- type: Damageable
damageContainer: Biological
- type: Penetratable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подобные изменение должны иметь комментарий, если вы меняете прототипы официального контента

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот компонент и так новый. Мы договорились не помечать в прототипах новые компоненты, так как и так понятно, что он не оффами добавлен.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Гадэм, в любом случае это будет на совести тех, кто делает апстртмы, чем я не занимаюсь

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот компонент и так новый. Мы договорились не помечать в прототипах новые компоненты, так как и так понятно, что он не оффами добавлен.

чзх, добавляй

stoppingPower: 1
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
types:
Piercing: 40
Structural: 30
penetrationScore: 3
- type: StaminaDamageOnCollide
damage: 35
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 19
penetrationScore: 1

- type: entity
id: BulletMinigun
Expand All @@ -19,3 +20,4 @@
damage:
types:
Piercing: 5
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 19
penetrationScore: 1

- type: entity
id: BulletLightRiflePractice
Expand All @@ -19,6 +20,7 @@
damage:
types:
Blunt: 2
penetrationScore: 1

- type: entity
id: BulletLightRifleIncendiary
Expand All @@ -31,6 +33,7 @@
types:
Blunt: 3
Heat: 16
penetrationScore: 1

- type: entity
id: BulletLightRifleUranium
Expand All @@ -43,3 +46,4 @@
types:
Radiation: 9
Piercing: 10
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 35
penetrationScore: 1

- type: entity
id: BulletMagnumPractice
Expand All @@ -19,6 +20,7 @@
damage:
types:
Blunt: 1
penetrationScore: 1

- type: entity
id: BulletMagnumIncendiary
Expand All @@ -31,6 +33,7 @@
types:
Blunt: 3
Heat: 32
penetrationScore: 1

- type: entity
id: BulletMagnumAP
Expand All @@ -43,6 +46,7 @@
types:
Piercing: 26 # 20% decrease
ignoreResistances: true
penetrationScore: 1

- type: entity
id: BulletMagnumUranium
Expand All @@ -55,3 +59,4 @@
types:
Radiation: 15
Piercing: 20
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 17
penetrationScore: 1

- type: entity
id: BulletRiflePractice
Expand All @@ -19,6 +20,7 @@
damage:
types:
Blunt: 2
penetrationScore: 1

- type: entity
id: BulletRifleIncendiary
Expand All @@ -31,6 +33,7 @@
types:
Blunt: 2
Heat: 15
penetrationScore: 1

- type: entity
id: BulletRifleUranium
Expand All @@ -43,4 +46,5 @@
types:
Radiation: 7
Piercing: 8
penetrationScore: 1

4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Structures/Walls/walls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallic
- type: Penetratable
stoppingPower: 2
- type: Physics
bodyType: Static
- type: Fixtures
Expand Down Expand Up @@ -594,6 +596,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallicStrong
- type: Penetratable
stoppingPower: 3
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: RGlass
- type: Penetratable
stoppingPower: 2
- type: RCDDeconstructable
cost: 6
delay: 6
Expand Down Expand Up @@ -84,6 +86,8 @@
sprite: Structures/Windows/cracks_directional.rsi
- type: Damageable
damageModifierSet: RGlass
- type: Penetratable
stoppingPower: 2
- type: RCDDeconstructable
cost: 4
delay: 4
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Structures/base_structure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- type: Clickable
- type: Physics
bodyType: Static
- type: Penetratable
stoppingPower: 1
- type: Fixtures
fixtures:
fix1:
Expand Down
Loading