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

New Interaction System #733

Merged
merged 24 commits into from
Aug 30, 2024

Conversation

Mnemotechnician
Copy link
Contributor

@Mnemotechnician Mnemotechnician commented Aug 14, 2024

Description

This implements the New Interaction Verb System™©, designed to allow defining verbs using yml and make adding new verbs way easier than it was before. This was initially designed just to bring back generic no-op interactions like hugging, but can now be used to create way more unique interactions for all the different entities.

In the core of the system lies InteractionVerbPrototype. Besides defining the obvious qualities of the verb itself, such as the name, description, interaction constraints, it also has several important properties:

  • The requirement of the verb - what is required for the verb to show up as "enabled" in the context menu and be allowed to be performed. There's just one requirement slot, but using the ComplexRequirement class you can use multiple requirements and choose whether they are combined via boolean or, boolean and, or something in-between.
  • The action of the verb - it defines its own IsAllowed (whether the action is applicable to the target entity at all), CanPerform (called before and after the potential do-after), which defines whether this exact attempt at performing the action succeeds and shows a success popup, or fails and shows a fail popup, and finally Perform, which tries to perform the action and return a boolean result, which determines... well, what was stated before. Similarly to requirements, there are complex and conditional actions which can be combined into whatever monstrousity you can imagine... In fact, it is entirely possible to build a turing-complete programming language out of actions!
  • Effects, specifically three of them: one that is shown when the interaction performs successfully, one that is shown when it fails, and one that is shown when the do-after for the interaction begins succesfully (which means the first CanPerform check of the verb has succeeded). Each one of them defines a popup (configuration for which is stored in a different prototype) and a sound. Those are also designed to be highly customizable: you can choose who sees the popup and where, and more.

Verbs can be global or local. Global verbs are added to any entity should it meet the prerequisites and pass all the necessary checks (which are also designed to be highly configurable). Local verbs are defined in OwnInteractionVerbsComponent and InteractionVerbsComponent of the user and target respectfully.

At the moment of writing there are 8 built-in global verbs and 1 non-global verb, not including abstract verbs:

  • 3 no-op actions that are made for RP purposes, that is looking at someone, hugging someone, petting someone. The latter two may be later used to modify the target's morale should the PR for it be merged.
  • 2 actions related to standing: one for forcing someone down, and one for helping them get up, waking them up and removing 2.5 seconds of stun in addition to that (before you could click someone with empty hand to remove 1.5 seconds of stun - I removed that in favor of the new system)
  • 1 action for making someone who's laying down (on the bed or otherwise) to sleep.
  • 1 actions for falling asleep yourself (no need for bed or bag or whatever to tell you that you can sleep - this does not provide any healing properties or anything like that, purely an RP feature).
  • 1 action for pinching yourself - made simply with the intent of testing some possibilities of the new system, I decided to keep it because it's a bit funny.

Local actions include:

  • An action for knocking on windows, doors, windoors, computers, machines.

More are to be added to this list as the progress continues.

TODO

  • Implement the core of the system
  • Add more, way more actions. Possible ideas include: [slapping/kicking someone, hugging toys/plushies, pressing random buttons on a computer, ... ]. I could use some ideas for that. - skipping for now, we can do it in follow-up prs to clutter this one less.
  • Port all InteractionPopupComponents to the new system, and remove their old usages from non-animals.
  • Introduce contests and a way to configure them (could reuse RangeSpecifier for that; certain actions such as pushing down/helping up would benefit a lot from this).
  • Hide chat logs for people who cannot see the action being performed.
  • Implement cooldowns
  • Cleanup.

Media

Note: this video was made before a few important fixes were made.

8mb.video-jPY-sQDrEIQu.mp4

Newer video - demonstrates various actions and shows that chat logs cannot be seen if the source of the logged popup is outside the view.

8mb.video-HpL-WUOsUdKk.mp4


Changelog

🆑

  • add: A new interaction system has been implemented. The right-click menu now provides a wide variety of different interactions with different entities. Some old default interactions, such as hugging, knocking, fence rattling, have also been moved to that system.

@github-actions github-actions bot added Changes: Audio Changes any ogg files Changes: C# Changes any cs files Changes: Localization Changes any ftl files Changes: YML Changes any yml files Status: Merge Conflict FIX YOUR PR AAAGH labels Aug 14, 2024
Copy link
Contributor

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

