From 60d6f32de9c98c67fc5735eede1e08dcf4d3deda Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 22 Aug 2007 07:09:51 +0000 Subject: A few additions to throwing nets. Flying monsters could now fall into a pool if also confused, otherwise you cannot trap them with a net. Also special cases for a few other monsters. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2023 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 8 ++++---- crawl-ref/source/beam.cc | 2 +- crawl-ref/source/items.cc | 2 +- crawl-ref/source/makeitem.cc | 12 +++++++++++ crawl-ref/source/misc.cc | 37 ++++++++++++++++++++++++++++++++-- crawl-ref/source/misc.h | 2 +- crawl-ref/source/mon-util.cc | 47 +++++++++++++++++++++++++++++++++++++++++++- crawl-ref/source/mon-util.h | 1 + crawl-ref/source/mstuff2.cc | 2 +- crawl-ref/source/output.cc | 8 +++++++- crawl-ref/source/player.cc | 2 +- 11 files changed, 110 insertions(+), 13 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index ff03888328..4bacfd7e37 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1013,7 +1013,7 @@ static void go_upstairs() if (you.attribute[ATTR_CAUGHT]) { - mpr("You're trapped in a net!"); + mpr("You're held in a net!"); return; } @@ -1046,7 +1046,7 @@ static void go_downstairs() if (you.attribute[ATTR_CAUGHT]) { - mpr("You're trapped in a net!"); + mpr("You're held in a net!"); return; } tag_followers(); // only those beside us right now can follow @@ -1258,7 +1258,7 @@ void process_command( command_type cmd ) } else if (you.attribute[ATTR_CAUGHT]) { - mpr("You cannot throw anything while trapped in a net!"); + mpr("You cannot throw anything while held in a net!"); break; } if (Options.tutorial_left) @@ -1274,7 +1274,7 @@ void process_command( command_type cmd ) } else if (you.attribute[ATTR_CAUGHT]) { - mpr("You cannot shoot anything while trapped in a net!"); + mpr("You cannot shoot anything while held in a net!"); break; } if (Options.tutorial_left) diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 134ae2709c..fac5d51e27 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3714,7 +3714,7 @@ static int affect_monster(bolt &beam, monsters *mon) } if (beam.name.find("throwing net") != std::string::npos) - monster_caught_in_net(mon); + monster_caught_in_net(mon, beam); // note that hurt_final was calculated above, so we don't need it again. // just need to apply flavoured specials (since we called with diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 495113a637..871ee6af21 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1304,7 +1304,7 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) if (you.attribute[ATTR_CAUGHT] && mitm[obj].base_type == OBJ_MISSILES && mitm[obj].sub_type == MI_THROWING_NET && item_is_stationary(mitm[obj])) { - mpr("You cannot pick up the net that traps you!"); + mpr("You cannot pick up the net that holds you!"); return (1); } diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index af5ec9787a..49b98b8f7e 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -3729,6 +3729,18 @@ static void give_ammo(monsters *mon, int level, item_race = MAKE_ITEM_ORCISH; qty = random_range(4, 7); break; + + case MONS_DRACONIAN_KNIGHT: + case MONS_GNOLL: + case MONS_HILL_GIANT: + if (one_chance_in(20)) + { + weap_class = OBJ_MISSILES; + weap_type = MI_THROWING_NET; + qty = 1; + } + break; + } if (weap_type == -1) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 1632e17a0f..5cf37f0ad6 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -871,13 +871,25 @@ void mark_net_trapping(int x, int y) } } -void monster_caught_in_net(monsters *mon) +void monster_caught_in_net(monsters *mon, bolt &pbolt) { if (mon->body_size(PSIZE_BODY) >= SIZE_GIANT) return; - if (mon->type == MONS_FIRE_VORTEX || mon->type == MONS_SPATIAL_VORTEX) + if (mons_is_insubstantial(mon->type)) + { + if (mons_near(mon) && player_monster_visible(mon)) + mprf("The net passes right through %s!", mon->name(DESC_NOCAP_THE).c_str()); return; + } + + const monsters* mons = static_cast(mon); + bool mon_flies = mons->flies(); + if (mon_flies && !mons_is_confused(mons)) + { + simple_monster_message(mon, " darts out from under the net!"); + return; + } if (!mons_is_caught(mon) && mon->add_ench(ENCH_CAUGHT)) { @@ -885,6 +897,12 @@ void monster_caught_in_net(monsters *mon) mpr("Something gets caught in the net!"); else simple_monster_message(mon, " is caught in the net!"); + + if (mon_flies) + { + simple_monster_message(mon, " falls like a stone!"); + mons_check_pool(mon, pbolt.killer(), pbolt.beam_source); + } } } @@ -893,11 +911,26 @@ void player_caught_in_net() if (you.body_size(PSIZE_BODY) >= SIZE_GIANT) return; + if (you.flies() && !you.confused()) + { + mpr("You dart out from under the net!"); + return; + } + if (!you.attribute[ATTR_CAUGHT]) { you.attribute[ATTR_CAUGHT] = 10; mpr("You become entangled in the net!"); + + // I guess levitation works differently, keeping both you + // and the net hovering above the floor + if (you.flies()) + { + mpr("You fall like a stone!"); + fall_into_a_pool(you.x_pos, you.y_pos, false, grd[you.x_pos][you.y_pos]); + } } + } void merfolk_start_swimming(void) diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 4ad5afc033..7654b12605 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -64,7 +64,7 @@ bool fall_into_a_pool( int entry_x, int entry_y, bool allow_shift, void handle_traps(char trt, int i, bool trap_known); int get_trapping_net(int x, int y, bool trapped = true); void mark_net_trapping(int x, int y); -void monster_caught_in_net(monsters *mon); +void monster_caught_in_net(monsters *mon, bolt &pbolt); void player_caught_in_net(void); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 2c1c048aa3..89d51e7719 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -347,6 +347,38 @@ bool mons_is_stationary(const monsters *mons) return (mons_class_is_stationary(mons->type)); } +// returns whether a monster is non-solid +// and thus can't be affected by some traps +bool mons_is_insubstantial(int type) +{ + switch(type) + { + // vortices + case MONS_FIRE_VORTEX: + case MONS_SPATIAL_VORTEX: + // elementals + case MONS_FIRE_ELEMENTAL: + case MONS_AIR_ELEMENTAL: + case MONS_WATER_ELEMENTAL: + // vapours + case MONS_INSUBSTANTIAL_WISP: + case MONS_VAPOUR: + // ghosts and some undead + case MONS_PLAYER_GHOST: + case MONS_HUNGRY_GHOST: + case MONS_SHADOW: + case MONS_SMOKE_DEMON: + case MONS_SHADOW_WRAITH: + // others + case MONS_BALL_LIGHTNING: + case MONS_GIANT_SPORE: + case MONS_ORB_OF_FIRE: + return true; + default: + return false; + } +} + bool mons_behaviour_perceptible(const monsters *mons) { return (!mons_class_flag(mons->type, M_NO_EXP_GAIN) @@ -2410,6 +2442,9 @@ bool monsters::can_use_missile(const item_def &item) const if (item.base_type != OBJ_MISSILES) return (false); + if (item.sub_type == MI_THROWING_NET && body_size(PSIZE_BODY) < SIZE_MEDIUM) + return (false); + if (item.sub_type == MI_LARGE_ROCK && !can_throw_rocks()) return (false); @@ -3920,7 +3955,7 @@ void monsters::apply_enchantment(const mon_enchant &me) // smaller monsters can escape more quickly if (mon_size < random2(SIZE_BIG) // BIG = 5 - && !has_ench(ENCH_BERSERK)) + && !has_ench(ENCH_BERSERK) && type != MONS_DANCING_WEAPON) { if (mons_near(this) && !player_monster_visible(this)) mpr("Something wriggles in the net."); @@ -3957,6 +3992,16 @@ void monsters::apply_enchantment(const mon_enchant &me) if (random2(SIZE_GIANT - mon_size) <= mon_size) damage++; + // handled specially to make up for its small size + if (type == MONS_DANCING_WEAPON) + { + damage += one_chance_in(3); + + if (can_cut_meat(mitm[inv[MSLOT_WEAPON]])) + damage++; + } + + // extra damage for large (50%) and big (always) if (mon_size == SIZE_BIG || mon_size == SIZE_LARGE && coinflip()) damage++; diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 67ab7c8f82..1461c5bd88 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -354,6 +354,7 @@ bool check_mons_resist_magic( const monsters *monster, int pow ); bool mons_class_is_stationary(int monsclass); bool mons_is_stationary(const monsters *mons); +bool mons_is_insubstantial(int type); bool mons_is_submerged( const monsters *mon ); bool invalid_monster(const monsters *mons); diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 758e826cab..d63534a425 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -230,7 +230,7 @@ void mons_trap(struct monsters *monster) } msg += "!"; mpr(msg.c_str()); - monster_caught_in_net(monster); + monster_caught_in_net(monster, beem); } } trap_item( OBJ_MISSILES, MI_THROWING_NET, diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 1ce982851a..eab28314be 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -556,6 +556,12 @@ void print_stats(void) cprintf( "Rot " ); } + if (you.attribute[ATTR_CAUGHT]) + { + textcolor( RED ); + cprintf( "Held " ); + } + if (you.backlit()) { textcolor( @@ -1473,7 +1479,7 @@ std::string status_mut_abilities() } if (you.attribute[ATTR_CAUGHT]) - text += "trapped, "; + text += "held, "; const int mr = player_res_magic(); snprintf(info, INFO_SIZE, "%s resistant to magic, ", diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index a9386da1f0..7d34b2f318 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -3296,7 +3296,7 @@ void display_char_status() mpr( "You are hovering above the floor." ); if (you.attribute[ATTR_CAUGHT]) - mpr( "You are trapped in a net." ); + mpr( "You are held in a net." ); if (you.duration[DUR_POISONING]) { -- cgit v1.2.3-54-g00ecf