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

"Proper" "Softcrit" "Support" #1545

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

RedFoxIV
Copy link
Contributor

@RedFoxIV RedFoxIV commented Jan 14, 2025

Description

Implements the softcrit functionality.
Similiar to critical state but spessmen will be able to communicate and crawl around, but not pick up items.
Also supports configuring what is and isn't allowed in different MobStates (per mob prototype): you can enable picking up items while in softcrit so people can pick up their lasgun and continue shooting after taking a 40x46mm to their ass cheeks from the guest nukies while being dragged to safety.

escape-from-tarkov-raid

Technical details

New prototype type: "mobStateParams" (`MobStateParametersPrototype`) Used to specify what can and can't be done when in a certain mobstate. Of note that they are not actually bound to any `MobState` by themselves. To assign a params prototype to a mobstate, use `InitMobStateParams` in `MobStateComponent`. It has to be a prototype because if I just did something akin to `Dictionary>`, you'd have to check the parent and copy every flag besides the one you wish to modify. That is, if I understand how the prototype system works correctly, which I frankly doubt.

MobStateComponent now has:

  • Dictionary<string, string> InitMobStateParams, for storing "mobstate - parameter prototype" pairs. <string, string> because it has to be editable via mob prototypes. Named "mobStateParams" for mob prototypes.
  • public Dictionary<MobState, MobStateParametersPrototype> MobStateParams for actually storing the params for each state
  • public Dictionary<MobState, MobStateParametersOverride> MobStateParamsOverrides for storing overrides. MobStateParametersOverride is a struct which mirrors all MobStateParametersPrototype's fields, except they're all nullable. This is meant for code which wants to temporarily override some setting, like a spell which allows dead people to talk. This is not the best solution, but it should do at first. A better option would be tracking each change separately, instead of hoping different systems overriding the same flag will play nicely with eachother.
  • a shitton of getter methods

TraitModifyMobState now has:

  • public Dictionary<string, string> Params to specify a new prototype to use.
  • Important note: All values of MobStateParametersPrototype are nullable, which is a hack to support TraitModifyMobState. This trait takes one MobStateParametersPrototype per mobstate and applies all of its non-null values. This way, a params prototype can be created which will only have pointing: true and the trait can apply it (e.g. to critstate, so we can spam pointing while dying like it's a game of turbo dota)
  • The above is why that wall of getters exists: They check the relevant override struct, then the relevant prototype. If both are null, they default to false (0f for floats.) The only exception is OxyDamageOverlay, because it's used both for oxy damage overlay (if null) and as a vision-limiting black void in crit..

MobStateSystem now has:

  • a bunch of new "IsSomething"/"CanDoSomething" methods to check the various flags, alongside rewritten old ones.
  • image lookin ahh predicate factory
---

TODO

done:

  • Make proper use of MobStateSystem.IsIncapacitated().
    done: some checks were changed, some left as they did what was (more or less) intended.
Previous `IsIncapacitated()` implementation simply checked if person was in crit or dead. Now there is a `IsIncapacitated` flag in the parameters, but it's heavily underutilized. I may need some help on this one, since I don't know where would be a good place to check for it and I absolutely will not just scour the entire build in search for them.
  • Separate force-dropping items from being downed
    done: dropItemsOnEntering bool field. If true, will drop items upon entering linked mobstate.
  • Don't drop items if ForceDown is true but PickingUp is also true.
    done: dropItemsOnEntering bool field. If true, will drop items upon entering linked mobstate.
  • Actually check what are "conscious attempts" are used for
    done: whether or not mob is conscious. Renamed the bool field accordingly.
  • Look into adding a way to make people choke "slowly" in softcrit as opposed to choking at "regular speed" in crit. Make that into a param option? Make that into a float so the speed can be finetuned?
    done: BreathingMultiplier float field added.
1f is regular breathing, 0.25 is "quarter-breathing". Air taken is multiplied by `BreathingMultiplier` and suffocation damage taken (that is dealt by RespiratorSystem, not all oxy damage) is multiplied by `1-BreathingMultiplier`.
  • make sure the serializer actually does its job
    done: it doesn't. Removed.
  • Make an option to prohibit using radio headsets while in softcrit
    done: Requires Incapacitated parameter to be false to be able to use headset radio.
  • Make sure it at least compiles

not done:

  • probably move some other stuff to Params if it makes sense. Same thing as with IsIncapacitated though: I kinda don't want to, at least for now.

No media

:p


Changelog

🆑

  • add: Soft critical state. Crawl to safety, or to your doom - whatever is closer.

RedFoxIV and others added 7 commits January 13, 2025 13:03
(cherry picked from commit 05759d916d03e77b4240e92b547e507e611d7258)

# Conflicts:
#	Content.Client/Overlays/EntityHealthBarOverlay.cs
#	Content.Server/FootPrint/FootPrintsSystem.cs
#	Content.Shared/Mobs/Components/MobStateComponent.cs
#	Content.Shared/Mobs/MobState.cs
#	Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
#	Content.Shared/Mobs/Systems/MobStateSystem.cs
#	Content.Shared/Shadowkin/SharedEtherealSystem.cs
# Conflicts:
#	Content.Server/Traits/TraitSystem.Functions.cs
#	Content.Shared/Mobs/Components/MobStateComponent.cs
#	Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
(cherry picked from commit 898ae4e91ef2abd1c8d6fc9dc63f11eacd8fbdc3)
(cherry picked from commit e2f31775ce29c14dca7c622f183bc21ec57fa6db)
(cherry picked from commit 289a0ee00c071cbf1841120f70e08771badfcee4)
(cherry picked from commit 4bd639d70be6d69067d1e07dba4ec2fac09c0e28)

# Conflicts:
#	Content.Client/Overlays/EntityHealthBarOverlay.cs
#	Content.Shared/Standing/SharedLayingDownSystem.cs
@github-actions github-actions bot added Changes: C# Changes any cs files Changes: UI Changes any XAML files Changes: YML Changes any yml files labels Jan 14, 2025
@SimpleStation14 SimpleStation14 changed the title "Proper" "softcrit" "support" "Proper" "Softcrit" "Support" Jan 14, 2025
@RedFoxIV
Copy link
Contributor Author

i probably should use ProtoId more, huh

@bruhmogus
Copy link

huh?? didnt we already have this???

@RedFoxIV
Copy link
Contributor Author

now that i am reading this a day later, I can confidently say this PR is borderline incomprehensible
wow

@BlueHNT
Copy link
Contributor

BlueHNT commented Jan 15, 2025

What the fuck happened here?

@RedFoxIV
Copy link
Contributor Author

RedFoxIV commented Jan 15, 2025

huh?? didnt we already have this???

MobState.SoftCritical was already present but went unused, as well as some other stuff relating to it. The closest thing to softcrit EE currently has is allowing people to crawl and/or talk while in crit.

What the fuck happened here?

lack of QA

@Erisfiregamer1
Copy link
Contributor

What the fuck happened here?

lack of QA

Nothing in SS14 has Quality Assurance, my friend

@github-actions github-actions bot added the Status: Merge Conflict FIX YOUR PR AAAGH label Jan 17, 2025
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com>
@github-actions github-actions bot removed the Status: Merge Conflict FIX YOUR PR AAAGH label Jan 17, 2025
@github-actions github-actions bot added the Status: Merge Conflict FIX YOUR PR AAAGH label Jan 18, 2025
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@RedFoxIV RedFoxIV marked this pull request as ready for review January 19, 2025 17:42
@github-actions github-actions bot removed the Status: Merge Conflict FIX YOUR PR AAAGH label Jan 19, 2025
@RedFoxIV
Copy link
Contributor Author

It's as ready as I will ever get it to be without someone else looking at it.

Copy link
Member

@VMSolidus VMSolidus left a comment

Choose a reason for hiding this comment

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

Holy shit this PR is amazing.

current.MergeWith(mod);
//current.FillDefaults();
}
comp.Dirty(); // why is this deprecated? it's much better than manually resolving entitymanager with ioc
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
comp.Dirty(); // why is this deprecated? it's much better than manually resolving entitymanager with ioc
comp.Dirty(); // why is this deprecated? it's much better than manually resolving entitymanager with ioc

