-
Notifications
You must be signed in to change notification settings - Fork 282
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(port): Add book binder with many QoL #2170
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
765dc6f
add ultra WIP version without paper usage, and spawn modif
leoCottret d447c3d
add paper usage, and change recipes shown logic
leoCottret 14c2fe6
revert ammo remaining changes
leoCottret 5e3263d
add misc changes and update doc
leoCottret 5de617a
increase book binder max charges to non debug amount
leoCottret 4005677
add usable pen (for the book binder)
leoCottret 2540320
change pen to tool
leoCottret 7d27343
improve requirement checks, add some(?), remove recipes already in bo…
leoCottret 1475cea
remove tmp file
leoCottret 6f92979
add automatic pages removal after learning a recipe + misc things
leoCottret 5e34eb5
astyle (here we go)
leoCottret 65a75c8
astyle
leoCottret 9300817
fix sneaky unrelated change
leoCottret 2ca2ac2
fix clang tidy with new property
leoCottret 01ac7a7
astyle, fix new change on recipe comparison
leoCottret c9ce4a6
fix duplicated word
leoCottret 42d8093
refactoring, clang tidy
leoCottret 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
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
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
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
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
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
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
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
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
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
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ | |||||
#include "avatar.h" | ||||||
#include "calendar.h" | ||||||
#include "character.h" | ||||||
#include "character_functions.h" | ||||||
#include "crafting.h" | ||||||
#include "debug.h" | ||||||
#include "enums.h" | ||||||
|
@@ -50,6 +51,7 @@ | |||||
|
||||||
static const itype_id itype_bone_human( "bone_human" ); | ||||||
static const itype_id itype_electrohack( "electrohack" ); | ||||||
static const itype_id itype_paper( "paper" ); | ||||||
|
||||||
static const skill_id skill_computer( "computer" ); | ||||||
|
||||||
|
@@ -60,6 +62,7 @@ static const mtype_id mon_skeleton( "mon_skeleton" ); | |||||
static const mtype_id mon_zombie_crawler( "mon_zombie_crawler" ); | ||||||
|
||||||
static const std::string flag_RELOAD_AND_SHOOT( "RELOAD_AND_SHOOT" ); | ||||||
static const std::string flag_WRITE_MESSAGE( "WRITE_MESSAGE" ); | ||||||
|
||||||
static const std::string has_thievery_witness( "has_thievery_witness" ); | ||||||
|
||||||
|
@@ -879,6 +882,74 @@ void hacking_activity_actor::finish( player_activity &act, Character &who ) | |||||
act.set_to_null(); | ||||||
} | ||||||
|
||||||
void bookbinder_copy_activity_actor::start( player_activity &act, Character & ) | ||||||
{ | ||||||
pages = 1 + rec_id->difficulty / 2; | ||||||
act.moves_total = to_moves<int>( pages * 1_minutes ); | ||||||
act.moves_left = to_moves<int>( pages * 1_minutes ); | ||||||
} | ||||||
|
||||||
void bookbinder_copy_activity_actor::do_turn( player_activity &, Character &p ) | ||||||
{ | ||||||
if( character_funcs::fine_detail_vision_mod( p ) > 4.0f ) { | ||||||
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. A function has been added for this, no need for magic numbers anymore
Suggested change
|
||||||
p.cancel_activity(); | ||||||
p.add_msg_if_player( m_info, _( "It's too dark to write!" ) ); | ||||||
return; | ||||||
} | ||||||
} | ||||||
|
||||||
void bookbinder_copy_activity_actor::finish( player_activity &act, Character &p ) | ||||||
{ | ||||||
const bool rec_added = book_binder->eipc_recipe_add( rec_id ); | ||||||
if( rec_added ) { | ||||||
p.add_msg_if_player( m_good, _( "You copy the recipe for %1$s into your recipe book." ), | ||||||
rec_id->result_name() ); | ||||||
|
||||||
p.use_charges( itype_paper, pages ); | ||||||
book_binder.get_item()->charges += pages; | ||||||
|
||||||
const std::vector<const item *> writing_tools_filter = | ||||||
p.crafting_inventory().items_with( [&]( const item & it ) { | ||||||
return it.has_flag( flag_WRITE_MESSAGE ) && it.ammo_remaining() >= it.ammo_required(); | ||||||
} ); | ||||||
|
||||||
std::vector<tool_comp> writing_tools; | ||||||
writing_tools.reserve( writing_tools_filter.size() ); | ||||||
for( const item *tool : writing_tools_filter ) { | ||||||
writing_tools.emplace_back( tool_comp( tool->typeId(), 1 ) ); | ||||||
} | ||||||
|
||||||
player *player = p.as_player(); | ||||||
|
||||||
player->consume_tools( writing_tools, pages ); | ||||||
} else { | ||||||
debugmsg( "Recipe book already has '%s' recipe when it should not.", rec_id.str() ); | ||||||
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. The cast here is done automatically
Suggested change
|
||||||
} | ||||||
|
||||||
act.set_to_null(); | ||||||
} | ||||||
|
||||||
void bookbinder_copy_activity_actor::serialize( JsonOut &jsout ) const | ||||||
{ | ||||||
jsout.start_object(); | ||||||
jsout.member( "book_binder", book_binder ); | ||||||
jsout.member( "rec_id", rec_id ); | ||||||
jsout.member( "pages", pages ); | ||||||
jsout.end_object(); | ||||||
} | ||||||
|
||||||
std::unique_ptr<activity_actor> bookbinder_copy_activity_actor::deserialize( JsonIn &jsin ) | ||||||
{ | ||||||
bookbinder_copy_activity_actor actor; | ||||||
|
||||||
JsonObject jsobj = jsin.get_object(); | ||||||
jsobj.read( "book_binder", actor.book_binder ); | ||||||
jsobj.read( "rec_id", actor.rec_id ); | ||||||
jsobj.read( "pages", actor.pages ); | ||||||
|
||||||
return actor.clone(); | ||||||
} | ||||||
|
||||||
void hacking_activity_actor::serialize( JsonOut &jsout ) const | ||||||
{ | ||||||
jsout.start_object(); | ||||||
|
@@ -1270,6 +1341,7 @@ const std::unordered_map<activity_id, std::unique_ptr<activity_actor>( * )( Json | |||||
deserialize_functions = { | ||||||
{ activity_id( "ACT_AIM" ), &aim_activity_actor::deserialize }, | ||||||
{ activity_id( "ACT_AUTODRIVE" ), &autodrive_activity_actor::deserialize }, | ||||||
{ activity_id( "ACT_BINDER_COPY_RECIPE" ), &bookbinder_copy_activity_actor::deserialize }, | ||||||
{ activity_id( "ACT_DIG" ), &dig_activity_actor::deserialize }, | ||||||
{ activity_id( "ACT_DIG_CHANNEL" ), &dig_channel_activity_actor::deserialize }, | ||||||
{ activity_id( "ACT_DROP" ), &drop_activity_actor::deserialize }, | ||||||
|
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
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
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.
Is adding this new item intentional? It looks like a merge conflict.
There are no references to
napkin
anywhere, it won't spawn in game world.