summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-07 11:58:54 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-07 11:58:54 +0000
commit167ae03b160a0ccadd7934b2bfe557d491f1cb1f (patch)
treec1ee0ef626b416c5eee0f62082da72cb9f4137c3 /crawl-ref/source/fight.cc
parent33dc7cedd5a65d3bd1ce8eff9006e4517a3390dd (diff)
downloadcrawl-ref-167ae03b160a0ccadd7934b2bfe557d491f1cb1f.tar.gz
crawl-ref-167ae03b160a0ccadd7934b2bfe557d491f1cb1f.zip
Another clean up, and add some new weapon speech.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6439 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 0bbfc47f96..21fcd0613c 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -1477,7 +1477,7 @@ void melee_attack::player_weapon_auto_id()
&& weapon->base_type == OBJ_WEAPONS
&& !is_range_weapon( *weapon )
&& !item_ident( *weapon, ISFLAG_KNOW_PLUSES )
- && random2(100) < you.skills[ wpn_skill ])
+ && x_chance_in_y(you.skills[ wpn_skill ], 100))
{
set_ident_flags( *weapon, ISFLAG_KNOW_PLUSES );
mprf("You are wielding %s.", weapon->name(DESC_NOCAP_A).c_str());
@@ -1542,7 +1542,7 @@ int melee_attack::player_stab(int damage)
if (mons_is_sleeping(def))
{
// Sleeping moster wakes up when stabbed but may be groggy.
- if (random2(200) <= you.skills[SK_STABBING] + you.dex)
+ if (x_chance_in_y(you.skills[SK_STABBING] + you.dex + 1, 200))
{
int stun = random2( you.dex + 1 );
@@ -2319,8 +2319,8 @@ bool melee_attack::apply_damage_brand()
break;
}
case SPWPN_PAIN:
- if (defender->res_negative_energy()
- && random2(8) <= attacker->skill(SK_NECROMANCY))
+ if (!defender->res_negative_energy()
+ && x_chance_in_y(attacker->skill(SK_NECROMANCY) + 1, 8))
{
if (defender_visible)
{
@@ -2350,7 +2350,7 @@ bool melee_attack::apply_damage_brand()
if (mons_class_is_confusable(def->type)
&& hdcheck >= defender->get_experience_level())
{
- // declaring these just to pass to the enchant function
+ // Declaring these just to pass to the enchant function.
bolt beam_temp;
beam_temp.thrower =
attacker->atype() == ACT_PLAYER? KILL_YOU : KILL_MON;
@@ -2586,13 +2586,13 @@ void melee_attack::player_apply_staff_damage()
case STAFF_POISON:
{
- // cap chance at 30% -- let staff of Olgreb shine
+ // Cap chance at 30% -- let staff of Olgreb shine.
int temp_rand = damage_done + you.skills[SK_POISON_MAGIC];
if (temp_rand > 30)
temp_rand = 30;
- if (random2(100) < temp_rand)
+ if (x_chance_in_y(temp_rand, 100))
{
// Poison monster message needs to arrive after hit message.
emit_nodmg_hit_message();
@@ -2605,7 +2605,7 @@ void melee_attack::player_apply_staff_damage()
if (mons_res_negative_energy(def))
break;
- if (random2(8) <= you.skills[SK_NECROMANCY])
+ if (x_chance_in_y(you.skills[SK_NECROMANCY] + 1, 8))
{
special_damage = player_staff_damage(SK_NECROMANCY);
@@ -2876,8 +2876,8 @@ void melee_attack::player_stab_check()
bool roll_needed = true;
int roll = 155;
- // This ordering is important!
+ // This ordering is important!
switch (unchivalric)
{
default:
@@ -2919,7 +2919,10 @@ void melee_attack::player_stab_check()
// See if we need to roll against dexterity / stabbing.
if (stab_attempt && roll_needed)
- stab_attempt = (random2(roll) <= you.skills[SK_STABBING] + you.dex);
+ {
+ stab_attempt = x_chance_in_y(you.skills[SK_STABBING] + you.dex + 1,
+ roll);
+ }
}
void melee_attack::player_apply_attack_delay()
@@ -3500,7 +3503,7 @@ void melee_attack::check_defender_train_armour()
return;
const item_def *arm = defender->slot_item(EQ_BODY_ARMOUR);
- if (arm && coinflip() && random2(1000) <= item_mass(*arm))
+ if (arm && coinflip() && x_chance_in_y(item_mass(*arm) + 1, 1000))
defender->exercise(SK_ARMOUR, coinflip()? 2 : 1);
}
@@ -3707,7 +3710,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
if (mons_is_summoned(def))
break;
- if (defender->res_negative_energy() > random2(3))
+ if (x_chance_in_y(defender->res_negative_energy(), 3))
break;
if (defender->stat_hp() < defender->stat_maxhp())