diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:55 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:55 +0100 |
commit | ebb2771875ec2fffd7c63ee138024e6ebc47ebf8 (patch) | |
tree | a82ea012cc8ca4d87c2a90c1c6035abe201f2b14 /src/spells5.cc | |
parent | 7d6273cfbbc9717c30792817824b5511f7aee05f (diff) |
Move school_spells array to spells5.cc
Diffstat (limited to 'src/spells5.cc')
-rw-r--r-- | src/spells5.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/spells5.cc b/src/spells5.cc index 31a085ad..4ce897b4 100644 --- a/src/spells5.cc +++ b/src/spells5.cc @@ -1,3 +1,4 @@ +#include "spells5.hpp" #include <angband.h> #include <assert.h> @@ -6,6 +7,8 @@ #include "device_allocation.h" #include "spells3.hpp" +static s16b school_spells_count = 0; +static struct spell_type *school_spells[SCHOOL_SPELLS_MAX]; static spell_type *spell_new(s32b *index, cptr name) { @@ -67,6 +70,30 @@ s16b get_random_spell(s16b random_type, int level) return -1; } +/* + * Get a spell for a device of a given tval (wand or staff). + */ +s16b get_random_stick(byte tval, int level) +{ + int tries; + + for (tries = 0; tries < 1000; tries++) + { + long spell_idx = rand_int(school_spells_count); + spell_type *spell = spell_at(spell_idx); + device_allocation *device_allocation = spell_type_device_allocation(spell, tval); + + if ((device_allocation != NULL) && + (rand_int(spell_type_skill_level(spell) * 3) < level) && + (magik(100 - device_allocation->rarity))) + { + return spell_idx; + } + } + + return -1; +} + static void spells_init_tome() { { |