From 9aea04f45a0902a19877de1f383264def728c862 Mon Sep 17 00:00:00 2001 From: dolorous Date: Thu, 22 Nov 2007 01:40:14 +0000 Subject: make player::has_claws() return an int indicating the level of claws available; this removes the need for some special cases dealing with trolls' and ghouls' built-in claws git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2890 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/externs.h | 2 +- crawl-ref/source/item_use.cc | 3 +-- crawl-ref/source/player.cc | 23 ++++++++++++++--------- crawl-ref/source/traps.cc | 7 +++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index d114228678..7e460918ea 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -766,7 +766,7 @@ public: int total_weight() const; int damage_type(int attk = -1); int damage_brand(int attk = -1); - bool has_claws() const; + int has_claws() const; bool has_usable_claws() const; item_def *weapon(int which_attack = -1); item_def *shield(); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 6920fdf814..9f310d87a4 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -777,8 +777,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary) if (sub_type == ARM_GLOVES) { - if (you.species == SP_TROLL || you.species == SP_GHOUL - || you.mutation[MUT_CLAWS] >= 3) + if (you.has_claws() >= 3) { if (verbose) mpr( "You can't wear gloves with your huge claws!" ); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 07b04ebd06..92778360cd 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6115,23 +6115,28 @@ void player::slow_down(int str) ::slow_player( str ); } -bool player::has_claws() const +int player::has_claws() const { // these transformations bring claws with them if (attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON || attribute[ATTR_TRANSFORMATION] == TRAN_SERPENT_OF_HELL) { - return true; + return 3; } - // these are the only other sources for claws - if (species != SP_TROLL && species != SP_GHOUL && !mutation[MUT_CLAWS]) - return false; - // transformations other than these will override claws - return ( attribute[ATTR_TRANSFORMATION] == TRAN_NONE - || attribute[ATTR_TRANSFORMATION] == TRAN_STATUE - || attribute[ATTR_TRANSFORMATION] == TRAN_LICH ); + if (attribute[ATTR_TRANSFORMATION] != TRAN_NONE + && attribute[ATTR_TRANSFORMATION] != TRAN_STATUE + && attribute[ATTR_TRANSFORMATION] != TRAN_LICH) + { + return 0; + } + + // these are the only other sources for claws + if (species == SP_TROLL || species == SP_GHOUL) + return 3; + else + return mutation[MUT_CLAWS]; } bool player::has_usable_claws() const diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 7b22ca0f52..db6d7b1f49 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -644,12 +644,11 @@ static int damage_or_escape_net(int hold) damage += 2; else if (you.has_usable_claws()) { - if (you.species == SP_TROLL || you.species == SP_GHOUL) - damage += 2; - else if (you.mutation[MUT_CLAWS] == 1) + int level = you.has_claws(); + if (level == 1) damage += coinflip(); else - damage += you.mutation[MUT_CLAWS] - 1; + damage += level - 1; } // Berserkers get a fighting bonus -- cgit v1.2.3-54-g00ecf