-
Notifications
You must be signed in to change notification settings - Fork 17
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
wCATw
wants to merge
8
commits into
master
Choose a base branch
from
kotovskiy/accuracy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,024
−77
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b4573ed
accuracy system + evasion system [Need test and prototypes]
01df590
xeno > mutant
1b3125b
mutant and stalker have evasion and size
fcce9da
fix
5251e83
projectiles and base weapon have accuracy and falloff
746e77c
fix
2ef7a22
wtf?? fix
c7b3ce1
file naming fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
/// <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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Чисто RMC хуйня у нас такого нет |
||
Invisibility = 1000, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Кровососы выебут тебя в очко |
||
SizeSmall = 10, | ||
SizeBig = -10 | ||
} |
10 changes: 10 additions & 0 deletions
10
Content.Shared/_Stalker/Evasion/EvasionRefreshModifiersEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Content.Shared/_Stalker/Projectiles/DeleteOnCollideComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
Content.Shared/_Stalker/Projectiles/ModifyTargetOnHitComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
7 changes: 7 additions & 0 deletions
7
Content.Shared/_Stalker/Projectiles/PreventCollideWithDeadComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
Content.Shared/_Stalker/Projectiles/ProjectileMaxRangeComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
88 changes: 88 additions & 0 deletions
88
Content.Shared/_Stalker/Projectiles/STProjectileAccuracyComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
59 changes: 59 additions & 0 deletions
59
Content.Shared/_Stalker/Projectiles/STProjectileDamageFalloffComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Разъеби лопатой эту хуйню, тут нормально бы смотрелись флоаты