diff options
-rw-r--r-- | crawl-ref/source/beam.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/it_use3.cc | 19 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 46 | ||||
-rw-r--r-- | crawl-ref/source/monplace.h | 3 |
4 files changed, 51 insertions, 35 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 3f2cbdda3e..032477d7a9 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -147,10 +147,10 @@ void zap_animation( int colour, const monsters *mon, bool force ) if (!see_grid( x, y )) return; - const int drawx = x - you.x_pos + 18; - const int drawy = y - you.y_pos + 9; + const int drawx = grid2viewX(x); + const int drawy = grid2viewY(y); - if (drawx > 8 && drawx < 26 && drawy > 0 && drawy < 18) + if (in_los_bounds(drawx, drawy)) { textcolor( colour ); gotoxy( drawx, drawy ); @@ -1402,10 +1402,10 @@ void fire_beam( struct bolt &pbolt, item_def *item ) // respect to killed monsters, cloud trails, etc. // draw new position - int drawx = tx - you.x_pos + 18; - int drawy = ty - you.y_pos + 9; + int drawx = grid2viewX(tx); + int drawy = grid2viewY(ty); // bounds check - if (drawx > 8 && drawx < 26 && drawy > 0 && drawy < 18) + if (in_los_bounds(drawx, drawy)) { if (pbolt.colour == BLACK) textcolor(random_colour()); @@ -4251,13 +4251,13 @@ static void explosion_cell(struct bolt &beam, int x, int y, bool drawOnly) if (drawOnly) { - int drawx = realx - you.x_pos + 18; - int drawy = realy - you.y_pos + 9; + int drawx = grid2viewX(realx); + int drawy = grid2viewY(realy); if (see_grid(realx, realy) || (realx == you.x_pos && realy == you.y_pos)) { // bounds check - if (drawx > 8 && drawx < 26 && drawy > 0 && drawy < 18) + if (in_los_bounds(drawx, drawy)) { if (beam.colour == BLACK) textcolor(random_colour()); diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index d2b4d5d733..a7b96a93ca 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -725,19 +725,24 @@ static bool efreet_flask(void) mpr("You open the flask..."); - dec_inv_item_quantity( you.equip[EQ_WEAPON], 1 ); - - if (create_monster( MONS_EFREET, ENCH_ABJ_V, behaviour, - you.x_pos, you.y_pos, MHITYOU, 250 ) != -1) + const int efreet = create_monster( MONS_EFREET, ENCH_ABJ_V, behaviour, + you.x_pos, you.y_pos, MHITYOU, 250, + false, false, true ); + if (efreet != -1) { + monsters *mon = &menv[efreet]; + mpr( "...and a huge efreet comes out." ); - - mpr( (behaviour == BEH_FRIENDLY) ? "\"Thank you for releasing me!\"" - : "It howls insanely!" ); + player_angers_monster(mon); + mpr( (mon->attitude == ATT_FRIENDLY)? + "\"Thank you for releasing me!\"" + : "It howls insanely!" ); } else canned_msg(MSG_NOTHING_HAPPENS); + dec_inv_item_quantity( you.equip[EQ_WEAPON], 1 ); + return (true); } // end efreet_flask() diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index e743667e80..9c70d802a2 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -1295,9 +1295,33 @@ coord_def find_newmons_square(int mons_class, int x, int y) return (pos); } +bool player_angers_monster(monsters *creation) +{ + // get the drawbacks, not the benefits... + // (to prevent demon-scumming) + if ( (you.religion == GOD_ZIN || + you.religion == GOD_SHINING_ONE || + you.religion == GOD_ELYVILON) && + mons_is_unholy(creation) ) + { + if ( creation->attitude != ATT_HOSTILE ) + { + creation->attitude = ATT_HOSTILE; + if ( see_grid(creation->x, creation->y) + && player_monster_visible(creation) ) + { + mprf("%s is enraged by your holy aura!", + ptr_monam(creation, DESC_CAP_THE)); + } + } + return (true); + } + return (false); +} + int create_monster( int cls, int dur, int beha, int cr_x, int cr_y, int hitting, int zsec, bool permit_bands, - bool force_place ) + bool force_place, bool force_behaviour ) { int summd = -1; coord_def pos = find_newmons_square(cls, cr_x, cr_y); @@ -1338,24 +1362,10 @@ int create_monster( int cls, int dur, int beha, int cr_x, int cr_y, if (beha == BEH_GOD_GIFT) creation->flags |= MF_GOD_GIFT; - - // get the drawbacks, not the benefits... - // (to prevent demon-scumming) - if ( (you.religion == GOD_ZIN || - you.religion == GOD_SHINING_ONE || - you.religion == GOD_ELYVILON) && - mons_is_unholy(creation) ) - { - if ( creation->attitude != ATT_HOSTILE ) - { - creation->attitude = ATT_HOSTILE; - if ( see_grid(cr_x, cr_y) ) - mpr("The monster is enraged by your holy aura!"); - } - creation->behaviour = BEH_HOSTILE; - beha = BEH_HOSTILE; - } + if (!force_behaviour && player_angers_monster(creation)) + beha = BEH_HOSTILE; + if (beha == BEH_CHARMED) { creation->attitude = ATT_HOSTILE; diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h index 5b89d73871..5f00448a2b 100644 --- a/crawl-ref/source/monplace.h +++ b/crawl-ref/source/monplace.h @@ -50,8 +50,9 @@ int mons_place( int mon_type, char behaviour, int target, bool summoned, * *********************************************************************** */ int create_monster( int cls, int dur, int beha, int cr_x, int cr_y, int hitting, int zsec, bool permit_bands = false, - bool force_place = false ); + bool force_place = false, bool force_behaviour = false ); +bool player_angers_monster(monsters *mon); // last updated 12may2000 {dlb} /* *********************************************************************** |