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

feat(balance): Allow for use of multiple sleep aids #5848

Merged

Conversation

RobbieNeko
Copy link
Collaborator

Checklist

Required

Purpose of change

As expressed by many, not allowing the survivor to use a pillow and a teddy bear at the same time is ridiculous. People use multiple pillows, cuddle a stuffed animal or body pillow while using a normal pillow, etc. As such, this is clearly a highly-desired change and is in-fact more realistic than how it was before.

Also, if any balance hinges on only one sleep aid being allowed, we have bigger problems.

Describe the solution

  • Removes the break lines that prevent multiple sleep aids from being used
  • Converts comfort_response.aid into a vector instead of an item pointer
  • Prints out each comfort aid you're making use of instead of just one

Describe alternatives you've considered

  • Pillow (not body pillow) specific flag to allow you to use a pillow and a normal sleep aid

Doesn't adequately account for the use cases.

  • Simply adjust the limit to be higher
  • Implode
  • Let someone else do it

Testing

It builds and it works on my machine
image

Additional context

I hope my conversion of comfort_response.aid to a vector isn't bad code.
Can't wait for the pillow-stacking meta of sleep comfort

And print them out too!
@github-actions github-actions bot added the src changes related to source code. label Dec 28, 2024
Copy link
Contributor

autofix-ci bot commented Dec 28, 2024

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

@RobbieNeko
Copy link
Collaborator Author

Huh, I accidentally made use of curly brace-less for loop. That's funny, good thing the tree caught it though

scarf005
scarf005 previously approved these changes Dec 28, 2024
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

code looks alright but needs playtesting

src/character_functions.cpp Outdated Show resolved Hide resolved
thanks scarf, very cool

Co-authored-by: scarf <[email protected]>
scarf005
scarf005 previously approved these changes Dec 28, 2024
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

also found some more nitpicks but that doesn't stop the PR from shipping

src/character_functions.cpp Outdated Show resolved Hide resolved
src/character_functions.cpp Show resolved Hide resolved
@@ -243,12 +244,11 @@ comfort_response_t base_comfort_value( const Character &who, const tripoint &p )
const std::optional<vpart_reference> board = vp.part_with_feature( "BOARDABLE", true );
if( carg ) {
const vehicle_stack items = vp->vehicle().get_items( carg->part_index() );
for( const item *items_it : items ) {
for( item *items_it : items ) {
Copy link
Member

Choose a reason for hiding this comment

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

does the const modifier here prevent putting it in comfort_info.aid? might go extra careful and could copy them (const good, mutability bad)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I had to remove the const modifier here to get rid of an error in the IDE

Copy link
Collaborator Author

@RobbieNeko RobbieNeko Dec 28, 2024

Choose a reason for hiding this comment

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

In particular, push_back complains when trying to put it into the vector

@@ -278,14 +278,13 @@ comfort_response_t base_comfort_value( const Character &who, const tripoint &p )
comfort -= here.move_cost( p );
}

if( comfort_response.aid == nullptr ) {
if( comfort_response.aid.empty() ) {
Copy link
Member

Choose a reason for hiding this comment

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

this if condition prevents player from getting aid from both vehicle and floor, is this intended behavior?

e.g below a car on floor is teddy bear, the car also has teddy bear -> only 1 teddy bear bonus (car)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not intentional in the sense that I had even thought of it, but I'd say it's sensible that only the item that's in the actual vehicle should count.

initialization should handle it
@RobbieNeko
Copy link
Collaborator Author

RobbieNeko commented Dec 28, 2024

After applying the suggestion to remove the unncecessary vector clearing (and the other pertinent small changes and suggestions), can confirm it still builds and works as expected on my machine

@chaosvolt
Copy link
Member

This definitely has potential to get spammy I suspect, but hmm.
image

@RobbieNeko
Copy link
Collaborator Author

This definitely has potential to get spammy I suspect, but hmm. image

I think it's fairly reasonable to assume that people aren't likely to go anywhere near that many pillows, haha

@chaosvolt
Copy link
Member

Hopefully, main thing however is that if you're bringing pillows from multiple houses one at a time, the stack-splitting might kick in and ensure every single one you add gets its own message line. That'll add up and will affect even a normal playthrough, just just someone who's hoardmaxxing.

@RobbieNeko
Copy link
Collaborator Author

Hmm.
I suppose we can just see how often that comes up in normal gameplay, and adjust accordingly if it ends up being an issue down the line?

@chaosvolt
Copy link
Member

Fair, it hopefully won't be too cursed.

@scarf005
Copy link
Member

scarf005 commented Dec 28, 2024

also wondering: does stacks work, e g is 40x teddy bear as effective as 1x teddy bear

@RobbieNeko
Copy link
Collaborator Author

... probably depends on if it's count / charges or individual items

@RobbieNeko
Copy link
Collaborator Author

It just iterates over the items on the tile, so it should work just fine if they're individual items?

@RobbieNeko
Copy link
Collaborator Author

In any case, looks like it behaves just fine. As such,
LGTM

@RobbieNeko RobbieNeko merged commit ddc7bd7 into cataclysmbnteam:main Dec 28, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants