本文整理汇总了C++中player::add_effect方法的典型用法代码示例。如果您正苦于以下问题:C++ player::add_effect方法的具体用法?C++ player::add_effect怎么用?C++ player::add_effect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::add_effect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fire
int turret_data::fire( player &p, const tripoint &target )
{
if( !veh || !part ) {
return 0;
}
int shots = 0;
p.add_effect( effect_on_roof, 1 );
p.recoil = abs( veh->velocity ) / 100 / 4;
auto mode = base()->gun_current_mode();
auto ammo = ammo_current();
long qty = mode->ammo_required();
if( part->info().has_flag( "USE_TANKS" ) ) {
mode->ammo_set( ammo, std::min( qty * mode.qty, long( veh->fuel_left( ammo ) ) ) );
}
shots = p.fire_gun( target, mode.qty, *mode );
if( part->info().has_flag( "USE_TANKS" ) ) {
veh->drain( ammo, qty * shots );
mode->ammo_unset();
}
veh->drain( fuel_type_battery, mode->get_gun_ups_drain() * shots );
p.remove_effect( effect_on_roof );
return shots;
}
示例2: handle_heli_crash
void start_location::handle_heli_crash( player &u ) const
{
for( int i = 2; i < num_hp_parts; i++ ) { // Skip head + torso for balance reasons.
auto part = hp_part( i );
auto bp_part = u.hp_to_bp( part );
int roll = int( rng( 1, 8 ) );
switch( roll ) {
case 1:
case 2:// Damage + Bleed
u.add_effect( effect_bleed, 60, bp_part );
/* fallthrough */
case 3:
case 4:
case 5: { // Just damage
auto maxHp = u.get_hp_max( part );
// Body part health will range from 33% to 66% with occasional bleed
int dmg = int( rng( maxHp / 3, maxHp * 2 / 3 ) );
u.apply_damage( nullptr, bp_part, dmg );
break;
}
default: // No damage
break;
}
}
}
示例3: apply_character_light
void map::apply_character_light( player &p )
{
if( p.has_effect( effect_onfire ) ) {
apply_light_source( p.pos(), 8 );
} else if( p.has_effect( effect_haslight ) ) {
apply_light_source( p.pos(), 4 );
}
float const held_luminance = p.active_light();
if( held_luminance > LIGHT_AMBIENT_LOW ) {
apply_light_source( p.pos(), held_luminance );
}
if( held_luminance >= 4 && held_luminance > ambient_light_at( p.pos() ) - 0.5f ) {
p.add_effect( effect_haslight, 1 );
}
}
示例4: addict_effect
void addict_effect( player &u, addiction &add )
{
const int in = std::min( 20, add.intensity );
switch( add.type ) {
case ADD_CIG:
if( !one_in( 2000 - 20 * in ) ) {
break;
}
u.add_msg_if_player( rng( 0, 6 ) < in ?
_( "You need some nicotine." ) :
_( "You could use some nicotine." ) );
u.add_morale( MORALE_CRAVING_NICOTINE, -15, -3 * in );
if( one_in( 800 - 50 * in ) ) {
u.mod_fatigue( 1 );
}
if( u.stim > -5 * in && one_in( 400 - 20 * in ) ) {
u.stim--;
}
break;
case ADD_CAFFEINE:
if( !one_in( 2000 - 20 * in ) ) {
break;
}
u.add_msg_if_player( m_warning, _( "You want some caffeine." ) );
u.add_morale( MORALE_CRAVING_CAFFEINE, -5, -30 );
if( u.stim > -10 * in && rng( 0, 10 ) < in ) {
u.stim--;
}
if( rng( 8, 400 ) < in ) {
u.add_msg_if_player( m_bad, _( "Your hands start shaking... you need it bad!" ) );
u.add_effect( effect_shakes, 20 );
}
break;
case ADD_ALCOHOL:
case ADD_DIAZEPAM: {
static const std::string alc_1 = _( "You could use a drink. " );
static const std::string alc_2 = _( "Your hands start shaking... you need a drink bad!" ) ;
static const std::string dia_1 = _( "You could use some diazepam." );
static const std::string dia_2 = _( "You're shaking... you need some diazepam!" );
const std::string &msg_1 = add.type == ADD_ALCOHOL ? alc_1 : dia_1;
const std::string &msg_2 = add.type == ADD_ALCOHOL ? alc_2 : dia_2;
const auto morale_type = add.type == ADD_ALCOHOL ? MORALE_CRAVING_ALCOHOL : MORALE_CRAVING_DIAZEPAM;
u.mod_per_bonus( -1 );
u.mod_int_bonus( -1 );
if( x_in_y( in, HOURS( 2 ) ) ) {
u.mod_healthy_mod( -1, -in * 10 );
}
if( one_in( 20 ) && rng( 0, 20 ) < in ) {
u.add_msg_if_player( m_warning, msg_1.c_str() );
u.add_morale( morale_type, -35, -10 * in );
} else if( rng( 8, 300 ) < in ) {
u.add_msg_if_player( m_bad, msg_2.c_str() );
u.add_morale( morale_type, -35, -10 * in );
u.add_effect( effect_shakes, 50 );
} else if( !u.has_effect( effect_hallu ) && rng( 10, 1600 ) < in ) {
u.add_effect( effect_hallu, 3600 );
}
break;
}
case ADD_SLEEP:
// No effects here--just in player::can_sleep()
// EXCEPT! Prolong this addiction longer than usual.
if( one_in( 2 ) && add.sated < 0 ) {
add.sated++;
}
break;
case ADD_PKILLER:
if( calendar::once_every( 100 - in * 4 ) && u.get_painkiller() > 20 - in ) {
u.mod_painkiller( -1 ); // Tolerance increases!
}
if( u.get_painkiller() >= 35 ) { // No further effects if we're doped up.
add.sated = 0;
break;
}
u.mod_str_bonus( -1 );
u.mod_per_bonus( -1 );
u.mod_dex_bonus( -1 );
if( u.get_pain() < in * 2 ) {
u.mod_pain( 1 );
}
if( one_in( 1200 - 30 * in ) ) {
u.mod_healthy_mod( -1, -in * 30 );
}
if( one_in( 20 ) && dice( 2, 20 ) < in ) {
u.add_msg_if_player( m_bad, _( "Your hands start shaking... you need some painkillers." ) );
u.add_morale( MORALE_CRAVING_OPIATE, -40, -10 * in );
u.add_effect( effect_shakes, 20 + in * 5 );
} else if( one_in( 20 ) && dice( 2, 30 ) < in ) {
u.add_msg_if_player( m_bad, _( "You feel anxious. You need your painkillers!" ) );
//.........这里部分代码省略.........
示例5: addict_effect
void addict_effect(player &u, addiction &add,
std::function<void (char const*)> const &cancel_activity)
{
int const in = add.intensity;
switch (add.type) {
case ADD_CIG:
if (in > 20 || one_in((500 - 20 * in))) {
u.add_msg_if_player(rng(0, 6) < in ? _("You need some nicotine.") :
_("You could use some nicotine."));
u.add_morale(MORALE_CRAVING_NICOTINE, -15, -50);
if (one_in(800 - 50 * in)) {
u.fatigue++;
}
if (u.stim > -50 && one_in(400 - 20 * in)) {
u.stim--;
}
}
break;
case ADD_CAFFEINE:
u.moves -= 2;
if (in > 20 || one_in((500 - 20 * in))) {
u.add_msg_if_player(m_warning, _("You want some caffeine."));
u.add_morale(MORALE_CRAVING_CAFFEINE, -5, -30);
if (u.stim > -150 && rng(0, 10) < in) {
u.stim--;
}
if (rng(8, 400) < in) {
u.add_msg_if_player(m_bad, _("Your hands start shaking... you need it bad!"));
u.add_effect("shakes", 20);
}
}
break;
case ADD_ALCOHOL:
u.mod_per_bonus(-1);
u.mod_int_bonus(-1);
if (rng(40, 1200) <= in * 10) {
u.mod_healthy_mod(-1, -in * 10);
}
if (one_in(20) && rng(0, 20) < in) {
u.add_msg_if_player(m_warning, _("You could use a drink."));
u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120);
} else if (rng(8, 300) < in) {
u.add_msg_if_player(m_bad, _("Your hands start shaking... you need a drink bad!"));
u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120);
u.add_effect("shakes", 50);
} else if (!u.has_effect("hallu") && rng(10, 1600) < in) {
u.add_effect("hallu", 3600);
}
break;
case ADD_SLEEP:
// No effects here--just in player::can_sleep()
// EXCEPT! Prolong this addiction longer than usual.
if (one_in(2) && add.sated < 0) {
add.sated++;
}
break;
case ADD_PKILLER:
if ((in >= 25 || int(calendar::turn) % (100 - in * 4) == 0) && u.pkill > 0) {
u.pkill--; // Tolerance increases!
}
if (u.pkill >= 35) { // No further effects if we're doped up.
add.sated = 0;
} else {
u.mod_str_bonus(-(1 + int(in / 7)));
u.mod_per_bonus(-1);
u.mod_dex_bonus(-1);
if (u.pain < in * 3) {
u.mod_pain(1);
}
if (in >= 40 || one_in(1200 - 30 * in)) {
u.mod_healthy_mod(-1, -in * 30);
}
if (one_in(20) && dice(2, 20) < in) {
u.add_msg_if_player(m_bad, _("Your hands start shaking... you need some painkillers."));
u.add_morale(MORALE_CRAVING_OPIATE, -40, -200);
u.add_effect("shakes", 20 + in * 5);
} else if (one_in(20) && dice(2, 30) < in) {
u.add_msg_if_player(m_bad, _("You feel anxious. You need your painkillers!"));
u.add_morale(MORALE_CRAVING_OPIATE, -30, -200);
} else if (one_in(50) && dice(3, 50) < in) {
u.add_msg_if_player(m_bad, _("You throw up heavily!"));
cancel_activity(_("Throwing up."));
u.vomit();
}
}
break;
case ADD_SPEED: {
// Minimal speed of PC is 0.25 * base speed, that is
// usually 25 moves, this ensures that even at minimal speed
// the PC gets 5 moves per turn.
int move_pen = std::min(in * 5, 20);
u.moves -= move_pen;
u.mod_int_bonus(-1);
u.mod_str_bonus(-1);
//.........这里部分代码省略.........
示例6: apply_buff
void ma_buff::apply_buff( player &u ) const
{
u.add_effect( get_effect_id(), buff_duration );
}