summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/player.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/player.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/player.cc')
-rw-r--r--crawl-ref/source/player.cc120
1 files changed, 90 insertions, 30 deletions
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 0a7f16c50e..86c6540f8b 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -24,6 +24,7 @@ REVISION("$Rev$");
#include "externs.h"
+#include "artefact.h"
#include "branch.h"
#include "cio.h"
#include "cloud.h"
@@ -49,7 +50,6 @@ REVISION("$Rev$");
#include "output.h"
#include "place.h"
#include "quiver.h"
-#include "randart.h"
#include "religion.h"
#include "skills.h"
#include "skills2.h"
@@ -953,9 +953,6 @@ int player_equip_ego_type( int slot, int special )
switch (slot)
{
case EQ_WEAPON:
- // This actually checks against the "branding", so it will catch
- // randart brands, but not fixed artefacts. -- bwr
-
// Hands can have more than just weapons.
wpn = you.equip[EQ_WEAPON];
if (wpn != -1
@@ -1005,6 +1002,78 @@ int player_equip_ego_type( int slot, int special )
return (ret);
}
+// Return's true if the indicated unrandart is equipped
+// [ds] There's no equivalent of calc_unid or req_id because as of now, weapons
+// and armour type-id on wield/wear.
+bool player_equip_unrand(int unrand_index)
+{
+ unrandart_entry* entry = get_unrand_entry(unrand_index);
+ equipment_type slot = get_item_slot(entry->base_type,
+ entry->sub_type);
+
+ if (!you_tran_can_wear(slot))
+ return (false);
+
+ int it;
+
+ switch (slot)
+ {
+ case EQ_WEAPON:
+ // Hands can have more than just weapons.
+ it = you.equip[EQ_WEAPON];
+ if (it != -1
+ && you.inv[it].base_type == OBJ_WEAPONS
+ && is_unrandom_artefact(you.inv[it])
+ && you.inv[it].special == unrand_index)
+ {
+ return (true);
+ }
+ break;
+
+ case EQ_RINGS:
+ it = you.equip[EQ_LEFT_RING];
+ if (it != -1
+ && is_unrandom_artefact(you.inv[it])
+ && you.inv[it].special == unrand_index)
+ {
+ return (true);
+ }
+
+ it = you.equip[EQ_RIGHT_RING];
+ if (it != -1
+ && is_unrandom_artefact(you.inv[it])
+ && you.inv[it].special == unrand_index)
+ {
+ return (true);
+ }
+ break;
+
+ case EQ_NONE:
+ case EQ_STAFF:
+ case EQ_LEFT_RING:
+ case EQ_RIGHT_RING:
+ case EQ_RINGS_PLUS:
+ case EQ_RINGS_PLUS2:
+ case EQ_ALL_ARMOUR:
+ // no unrandarts for these slots.
+ break;
+
+ default:
+ // Check a specific slot.
+ it = you.equip[slot];
+ if (it != -1
+ && is_unrandom_artefact(you.inv[it])
+ && you.inv[it].special == unrand_index)
+ {
+ return (true);
+ }
+ break;
+ }
+
+ return (false);
+}
+
+
int player_damage_type( void )
{
return you.damage_type();
@@ -1031,7 +1100,7 @@ int player_teleport(bool calc_unid)
// randart weapons only
if (you.weapon()
&& you.weapon()->base_type == OBJ_WEAPONS
- && is_random_artefact(*you.weapon()))
+ && is_artefact(*you.weapon()))
{
tp += scan_artefacts(ARTP_CAUSE_TELEPORTATION, calc_unid);
}
@@ -1171,13 +1240,19 @@ int player_hunger_rate(void)
// weapon ego types
if (you.species != SP_VAMPIRE)
{
- hunger += 6 * player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRICISM );
- hunger += 9 * player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRES_TOOTH );
+ if (player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRICISM ))
+ {
+ hunger += 6;
+ hunger += 3 * player_equip_unrand( SPWPN_VAMPIRES_TOOTH );
+ }
}
else
{
- hunger += 1 * player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRICISM );
- hunger += 2 * player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRES_TOOTH );
+ if (player_equip_ego_type( EQ_WEAPON, SPWPN_VAMPIRICISM ))
+ {
+ hunger += 1;
+ hunger += 1 * player_equip_unrand( SPWPN_VAMPIRES_TOOTH );
+ }
}
// troll leather armour
@@ -1591,14 +1666,6 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
// Staves
rp += player_equip( EQ_STAFF, STAFF_POISON, calc_unid );
- // the staff of Olgreb:
- if (you.weapon()
- && you.weapon()->base_type == OBJ_WEAPONS
- && you.weapon()->special == SPWPN_STAFF_OF_OLGREB)
- {
- rp++;
- }
-
// ego armour:
rp += player_equip_ego_type( EQ_ALL_ARMOUR, SPARM_POISON_RESISTANCE );
@@ -1789,12 +1856,8 @@ int player_spec_poison()
// Staves
sp += player_equip( EQ_STAFF, STAFF_POISON );
- if (you.weapon()
- && you.weapon()->base_type == OBJ_WEAPONS
- && you.weapon()->special == SPWPN_STAFF_OF_OLGREB)
- {
+ if (player_equip_unrand(SPWPN_STAFF_OF_OLGREB))
sp++;
- }
return sp;
}
@@ -3574,7 +3637,7 @@ int check_stealth(void)
return (1000);
#endif
- if (you.special_wield == SPWLD_SHADOW || you.duration[DUR_BERSERKER])
+ if (you.unrand_reacts == SPWLD_SHADOW || you.duration[DUR_BERSERKER])
return (0);
int stealth = you.dex * 3;
@@ -4560,7 +4623,7 @@ bool items_give_ability(const int slot, artefact_prop_type abil)
}
// other items are not evokable
- if (!is_random_artefact( you.inv[ eq ] ))
+ if (!is_artefact( you.inv[ eq ] ))
continue;
if (artefact_wpn_property(you.inv[ eq ], abil))
@@ -4589,7 +4652,7 @@ int scan_artefacts(artefact_prop_type which_property, bool calc_unid)
if (i == EQ_WEAPON && you.inv[ eq ].base_type != OBJ_WEAPONS)
continue;
- if (!is_random_artefact( you.inv[ eq ] ))
+ if (!is_artefact( you.inv[ eq ] ))
continue;
// Ignore unidentified items [TileCrawl dump enhancements].
@@ -5849,7 +5912,7 @@ void player::init()
disease = 0;
elapsed_time = 0;
rotting = 0;
- special_wield = SPWLD_NONE;
+ unrand_reacts = SPWLD_NONE;
synch_time = 0;
magic_contamination = 0;
@@ -5931,9 +5994,6 @@ void player::init()
unique_items.init(UNIQ_NOT_EXISTS);
- for (int i = 0; i < NO_UNRANDARTS; i++)
- set_unrandart_exist(i, false);
-
skills.init(0);
skill_points.init(0);
skill_order.init(MAX_SKILL_ORDER);
@@ -6509,7 +6569,7 @@ static bool _equipment_make_berserk()
if (!item)
continue;
- if (!is_random_artefact(*item))
+ if (!is_artefact(*item))
continue;
if (artefact_wpn_property(*item, ARTP_ANGRY) && one_chance_in(20))