void trapfuncm::pit(monster *z, int x, int y) { // tiny animals aren't hurt by falling into pits if (z->type->size == MS_TINY) return; if (g->u_see(x, y)) { g->add_msg(_("The %s falls in a pit!"), z->name().c_str()); } if (z->hurt(pit_effectiveness(x, y) * rng(10, 20))) { g->kill_mon(g->mon_at(x, y)); } else { z->moves = -1000; } }
void trapfunc::pit(game *g, int x, int y) { g->add_msg(_("You fall in a pit!")); if (g->u.has_trait("WINGS_BIRD")) { g->add_msg(_("You flap your wings and flutter down gracefully.")); } else { float eff = pit_effectiveness(g, x, y); int dodge = g->u.dodge(g); int damage = eff * rng(10, 20) - rng(dodge, dodge * 5); if (damage > 0) { g->add_msg(_("You hurt yourself!")); g->u.hurtall(rng(int(damage / 2), damage)); g->u.hit(g, bp_legs, 0, damage, 0); g->u.hit(g, bp_legs, 1, damage, 0); } else { g->add_msg(_("You land nimbly.")); } } g->u.add_disease("in_pit", -1); }
void trapfunc::pit_spikes(int x, int y) { g->add_msg(_("You fall in a pit!")); g->u.add_memorial_log(pgettext("memorial_male", "Fell into a spiked pit."), pgettext("memorial_female", "Fell into a spiked pit.")); int dodge = g->u.get_dodge(); int damage = pit_effectiveness(x, y) * rng(20, 50); if (g->u.has_trait("WINGS_BIRD")) { g->add_msg(_("You flap your wings and flutter down gracefully.")); } else if (0 == damage || rng(5, 30) < dodge) { g->add_msg(_("You avoid the spikes within.")); } else { body_part hit = num_bp; switch (rng(1, 10)) { case 1: case 2: hit = bp_legs; break; case 3: case 4: hit = bp_arms; break; case 5: case 6: case 7: case 8: case 9: case 10: hit = bp_torso; break; } int side = random_side(hit); g->add_msg(_("The spikes impale your %s!"), body_part_name(hit, side).c_str()); g->u.hit(NULL, hit, side, 0, damage); if (one_in(4)) { g->add_msg(_("The spears break!")); g->m.ter_set(x, y, t_pit); g->m.add_trap(x, y, tr_pit); for (int i = 0; i < 4; i++) { // 4 spears to a pit if (one_in(3)) { g->m.spawn_item(x, y, "spear_wood"); } } } } g->u.add_disease("in_pit", 1, true); }
void trapfunc::pit(int x, int y) { g->add_msg(_("You fall in a pit!")); g->u.add_memorial_log(pgettext("memorial_male", "Fell in a pit."), pgettext("memorial_female", "Fell in a pit.")); if (g->u.has_trait("WINGS_BIRD")) { g->add_msg(_("You flap your wings and flutter down gracefully.")); } else { float eff = pit_effectiveness(x, y); int dodge = g->u.get_dodge(); int damage = eff * rng(10, 20) - rng(dodge, dodge * 5); if (damage > 0) { g->add_msg(_("You hurt yourself!")); g->u.hurtall(rng(int(damage / 2), damage)); g->u.hit(NULL, bp_legs, 0, damage, 0); g->u.hit(NULL, bp_legs, 1, damage, 0); } else { g->add_msg(_("You land nimbly.")); } } g->u.add_disease("in_pit", 1, true); }
void trapfunc::pit( Creature *c, const tripoint &p ) { // tiny animals aren't hurt by falling into pits if( c != nullptr && c->get_size() == MS_TINY ) { return; } if( c != nullptr ) { const float eff = pit_effectiveness( p ); c->add_msg_player_or_npc( m_bad, _( "You fall in a pit!" ), _( "<npcname> falls in a pit!" ) ); c->add_memorial_log( pgettext( "memorial_male", "Fell in a pit." ), pgettext( "memorial_female", "Fell in a pit." ) ); c->add_effect( "in_pit", 1, num_bp, true ); monster *z = dynamic_cast<monster *>( c ); player *n = dynamic_cast<player *>( c ); if( n != nullptr ) { if( ( n->has_trait( "WINGS_BIRD" ) ) || ( ( one_in( 2 ) ) && ( n->has_trait( "WINGS_BUTTERFLY" ) ) ) ) { n->add_msg_if_player( _( "You flap your wings and flutter down gracefully." ) ); } else { int dodge = n->get_dodge(); int damage = eff * rng( 10, 20 ) - rng( dodge, dodge * 5 ); if( damage > 0 ) { n->add_msg_if_player( m_bad, _( "You hurt yourself!" ) ); n->hurtall( rng( int( damage / 2 ), damage ), n ); // like the message says \-: n->deal_damage( nullptr, bp_leg_l, damage_instance( DT_BASH, damage ) ); n->deal_damage( nullptr, bp_leg_r, damage_instance( DT_BASH, damage ) ); } else { n->add_msg_if_player( _( "You land nimbly." ) ); } } } else if( z != nullptr ) { z->apply_damage( nullptr, bp_torso, eff * rng( 10, 20 ) ); } c->check_dead_state(); } }
void trapfunc::pit_glass( Creature *c, const tripoint &p ) { // tiny animals aren't hurt by falling into glass pits if( c != nullptr && c->get_size() == MS_TINY ) { return; } if( c != nullptr ) { c->add_msg_player_or_npc( m_bad, _( "You fall in a pit filled with glass shards!" ), _( "<npcname> falls in pit filled with glass shards!" ) ); c->add_memorial_log( pgettext( "memorial_male", "Fell into a pit filled with glass shards." ), pgettext( "memorial_female", "Fell into a pit filled with glass shards." ) ); c->add_effect( "in_pit", 1, num_bp, true ); monster *z = dynamic_cast<monster *>( c ); player *n = dynamic_cast<player *>( c ); if( n != nullptr ) { int dodge = n->get_dodge(); int damage = pit_effectiveness( p ) * rng( 15, 35 ); if( ( n->has_trait( "WINGS_BIRD" ) ) || ( ( one_in( 2 ) ) && ( n->has_trait( "WINGS_BUTTERFLY" ) ) ) ) { n->add_msg_if_player( _( "You flap your wings and flutter down gracefully." ) ); } else if( 0 == damage || rng( 5, 30 ) < dodge ) { n->add_msg_if_player( _( "You avoid the glass shards within." ) ); } else { body_part hit = num_bp; switch( rng( 1, 10 ) ) { case 1: hit = bp_leg_l; break; case 2: hit = bp_leg_r; break; case 3: hit = bp_arm_l; break; case 4: hit = bp_arm_r; break; case 5: hit = bp_foot_l; break; case 6: hit = bp_foot_r; break; case 7: case 8: case 9: case 10: hit = bp_torso; break; } n->add_msg_if_player( m_bad, _( "The glass shards slash your %s!" ), body_part_name_accusative( hit ).c_str() ); n->deal_damage( nullptr, hit, damage_instance( DT_CUT, damage ) ); 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 ); } } } else if( z != nullptr ) { z->apply_damage( nullptr, bp_torso, rng( 20, 50 ) ); } c->check_dead_state(); } if( one_in( 5 ) ) { if( g->u.sees( p ) ) { add_msg( _( "The shards shatter!" ) ); } g->m.ter_set( p, t_pit ); for( int i = 0; i < 20; i++ ) { // 20 shards in a pit. if( one_in( 3 ) ) { g->m.spawn_item( p, "glass_shard" ); } } } }