diff options
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() { { |