summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-19 15:22:25 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-19 15:22:25 +0000
commitf867bed2e7c45126ec6b5013178ca2d631cc3318 (patch)
tree3e12bc01d865fa91d96e130fa4a1e5e8e6038653 /crawl-ref/source
parent047dbc83010295b9937e88293d627f52792d182f (diff)
downloadcrawl-ref-f867bed2e7c45126ec6b5013178ca2d631cc3318.tar.gz
crawl-ref-f867bed2e7c45126ec6b5013178ca2d631cc3318.zip
Restrict randart names to a maximum length of 30. (I'd really like to
restrict it to about 25, but "The Shining One's" needs 20 letters, so that's out.) Don't automatically regard unID'd jewellery randarts as {tried}, instead use a (very) rough estimate: if you know at least one property, the item will be marked as tried, otherwise (e.g. if the only property is +Dam, or prevents spellcasting) it won't be marked at all. I'm not actually sure this is better than never outputting {tried} for randarts, but we'll see... git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4374 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/database/rand_wpn.txt22
-rw-r--r--crawl-ref/source/dat/database/randname.txt26
-rw-r--r--crawl-ref/source/item_use.cc16
-rw-r--r--crawl-ref/source/itemname.cc23
-rw-r--r--crawl-ref/source/itemprop.h22
-rw-r--r--crawl-ref/source/randart.cc99
-rw-r--r--crawl-ref/source/randart.h8
7 files changed, 132 insertions, 84 deletions
diff --git a/crawl-ref/source/dat/database/rand_wpn.txt b/crawl-ref/source/dat/database/rand_wpn.txt
index 67ffaeda36..d4d5eb3592 100644
--- a/crawl-ref/source/dat/database/rand_wpn.txt
+++ b/crawl-ref/source/dat/database/rand_wpn.txt
@@ -829,8 +829,6 @@ monster_name
@short_monster_name@
-@player_name@
-
@player_species@
Killer Bee
@@ -853,19 +851,20 @@ killer_name
's Death
-'s Death Toll
-
's Doom
's Foe
-'s Funeral
+'s Regret
-'s Harbinger of Death
+%%%%
+long_killer_name
-'s Nightmare
+'s Death Toll
-'s Regret
+'s Funeral
+
+'s Nightmare
%%%%
real_weapon_name
@@ -999,8 +998,15 @@ plain_weapon_name
w:15
@short_monster_name@@short_killer_name@
+w:8
@monster_name@@killer_name@
+w:2
+@short_monster_name@@long_killer_name@
+
+w:1
+@player_death@
+
w:15
@real_weapon_name@
diff --git a/crawl-ref/source/dat/database/randname.txt b/crawl-ref/source/dat/database/randname.txt
index 14571ca145..9beb73d09d 100644
--- a/crawl-ref/source/dat/database/randname.txt
+++ b/crawl-ref/source/dat/database/randname.txt
@@ -78,7 +78,7 @@ of @power_or_anger@
of @battle_or_war@
w:1
-of @player_name@'s @death_or_doom@
+of @player_doom@
w:9
of @death_or_doom@
@@ -253,7 +253,7 @@ jewellery
# jewellery specials (see rand_all.txt)
w:3
-of @jewellery_animal@
+of the @jewellery_animal@
of @jewellery_special_name@
@@ -275,7 +275,7 @@ of @other_weapon_name@
# as defined for armour (see rand_arm.txt)
w:20
-of @armour_animal@
+of the @armour_animal@
w:3
of @flower_name@
@@ -460,7 +460,7 @@ w:2
of Okawaru's @divine_esteem@
w:2
-of @armour_animal@
+of the @armour_animal@
w:1
of @good_or_divine@
@@ -503,10 +503,10 @@ w:5
of @chaos_name@
w:5
-of @xom_name@'s @xom_esteem@
+of Xom's @xom_esteem@
w:2
-of @xom_name@'s @divine_esteem@
+of Xom's @divine_esteem@
# uses the long name
w:1
@@ -534,10 +534,10 @@ w:5
of @chaos_name@
w:5
-of @xom_name@'s @xom_esteem@
+of Xom's @xom_esteem@
w:2
-of @xom_name@'s @divine_esteem@
+of Xom's @divine_esteem@
# uses the long name
w:1
@@ -547,7 +547,7 @@ w:1
of @game_name@
w:1
-of @player_name@'s @killer_name@
+of @player_death@
w:400
@armour@
@@ -567,10 +567,10 @@ w:5
of @chaos_name@
w:5
-of @xom_name@'s @xom_esteem@
+of Xom's @xom_esteem@
w:2
-of @xom_name@'s @divine_esteem@
+of Xom's @divine_esteem@
# uses the long name
w:1
@@ -580,10 +580,10 @@ w:1
of @game_name@
w:1
-of @player_name@'s @killer_name@
+of @player_death@
w:1
-of @player_name@'s @killer_name@
+of @player_doom@
w:300
@jewellery@
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index f125c32cef..78f2315915 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2139,9 +2139,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
// it's too weird. Also it messes up the messages.
if (item_ident(you.inv[you.equip[EQ_WEAPON]], ISFLAG_KNOW_PLUSES))
{
- if ( !teleport &&
- !item_ident(you.inv[throw_2], ISFLAG_KNOW_PLUSES) &&
- random2(100) < shoot_skill )
+ if ( !teleport
+ && !item_ident(you.inv[throw_2], ISFLAG_KNOW_PLUSES)
+ && random2(100) < shoot_skill )
{
set_ident_flags( item, ISFLAG_KNOW_PLUSES );
set_ident_flags( you.inv[throw_2], ISFLAG_KNOW_PLUSES );
@@ -2312,9 +2312,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
exercise(SK_THROWING, 1);
// ID check
- if ( !teleport &&
- !item_ident(you.inv[throw_2], ISFLAG_KNOW_PLUSES) &&
- random2(100) < you.skills[SK_THROWING] )
+ if ( !teleport
+ && !item_ident(you.inv[throw_2], ISFLAG_KNOW_PLUSES)
+ && random2(100) < you.skills[SK_THROWING] )
{
set_ident_flags( item, ISFLAG_KNOW_PLUSES );
set_ident_flags( you.inv[throw_2], ISFLAG_KNOW_PLUSES );
@@ -2563,8 +2563,8 @@ void jewellery_wear_effects(item_def &item)
const bool artefact = is_random_artefact( item );
const bool known_pluses = item_ident( item, ISFLAG_KNOW_PLUSES );
const bool known_cursed = item_known_cursed( item );
- const bool known_bad = item_type_known( item )
- && (item_value( item ) <= 2);
+ const bool known_bad = (item_type_known( item )
+ && item_value( item ) <= 2);
switch (item.sub_type)
{
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 365e03110f..63faef7768 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -235,10 +235,7 @@ std::string item_def::name(description_level_type descrip,
if (descrip != DESC_PLAIN && descrip != DESC_BASENAME)
{
- const bool tried = !ident && !equipped
- && (item_type_tried(*this)
- || this->base_type == OBJ_JEWELLERY
- && is_artefact && !item_type_known(*this));
+ const bool tried = !ident && !equipped && item_type_tried(*this);
std::string tried_str = "";
if (tried)
@@ -1697,15 +1694,29 @@ bool item_type_known(const object_class_type base_type, const int sub_type)
return false;
}
+static bool _randart_has_known_property(const item_def &item)
+{
+ for (int rap = 0; rap < RAP_NUM_PROPERTIES; rap++)
+ if (randart_wpn_known_prop( item, static_cast<randart_prop_type>(rap) ))
+ return true;
+
+ return false;
+}
+
bool item_type_tried( const item_def& item )
{
if ( item_type_known(item) )
return false;
- // Well, if we ever put in scroll or potion artefacts, this
- // might be necessary...
if ( is_artefact(item) )
+ {
+ if (item.base_type == OBJ_JEWELLERY
+ && _randart_has_known_property(item))
+ {
+ return true;
+ }
return false;
+ }
const item_type_id_type idt = objtype_to_idtype(item.base_type);
if (idt != NUM_IDTYPE && item.sub_type < 50)
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 83c4e4ce55..23cc7eeaa3 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -145,7 +145,7 @@ enum corpse_type
enum hands_reqd_type
{
HANDS_ONE,
- HANDS_HALF,
+ HANDS_HALF,
HANDS_TWO,
HANDS_DOUBLE // not a level, marks double ended weapons (== half)
@@ -168,7 +168,7 @@ enum helmet_desc_type
enum jewellery_type
{
RING_FIRST_RING = 0,
-
+
RING_REGENERATION = RING_FIRST_RING, // 0
RING_PROTECTION,
RING_PROTECTION_FROM_FIRE,
@@ -208,7 +208,7 @@ enum jewellery_type
AMU_CONTROLLED_FLIGHT,
AMU_INACCURACY,
AMU_RESIST_MUTATION,
-
+
NUM_JEWELLERY
};
@@ -286,7 +286,7 @@ enum rune_type
RUNE_DEMONIC = 50,
RUNE_ABYSSAL,
- // Runes 60-63 correspond to the Pandemonium demonlords,
+ // Runes 60-63 correspond to the Pandemonium demonlords,
// and are equal to the corresponding vault.
RUNE_MNOLEG = 60,
RUNE_LOM_LOBON,
@@ -505,8 +505,8 @@ enum weapon_property_type
enum vorpal_damage_type
{
- // Types of damage a weapon can do... currently assuming that anything
- // with BLUDGEON always does "AND" with any other specified types,
+ // Types of damage a weapon can do... currently assuming that anything
+ // with BLUDGEON always does "AND" with any other specified types,
// and and sets not including BLUDGEON are "OR".
DAM_BASH = 0x0000, // non-melee weapon blugeoning
DAM_BLUDGEON = 0x0001, // crushing
@@ -522,7 +522,7 @@ enum vorpal_damage_type
DVORP_CHOPPING = 0x4000, // used for axes
DVORP_SLASHING = 0x5000, // used for whips
DVORP_STABBING = 0x6000, // used for knives/daggers
-
+
DVORP_CLAWING = 0x7000, // claw damage
// These are shortcuts to tie vorpal/damage types for easy setting...
@@ -582,8 +582,8 @@ bool item_is_critical(const item_def &item);
bool item_cursed( const item_def &item );
bool item_known_cursed( const item_def &item );
bool item_known_uncursed( const item_def &item );
-void do_curse_item( item_def &item );
-void do_uncurse_item( item_def &item );
+void do_curse_item( item_def &item );
+void do_uncurse_item( item_def &item );
// stationary:
void set_item_stationary( item_def &item );
@@ -613,7 +613,7 @@ bool is_helmet( const item_def& item );
bool is_hard_helmet( const item_def& item );
// ego items:
-bool set_item_ego_type( item_def &item, int item_type, int ego_type );
+bool set_item_ego_type( item_def &item, int item_type, int ego_type );
int get_weapon_brand( const item_def &item );
special_armour_type get_armour_ego_type( const item_def &item );
int get_ammo_brand( const item_def &item );
@@ -726,7 +726,7 @@ size_type item_size( const item_def &item );
bool is_colourful_item( const item_def &item );
bool is_shield(const item_def &item);
-bool is_shield_incompatible(const item_def &weapon,
+bool is_shield_incompatible(const item_def &weapon,
const item_def *shield = NULL);
// Only works for armour/weapons/missiles
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 8bd5d2f35a..615c224321 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -40,7 +40,7 @@
mainly.
*/
-static bool god_fits_artefact(const god_type which_god, const item_def &item)
+static bool _god_fits_artefact(const god_type which_god, const item_def &item)
{
if (which_god == GOD_NO_GOD)
return (false);
@@ -92,9 +92,7 @@ static bool god_fits_artefact(const god_type which_god, const item_def &item)
case GOD_SHINING_ONE: // holiness, honourable combat
if (item.base_type == OBJ_WEAPONS && brand != SPWPN_HOLY_WRATH)
- {
return (false);
- }
if (randart_wpn_property( item, RAP_INVISIBLE )
|| randart_wpn_property( item, RAP_STEALTH ) > 0)
@@ -158,7 +156,7 @@ static bool god_fits_artefact(const god_type which_god, const item_def &item)
return (true);
}
-static god_type gift_from_god(const item_def item)
+static god_type _gift_from_god(const item_def item)
{
// maybe god gift?
god_type god_gift = GOD_NO_GOD;
@@ -173,23 +171,34 @@ static god_type gift_from_god(const item_def item)
return god_gift;
}
-static std::string replace_name_parts(const std::string name_in,
- const item_def item)
+static std::string _replace_name_parts(const std::string name_in,
+ const item_def item)
{
std::string name = name_in;
- god_type god_gift = gift_from_god(item);
+ god_type god_gift = _gift_from_god(item);
// Don't allow "player's Death" type names for god gifts (except Xom!)
- if (god_gift != GOD_NO_GOD && god_gift != GOD_XOM
- && name.find("@player_name@'s", 0) != std::string::npos
- && name.find("Death", 0) != std::string::npos)
+ if (name.find("@player_death@", 0) != std::string::npos
+ || name.find("@player_doom@", 0) != std::string::npos)
{
- // simply overwrite the name with one of type "god's Favour"
- name = "of ";
- name += god_name(god_gift, false);
- name += "'s ";
- name += getRandNameString("divine_esteem");
+ if (god_gift == GOD_NO_GOD || god_gift == GOD_XOM)
+ {
+ name = replace_all(name, "@player_death@",
+ "@player_name@'s "
+ + getRandNameString("killer_name"));
+ name = replace_all(name, "@player_doom@",
+ "@player_name@'s "
+ + getRandNameString("death_or_doom"));
+ }
+ else
+ {
+ // simply overwrite the name with one of type "god's Favour"
+ name = "of ";
+ name += god_name(god_gift, false);
+ name += "'s ";
+ name += getRandNameString("divine_esteem");
+ }
}
name = replace_all(name, "@player_name@", you.your_name);
@@ -250,11 +259,11 @@ static std::string replace_name_parts(const std::string name_in,
which_god = god_gift;
else
{
- do
- {
+ do
+ {
which_god = static_cast<god_type>(random2(NUM_GODS));
- }
- while (!god_fits_artefact(which_god, item));
+ }
+ while (!_god_fits_artefact(which_god, item));
}
name = replace_all(name, "@god_name@", god_name(which_god, false));
@@ -1300,23 +1309,45 @@ std::string randart_name( const item_def &item )
{
result += item_base_name(item) + " ";
- std::string name = getRandNameString(lookup);
-
- if (name.empty() && god_gift) // if nothing found, try god name alone
+ int tries = 100;
+ std::string name = "";
+ do
{
- name = getRandNameString(god_name(static_cast<god_type>(item_orig), false));
+ name = getRandNameString(lookup);
- if (name.empty()) // if still nothing found, try base type alone
- name = getRandNameString(get_artefact_type(item.base_type).c_str());
+ if (name.empty() && god_gift)
+ {
+ // if nothing found, try god name alone
+ name = getRandNameString(
+ god_name(static_cast<god_type>(item_orig), false));
+
+ if (name.empty())
+ {
+ // if still nothing found, try base type alone
+ name = getRandNameString(
+ get_artefact_type(item.base_type).c_str());
+ }
+ }
+
+ name = _replace_name_parts(name, item);
+
+ if (name.length() > 30)
+ {
+ mprf(MSGCH_DIAGNOSTICS,
+ "over-long name: %s (length: %d)",
+ name.c_str(), name.length());
+ }
}
+ while (--tries > 0 && name.length() > 30);
if (name.empty()) // still nothing found?
result += "of Bugginess";
else
- result += replace_name_parts(name, item);
+ result += name;
}
else
{
+ // construct a unique name
const std::string st_p = make_name(random_int(), false);
result += item_base_name(item);
@@ -1540,8 +1571,8 @@ bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which )
return (true);
}
-static bool randart_is_redundant( const item_def &item,
- randart_properties_t &proprt )
+static bool _randart_is_redundant( const item_def &item,
+ randart_properties_t &proprt )
{
if (item.base_type != OBJ_JEWELLERY)
return false;
@@ -1647,8 +1678,8 @@ static bool randart_is_redundant( const item_def &item,
return false;
}
-static bool randart_is_conflicting( const item_def &item,
- randart_properties_t &proprt )
+static bool _randart_is_conflicting( const item_def &item,
+ randart_properties_t &proprt )
{
if (item.base_type != OBJ_JEWELLERY)
return false;
@@ -1696,8 +1727,8 @@ bool randart_is_bad( const item_def &item, randart_properties_t &proprt )
if (randart_wpn_num_props( proprt ) == 0)
return true;
- return ( randart_is_redundant( item, proprt ) ||
- randart_is_conflicting( item, proprt ) );
+ return ( _randart_is_redundant( item, proprt )
+ || _randart_is_conflicting( item, proprt ) );
}
bool randart_is_bad( const item_def &item )
@@ -1732,14 +1763,14 @@ bool make_item_randart( item_def &item )
item.flags |= ISFLAG_RANDART;
- god_type god_gift = gift_from_god(item);
+ god_type god_gift = _gift_from_god(item);
do
{
item.special = (random_int() & RANDART_SEED_MASK);
}
while (randart_is_bad(item)
- || (god_gift != GOD_NO_GOD && !god_fits_artefact(god_gift, item)));
+ || god_gift != GOD_NO_GOD && !_god_fits_artefact(god_gift, item));
return (true);
}
diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h
index ce77411b9d..8a81b88758 100644
--- a/crawl-ref/source/randart.h
+++ b/crawl-ref/source/randart.h
@@ -57,16 +57,16 @@ typedef FixedVector< bool, RA_PROPERTIES > randart_known_props_t;
/* ***********************************************************************
* called from: describe - fight - it_use2 - item_use - player
* *********************************************************************** */
-void randart_desc_properties( const item_def &item,
+void randart_desc_properties( const item_def &item,
randart_properties_t &proprt,
randart_known_props_t &known,
bool force_fake_props = false);
-void randart_wpn_properties( const item_def &item,
+void randart_wpn_properties( const item_def &item,
randart_properties_t &proprt,
randart_known_props_t &known );
-void randart_wpn_properties( const item_def &item,
+void randart_wpn_properties( const item_def &item,
randart_properties_t &proprt );
int randart_wpn_property( const item_def &item, randart_prop_type prop,
@@ -80,7 +80,7 @@ int randart_wpn_num_props( const item_def &item );
int randart_wpn_num_props( const randart_properties_t &proprt );
void randart_wpn_learn_prop( item_def &item, randart_prop_type prop );
-bool randart_wpn_known_prop( item_def &item, randart_prop_type prop );
+bool randart_wpn_known_prop( const item_def &item, randart_prop_type prop );
/* ***********************************************************************
* called from: dungeon