forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
talker_avatar.cpp
124 lines (109 loc) · 3.61 KB
/
talker_avatar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <memory>
#include <string>
#include "avatar.h"
#include "calendar.h"
#include "character.h"
#include "game.h"
#include "messages.h"
#include "monster.h"
#include "mtype.h"
#include "npc.h"
#include "npctrade.h"
#include "output.h"
#include "skill.h"
#include "talker.h"
#include "talker_avatar.h"
#include "translations.h"
static const efftype_id effect_pacified( "pacified" );
static const efftype_id effect_pet( "pet" );
static const itype_id itype_foodperson_mask( "foodperson_mask" );
static const itype_id itype_foodperson_mask_on( "foodperson_mask_on" );
static const trait_id trait_PROF_FOODP( "PROF_FOODP" );
talker_avatar::talker_avatar( avatar *new_me )
{
me_chr = new_me;
me_chr_const = new_me;
}
std::vector<std::string> talker_avatar::get_topics( bool )
{
std::vector<std::string> add_topics;
if( has_trait( trait_PROF_FOODP ) && !( is_wearing( itype_foodperson_mask ) ||
is_wearing( itype_foodperson_mask_on ) ) ) {
add_topics.emplace_back( "TALK_NOFACE" );
}
return add_topics;
}
int talker_avatar::parse_mod( const std::string &attribute, const int factor ) const
{
int modifier = 0;
if( attribute == "U_INTIMIDATE" ) {
modifier = me_chr->intimidation();
}
modifier *= factor;
return modifier;
}
int talker_avatar::trial_chance_mod( const std::string &trial_type ) const
{
int chance = 0;
const social_modifiers &me_mods = me_chr->get_mutation_bionic_social_mods();
if( trial_type == "lie" ) {
chance += me_chr->talk_skill() + me_mods.lie;
} else if( trial_type == "persuade" ) {
chance += me_chr->talk_skill() + me_mods.persuade;
} else if( trial_type == "intimidate" ) {
chance += me_chr->intimidation() + me_mods.intimidate;
}
return chance;
}
std::vector<skill_id> talker_avatar::skills_offered_to( const talker &student ) const
{
if( !student.get_character() ) {
return {};
}
const Character &c = *student.get_character();
std::vector<skill_id> ret;
for( const auto &pair : *me_chr->_skills ) {
const skill_id &id = pair.first;
if( c.get_knowledge_level( id ) < pair.second.level() ) {
ret.push_back( id );
}
}
return ret;
}
bool talker_avatar::buy_monster( talker &seller, const mtype_id &mtype, int cost,
int count, bool pacified, const translation &name )
{
npc *seller_guy = seller.get_npc();
if( !seller_guy ) {
popup( _( "%s can't sell you any %s" ), seller.disp_name(), mtype.obj().nname( 2 ) );
return false;
}
if( cost > 0 && !npc_trading::pay_npc( *seller_guy, cost ) ) {
popup( _( "You can't afford it!" ) );
return false;
}
for( int i = 0; i < count; i++ ) {
monster *const mon_ptr = g->place_critter_around( mtype, me_chr->pos(), 3 );
if( !mon_ptr ) {
add_msg_debug( debugmode::DF_TALKER, "Cannot place u_buy_monster, no valid placement locations." );
break;
}
monster &tmp = *mon_ptr;
// Our monster is always a pet.
tmp.friendly = -1;
tmp.add_effect( effect_pet, 1_turns, true );
if( pacified ) {
tmp.add_effect( effect_pacified, 1_turns, true );
}
if( !name.empty() ) {
tmp.unique_name = name.translated();
}
}
if( name.empty() ) {
popup( _( "%1$s gives you %2$d %3$s." ), seller_guy->get_name(),
count, mtype.obj().nname( count ) );
} else {
popup( _( "%1$s gives you %2$s." ), seller_guy->get_name(), name );
}
return true;
}