@SimpleStation14 SimpleStation14 changed the title New interaction system New Interaction System Aug 14, 2024
@github-actions github-actions bot removed the Status: Merge Conflict FIX YOUR PR AAAGH label Aug 15, 2024
@Mnemotechnician Mnemotechnician marked this pull request as ready for review August 16, 2024 22:47
@Mnemotechnician
Copy link
Contributor Author

Mnemotechnician commented Aug 16, 2024

This is mostly ready for review now. I still have yet to implement more unique interactions (and I could use some ideas for that).

Additionally, I'm keeping InteractionPopupComponents on simple mobs since those are very minor.

Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

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

test fail VALID

@DEATHB4DEFEAT DEATHB4DEFEAT dismissed DangerRevolution’s stale review August 20, 2024 06:51

Don't request changes to say "fix the tests"

@DangerRevolution
Copy link
Contributor

Don't request changes to say "fix the tests"

I'm requesting the test fail to be fixed?

@Mnemotechnician
Copy link
Contributor Author

Oops, that's my own test that failed. Easy fix...

Signed-off-by: Mnemotechnican <[email protected]>
@DangerRevolution
Copy link
Contributor

image

image

Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

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

i'm gonna be real i couldn't really wrap my head around most of this; maybe i'm just tired but this definitely needs another maintainer thorough review

@Mnemotechnician
Copy link
Contributor Author

Ugh, the new test fail doesn't seem like it's caused by my PR... unless it's something obscure.

@ShatteredSwords
Copy link
Contributor

Is this going to interact with the mood system or will that be in a separate PR?

@Mnemotechnician
Copy link
Contributor Author

uh, I don't know how to interact with the mood system yet.

@VMSolidus
Copy link
Member

uh, I don't know how to interact with the mood system yet.

Very simple, interaction raises an event, declaring a string that must match to a moodlet ID. Whoever receives the event will receive the moodlet. The behavior of said moodlet is declared in yml. However I'm not really going to ask you to do mood integrations in this PR.

Copy link
Member

@FoxxoTrystan FoxxoTrystan left a comment

Choose a reason for hiding this comment

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

This is nice.

Comment on lines +35 to +62
- type: Interaction
id: Hug
parent: [BaseGlobal, BaseHands]
priority: 2
#icon: /Textures/Interface/Actions/hug.png
delay: 0.7
range: {max: 1}
hideByRequirement: true
requirement:
!type:MobStateRequirement
inverted: true
action:
# TODO: this should pull the target closer or sumth, but I need to code that action first
!type:NoOpAction

- type: Interaction
id: Pet
parent: [BaseGlobal, BaseHands]
priority: 1
#icon: /Textures/Interface/Actions/hug.png
delay: 0.4
range: {max: 1}
hideByRequirement: true
requirement:
!type:MobStateRequirement
inverted: true
action:
!type:NoOpAction
Copy link
Member

Choose a reason for hiding this comment

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

We should make those two affected by the mood system.

Hug/Pet give mood, pehaps pet gives only mood to vulp, ect...
Hugs to tall, traits for that, ect...

@VMSolidus VMSolidus merged commit 5fa2591 into Simple-Station:master Aug 30, 2024
11 checks passed
SimpleStation14 added a commit that referenced this pull request Aug 30, 2024
VMSolidus pushed a commit that referenced this pull request Sep 8, 2024
# Description
Something that was omitted in #733. Hugging and petting now give
positive moodlets.

The petting interaction was split into two: one for animals and one for
humanoids. The one for animals improves both your own mood and the mood
of the animal, whereas petting a humanoid only improves their own mood.
In addition to all that, being hugged and being pet do not stack.

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/user-attachments/assets/47e8f722-44ee-4d03-a580-65a2946a1920

</p>
</details>

# Changelog
:cl:
- tweak: Hugging and petting interactions now influence mood, just like
the old hugging.

---------

Signed-off-by: Mnemotechnican <[email protected]>
Co-authored-by: DEATHB4DEFEAT <[email protected]>
VMSolidus pushed a commit that referenced this pull request Sep 26, 2024
# Description
Grrrr, I may have forgotten to remove it as a part of #733.

Signed-off-by: Mnemotechnican <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: Audio Changes any ogg files Changes: C# Changes any cs files Changes: Localization Changes any ftl files Changes: YML Changes any yml files Status: Needs Review Someone please review this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants