示例#1
0
void trapfunc::shotgun(int x, int y)
{
 g->add_msg(_("You trigger a shotgun trap!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a shotgun trap."),
                       pgettext("memorial_female", "Triggered a shotgun trap."));
 int shots = (one_in(8) || one_in(20 - g->u.str_max) ? 2 : 1);
 if (g->m.tr_at(x, y) == tr_shotgun_1)
  shots = 1;
 if (rng(5, 50) > g->u.get_dodge()) {
  body_part hit = num_bp;
  switch (rng(1, 10)) {
   case  1: hit = bp_feet; break;
   case  2:
   case  3:
   case  4: hit = bp_legs; break;
   case  5:
   case  6:
   case  7:
   case  8:
   case  9: hit = bp_torso; break;
   case 10: hit = bp_head; break;
  }
  int side = random_side(hit);
  g->add_msg(_("Your %s is hit!"), body_part_name(hit, side).c_str());
  g->u.hit(NULL, hit, side, 0, rng(40 * shots, 60 * shots));
 } else
  g->add_msg(_("You dodge the shot!"));
 if (shots == 2 || g->m.tr_at(x, y) == tr_shotgun_1) {
  g->m.spawn_item(x, y, "shotgun_sawn");
  g->m.spawn_item(x, y, "string_6");
  g->m.remove_trap(x, y);
 } else
  g->m.add_trap(x, y, tr_shotgun_1);
}
示例#2
0
void Creature::process_effects()
{
    for( auto it = effects.begin(); it != effects.end(); ++it ) {
        if( !it->second.is_permanent() ) {
            it->second.mod_duration( -1 );
            add_msg( m_debug, "Duration %d", it->second.get_duration() );
        }
    }
    for( auto it = effects.begin(); it != effects.end(); ) {
        if( !it->second.is_permanent() && it->second.get_duration() <= 0 ) {
            const effect_type *type = it->second.get_effect_type();
            if(type->get_remove_message() != "") {
                add_msg( type->lose_game_message_type(), _(type->get_remove_message().c_str()) );
            }
            g->u.add_memorial_log(
                pgettext("memorial_male", type->get_remove_memorial_log().c_str() ),
                pgettext("memorial_female", type->get_remove_memorial_log().c_str()) );
            const auto id = it->second.get_id();
            ++it;
            remove_effect( id );
        } else {
            ++it;
        }
    }
}
void activity_handlers::train_finish( player_activity *act, player *p )
{
    const Skill *skill = Skill::skill(act->name);
    if( skill == NULL ) {
        auto &mastyle = matype_id( act->name ).obj();
        // Trained martial arts,
        add_msg(m_good, _("You learn %s."), mastyle.name.c_str());
        //~ %s is martial art
        p->add_memorial_log(pgettext("memorial_male", "Learned %s."),
                            pgettext("memorial_female", "Learned %s."),
                            mastyle.name.c_str());
        p->add_martialart( mastyle.id );
    } else {
        int new_skill_level = p->skillLevel(skill) + 1;
        p->skillLevel(skill).level(new_skill_level);
        add_msg(m_good, _("You finish training %s to level %d."),
                skill->name().c_str(),
                new_skill_level);
        if( new_skill_level % 4 == 0 ) {
            //~ %d is skill level %s is skill name
            p->add_memorial_log(pgettext("memorial_male", "Reached skill level %1$d in %2$s."),
                                pgettext("memorial_female", "Reached skill level %1$d in %2$s."),
                                new_skill_level, skill->name().c_str());
        }
    }
    act->type = ACT_NULL;
}
示例#4
0
void trapfunc::snake(int x, int y)
{
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a shadow snake trap."),
                       pgettext("memorial_female", "Triggered a shadow snake trap."));
 if (one_in(3)) {
  monster spawned(GetMType("mon_shadow_snake"));
  int tries = 0, monx, mony, junk;
  do {
   if (one_in(2)) {
    monx = rng(g->u.posx - 5, g->u.posx + 5);
    mony = (one_in(2) ? g->u.posy - 5 : g->u.posy + 5);
   } else {
    monx = (one_in(2) ? g->u.posx - 5 : g->u.posx + 5);
    mony = rng(g->u.posy - 5, g->u.posy + 5);
   }
  } while (tries < 5 && !g->is_empty(monx, mony) &&
           !g->m.sees(monx, mony, g->u.posx, g->u.posy, 10, junk));

  if (tries < 5) {
   g->add_msg(_("A shadowy snake forms nearby."));
   spawned.spawn(monx, mony);
   g->add_zombie(spawned);
   g->m.remove_trap(x, y);
   return;
  }
 }
 //~ the sound a snake makes
 g->sound(x, y, 10, _("ssssssss"));
 if (one_in(6))
  g->m.remove_trap(x, y);
}
示例#5
0
void trapfunc::dissector( Creature *c, const tripoint &p )
{
    //~ the sound of a dissector dissecting
    sounds::sound( p, 10, _( "BRZZZAP!" ) );
    if( c != nullptr ) {
        c->add_msg_player_or_npc( m_bad, _( "Electrical beams emit from the floor and slice your flesh!" ),
                                  _( "Electrical beams emit from the floor and slice <npcname>s flesh!" ) );
        c->add_memorial_log( pgettext( "memorial_male", "Stepped into a dissector." ),
                             pgettext( "memorial_female", "Stepped into a dissector." ) );
        monster *z = dynamic_cast<monster *>( c );
        player *n = dynamic_cast<player *>( c );
        if( n != nullptr ) {
            n->deal_damage( nullptr, bp_head, damage_instance( DT_CUT, 15 ) );
            n->deal_damage( nullptr, bp_torso, damage_instance( DT_CUT, 20 ) );
            n->deal_damage( nullptr, bp_arm_r, damage_instance( DT_CUT, 12 ) );
            n->deal_damage( nullptr, bp_arm_l, damage_instance( DT_CUT, 12 ) );
            n->deal_damage( nullptr, bp_hand_r, damage_instance( DT_CUT, 10 ) );
            n->deal_damage( nullptr, bp_hand_l, damage_instance( DT_CUT, 10 ) );
            n->deal_damage( nullptr, bp_leg_r, damage_instance( DT_CUT, 12 ) );
            n->deal_damage( nullptr, bp_leg_r, damage_instance( DT_CUT, 12 ) );
            n->deal_damage( nullptr, bp_foot_l, damage_instance( DT_CUT, 10 ) );
            n->deal_damage( nullptr, bp_foot_r, damage_instance( DT_CUT, 10 ) );
        } else if( z != nullptr ) {
            z->apply_damage( nullptr, bp_torso, 60 );
            if( z->is_dead() ) {
                z->explode();
            }
        }
        c->check_dead_state();
    }
}
示例#6
0
bool Creature::remove_effect(efftype_id eff_id, body_part bp)
{
    if (!has_effect(eff_id, bp)) {
        //Effect doesn't exist, so do nothing
        return false;
    }

    if (is_player()) {
        // Print the removal message and add the memorial log if needed
        if(effect_types[eff_id].get_remove_message() != "") {
            add_msg(effect_types[eff_id].lose_game_message_type(),
                         _(effect_types[eff_id].get_remove_message().c_str()));
        }
        add_memorial_log(pgettext("memorial_male",
                                       effect_types[eff_id].get_remove_memorial_log().c_str()),
                              pgettext("memorial_female",
                                       effect_types[eff_id].get_remove_memorial_log().c_str()));
    }

    // num_bp means remove all of a given effect id
    if (bp == num_bp) {
        effects.erase(eff_id);
    } else {
        effects[eff_id].erase(bp);
        // If there are no more effects of a given type remove the type map
        if (effects[eff_id].empty()) {
            effects.erase(eff_id);
        }
    }
    return true;
}
示例#7
0
/*
 * Effect-related methods
 */
void Creature::add_effect(efftype_id eff_id, int dur, int intensity, bool permanent)
{
    // check if we already have it
    auto found_effect = effects.find( eff_id );

    if (found_effect != effects.end()) {
        effect &e = found_effect->second;
        // if we do, mod the duration
        e.mod_duration(dur);
        // Adding a permanent effect makes it permanent
        if( e.is_permanent() ) {
            e.pause_effect();
        }
        if( e.get_intensity() + intensity <= e.get_max_intensity() ) {
            e.mod_intensity( intensity );
        }
    } else {
        // if we don't already have it then add a new one
        if (effect_types.find(eff_id) == effect_types.end()) {
            return;
        }
        effect new_eff(&effect_types[eff_id], dur, intensity, permanent);
        effects[eff_id] = new_eff;
        if (is_player()) { // only print the message if we didn't already have it
            add_msg( effect_types[eff_id].gain_game_message_type(),
                     effect_types[eff_id].get_apply_message().c_str() );
            g->u.add_memorial_log(pgettext("memorial_male",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()),
                                  pgettext("memorial_female",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()));
        }
    }
}
示例#8
0
void trapfunc::crossbow(int x, int y)
{
 bool add_bolt = true;
 g->add_msg(_("You trigger a crossbow trap!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a crossbow trap."),
                       pgettext("memorial_female", "Triggered a crossbow trap."));
 if (!one_in(4) && rng(8, 20) > g->u.get_dodge()) {
  body_part hit = num_bp;
  switch (rng(1, 10)) {
   case  1: hit = bp_feet; break;
   case  2:
   case  3:
   case  4: hit = bp_legs; break;
   case  5:
   case  6:
   case  7:
   case  8:
   case  9: hit = bp_torso; break;
   case 10: hit = bp_head; break;
  }
  int side = random_side(hit);
  g->add_msg(_("Your %s is hit!"), body_part_name(hit, side).c_str());
  g->u.hit(NULL, hit, side, 0, rng(20, 30));
  add_bolt = !one_in(10);
 } else
  g->add_msg(_("You dodge the shot!"));
 g->m.remove_trap(x, y);
 g->m.spawn_item(x, y, "crossbow");
 g->m.spawn_item(x, y, "string_6");
 if (add_bolt)
  g->m.spawn_item(x, y, "bolt_steel", 1, 1);
}
示例#9
0
std::vector<std::string> Messages::dialog::filter_help_text( int width )
{
    const auto &help_fmt = _(
                               "Format is [[TYPE]:]TEXT. The values for TYPE are: %s\n"
                               "Examples:\n"
                               "  good:mutation\n"
                               "  :you pick up: 1\n"
                               "  crash!\n"
                           );
    std::stringstream type_text;
    const auto &type_list = msg_type_and_names();
    for( auto it = type_list.begin(); it != type_list.end(); ++it ) {
        // Skip m_debug outside debug mode (but allow searching for it)
        if( debug_mode || it->first != m_debug ) {
            const auto &col_name = get_all_colors().get_name( msgtype_to_color( it->first ) );
            auto next_it = std::next( it );
            // Skip m_debug outside debug mode
            if( !debug_mode && next_it != type_list.end() && next_it->first == m_debug ) {
                next_it = std::next( next_it );
            }
            if( next_it != type_list.end() ) {
                //~ the 2nd %s is a type name, this is used to format a list of type names
                type_text << string_format( pgettext( "message log", "<color_%s>%s</color>, " ),
                                            col_name, pgettext( "message type", it->second ) );
            } else {
                //~ the 2nd %s is a type name, this is used to format the last type name in a list of type names
                type_text << string_format( pgettext( "message log", "<color_%s>%s</color>." ),
                                            col_name, pgettext( "message type", it->second ) );
            }
        }
    }
    return foldstring( string_format( help_fmt, type_text.str() ), width );
}
示例#10
0
void trapfunc::board( Creature *c, const tripoint& )
{
    // tiny animals don't trigger spiked boards, they can squeeze between the nails
    if( c != nullptr && c->get_size() == MS_TINY ) {
        return;
    }
    if( c != nullptr ) {
        c->add_memorial_log( pgettext( "memorial_male", "Stepped on a spiked board." ),
                             pgettext( "memorial_female", "Stepped on a spiked board." ) );
        c->add_msg_player_or_npc( m_bad, _( "You step on a spiked board!" ),
                                  _( "<npcname> steps on a spiked board!" ) );
        monster *z = dynamic_cast<monster *>( c );
        player *n = dynamic_cast<player *>( c );
        if( z != nullptr ) {
            z->moves -= 80;
            z->apply_damage( nullptr, bp_foot_l, rng( 3, 5 ) );
            z->apply_damage( nullptr, bp_foot_r, rng( 3, 5 ) );
        } else {
            c->deal_damage( nullptr, bp_foot_l, damage_instance( DT_CUT, rng( 6, 10 ) ) );
            c->deal_damage( nullptr, bp_foot_r, damage_instance( DT_CUT, rng( 6, 10 ) ) );
            if( ( n->has_trait( "INFRESIST" ) ) && ( one_in( 256 ) ) ) {
                n->add_effect( "tetanus", 1, num_bp, true );
            } else if( ( !n->has_trait( "INFIMMUNE" ) || !n->has_trait( "INFRESIST" ) ) && ( one_in( 35 ) ) ) {
                n->add_effect( "tetanus", 1, num_bp, true );
            }
        }
        c->check_dead_state();
    }
}
示例#11
0
void trapfunc::shadow( Creature *c, const tripoint &p )
{
    if( c != &g->u ) {
        return;
    }
    // Monsters and npcs are completely ignored here, should they?
    g->u.add_memorial_log( pgettext( "memorial_male", "Triggered a shadow trap." ),
                           pgettext( "memorial_female", "Triggered a shadow trap." ) );
    int tries = 0;
    tripoint monp = p;
    do {
        if( one_in( 2 ) ) {
            monp.x = rng( g->u.posx() - 5, g->u.posx() + 5 );
            monp.y = ( one_in( 2 ) ? g->u.posy() - 5 : g->u.posy() + 5 );
        } else {
            monp.x = ( one_in( 2 ) ? g->u.posx() - 5 : g->u.posx() + 5 );
            monp.y = rng( g->u.posy() - 5, g->u.posy() + 5 );
        }
    } while( tries < 5 && !g->is_empty( monp ) &&
             !g->m.sees( monp, g->u.pos(), 10 ) );

    if( tries < 5 ) {
        if( g->summon_mon( mon_shadow, monp ) ) {
            add_msg( m_warning, _( "A shadow forms nearby." ) );
            monster *spawned = g->monster_at( monp );
            spawned->reset_special_rng( 0 );
        }
        g->m.remove_trap( p );
    }
}
示例#12
0
void Creature::add_effect(efftype_id eff_id, int dur)
{
    // check if we already have it
    std::vector<effect>::iterator first_eff =
        std::find_if(effects.begin(), effects.end(), is_id_functor(eff_id));

    if (first_eff != effects.end()) {
        // if we do, mod the duration
        first_eff->mod_duration(dur);
    } else {
        // if we don't already have it then add a new one
        if (effect_types.find(eff_id) == effect_types.end()) {
            return;
        }
        effect new_eff(&effect_types[eff_id], dur);
        effects.push_back(new_eff);
        if (is_player()) { // only print the message if we didn't already have it
            g->add_msg_string(effect_types[eff_id].get_apply_message());
            g->u.add_memorial_log(pgettext("memorial_male",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()),
                                  pgettext("memorial_female",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()));
        }
    }
}
示例#13
0
std::string faction::describe() const
{
    std::string ret = _( desc.c_str() );
    ret = ret + "\n\n" + string_format( _( "%1$s have the ultimate goal of %2$s." ), _( name.c_str() ),
                                        pgettext( "faction_goal", facgoal_data[goal].name.c_str() ) );
    if( job2 == FACJOB_NULL ) {
        ret += string_format( _( " Their primary concern is %s." ),
                              pgettext( "faction_job", facjob_data[job1].name.c_str() ) );
    } else {
        ret += string_format( _( " Their primary concern is %1$s, but they are also involved in %2$s." ),
                              pgettext( "faction_job", facjob_data[job1].name.c_str() ),
                              pgettext( "faction_job", facjob_data[job2].name.c_str() ) );
    }
    if( values == 0 ) {
        return ret;
    }
    std::vector<faction_value> vals;
    vals.reserve( NUM_FACVALS );
    for( int i = 0; i < NUM_FACVALS; i++ ) {
        vals.push_back( faction_value( i ) );
    }
    const std::string known_vals = enumerate_as_string( vals.begin(),
    vals.end(), [ this ]( const faction_value val ) {
        return has_value( val ) ? pgettext( "faction_value", facval_data[val].name.c_str() ) : "";
    } );
    if( !known_vals.empty() ) {
        ret += _( " They are known for " ) + known_vals + ".";
    }
    return ret;
}
示例#14
0
void trapfunc::blade(int, int)
{
 g->add_msg(_("A blade swings out and hacks your torso!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a blade trap."),
                       pgettext("memorial_female", "Triggered a blade trap."));
 g->u.hit(NULL, bp_torso, -1, 12, 30);
}
示例#15
0
void trapfunc::snare_light( Creature *c, const tripoint &p )
{
    sounds::sound( p, 2, _( "Snap!" ) );
    g->m.remove_trap( p );
    if( c != nullptr ) {
        // Determine what gets hit
        body_part hit = num_bp;
        if( one_in( 2 ) ) {
            hit = bp_leg_l;
        } else {
            hit = bp_leg_r;
        }
        // Messages
        c->add_msg_player_or_npc( m_bad, _( "A snare closes on your leg." ),
                                  _( "A snare closes on <npcname>s leg." ) );
        c->add_memorial_log( pgettext( "memorial_male", "Triggered a light snare." ),
                             pgettext( "memorial_female", "Triggered a light snare." ) );

        // Actual effects
        c->add_effect( "lightsnare", 1, hit, true );
        monster *z = dynamic_cast<monster *>( c );
        if( z != nullptr && z->type->size == MS_TINY ) {
            z->apply_damage( nullptr, one_in( 2 ) ? bp_leg_l : bp_leg_r, 10 );
        }
        c->check_dead_state();
    }
}
示例#16
0
void Creature::add_effect(efftype_id eff_id, int dur, int intensity, bool permanent)
{
    // check if we already have it
    std::vector<effect>::iterator first_eff =
        std::find_if(effects.begin(), effects.end(), is_id_functor(eff_id));

    if (first_eff != effects.end()) {
        // if we do, mod the duration
        first_eff->mod_duration(dur);
        // Adding a permanent effect makes it permanent
        if (first_eff->is_permanent()) {
            first_eff->pause_effect();
        }
        if (first_eff->get_intensity() + intensity <= first_eff->get_max_intensity()) {
            first_eff->mod_intensity(intensity);
        }
    } else {
        // if we don't already have it then add a new one
        if (effect_types.find(eff_id) == effect_types.end()) {
            return;
        }
        effect new_eff(&effect_types[eff_id], dur, intensity, permanent);
        effects.push_back(new_eff);
        if (is_player()) { // only print the message if we didn't already have it
            add_msg(effect_types[eff_id].gain_game_message_type(), effect_types[eff_id].get_apply_message().c_str());
            g->u.add_memorial_log(pgettext("memorial_male",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()),
                                  pgettext("memorial_female",
                                           effect_types[eff_id].get_apply_memorial_log().c_str()));
        }
    }
}
示例#17
0
void trapfunc::goo( Creature *c, const tripoint &p )
{
    if( c != nullptr ) {
        c->add_msg_player_or_npc( m_bad, _( "You step in a puddle of thick goo." ),
                                  _( "<npcname> steps in a puddle of thick goo." ) );
        c->add_memorial_log( pgettext( "memorial_male", "Stepped into thick goo." ),
                             pgettext( "memorial_female", "Stepped into thick goo." ) );
        monster *z = dynamic_cast<monster *>( c );
        player *n = dynamic_cast<player *>( c );
        if( n != nullptr ) {
            n->add_env_effect( "slimed", bp_foot_l, 6, 20 );
            n->add_env_effect( "slimed", bp_foot_r, 6, 20 );
            if( one_in( 3 ) ) {
                n->add_msg_if_player( m_bad, _( "The acidic goo eats away at your feet." ) );
                n->deal_damage( nullptr, bp_foot_l, damage_instance( DT_CUT, 5 ) );
                n->deal_damage( nullptr, bp_foot_r, damage_instance( DT_CUT, 5 ) );
                n->check_dead_state();
            }
        } else if( z != nullptr ) {
            if( z->type->id == mon_blob ) {
                z->set_speed_base( z->get_speed_base() + 15 );
                z->set_hp( z->get_speed() );
            } else {
                z->poly( mon_blob );
                z->set_speed_base( z->get_speed_base() - 15 );
                z->set_hp( z->get_speed() );
            }
        }
    }
    g->m.remove_trap( p );
}
示例#18
0
void trapfunc::drain(int, int)
{
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a life-draining trap."),
                       pgettext("memorial_female", "Triggered a life-draining trap."));
 g->add_msg(_("You feel your life force sapping away."));
 g->u.hurtall(1);
}
示例#19
0
void trapfunc::shadow(int x, int y)
{
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a shadow trap."),
                       pgettext("memorial_female", "Triggered a shadow trap."));
 monster spawned(GetMType("mon_shadow"));
 int tries = 0, monx, mony, junk;
 do {
  if (one_in(2)) {
   monx = rng(g->u.posx - 5, g->u.posx + 5);
   mony = (one_in(2) ? g->u.posy - 5 : g->u.posy + 5);
  } else {
   monx = (one_in(2) ? g->u.posx - 5 : g->u.posx + 5);
   mony = rng(g->u.posy - 5, g->u.posy + 5);
  }
 } while (tries < 5 && !g->is_empty(monx, mony) &&
          !g->m.sees(monx, mony, g->u.posx, g->u.posy, 10, junk));

 if (tries < 5) {
  g->add_msg(_("A shadow forms nearby."));
  spawned.sp_timeout = rng(2, 10);
  spawned.spawn(monx, mony);
  g->add_zombie(spawned);
  g->m.remove_trap(x, y);
 }
}
示例#20
0
void trapfunc::ledge(int, int)
{
 g->add_msg(_("You fall down a level!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Fell down a ledge."),
                       pgettext("memorial_female", "Fell down a ledge."));
 g->vertical_move(-1, true);
}
示例#21
0
void trapfunc::snake( Creature *c, const tripoint &p )
{
    //~ the sound a snake makes
    sounds::sound( p, 10, _( "ssssssss" ) );
    if( one_in( 6 ) ) {
        g->m.remove_trap( p );
    }
    if( c != nullptr ) {
        c->add_memorial_log( pgettext( "memorial_male", "Triggered a shadow snake trap." ),
                             pgettext( "memorial_female", "Triggered a shadow snake trap." ) );
    }
    if( one_in( 3 ) ) {
        int tries = 0;
        tripoint monp = p;
        // This spawns snakes only when the player can see them, why?
        do {
            if( one_in( 2 ) ) {
                monp.x = rng( g->u.posx() - 5, g->u.posx() + 5 );
                monp.y = ( one_in( 2 ) ? g->u.posy() - 5 : g->u.posy() + 5 );
            } else {
                monp.x = ( one_in( 2 ) ? g->u.posx() - 5 : g->u.posx() + 5 );
                monp.y = rng( g->u.posy() - 5, g->u.posy() + 5 );
            }
        } while( tries < 5 && !g->is_empty( monp ) &&
                 !g->m.sees( monp, g->u.pos(), 10 ) );

        if( tries < 5 ) {
            add_msg( m_warning, _( "A shadowy snake forms nearby." ) );
            g->summon_mon( mon_shadow_snake, p );
            g->m.remove_trap( p );
        }
    }
}
示例#22
0
bool player::install_bionics(it_bionic *type)
{
    if (type == NULL) {
        debugmsg("Tried to install NULL bionic");
        return false;
    }
    if (bionics.count(type->id) == 0) {
        popup("invalid / unknown bionic id %s", type->id.c_str());
        return false;
    }
    if (has_bionic(type->id)) {
        if (!(type->id == "bio_power_storage" || type->id == "bio_power_storage_mkII")) {
            popup(_("You have already installed this bionic."));
            return false;
        }
    }
    int chance_of_success = bionic_manip_cos(int_cur,
                            skillLevel("electronics"),
                            skillLevel("firstaid"),
                            skillLevel("mechanics"),
                            type->difficulty);

    if (!query_yn(
            _("WARNING: %i percent chance of genetic damage, blood loss, or damage to existing bionics! Install anyway?"),
            100 - chance_of_success)) {
        return false;
    }
    int pow_up = 0;
    if (type->id == "bio_power_storage" || type->id == "bio_power_storage_mkII") {
        pow_up = BATTERY_AMOUNT;
        if (type->id == "bio_power_storage_mkII") {
            pow_up = 250;
        }
    }

    practice( "electronics", int((100 - chance_of_success) * 1.5) );
    practice( "firstaid", int((100 - chance_of_success) * 1.0) );
    practice( "mechanics", int((100 - chance_of_success) * 0.5) );
    int success = chance_of_success - rng(1, 100);
    if (success > 0) {
        add_memorial_log(pgettext("memorial_male", "Installed bionic: %s."),
                         pgettext("memorial_female", "Installed bionic: %s."),
                         bionics[type->id]->name.c_str());
        if (pow_up) {
            max_power_level += pow_up;
            add_msg_if_player(m_good, _("Increased storage capacity by %i"), pow_up);
        } else {
            add_msg(m_good, _("Successfully installed %s."), bionics[type->id]->name.c_str());
            add_bionic(type->id);
        }
    } else {
        add_memorial_log(pgettext("memorial_male", "Installed bionic: %s."),
                         pgettext("memorial_female", "Installed bionic: %s."),
                         bionics[type->id]->name.c_str());
        bionics_install_failure(this, type, success);
    }
    g->refresh_all();
    return true;
}
示例#23
0
void trapfunc::sinkhole(int x, int y)
{
    (void)x; (void)y; // unused
 g->add_msg(_("You step into a sinkhole, and start to sink down!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped into a sinkhole."),
                       pgettext("memorial_female", "Stepped into a sinkhole."));
 if (g->u.has_amount("rope_30", 1) &&
     query_yn(_("There is a sinkhole here. Throw your rope out to try to catch something?"))) {
  int throwroll = rng(g->u.skillLevel("throw"),
                      g->u.skillLevel("throw") + g->u.str_cur + g->u.dex_cur);
  if (throwroll >= 12) {
   g->add_msg(_("The rope catches something!"));
   if (rng(g->u.skillLevel("unarmed"),
           g->u.skillLevel("unarmed") + g->u.str_cur) > 6) {
// Determine safe places for the character to get pulled to
    std::vector<point> safe;
    for (int i = g->u.posx - 1; i <= g->u.posx + 1; i++) {
     for (int j = g->u.posy - 1; j <= g->u.posy + 1; j++) {
      if (g->m.move_cost(i, j) > 0 && g->m.tr_at(i, j) != tr_pit)
       safe.push_back(point(i, j));
     }
    }
    if (safe.empty()) {
     g->add_msg(_("There's nowhere to pull yourself to, and you sink!"));
     g->u.use_amount("rope_30", 1);
     g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
     g->m.ter_set(g->u.posx, g->u.posy, t_hole);
     g->vertical_move(-1, true);
    } else {
     g->add_msg(_("You pull yourself to safety!  The sinkhole collapses."));
     int index = rng(0, safe.size() - 1);
     g->m.ter_set(g->u.posx, g->u.posy, t_hole);
     g->u.posx = safe[index].x;
     g->u.posy = safe[index].y;
     g->update_map(g->u.posx, g->u.posy);
    }
   } else {
    g->add_msg(_("You're not strong enough to pull yourself out..."));
    g->u.moves -= 100;
    g->u.use_amount("rope_30", 1);
    g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
    g->m.ter_set(g->u.posx, g->u.posy, t_hole);
    g->vertical_move(-1, true);
   }
  } else {
   g->add_msg(_("Your throw misses completely, and you sink!"));
   if (one_in((g->u.str_cur + g->u.dex_cur) / 3)) {
    g->u.use_amount("rope_30", 1);
    g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
   }
   g->m.ter_set(g->u.posx, g->u.posy, t_hole);
   g->vertical_move(-1, true);
  }
 } else {
  g->add_msg(_("You sink into the sinkhole!"));
  g->m.ter_set(g->u.posx, g->u.posy, t_hole);
  g->vertical_move(-1, true);
 }
}
示例#24
0
void trapfunc::boobytrap(int x, int y)
{
 g->add_msg(_("You trigger a booby trap!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Triggered a booby trap."),
                       pgettext("memorial_female", "Triggered a booby trap."));
 g->explosion(x, y, 18, 12, false);
 g->m.remove_trap(x, y);
}
示例#25
0
void trapfunc::landmine(int x, int y)
{
 g->add_msg(_("You trigger a land mine!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped on a land mine."),
                       pgettext("memorial_female", "Stepped on a land mine."));
 g->explosion(x, y, 10, 8, false);
 g->m.remove_trap(x, y);
}
示例#26
0
void trapfunc::board(int, int)
{
 g->add_msg(_("You step on a spiked board!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped on a spiked board."),
                       pgettext("memorial_female", "Stepped on a spiked board."));
 g->u.hit(NULL, bp_feet, 0, 0, rng(6, 10));
 g->u.hit(NULL, bp_feet, 1, 0, rng(6, 10));
}
示例#27
0
void trapfunc::caltrops(int, int)
{
 g->add_msg(_("You step on a sharp metal caltrop!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped on a caltrop."),
                       pgettext("memorial_female", "Stepped on a caltrop."));
 g->u.hit(NULL, bp_feet, 0, 0, rng(9, 30));
 g->u.hit(NULL, bp_feet, 1, 0, rng(9, 30));
}
示例#28
0
void trapfunc::bubble(int x, int y)
{
 g->add_msg(_("You step on some bubble wrap!"));
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped on bubble wrap."),
                       pgettext("memorial_female", "Stepped on bubble wrap."));
 g->sound(x, y, 18, _("Pop!"));
 g->m.remove_trap(x, y);
}
示例#29
0
void trapfunc::telepad(int x, int y)
{
    //~ the sound of a telepad functioning
    g->sound(x, y, 6, _("vvrrrRRMM*POP!*"));
    g->add_msg(_("The air shimmers around you..."));
    g->u.add_memorial_log(pgettext("memorial_male", "Triggered a teleport trap."),
                          pgettext("memorial_female", "Triggered a teleport trap."));
    g->teleport();
}
示例#30
0
void trapfunc::lava(int x, int y)
{
 g->add_msg(_("The %s burns you horribly!"), g->m.tername(x, y).c_str());
 g->u.add_memorial_log(pgettext("memorial_male", "Stepped into lava."),
                       pgettext("memorial_female", "Stepped into lava."));
 g->u.hit(NULL, bp_feet, 0, 0, 20);
 g->u.hit(NULL, bp_feet, 1, 0, 20);
 g->u.hit(NULL, bp_legs, 0, 0, 20);
 g->u.hit(NULL, bp_legs, 1, 0, 20);
}