From: <j-...@us...> - 2008-11-28 11:58:31
|
Revision: 7673 http://crawl-ref.svn.sourceforge.net/crawl-ref/?rev=7673&view=rev Author: j-p-e-g Date: 2008-11-28 11:58:20 +0000 (Fri, 28 Nov 2008) Log Message: ----------- * Fixed a few issues with transformations. * Moved fixed arts' plusses, name and colour into a struct in randart.cc. (This should maybe be moved into unrand.h.) Name and description are now stored in the props vector like for randarts, and artefact_name() now handles all randarts, unrandarts and fixed artefacts. The Knife of Accuracy should probably be turned into an unrandart. Modified Paths: -------------- trunk/crawl-ref/source/beam.cc trunk/crawl-ref/source/effects.cc trunk/crawl-ref/source/fight.cc trunk/crawl-ref/source/food.cc trunk/crawl-ref/source/invent.cc trunk/crawl-ref/source/it_use2.cc trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/itemname.cc trunk/crawl-ref/source/makeitem.cc trunk/crawl-ref/source/player.cc trunk/crawl-ref/source/randart.cc trunk/crawl-ref/source/randart.h Modified: trunk/crawl-ref/source/beam.cc =================================================================== --- trunk/crawl-ref/source/beam.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/beam.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -1331,13 +1331,13 @@ } // Fill - pbolt.name = zinfo->name; - pbolt.flavour = zinfo->flavour; - pbolt.colour = zinfo->colour; - pbolt.type = dchar_glyph(zinfo->glyph); + pbolt.name = zinfo->name; + pbolt.flavour = zinfo->flavour; + pbolt.colour = zinfo->colour; + pbolt.type = dchar_glyph(zinfo->glyph); pbolt.obvious_effect = zinfo->always_obvious; - pbolt.is_beam = zinfo->can_beam; - pbolt.is_explosion = zinfo->is_explosion; + pbolt.is_beam = zinfo->can_beam; + pbolt.is_explosion = zinfo->is_explosion; if (zinfo->power_cap > 0) power = std::min(zinfo->power_cap, power); Modified: trunk/crawl-ref/source/effects.cc =================================================================== --- trunk/crawl-ref/source/effects.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/effects.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -1694,11 +1694,11 @@ if (is_random_artefact(thing)) { origin_acquired(thing, agent); - if ( !is_unrandom_artefact(thing) ) + if (!is_unrandom_artefact(thing)) { - // give another name that takes god gift into account + // Give another name that takes god gift into account. thing.props["randart_name"].get_string() = - randart_name(thing, false); + artefact_name(thing, false); } } } Modified: trunk/crawl-ref/source/fight.cc =================================================================== --- trunk/crawl-ref/source/fight.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/fight.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -4064,7 +4064,8 @@ if (!you.received_weapon_warning && !you.confused() && (weapon && weapon->base_type != OBJ_STAVES && (weapon->base_type != OBJ_WEAPONS || is_range_weapon(*weapon)) - || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])) + || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] + && you_tran_can_wear(EQ_WEAPON))) { std::string prompt = "Really attack while "; if (!weapon) Modified: trunk/crawl-ref/source/food.cc =================================================================== --- trunk/crawl-ref/source/food.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/food.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -179,6 +179,7 @@ you.time_taken /= 10; } + you.wield_change = true; you.turn_is_over = true; } Modified: trunk/crawl-ref/source/invent.cc =================================================================== --- trunk/crawl-ref/source/invent.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/invent.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -806,7 +806,7 @@ switch (selector) { case OBJ_ARMOUR: - return (you_tran_can_wear(i)); + return (itype == OBJ_ARMOUR && you_tran_can_wear(i)); case OSEL_UNIDENT: return !fully_identified(i); Modified: trunk/crawl-ref/source/it_use2.cc =================================================================== --- trunk/crawl-ref/source/it_use2.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/it_use2.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -425,7 +425,6 @@ if (showMsgs) mpr("You feel less violent."); break; - case SPWPN_SCYTHE_OF_CURSES: case SPWPN_STAFF_OF_OLGREB: item.plus = 0; item.plus2 = 0; Modified: trunk/crawl-ref/source/item_use.cc =================================================================== --- trunk/crawl-ref/source/item_use.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/item_use.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -718,7 +718,7 @@ case SPWPN_SCYTHE_OF_CURSES: you.special_wield = SPWLD_CURSE; - if (!item_cursed(item) && one_chance_in(5)) + if (!item_cursed(item) && one_chance_in(3)) do_curse_item(item, false); break; Modified: trunk/crawl-ref/source/itemname.cc =================================================================== --- trunk/crawl-ref/source/itemname.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/itemname.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -261,54 +261,6 @@ } -static const char* fixed_artefact_name( const item_def& item, bool ident ) -{ - if (ident) - { - switch (item.special) - { - case SPWPN_SINGING_SWORD: return "Singing Sword"; - case SPWPN_WRATH_OF_TROG: return "Wrath of Trog"; - case SPWPN_SCYTHE_OF_CURSES: return "Scythe of Curses"; - case SPWPN_MACE_OF_VARIABILITY: return "Mace of Variability"; - case SPWPN_GLAIVE_OF_PRUNE: return "Glaive of Prune"; - case SPWPN_SCEPTRE_OF_TORMENT: return "Sceptre of Torment"; - case SPWPN_SWORD_OF_ZONGULDROK: return "Sword of Zonguldrok"; - case SPWPN_SWORD_OF_CEREBOV: return "Sword of Cerebov"; - case SPWPN_STAFF_OF_DISPATER: return "Staff of Dispater"; - case SPWPN_SCEPTRE_OF_ASMODEUS: return "Sceptre of Asmodeus"; - case SPWPN_SWORD_OF_POWER: return "Sword of Power"; - case SPWPN_KNIFE_OF_ACCURACY: return "Knife of Accuracy"; - case SPWPN_STAFF_OF_OLGREB: return "Staff of Olgreb"; - case SPWPN_VAMPIRES_TOOTH: return "Vampire's Tooth"; - case SPWPN_STAFF_OF_WUCAD_MU: return "Staff of Wucad Mu"; - default: return "Brodale's Buggy Bola"; - } - } - else - { - switch (item.special) - { - case SPWPN_SINGING_SWORD: return "golden long sword"; - case SPWPN_WRATH_OF_TROG: return "bloodstained battleaxe"; - case SPWPN_SCYTHE_OF_CURSES: return "warped scythe"; - case SPWPN_MACE_OF_VARIABILITY: return "shimmering mace"; - case SPWPN_GLAIVE_OF_PRUNE: return "purple glaive"; - case SPWPN_SCEPTRE_OF_TORMENT: return "jewelled golden mace"; - case SPWPN_SWORD_OF_ZONGULDROK: return "bone long sword"; - case SPWPN_SWORD_OF_CEREBOV: return "great serpentine sword"; - case SPWPN_STAFF_OF_DISPATER: return "golden staff"; - case SPWPN_SCEPTRE_OF_ASMODEUS: return "ruby sceptre"; - case SPWPN_SWORD_OF_POWER: return "chunky great sword"; - case SPWPN_KNIFE_OF_ACCURACY: return "thin dagger"; - case SPWPN_STAFF_OF_OLGREB: return "green glowing staff"; - case SPWPN_VAMPIRES_TOOTH: return "ivory dagger"; - case SPWPN_STAFF_OF_WUCAD_MU: return "ephemeral quarterstaff"; - default: return "buggy bola"; - } - } -} - const char* weapon_brand_name(const item_def& item, bool terse) { switch (get_weapon_brand(item)) @@ -1053,18 +1005,12 @@ buff << " "; } - if (is_random_artefact( *this ) && !dbname) + if (is_artefact( *this ) && !dbname) { - buff << get_randart_name(*this); + buff << get_artefact_name(*this); break; } - if (is_fixed_artefact( *this ) && !dbname) - { - buff << fixed_artefact_name( *this, know_type ); - break; - } - // Now that we can have "glowing elven" weapons, it's // probably a good idea to cut out the descriptive // term once it's become obsolete. -- bwr @@ -1168,7 +1114,7 @@ // When asking for the base item name, randartism is ignored. if (is_random_artefact( *this ) && !basename && !dbname) { - buff << get_randart_name(*this); + buff << get_artefact_name(*this); break; } @@ -1419,7 +1365,7 @@ if (is_randart && !dbname) { - buff << get_randart_name(*this); + buff << get_artefact_name(*this); break; } Modified: trunk/crawl-ref/source/makeitem.cc =================================================================== --- trunk/crawl-ref/source/makeitem.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/makeitem.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -347,48 +347,9 @@ switch (item.base_type) { case OBJ_WEAPONS: - if (is_unrandom_artefact( item )) - break; // unrandarts already coloured + if (is_unrandom_artefact( item ) || is_fixed_artefact( item )) + break; // unrandarts and fixed arts already coloured - if (is_fixed_artefact( item )) - { - switch (item.special) - { - case SPWPN_SINGING_SWORD: - case SPWPN_SCEPTRE_OF_TORMENT: - item.colour = YELLOW; - break; - case SPWPN_WRATH_OF_TROG: - case SPWPN_SWORD_OF_POWER: - item.colour = RED; - break; - case SPWPN_SCYTHE_OF_CURSES: - item.colour = DARKGREY; - break; - case SPWPN_MACE_OF_VARIABILITY: - item.colour = random_colour(); - break; - case SPWPN_GLAIVE_OF_PRUNE: - item.colour = MAGENTA; - break; - case SPWPN_SWORD_OF_ZONGULDROK: - item.colour = LIGHTGREY; - break; - case SPWPN_KNIFE_OF_ACCURACY: - item.colour = LIGHTCYAN; - break; - case SPWPN_STAFF_OF_OLGREB: - item.colour = GREEN; - break; - case SPWPN_VAMPIRES_TOOTH: - item.colour = WHITE; - break; - case SPWPN_STAFF_OF_WUCAD_MU: - item.colour = BROWN; - break; - } - break; - } if (is_demonic( item )) item.colour = random_uncommon_colour(); Modified: trunk/crawl-ref/source/player.cc =================================================================== --- trunk/crawl-ref/source/player.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/player.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -571,8 +571,8 @@ if (you.species == SP_GHOUL && eq == EQ_GLOVES) return (false); - if (eq == EQ_HELMET - && (player_mutation_level(MUT_HORNS) || player_mutation_level(MUT_BEAK))) + if (eq == EQ_HELMET && (player_mutation_level(MUT_HORNS) + || player_mutation_level(MUT_BEAK))) { return (special_armour); } Modified: trunk/crawl-ref/source/randart.cc =================================================================== --- trunk/crawl-ref/source/randart.cc 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/randart.cc 2008-11-28 11:58:20 UTC (rev 7673) @@ -31,6 +31,8 @@ #define RANDART_NAME_KEY "randart_name" #define RANDART_APPEAR_KEY "randart_appearance" +static const char* _get_fixedart_name(const item_def &item); + // The initial generation of a randart is very simple - it occurs in // dungeon.cc and consists of giving it a few random things - plus & // plus2 mainly. @@ -1290,7 +1292,7 @@ } } -std::string randart_name(const item_def &item, bool appearance) +std::string artefact_name(const item_def &item, bool appearance) { ASSERT(is_artefact(item)); @@ -1298,6 +1300,9 @@ || item.base_type == OBJ_ARMOUR || item.base_type == OBJ_JEWELLERY); + if (is_fixed_artefact( item )) + return _get_fixedart_name( item ); + if (is_unrandom_artefact( item )) { const unrandart_entry *unrand = _seekunrandart( item ); @@ -1411,7 +1416,7 @@ return result; } -std::string get_randart_name( const item_def &item ) +std::string get_artefact_name( const item_def &item ) { ASSERT( is_artefact( item ) ); @@ -1420,12 +1425,12 @@ // print artefact's real name if (item.props.exists(RANDART_NAME_KEY)) return item.props[RANDART_NAME_KEY].get_string(); - return randart_name(item, false); + return artefact_name(item, false); } // print artefact appearance if (item.props.exists(RANDART_APPEAR_KEY)) return item.props[RANDART_APPEAR_KEY].get_string(); - return randart_name(item, false); + return artefact_name(item, false); } int find_unrandart_index(const item_def& artefact) @@ -1482,11 +1487,222 @@ return (ret); } +struct fixedart_setting +{ + int which; + const char* name; + const char* appearance; + object_class_type base; + int subtype; + int acc; + int dam; + int colour; + bool curse; +}; + +const fixedart_setting fixedarts[] = { + + { + SPWPN_SINGING_SWORD, + "Singing Sword", + "golden long sword", + OBJ_WEAPONS, + WPN_LONG_SWORD, + 7, + 7, + YELLOW, + false + }, + + { + SPWPN_WRATH_OF_TROG, + "Wrath of Trog", + "bloodstained battleaxe", + OBJ_WEAPONS, + WPN_BATTLEAXE, + 3, + 11, + RED, + false + }, + + { + SPWPN_SCYTHE_OF_CURSES, + "Scythe of Curses", + "warped scythe", + OBJ_WEAPONS, + WPN_SCYTHE, + 13, + 13, + DARKGREY, + true + }, + + { + SPWPN_MACE_OF_VARIABILITY, + "Mace of Variability", + "shimmering mace", + OBJ_WEAPONS, + WPN_MACE, + random2(16) - 4, + random2(16) - 4, + random_colour(), + false + }, + + { + SPWPN_GLAIVE_OF_PRUNE, + "Glaive of Prune", + "purple glaive", + OBJ_WEAPONS, + WPN_GLAIVE, + 0, + 12, + MAGENTA, + false + }, + + { + SPWPN_SCEPTRE_OF_TORMENT, + "Sceptre of Torment", + "jewelled golden mace", + OBJ_WEAPONS, + WPN_MACE, + 7, + 6, + YELLOW, + false + }, + + { + SPWPN_SWORD_OF_ZONGULDROK, + "Sword of Zonguldrok", + "bone long sword", + OBJ_WEAPONS, + WPN_LONG_SWORD, + 9, + 9, + LIGHTGREY, + false + }, + + { + SPWPN_SWORD_OF_POWER, + "Sword of Power", + "chunky great sword", + OBJ_WEAPONS, + WPN_GREAT_SWORD, + 0, // set on wield + 0, // set on wield + RED, + false + }, + + { + SPWPN_KNIFE_OF_ACCURACY, + "Knife of Accuracy", + "thin dagger", + OBJ_WEAPONS, + WPN_DAGGER, + 27, + -1, + LIGHTCYAN, + false + }, + + { + SPWPN_STAFF_OF_OLGREB, + "Staff of Olgreb", + "green glowing staff", + OBJ_WEAPONS, + WPN_QUARTERSTAFF, + 0, // set on wield + 0, // set on wield + GREEN, + false + }, + + { + SPWPN_VAMPIRES_TOOTH, + "Vampire's Tooth", + "ivory dagger", + OBJ_WEAPONS, + WPN_DAGGER, + 3, + 4, + WHITE, + false + }, + + { + SPWPN_STAFF_OF_WUCAD_MU, + "Staff of Wucad Mu", + "ephemeral quarterstaff", + OBJ_WEAPONS, + WPN_QUARTERSTAFF, + 0, // set on wield + 0, // set on wield + BROWN, + false + }, + + { + SPWPN_SWORD_OF_CEREBOV, + "Sword of Cerebov", + "great serpentine sword", + OBJ_WEAPONS, + WPN_GREAT_SWORD, + 6, + 6, + YELLOW, + true + }, + + { + SPWPN_STAFF_OF_DISPATER, + "Staff of Dispater", + "golden staff", + OBJ_WEAPONS, + WPN_QUARTERSTAFF, + 4, + 4, + YELLOW, + false + }, + + { + SPWPN_SCEPTRE_OF_ASMODEUS, + "Sceptre of Asmodeus", + "ruby sceptre", + OBJ_WEAPONS, + WPN_QUARTERSTAFF, + 7, + 7, + RED, + false + } +}; + +static const char* _get_fixedart_name(const item_def &item) +{ + // Find the appropriate fixed artefact. + for (unsigned int i = 0; i < ARRAYSZ(fixedarts); ++i) + { + if (fixedarts[i].which == item.special) + { + const fixedart_setting *fixed = &fixedarts[i]; + return (item_type_known(item) ? fixed->name : fixed->appearance); + } + } + return (item_type_known(item) ? "Unnamed Artefact" : "buggy fixedart"); +} + // which == 0 (default) gives random fixed artefact. // Returns true if successful. bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which ) { const bool force = (which != 0); + const fixedart_setting *fixedart = NULL; if (!force) { @@ -1505,126 +1721,45 @@ return (false); } - switch (which) + // Find the appropriate fixed artefact. + for (unsigned int i = 0; i < ARRAYSZ(fixedarts); ++i) { - case SPWPN_SINGING_SWORD: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_LONG_SWORD; - item.plus = 7; - item.plus2 = 7; - break; + if (fixedarts[i].which == which) + { + fixedart = &fixedarts[i]; + break; + } + } - case SPWPN_WRATH_OF_TROG: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_BATTLEAXE; - item.plus = 3; - item.plus2 = 11; - break; + // None found? + if (fixedart == NULL) + { +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_ERROR, "Couldn't find fixed artefact %d", which); +#endif + return (false); + } - case SPWPN_SCYTHE_OF_CURSES: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_SCYTHE; - item.plus = 13; - item.plus2 = 13; - break; + // If we get here, we've made the artefact + item.base_type = fixedart->base; + item.sub_type = fixedart->subtype; + item.plus = fixedart->acc; + item.plus2 = fixedart->dam; + item.colour = fixedart->colour; + item.special = which; + item.quantity = 1; - case SPWPN_MACE_OF_VARIABILITY: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_MACE; - item.plus = random2(16) - 4; - item.plus2 = random2(16) - 4; - break; + // get true artefact name + ASSERT(!item.props.exists( RANDART_NAME_KEY )); + item.props[RANDART_NAME_KEY].get_string() = fixedart->name; - case SPWPN_GLAIVE_OF_PRUNE: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_GLAIVE; - item.plus = 0; - item.plus2 = 12; - break; + // get artefact appearance + ASSERT(!item.props.exists( RANDART_APPEAR_KEY )); + item.props[RANDART_APPEAR_KEY].get_string() = fixedart->appearance; - case SPWPN_SCEPTRE_OF_TORMENT: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_MACE; - item.plus = 7; - item.plus2 = 6; - break; + if (fixedart->curse) + do_curse_item(item); - case SPWPN_SWORD_OF_ZONGULDROK: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_LONG_SWORD; - item.plus = 9; - item.plus2 = 9; - break; - - case SPWPN_SWORD_OF_POWER: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_GREAT_SWORD; - item.plus = 0; // set on wield - item.plus2 = 0; // set on wield - break; - - case SPWPN_KNIFE_OF_ACCURACY: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_DAGGER; - item.plus = 27; - item.plus2 = -1; - break; - - case SPWPN_STAFF_OF_OLGREB: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_QUARTERSTAFF; - item.plus = 0; // set on wield - item.plus2 = 0; // set on wield - break; - - case SPWPN_VAMPIRES_TOOTH: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_DAGGER; - item.plus = 3; - item.plus2 = 4; - break; - - case SPWPN_STAFF_OF_WUCAD_MU: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_QUARTERSTAFF; - item.plus = 0; // set on wield - item.plus2 = 0; // set on wield - break; - - case SPWPN_SWORD_OF_CEREBOV: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_GREAT_SWORD; - item.plus = 6; - item.plus2 = 6; - item.colour = YELLOW; - do_curse_item( item ); - break; - - case SPWPN_STAFF_OF_DISPATER: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_QUARTERSTAFF; - item.plus = 4; - item.plus2 = 4; - item.colour = YELLOW; - break; - - case SPWPN_SCEPTRE_OF_ASMODEUS: - item.base_type = OBJ_WEAPONS; - item.sub_type = WPN_QUARTERSTAFF; - item.plus = 7; - item.plus2 = 7; - item.colour = RED; - break; - - default: - DEBUGSTR( "Trying to create illegal fixed artefact!" ); - return (false); - } - - // If we get here, we've made the artefact - item.special = which; - item.quantity = 1; - // Items originally generated in the abyss and not found will be // shifted to "lost in abyss", and will only be found there. -- bwr set_unique_item_status( OBJ_WEAPONS, which, UNIQ_EXISTS ); @@ -1882,11 +2017,11 @@ // get true artefact name ASSERT(!item.props.exists( RANDART_NAME_KEY )); - item.props[RANDART_NAME_KEY].get_string() = randart_name(item, false); + item.props[RANDART_NAME_KEY].get_string() = artefact_name(item, false); // get artefact appearance ASSERT(!item.props.exists( RANDART_APPEAR_KEY )); - item.props[RANDART_APPEAR_KEY].get_string() = randart_name(item, true); + item.props[RANDART_APPEAR_KEY].get_string() = artefact_name(item, true); return (true); } Modified: trunk/crawl-ref/source/randart.h =================================================================== --- trunk/crawl-ref/source/randart.h 2008-11-28 11:10:55 UTC (rev 7672) +++ trunk/crawl-ref/source/randart.h 2008-11-28 11:58:20 UTC (rev 7673) @@ -33,12 +33,12 @@ /* *********************************************************************** * called from: itemname * *********************************************************************** */ -std::string get_randart_name( const item_def &item ); +std::string get_artefact_name( const item_def &item ); /* *********************************************************************** * called from: effects * *********************************************************************** */ -std::string randart_name( const item_def &item, bool appearance = false ); +std::string artefact_name( const item_def &item, bool appearance = false ); /* *********************************************************************** * called from: describe This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |