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

Точность и спад урона #188

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
43 changes: 43 additions & 0 deletions Content.Shared/_Stalker/Evasion/EvasionComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;

namespace Content.Shared._Stalker.Evasion;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(EvasionSystem))]
public sealed partial class EvasionComponent : Component
{
/// <summary>
/// Base evasion value.
/// Conversion from 13: evasion
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 Evasion = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Разъеби лопатой эту хуйню, тут нормально бы смотрелись флоаты


/// <summary>
/// Evasion value after applicable modifiers. This is subtracted from the hit chance of most incoming projectiles.
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 ModifiedEvasion = 0;

/// <summary>
/// Base evasion value for friendly fire.
/// Conversion from 13: FF_hit_evade
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 EvasionFriendly = 15;

/// <summary>
/// Evasion value after applicable modifiers. This is subtracted from the hit chance of most incoming friendly projectiles.
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 ModifiedEvasionFriendly = 0;
}

public enum EvasionModifiers : int
{
Rest = -15,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Чисто RMC хуйня у нас такого нет

Invisibility = 1000,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Кровососы выебут тебя в очко

SizeSmall = 10,
SizeBig = -10
}
10 changes: 10 additions & 0 deletions Content.Shared/_Stalker/Evasion/EvasionRefreshModifiersEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Content.Shared.FixedPoint;

namespace Content.Shared._Stalker.Evasion;

[ByRefEvent]
public record struct EvasionRefreshModifiersEvent(
Entity<EvasionComponent> Entity,
FixedPoint2 Evasion,
FixedPoint2 EvasionFriendly
);
56 changes: 56 additions & 0 deletions Content.Shared/_Stalker/Evasion/EvasionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared._Stalker.Stun;
using Content.Shared.Standing;

namespace Content.Shared._Stalker.Evasion;

public sealed class EvasionSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<EvasionComponent, MapInitEvent>(CallRefresh);
SubscribeLocalEvent<EvasionComponent, DownedEvent>(CallRefresh);
SubscribeLocalEvent<EvasionComponent, StoodEvent>(CallRefresh);

SubscribeLocalEvent<STSizeComponent, EvasionRefreshModifiersEvent>(OnSizeRefreshEvasion);
}

public void RefreshEvasionModifiers(EntityUid entity)
{
if (!TryComp(entity, out EvasionComponent? evasionComponent))
return;

RefreshEvasionModifiers((entity, evasionComponent));
}

public void RefreshEvasionModifiers(Entity<EvasionComponent> entity)
{
var ev = new EvasionRefreshModifiersEvent(
entity,
entity.Comp.Evasion,
entity.Comp.EvasionFriendly);

RaiseLocalEvent(entity.Owner, ref ev);

entity.Comp.ModifiedEvasion = ev.Evasion;
entity.Comp.ModifiedEvasionFriendly = ev.EvasionFriendly;

Dirty(entity);
}

private void CallRefresh<T>(Entity<EvasionComponent> entity, ref T args) where T : notnull
{
RefreshEvasionModifiers(entity);
}

private void OnSizeRefreshEvasion(Entity<STSizeComponent> size, ref EvasionRefreshModifiersEvent args)
{
if (size.Owner != args.Entity.Owner)
return;

if (size.Comp.Size <= STSizes.Small)
args.Evasion += (int) EvasionModifiers.SizeSmall;

if (size.Comp.Size >= STSizes.Big)
args.Evasion += (int) EvasionModifiers.SizeBig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Robust.Shared.GameStates;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent]
[Access(typeof(STProjectileSystem))]
public sealed partial class DeleteOnCollideComponent : Component;
16 changes: 16 additions & 0 deletions Content.Shared/_Stalker/Projectiles/ModifyTargetOnHitComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(STProjectileSystem))]
public sealed partial class ModifyTargetOnHitComponent : Component
{
[DataField]
public ComponentRegistry? Add;

[DataField, AutoNetworkedField]
public EntityWhitelist? Whitelist;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Robust.Shared.GameStates;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent]
[Access(typeof(STProjectileSystem))]
public sealed partial class PreventCollideWithDeadComponent : Component;
18 changes: 18 additions & 0 deletions Content.Shared/_Stalker/Projectiles/ProjectileMaxRangeComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;
using Robust.Shared.Map;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(STProjectileSystem))]
public sealed partial class ProjectileMaxRangeComponent : Component
{
[DataField, AutoNetworkedField]
public EntityCoordinates? Origin;

[DataField(required: true), AutoNetworkedField]
public float Max;

[DataField, AutoNetworkedField]
public bool Delete = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Content.Shared._Stalker.Random;
using Content.Shared._Stalker.Weapons.Ranged;
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Serialization;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(STProjectileSystem), typeof(STGunSystem))]
public sealed partial class STProjectileAccuracyComponent : Component
{
/// <summary>
/// This lists all the thresholds and their falloff values.
/// </summary>
[DataField, AutoNetworkedField]
public List<AccuracyFalloffThreshold> Thresholds = new()
{
new AccuracyFalloffThreshold(5f, 10, false)
};

/// <summary>
/// Minimum hit chance.
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 MinAccuracy = 5;

/// <summary>
/// The accuracy of the projectile before taking into account any modifiers reliant on the target.
/// This value is multiplied by the firing weapon's accuracy multiplier upon the projectile being shot.
/// Conversion from 13: accuracy + accuracy (one from the ammo, the other from the projectile itself)
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 Accuracy = 90;

/// <summary>
/// Setting this to true will make the projectile not apply the usual penalty accuracy penalty when attacking friendlies.
/// </summary>
[DataField, AutoNetworkedField]
public bool IgnoreFriendlyEvasion = false;

/// <summary>
/// If set to true, this makes the projectile automatically hit regardless of accuracy or any other modifiers.
/// </summary>
[DataField, AutoNetworkedField]
public bool ForceHit = false;

/// <summary>
/// These are the coordinates from which the projectile was shot. Used to determine the distance travelled.
/// </summary>
[DataField, AutoNetworkedField]
public EntityCoordinates? ShotFrom;

[DataField, AutoNetworkedField]
public long GunSeed;

[DataField, AutoNetworkedField]
public uint Tick;
}

[DataRecord, Serializable, NetSerializable]
public record struct AccuracyFalloffThreshold(
/// <summary>
/// The range at which accuracy falloff starts to take effect.
/// Conversion from 13: accurate_range
/// Conversion from 13 for buildup: accurate_range_min
/// </summary>
float Range,

/// <summary>
/// This is the number by which the projectile's accuracy is decreased for each tile travelled beyond its effective range.
/// Conversion from 13: 10
/// Conversion from 13 for buildup: accuracy_range_falloff
/// </summary>
FixedPoint2 Falloff,

/// <summary>
/// Setting this to true makes it so AccurateRange is treated as the minimum accurate range.
/// Falloff is applied by how much the shot falls short of that distance, instead of by how much it exceeds it.
/// </summary>
bool Buildup
);

public enum AccuracyModifiers : int
{
TargetOccluded = -15
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Serialization;

namespace Content.Shared._Stalker.Projectiles;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(STProjectileSystem))]
public sealed partial class STProjectileDamageFalloffComponent : Component
{
/// <summary>
/// This lists all the thresholds and their falloff values.
/// </summary>
[DataField, AutoNetworkedField]
public List<DamageFalloffThreshold> Thresholds = new()
{
new DamageFalloffThreshold(0f, 1, false),
new DamageFalloffThreshold(22f, 9999, true)
};

/// <summary>
/// This determines the minimum fraction of the projectile's original damage that must remain after falloff is applied.
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 MinRemainingDamageMult = 0.05f;

/// <summary>
/// This is the additional falloff multiplier applied by the firing weapon.
/// </summary>
[DataField, AutoNetworkedField]
public FixedPoint2 WeaponMult = 1;

/// <summary>
/// These are the coordinates from which the projectile was shot. Used to determine the distance travelled.
/// </summary>
[DataField, AutoNetworkedField]
public EntityCoordinates? ShotFrom;
}

[DataRecord, Serializable, NetSerializable]
public record struct DamageFalloffThreshold(
/// <summary>
/// The range at which falloff starts to take effect.
/// Conversion from 13: effective_range_max
/// </summary>
float Range,

/// <summary>
/// This is the number by which the projectile's damage is decreased for each tile travelled beyond its effective range.
/// Conversion from 13: damage_falloff
/// </summary>
FixedPoint2 Falloff,

/// <summary>
/// This makes this falloff value ignore the firing weapon's falloff multiplier. Used primarily to simulate having a capped maximum range. Should generally be false.
/// </summary>
bool IgnoreModifiers
);
Loading