CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.12k forks source link

NPC won't state why it won't study from a book #75562

Open l29ah opened 1 month ago

l29ah commented 1 month ago

Describe the bug

No matter the orders.

Attach save file

2024.07.14.zip

Steps to reproduce

Expected behavior

NPC studying from the book it has in the inventory.

Screenshots

No response

Versions and configuration

Additional context

No response

PatrikLundell commented 1 month ago

Looks like you're asking a companion to study a book training dodge up to 3 when the skill is above that?

l29ah commented 1 month ago

The skill is 0 (27%).

PatrikLundell commented 1 month ago

You're correct. I fail to read the dodge entry correctly every time...

If you order him to read a specific book (but only then) you'll see why: "Elton Naylor's eyes won't focus without reading glasses." He's far-sighted.

Maleclypse commented 1 month ago

Confirming since message should pop up on any way you can request the npc to read, not just a single one of them.

marilynias commented 1 month ago

for future prosperity

// src/activity_item_handling.cpp:1250
if( act == ACT_MULTIPLE_READ ) {
        const item_filter filter = [ &you ]( const item & i ) {
            // Check well lit after
            read_condition_result condition = you.check_read_condition( i );
            return condition == read_condition_result::SUCCESS ||
                   condition == read_condition_result::TOO_DARK;
        };
        if( !you.items_with( filter ).empty() ) {
            return activity_reason_info::ok( do_activity_reason::NEEDS_BOOK_TO_LEARN );
        }
        // TODO: find books from zone?
        return activity_reason_info::fail( do_activity_reason::ALREADY_DONE );
    }

~Doesn't seem to check for a lot of failure conditions.~ ~Also if I read this right read_condition_result returns a byte with every every condition byte able to be set. So you probably want to & it instead of ==, since multiple conditions could be true.~

~but Im not too familiar with cpp, so if someone more competent wants to correct me, go ahead.~

~I will probably try to fix it later.~

edit: ==comparison are on purpose, since all other results are failure results and the function only returns successful reads and reads that would be successful if in the correct lighting condition.

also working to fix it I really dont like my solutions and im not confident enough in my cpp experience so if anyone wants to look at displaying failure failure reasons, please do.

PatrikLundell commented 1 month ago

The VS compiler agrees with you: "Use 'bitwise and' to check if a flag is true" marking the TOO_DARK line (and the reasoning also makes logical sense).