Skip to content

Commit

Permalink
dog whistle fluff (CleverRaven#51549)
Browse files Browse the repository at this point in the history
Co-authored-by: Saicchi <Saicchi@users.noreply.github.com>
  • Loading branch information
Saicchi and Saicchi authored Sep 14, 2021
1 parent aa69568 commit 7a4f3a2
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "iuse_actor.h" // For firestarter
#include "json.h"
#include "line.h"
#include "make_static.h"
#include "map.h"
#include "map_iterator.h"
#include "mapdata.h"
Expand Down Expand Up @@ -4661,11 +4662,52 @@ cata::optional<int> iuse::vortex( Character *p, item *it, bool, const tripoint &

cata::optional<int> iuse::dog_whistle( Character *p, item *it, bool, const tripoint & )
{
if( !p->is_avatar() ) {
return cata::nullopt;
}
if( p->is_underwater() ) {
p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) );
return cata::nullopt;
}
p->add_msg_if_player( _( "You blow your dog whistle." ) );

std::array<std::string, 4> messages_friendly_or_neutral = {
_( "What is this unbearable sound!?" ),
_( "STOP. MY EARS" ),
_( "I'm not a dog…" ),
_( "Would you kindly not do that?" )
};

std::array<std::string, 5> messages_hostile = {
_( "I WILL MURDER YOU" ),
_( "I'LL SHOVE THAT WHISTLE DOWN YOUR THROAT" ),
_( "You're seriously pissing me off…" ),
_( "I'm not a dog…" ),
_( "What is this unbearable sound!?" ),
};

// Can the Character hear the dog whistle?
auto hearing_check = [p]( const Character & who ) -> bool {
return !who.is_deaf() && p->sees( who ) &&
who.has_trait( STATIC( trait_id( "THRESH_LUPINE" ) ) );
};

for( const npc &subject : g->all_npcs() ) {
if( !( one_in( 3 ) && hearing_check( subject ) ) ) {
continue;
}

if( p->attitude_to( subject ) == Creature::Attitude::HOSTILE ) {
subject.say( random_entry( messages_hostile ) );
} else {
subject.say( random_entry( messages_friendly_or_neutral ) );
}
}

if( hearing_check( *p ) && one_in( 3 ) ) {
p->add_msg_if_player( m_info, _( "You hate this loud sound." ) );
}

for( monster &critter : g->all_monsters() ) {
if( critter.friendly != 0 && critter.has_flag( MF_DOGFOOD ) ) {
bool u_see = get_player_view().sees( critter );
Expand Down

0 comments on commit 7a4f3a2

Please sign in to comment.