void trapfuncm::beartrap(game *g, monster *z, int x, int y) { g->sound(x, y, 8, "SNAP!"); if (z->hurt(35)) g->kill_mon(g->mon_at(x, y)); else { z->moves = 0; z->add_effect(ME_BEARTRAP, rng(8, 15)); } g->m.tr_at(x, y) = tr_null; item beartrap(g->itypes[itm_beartrap], 0); z->add_item(beartrap); }
void trapfuncm::beartrap(game *g, monster *z, int x, int y) { // tiny animals don't trigger bear traps if (z->type->size == MS_TINY) return; g->sound(x, y, 8, "SNAP!"); if (z->hurt(35)) { g->kill_mon(g->mon_at(x, y)); g->m.spawn_item(x, y, g->itypes["beartrap"], 0); } else { z->moves = 0; z->add_effect(ME_BEARTRAP, rng(8, 15)); } g->m.tr_at(x, y) = tr_null; item beartrap(g->itypes["beartrap"], 0); z->add_item(beartrap); }
void trapfuncm::beartrap(monster *z, int x, int y) { // tiny animals don't trigger bear traps if (z->type->size == MS_TINY) return; g->sound(x, y, 8, _("SNAP!")); if (z->hurt(35)) { g->kill_mon(g->mon_at(x, y)); g->m.spawn_item(x, y, "beartrap"); } else { z->moves = 0; z->add_effect("beartrap", rng(8, 15)); } g->m.remove_trap(x, y); item beartrap(itypes["beartrap"], 0); z->add_item(beartrap); }
bool Character::move_effects(bool attacking) { if (has_effect("downed")) { ///\EFFECT_DEX increases chance to stand up when knocked down ///\EFFECT_STR increases chance to stand up when knocked down, slightly if (rng(0, 40) > get_dex() + get_str() / 2) { add_msg_if_player(_("You struggle to stand.")); } else { add_msg_player_or_npc(m_good, _("You stand up."), _("<npcname> stands up.")); remove_effect("downed"); } return false; } if (has_effect("webbed")) { ///\EFFECT_STR increases chance to escape webs if (x_in_y(get_str(), 6 * get_effect_int("webbed"))) { add_msg_player_or_npc(m_good, _("You free yourself from the webs!"), _("<npcname> frees themselves from the webs!")); remove_effect("webbed"); } else { add_msg_if_player(_("You try to free yourself from the webs, but can't get loose!")); } return false; } if (has_effect("lightsnare")) { ///\EFFECT_STR increases chance to escape light snare ///\EFFECT_DEX increases chance to escape light snare if(x_in_y(get_str(), 12) || x_in_y(get_dex(), 8)) { remove_effect("lightsnare"); add_msg_player_or_npc(m_good, _("You free yourself from the light snare!"), _("<npcname> frees themselves from the light snare!")); item string("string_36", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), string); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the light snare, but can't get loose!")); } return false; } if (has_effect("heavysnare")) { ///\EFFECT_STR increases chance to escape heavy snare, slightly ///\EFFECT_DEX increases chance to escape light snare if(x_in_y(get_str(), 32) || x_in_y(get_dex(), 16)) { remove_effect("heavysnare"); add_msg_player_or_npc(m_good, _("You free yourself from the heavy snare!"), _("<npcname> frees themselves from the heavy snare!")); item rope("rope_6", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), rope); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the heavy snare, but can't get loose!")); } return false; } if (has_effect("beartrap")) { /* Real bear traps can't be removed without the proper tools or immense strength; eventually this should allow normal players two options: removal of the limb or removal of the trap from the ground (at which point the player could later remove it from the leg with the right tools). As such we are currently making it a bit easier for players and NPC's to get out of bear traps. */ ///\EFFECT_STR increases chance to escape bear trap if(x_in_y(get_str(), 100)) { remove_effect("beartrap"); add_msg_player_or_npc(m_good, _("You free yourself from the bear trap!"), _("<npcname> frees themselves from the bear trap!")); item beartrap("beartrap", calendar::turn); g->m.add_item_or_charges(posx(), posy(), beartrap); } else { add_msg_if_player(m_bad, _("You try to free yourself from the bear trap, but can't get loose!")); } return false; } if (has_effect("crushed")) { ///\EFFECT_STR increases chance to escape crushing rubble ///\EFFECT_DEX increases chance to escape crushing rubble, slightly if(x_in_y(get_str() + get_dex() / 4, 100)) { remove_effect("crushed"); add_msg_player_or_npc(m_good, _("You free yourself from the rubble!"), _("<npcname> frees themselves from the rubble!")); } else { add_msg_if_player(m_bad, _("You try to free yourself from the rubble, but can't get loose!")); } return false; } // Below this point are things that allow for movement if they succeed // Currently we only have one thing that forces movement if you succeed, should we get more // than this will need to be reworked to only have success effects if /all/ checks succeed if (has_effect("in_pit")) { ///\EFFECT_STR increases chance to escape pit ///\EFFECT_DEX increases chance to escape pit, slightly if (rng(0, 40) > get_str() + get_dex() / 2) { add_msg_if_player(m_bad, _("You try to escape the pit, but slip back in.")); return false; } else { add_msg_player_or_npc(m_good, _("You escape the pit!"), _("<npcname> escapes the pit!")); remove_effect("in_pit"); } } if( has_effect( "grabbed" ) && !attacking ) { int zed_number = 0; for( auto &&dest : g->m.points_in_radius( pos(), 1, 0 ) ){ if( g->mon_at( dest ) != -1 && ( g->zombie( g->mon_at( dest ) ).has_flag( MF_GRABS ) || g->zombie( g->mon_at( dest ) ).type->has_special_attack( "GRAB" ) ) ) { zed_number ++; } } if( zed_number == 0 ) { add_msg_player_or_npc( m_good, _( "You find yourself no longer grabbed." ), _( "<npcname> finds themselves no longer grabbed." ) ); remove_effect( "grabbed" ); ///\EFFECT_DEX increases chance to escape grab, if >STR ///\EFFECT_STR increases chance to escape grab, if >DEX } else if( rng( 0, std::max( get_dex(), get_str() ) ) < rng( get_effect_int( "grabbed" ), 8 ) ) { // Randomly compare higher of dex or str to grab intensity. add_msg_player_or_npc( m_bad, _( "You try break out of the grab, but fail!" ), _( "<npcname> tries to break out of the grab, but fails!" ) ); return false; } else { add_msg_player_or_npc( m_good, _( "You break out of the grab!" ), _( "<npcname> breaks out of the grab!" ) ); remove_effect( "grabbed" ); } } return Creature::move_effects( attacking ); }
bool Character::move_effects(bool attacking) { if (has_effect("downed")) { if (rng(0, 40) > get_dex() + int(get_str() / 2)) { add_msg_if_player(_("You struggle to stand.")); } else { add_msg_player_or_npc(m_good, _("You stand up."), _("<npcname> stands up.")); remove_effect("downed"); } return false; } if (has_effect("webbed")) { if (x_in_y(get_str(), 6 * get_effect_int("webbed"))) { add_msg_player_or_npc(m_good, _("You free yourself from the webs!"), _("<npcname> frees themselves from the webs!")); remove_effect("webbed"); } else { add_msg_if_player(_("You try to free yourself from the webs, but can't get loose!")); } return false; } if (has_effect("lightsnare")) { if(x_in_y(get_str(), 12) || x_in_y(get_dex(), 8)) { remove_effect("lightsnare"); add_msg_player_or_npc(m_good, _("You free yourself from the light snare!"), _("<npcname> frees themselves from the light snare!")); item string("string_36", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), string); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the light snare, but can't get loose!")); } return false; } if (has_effect("heavysnare")) { if(x_in_y(get_str(), 32) || x_in_y(get_dex(), 16)) { remove_effect("heavysnare"); add_msg_player_or_npc(m_good, _("You free yourself from the heavy snare!"), _("<npcname> frees themselves from the heavy snare!")); item rope("rope_6", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), rope); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the heavy snare, but can't get loose!")); } return false; } if (has_effect("beartrap")) { /* Real bear traps can't be removed without the proper tools or immense strength; eventually this should allow normal players two options: removal of the limb or removal of the trap from the ground (at which point the player could later remove it from the leg with the right tools). As such we are currently making it a bit easier for players and NPC's to get out of bear traps. */ if(x_in_y(get_str(), 100)) { remove_effect("beartrap"); add_msg_player_or_npc(m_good, _("You free yourself from the bear trap!"), _("<npcname> frees themselves from the bear trap!")); item beartrap("beartrap", calendar::turn); g->m.add_item_or_charges(posx(), posy(), beartrap); } else { add_msg_if_player(m_bad, _("You try to free yourself from the bear trap, but can't get loose!")); } return false; } if (has_effect("crushed")) { // Strength helps in getting free, but dex also helps you worm your way out of the rubble if(x_in_y(get_str() + get_dex() / 4, 100)) { remove_effect("crushed"); add_msg_player_or_npc(m_good, _("You free yourself from the rubble!"), _("<npcname> frees themselves from the rubble!")); } else { add_msg_if_player(m_bad, _("You try to free yourself from the rubble, but can't get loose!")); } return false; } // Below this point are things that allow for movement if they succeed // Currently we only have one thing that forces movement if you succeed, should we get more // than this will need to be reworked to only have success effects if /all/ checks succeed if (has_effect("in_pit")) { if (rng(0, 40) > get_str() + int(get_dex() / 2)) { add_msg_if_player(m_bad, _("You try to escape the pit, but slip back in.")); return false; } else { add_msg_player_or_npc(m_good, _("You escape the pit!"), _("<npcname> escapes the pit!")); remove_effect("in_pit"); } } if (has_effect("grabbed")){ int zed_number = 0; for( auto &&dest : g->m.points_in_radius( pos(), 1, 0 ) ){ if (g->mon_at(dest) != -1){ zed_number ++; } } if (attacking == true || zed_number == 0){ return true; } if (get_dex() > get_str() ? rng(0, get_dex()) : rng( 0, get_str()) < rng( get_effect_int("grabbed") , 8) ){ add_msg_player_or_npc(m_bad, _("You try break out of the grab, but fail!"), _("<npcname> tries to break out of the grab, but fails!")); return false; } else { add_msg_player_or_npc(m_good, _("You break out of the grab!"), _("<npcname> breaks out of the grab!")); remove_effect("grabbed"); } } return Creature::move_effects(attacking); }
bool Character::move_effects() { if (has_effect("downed")) { if (rng(0, 40) > get_dex() + int(get_str() / 2)) { add_msg_if_player(_("You struggle to stand.")); } else { add_msg_player_or_npc(m_good, _("You stand up."), _("<npcname> stands up.")); remove_effect("downed"); } return false; } if (has_effect("webbed")) { if (x_in_y(get_str(), 6 * get_effect_int("webbed"))) { add_msg_player_or_npc(m_good, _("You free yourself from the webs!"), _("<npcname> frees themselves from the webs!")); remove_effect("webbed"); } else { add_msg_if_player(_("You try to free yourself from the webs, but can't get loose!")); } return false; } if (has_effect("lightsnare")) { if(x_in_y(get_str(), 12) || x_in_y(get_dex(), 8)) { remove_effect("lightsnare"); add_msg_player_or_npc(m_good, _("You free yourself from the light snare!"), _("<npcname> frees themselves from the light snare!")); item string("string_36", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), string); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the light snare, but can't get loose!")); } return false; } if (has_effect("heavysnare")) { if(x_in_y(get_str(), 32) || x_in_y(get_dex(), 16)) { remove_effect("heavysnare"); add_msg_player_or_npc(m_good, _("You free yourself from the heavy snare!"), _("<npcname> frees themselves from the heavy snare!")); item rope("rope_6", calendar::turn); item snare("snare_trigger", calendar::turn); g->m.add_item_or_charges(posx(), posy(), rope); g->m.add_item_or_charges(posx(), posy(), snare); } else { add_msg_if_player(m_bad, _("You try to free yourself from the heavy snare, but can't get loose!")); } return false; } if (has_effect("beartrap")) { /* Real bear traps can't be removed without the proper tools or immense strength; eventually this should allow normal players two options: removal of the limb or removal of the trap from the ground (at which point the player could later remove it from the leg with the right tools). As such we are currently making it a bit easier for players and NPC's to get out of bear traps. */ if(x_in_y(get_str(), 100)) { remove_effect("beartrap"); add_msg_player_or_npc(m_good, _("You free yourself from the bear trap!"), _("<npcname> frees themselves from the bear trap!")); item beartrap("beartrap", calendar::turn); g->m.add_item_or_charges(posx(), posy(), beartrap); } else { add_msg_if_player(m_bad, _("You try to free yourself from the bear trap, but can't get loose!")); } return false; } if (has_effect("crushed")) { // Strength helps in getting free, but dex also helps you worm your way out of the rubble if(x_in_y(get_str() + get_dex() / 4, 100)) { remove_effect("crushed"); add_msg_player_or_npc(m_good, _("You free yourself from the rubble!"), _("<npcname> frees themselves from the rubble!")); } else { add_msg_if_player(m_bad, _("You try to free yourself from the rubble, but can't get loose!")); } return false; } if (has_effect("amigara")) { int curdist = 999, newdist = 999; for (int cx = 0; cx < SEEX * MAPSIZE; cx++) { for (int cy = 0; cy < SEEY * MAPSIZE; cy++) { if (g->m.ter(cx, cy) == t_fault) { int dist = rl_dist(cx, cy, posx(), posy()); if (dist < curdist) { curdist = dist; } dist = rl_dist(cx, cy, posx(), posy()); if (dist < newdist) { newdist = dist; } } } } if (newdist > curdist) { add_msg_if_player(m_info, _("You cannot pull yourself away from the faultline...")); return false; } } // Below this point are things that allow for movement if they succeed // Currently we only have one thing that forces movement if you succeed, should we get more // than this will need to be reworked to only have success effects if /all/ checks succeed if (has_effect("in_pit")) { if (rng(0, 40) > get_str() + int(get_dex() / 2)) { add_msg_if_player(m_bad, _("You try to escape the pit, but slip back in.")); return false; } else { add_msg_player_or_npc(m_good, _("You escape the pit!"), _("<npcname> escapes the pit!")); remove_effect("in_pit"); } } return Creature::move_effects(); }