View Single Post
Old September 14, 2015, 02:23   #4
TricksterWolf
Scout
 
Join Date: Sep 2012
Posts: 43
TricksterWolf is on a distinguished road
Quote:
Originally Posted by Nick View Post
Why do you think 98 is the limit? I don't think there is a limit in 4.0.

Interesting ideas, btw
It should be 99 actually.

The magic number 99 is used as a marker in spell_order* to denote a spell that has never been learned so that it will be skipped when forgetting spells. This implies a player with 100 spells will end up marking a spell as "never learned" in the spell_order, which will cause you to forget only the first 99 spells you learn rather than the most recent spells (among other potentially more serious errors). This is more of an issue for my build because the spell information is no longer going to be stored with the player at all, so I'll want spell_order* to range over all spells in the entire game for simplicity.

I've fixed this by defining PY_SPELL_NEVER_LEARNED to 65000 (instead of using hard-coded 99 as the cap for spells remembered) and changing it to a u16b. This inflates savefiles by a couple of kilobytes, but means I should be safe for up to 65000 spells.

And it seems to work so far. The big changes I'm working on now are as follows:

struct player_magic (loaded from both race.txt and class.txt into player)
. int spell_first (lv of 1st spell over all spell sources/realms)
. int spell_weight (by class)
. int mana_stat (by class; casting stat may be different!)
. byte *spell_level (req. lv for all spells cast by THIS character, 0 if can't)
. byte *spell_mana (mana for each spell; 0 is possible)
. byte *spell_fail (base fail-rate for spells cast by THIS character)
. byte *spell_flags (moved from player. to player->magic.)
. u16b *spell_order (moved from player. to player->magic.)

struct magic_book (loaded from books.txt, probably into obj_kind)
. int tval
. int sval
. int num_spells
. int *spell_index (must contain at least one spell: spell 0 determines book realm)

struct magic_spell (loaded from spells.txt into new m_info var)
. int index
. char *name
. int spell_realm
. char *text
. struct effect *effect (as before)

in obj-util.c:
. struct magic_spell *m_info

I'm probably adding magic_book to obj_kind (best guestimate), and player_magic is replacing class_magic in player. So it will be player->magic. instead of player->class->magic. essentially, and global m_info will hold all the spell information.

The big work during birth will be carefully updating the level and fail rates for spells so that the character gets the best level and fail rate from any overlapping items.

I'm removing sexp entirely in favor of just using (spell_level+1)*(spell_mana+1) to determine exp gain the first time a spell is cast (at all, not per book).

EDIT: I'm updating this as I change stuff around.

Last edited by TricksterWolf; September 14, 2015 at 17:01.
TricksterWolf is offline   Reply With Quote