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

Traps disarming gives morale effects #29466

Merged
merged 3 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/json/morale_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@
"type": "morale_type",
"text": "Communed with the trees"
},
{
"id": "morale_accomplishment",
"type": "morale_type",
"text": "Accomplishment"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like to be a way too generic name. Imagine we add several reasons for this morale bonus to shoot, and the player could see several "Accomplishment"s in his morale display. I believe it needs to be specified to what type of accomplishment caused this morale boost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was intentional. We should use generic morale types and less of them instead of creating more of similar types.

Copy link
Member

Choose a reason for hiding this comment

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

There used to be a stacking issue, but now it's just a matter of avoiding clutter in the UI, which is still a pretty big deal. The player is notified specifically what the accomplishment was when they perform the action, but minutes or hours later, does it matter what it was, or that they're happy about it?

},
{
"id": "morale_failure",
"type": "morale_type",
"text": "Failure"
},
{
"id": "morale_perm_debug",
"type": "morale_type",
Expand Down
10 changes: 10 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "messages.h"
#include "mongroup.h"
#include "monster.h"
#include "morale_types.h"
#include "mtype.h"
#include "npc.h"
#include "options.h"
Expand Down Expand Up @@ -5251,17 +5252,26 @@ void map::disarm_trap( const tripoint &p )
}
if( roll >= diff ) {
add_msg( _( "You disarm the trap!" ) );
const int morale_buff = tr.get_avoidance() * 0.4 + tr.get_difficulty() + rng( 0, 4 );
g->u.rem_morale( MORALE_FAILURE );
g->u.add_morale( MORALE_ACCOMPLISHMENT, morale_buff, 40 );
tr.on_disarmed( *this, p );
if( diff > 1.25 * tSkillLevel ) { // failure might have set off trap
g->u.practice( skill_traps, 1.5 * ( diff - tSkillLevel ) );
}
} else if( roll >= diff * .8 ) {
add_msg( _( "You fail to disarm the trap." ) );
const int morale_debuff = -rng( 6, 18 );
g->u.rem_morale( MORALE_ACCOMPLISHMENT );
g->u.add_morale( MORALE_FAILURE, morale_debuff, -40 );
if( diff > 1.25 * tSkillLevel ) {
g->u.practice( skill_traps, 1.5 * ( diff - tSkillLevel ) );
}
} else {
add_msg( m_bad, _( "You fail to disarm the trap, and you set it off!" ) );
const int morale_debuff = -rng( 12, 24 );
g->u.rem_morale( MORALE_ACCOMPLISHMENT );
g->u.add_morale( MORALE_FAILURE, morale_debuff, -40 );
tr.trigger( p, &g->u );
if( diff - roll <= 6 ) {
// Give xp for failing, but not if we failed terribly (in which
Expand Down
5 changes: 5 additions & 0 deletions src/morale_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ const morale_type &morale_type_data::convert_legacy( int lmt )
morale_type( "morale_butcher" ),
morale_type( "morale_gravedigger" ),

morale_type( "morale_accomplishment" ),
morale_type( "morale_failure" ),

morale_type( "morale_null" )
}
};
Expand Down Expand Up @@ -182,6 +185,8 @@ const morale_type MORALE_PERM_DEBUG( "morale_perm_debug" );
const morale_type MORALE_BUTCHER( "morale_butcher" );
const morale_type MORALE_GRAVEDIGGER( "morale_gravedigger" );
const morale_type MORALE_TREE_COMMUNION( "morale_tree_communion" );
const morale_type MORALE_ACCOMPLISHMENT( "morale_accomplishment" );
const morale_type MORALE_FAILURE( "morale_failure" );

namespace
{
Expand Down
2 changes: 2 additions & 0 deletions src/morale_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,7 @@ extern const morale_type MORALE_PERM_DEBUG;
extern const morale_type MORALE_BUTCHER;
extern const morale_type MORALE_GRAVEDIGGER;
extern const morale_type MORALE_TREE_COMMUNION;
extern const morale_type MORALE_ACCOMPLISHMENT;
extern const morale_type MORALE_FAILURE;

#endif