summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/makeitem.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-25 02:29:14 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-25 02:29:14 +0000
commit2fad05374f70f21d4af3d147325581bf1047b5be (patch)
tree40a46254f044837f658e4dbabb07ce3c52b72804 /crawl-ref/source/makeitem.cc
parentab0e3274d569d1cdea4010f4ed1d4b24cd3804e9 (diff)
downloadcrawl-ref-2fad05374f70f21d4af3d147325581bf1047b5be.tar.gz
crawl-ref-2fad05374f70f21d4af3d147325581bf1047b5be.zip
First part of the merger of fixed artefacts into unrandom artefacts
(further changes will be much smaller). Breaks savefile compatibility, and bumps the major savefile version up to 6. Some changes made to some tiles files, but it hasn't been tested with a tiles build. Overview of changes: * Unrand artefacts are now defined in art-data.txt and is turned into C code via util/art-data.pl. This has the dual advantage of being more readable by humans, and that if the unrand data structure changes then you can just change util/art-data.pl and regenerate the C code rather than having to change some 70 different C structs by hand. * util/art-data.pl automatically updates NO_UNRANDARTS, and also automatically generates an enumeration of all the unrands which are equal to their item.special field. * randart.cc and randart.h have been renamed to artefact.cc and artefact.h, since the files covers all types of artefacts, and the differences between randarts, unrandarts and (former) fixed arts have been minimized since the terms were introduced. Also renamed unrand.h to art-data.h * The brands and resistances of former fixed arts are now handled via artefact properties, but the rest of their special behaviours are still hardcoded. * Unrandarts are now distinguished between normal and "special", with the special ones currently just being identical to the list of the formed fixed arts. Special unrandarts are randomly generated less often than normal unrandarts, can be generated in the Abyss if they've been lost, can't be picked up by monsters, and can't be affected by Tukima's Dance. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10035 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/makeitem.cc')
-rw-r--r--crawl-ref/source/makeitem.cc89
1 files changed, 61 insertions, 28 deletions
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 640c947ea4..96e4b80f85 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -15,6 +15,7 @@ REVISION("$Rev$");
#include "externs.h"
#include "makeitem.h"
+#include "artefact.h"
#include "decks.h"
#include "describe.h"
#include "dungeon.h"
@@ -26,7 +27,6 @@ REVISION("$Rev$");
#include "misc.h"
#include "mon-util.h"
#include "player.h"
-#include "randart.h"
#include "spl-book.h"
#include "stuff.h"
#include "travel.h"
@@ -349,9 +349,8 @@ void item_colour(item_def &item)
switch (item.base_type)
{
case OBJ_WEAPONS:
- if (is_unrandom_artefact( item ) || is_fixed_artefact( item ))
- break; // unrandarts and fixed arts already coloured
-
+ if (is_unrandom_artefact(item))
+ break; // unrandarts already coloured
if (is_demonic( item ))
item.colour = random_uncommon_colour();
@@ -883,6 +882,26 @@ static weapon_type _determine_weapon_subtype(int item_level)
return rc;
}
+static bool _try_make_item_special_unrand(item_def& item, int force_type,
+ int item_level)
+{
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "Making special unrand artefact.");
+#endif
+
+ bool abyss = item_level == level_id(LEVEL_ABYSS).absdepth();
+ int idx = find_okay_unrandart(item.base_type, force_type,
+ UNRANDPSEC_SPECIAL, abyss);
+
+ if (idx != -1)
+ {
+ if (make_item_unrandart(item, idx))
+ return (true);
+ }
+
+ return (false);
+}
+
// Return whether we made an artefact.
static bool _try_make_weapon_artefact(item_def& item, int force_type,
int item_level)
@@ -897,7 +916,8 @@ static bool _try_make_weapon_artefact(item_def& item, int force_type,
&& you.level_type != LEVEL_PANDEMONIUM
&& one_chance_in(50))
{
- const int idx = find_okay_unrandart(OBJ_WEAPONS, force_type);
+ const int idx = find_okay_unrandart(OBJ_WEAPONS, force_type,
+ UNRANDSPEC_NORMAL);
if (idx != -1)
{
make_item_unrandart(item, idx);
@@ -936,18 +956,12 @@ static bool _try_make_weapon_artefact(item_def& item, int force_type,
return (true);
}
- // If it isn't an artefact yet, try to make a fixed artefact.
+ // If it isn't an artefact yet, try to make a special unrand artefact.
if (item_level > 6
&& one_chance_in(12)
&& x_chance_in_y(31 + item_level * 3, 3000))
{
-#ifdef DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS, "Making fixed artefact.");
-#endif
- if (make_item_fixed_artefact(
- item,
- (item_level == level_id(LEVEL_ABYSS).absdepth()) ))
- return (true);
+ return _try_make_item_special_unrand(item, force_type, item_level);
}
return (false);
@@ -1528,7 +1542,7 @@ static void _generate_weapon_item(item_def& item, bool allow_uniques,
return;
}
- ASSERT(!is_fixed_artefact(item) && !is_random_artefact(item));
+ ASSERT(!is_artefact(item));
// Artefacts handled, let's make a normal item.
const bool force_good = (item_level == MAKE_GOOD_ITEM);
@@ -1828,7 +1842,8 @@ static bool _try_make_armour_artefact(item_def& item, int force_type,
&& one_chance_in(50))
{
// The old generation code did not respect force_type here.
- const int idx = find_okay_unrandart(OBJ_ARMOUR, force_type);
+ const int idx = find_okay_unrandart(OBJ_ARMOUR, force_type,
+ UNRANDSPEC_NORMAL);
if (idx != -1)
{
make_item_unrandart(item, idx);
@@ -1874,6 +1889,14 @@ static bool _try_make_armour_artefact(item_def& item, int force_type,
return (true);
}
+ // If it isn't an artefact yet, try to make a special unrand artefact.
+ if (item_level > 6
+ && one_chance_in(12)
+ && x_chance_in_y(31 + item_level * 3, 3000))
+ {
+ return _try_make_item_special_unrand(item, force_type, item_level);
+ }
+
return (false);
}
@@ -2079,7 +2102,8 @@ static special_armour_type _determine_armour_ego(const item_def& item,
}
static void _generate_armour_item(item_def& item, bool allow_uniques,
- int force_type, int item_level, int item_race)
+ int force_type, int item_level,
+ int item_race)
{
if (force_type != OBJ_RANDOM)
item.sub_type = force_type;
@@ -2588,7 +2612,8 @@ static bool _try_make_jewellery_unrandart(item_def& item, int force_type,
&& x_chance_in_y(101 + item_level * 3, 2000))
{
// The old generation code did not respect force_type here.
- const int idx = find_okay_unrandart(OBJ_JEWELLERY, force_type);
+ const int idx = find_okay_unrandart(OBJ_JEWELLERY, force_type,
+ UNRANDSPEC_NORMAL);
if (idx != -1)
{
make_item_unrandart(item, idx);
@@ -2629,7 +2654,8 @@ static int _determine_ring_plus(int subtype)
}
static void _generate_jewellery_item(item_def& item, bool allow_uniques,
- int force_type, int item_level, int agent)
+ int force_type, int item_level,
+ int agent)
{
if (allow_uniques
&& _try_make_jewellery_unrandart(item, force_type, item_level))
@@ -2684,6 +2710,13 @@ static void _generate_jewellery_item(item_def& item, bool allow_uniques,
{
make_item_randart(item);
}
+ // If it isn't an artefact yet, try to make a special unrand artefact.
+ else if (item_level > 6
+ && one_chance_in(12)
+ && x_chance_in_y(31 + item_level * 3, 3000))
+ {
+ _try_make_item_special_unrand(item, force_type, item_level);
+ }
else if (item.sub_type == RING_HUNGER || item.sub_type == RING_TELEPORTATION
|| one_chance_in(50))
{
@@ -2771,7 +2804,7 @@ int items(int allow_uniques, // not just true-false,
const bool force_good = (item_level == MAKE_GOOD_ITEM);
- if (force_ego > 0)
+ if (force_ego != 0)
allow_uniques = false;
item.special = force_ego;
@@ -2814,11 +2847,12 @@ int items(int allow_uniques, // not just true-false,
item.quantity = 1; // generally the case
- if (force_ego >= SPWPN_START_FIXEDARTS && force_ego <= SPWPN_END_FIXEDARTS)
+ if (force_ego < SP_FORBID_EGO)
{
- if (get_unique_item_status(OBJ_WEAPONS, force_ego) == UNIQ_NOT_EXISTS)
+ force_ego = -force_ego;
+ if (get_unique_item_status(force_ego) == UNIQ_NOT_EXISTS)
{
- make_item_fixed_artefact(mitm[p], false, force_ego);
+ make_item_unrandart(mitm[p], force_ego);
return (p);
}
// the base item otherwise
@@ -2874,7 +2908,6 @@ int items(int allow_uniques, // not just true-false,
case OBJ_ORBS: // always forced in current setup {dlb}
item.sub_type = force_type;
- set_unique_item_status(OBJ_ORBS, item.sub_type, UNIQ_EXISTS);
break;
case OBJ_MISCELLANY:
@@ -2958,7 +2991,7 @@ static bool _weapon_is_visibly_special(const item_def &item)
if (get_equip_desc(item) != ISFLAG_NO_DESC)
return (false);
- if (visibly_branded || is_random_artefact(item))
+ if (visibly_branded || is_artefact(item))
return (true);
if ((item.plus || item.plus2)
@@ -2981,7 +3014,7 @@ static bool _armour_is_visibly_special(const item_def &item)
if (get_equip_desc(item) != ISFLAG_NO_DESC)
return (false);
- if (visibly_branded || is_random_artefact(item))
+ if (visibly_branded || is_artefact(item))
return (true);
if (item.plus && !one_chance_in(3))
@@ -3701,17 +3734,17 @@ static item_make_species_type _give_weapon(monsters *mon, int level,
case MONS_CEREBOV:
force_item = true;
- make_item_fixed_artefact( item, false, SPWPN_SWORD_OF_CEREBOV );
+ make_item_unrandart( item, SPWPN_SWORD_OF_CEREBOV );
break;
case MONS_DISPATER:
force_item = true;
- make_item_fixed_artefact( item, false, SPWPN_STAFF_OF_DISPATER );
+ make_item_unrandart( item, SPWPN_STAFF_OF_DISPATER );
break;
case MONS_ASMODEUS:
force_item = true;
- make_item_fixed_artefact( item, false, SPWPN_SCEPTRE_OF_ASMODEUS );
+ make_item_unrandart( item, SPWPN_SCEPTRE_OF_ASMODEUS );
break;
case MONS_GERYON: