summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/melee_attack.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-13 16:50:22 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-13 17:19:03 -0700
commitd9166791303aa4bae9a3fa4c5d16a3aa4625749d (patch)
tree2d360b95907ec7e724ab148368922e75d8992087 /crawl-ref/source/melee_attack.cc
parentd22ebac678fa1c1d0a60048a72ba445e3ed190d1 (diff)
downloadcrawl-ref-d9166791303aa4bae9a3fa4c5d16a3aa4625749d.tar.gz
crawl-ref-d9166791303aa4bae9a3fa4c5d16a3aa4625749d.zip
Partially refactor tendril_disarm()
Diffstat (limited to 'crawl-ref/source/melee_attack.cc')
-rw-r--r--crawl-ref/source/melee_attack.cc58
1 files changed, 38 insertions, 20 deletions
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index 22f2895f44..39a25defed 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -3498,33 +3498,51 @@ void melee_attack::tendril_disarm()
monster *mon = attacker->as_monster();
item_def *mons_wpn = mon->mslot_item(MSLOT_WEAPON);
- if (!mons_wpn)
+ // is it ok to move the weapon into your tile (w/o destroying it?)
+ const bool your_tile_ok = (grd(you.pos()) != DNGN_DEEP_WATER
+ || species_likes_water(you.species))
+ && grd(you.pos()) != DNGN_LAVA;
+ // what about their tile?
+ const bool mon_tile_ok = grd(mon->pos()) != DNGN_LAVA
+ && (your_tile_ok
+ || grd(mon->pos()) != DNGN_DEEP_WATER
+ || species_likes_water(you.species));
+ // XXX: refactor the above to use player.cc functions
+
+ if (!you.mutation[MUT_TENDRILS]
+ || !mons_wpn
+ || mons_wpn->cursed()
+ || !attacker->alive()
+ || mons_class_is_animated_weapon(mon->type)
+ || !adjacent(you.pos(), mon->pos())
+ || !you.can_see(mon)
+ || !mon_tile_ok
+ || !one_chance_in(5))
+ {
return;
+ }
+
+ const int mon_hd = mon->get_hit_dice();
+ const int adj_mon_hd = mons_class_flag(mon->type, M_FIGHTER) ? mon_hd * 3/2
+ : mon_hd;
+ // some rounding errors here, but not significant
- // assume the player would not pull weapons into terrain that would destroy them
- if (!((feat_has_solid_floor(grd(you.pos()))
- && feat_has_solid_floor(grd(mon->pos())))
- || (feat_is_watery(grd(you.pos())) && species_likes_water(you.species)
- && grd(mon->pos()) != DNGN_LAVA)))
+ if (random2(you.dex()) <= adj_mon_hd
+ && random2(you.strength()) <= adj_mon_hd)
{
return;
}
- if (you.mutation[MUT_TENDRILS]
- && attacker->alive()
- && (!mons_class_is_animated_weapon(mon->type))
- && adjacent(you.pos(), mon->pos())
- && you.can_see(mon)
- && one_chance_in(5)
- && (random2(you.dex()) > (mons_class_flag(mon->type, M_FIGHTER)) ? mon->get_hit_dice() * 1.5 : mon->get_hit_dice()
- || random2(you.strength()) > (mons_class_flag(mon->type, M_FIGHTER)) ? mon->get_hit_dice() * 1.5 : mon->get_hit_dice())
- && !mons_wpn->cursed())
- {
- mprf("Your tendrils lash around %s %s and pull it to the ground!",
- apostrophise(mon->name(DESC_THE)).c_str(), mons_wpn->name(DESC_PLAIN).c_str());
-
- mon->drop_item(MSLOT_WEAPON, false);
+ mprf("Your tendrils lash around %s %s and pull it to the ground!",
+ apostrophise(mon->name(DESC_THE)).c_str(),
+ mons_wpn->name(DESC_PLAIN).c_str());
+
+ mon->drop_item(MSLOT_WEAPON, false);
+ if (your_tile_ok)
+ {
move_top_item(mon->pos(), you.pos());
+ // assumes nothing's re-ordering items - e.g. gozag gold
+ // (but that shouldn't interact with jiyva tendrils...?)
}
}