It's deprecated because it's been replaced with Dirty(uid, comp); instead of Dirty(comp). I think you might be able to get around the deprecated warning by doing comp.Dirty(uid);. The reason for the deprecation is because you're supposed to only dirty one component at a time, and if you dirty just the component, the system now has to dirty all of that component, so it needs UID + Component.

However we now have as an engine option, the ability to dirty individual datafields in components, feel free to take a look at that if you wish!

if (AllowHandInteractWhileDead is not null)
mobStateComponent.AllowHandInteractWhileDead = AllowHandInteractWhileDead.Value;
foreach (var pair in Params) {
DebugTools.Assert(_reflection.TryParseEnumReference($"enum.MobState.{pair.Key}", out var e), $"MobState.{pair.Key} does not exist.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
DebugTools.Assert(_reflection.TryParseEnumReference($"enum.MobState.{pair.Key}", out var e), $"MobState.{pair.Key} does not exist.");
DebugTools.Assert(_reflection.TryParseEnumReference($"enum.MobState.{pair.Key}", out var e), $"MobState.{pair.Key} does not exist.");

You're not allowed to use e as a variable here because it straight up won't exist in Release configuration. Separate out TryParseEnumReference into an If Not {Assert; Continue;} statement to clear the error

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool CanEquipOther(MobState? State = null) => GetOverride(State).CanEquipOther ?? GetParams(State)?.CanEquipOther ?? false;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool CanUnequipOther(MobState? State = null) => GetOverride(State).CanUnequipOther ?? GetParams(State)?.CanUnequipOther ?? false;
Copy link
Member

Choose a reason for hiding this comment

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

Holy fuck this is amazing. I'm taking notes.

@github-actions github-actions bot added the Status: Merge Conflict FIX YOUR PR AAAGH label Jan 25, 2025
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: C# Changes any cs files Changes: UI Changes any XAML files Changes: YML Changes any yml files Status: Merge Conflict FIX YOUR PR AAAGH Status: Needs Review Someone please review this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants