I try not to ask for coding help here, but I've wasted most of the day trying to figure this out and can't get it to work right.
I'm modifying the object generation code to catch spellbooks and change it into the type of spellbook that the character can use.
Here's what I put into the get_obj_num(int level) function in object2.c
(in the Process probabilities loop, I included the chest part to show exactly where it is in the code)
I don't know what the table[i] stuff means.
In game, this is what happens:
(playing a ranger who uses nature magic)
I get a "Book of Nature Magic []" with the name of a book of a different spell realm in the []. I can cast spells from it as if it were the nature realm spellbook but the name is wrong (and I can't stand giving up on this piece of code when it's this close to working right).
I'm modifying the object generation code to catch spellbooks and change it into the type of spellbook that the character can use.
Here's what I put into the get_obj_num(int level) function in object2.c
(in the Process probabilities loop, I included the chest part to show exactly where it is in the code)
Code:
/* Hack -- prevent embedded chests */ if (opening_chest && (k_ptr->tval == TV_CHEST)) continue; /* DAJ: appropriate spellbooks much more likely to appear than others */ /* this is a must-have because of having several spell realms */ /* check for spellbook tval */ if ((k_ptr->tval >= TV_MAGIC_BOOK) && (k_ptr->tval < TV_GOLD)) { /* is it an appropriate spell book? */ if (!(k_ptr->tval == cp_ptr->spell_book)) { k_ptr->tval = cp_ptr->spell_book; /* Hopefully, this will actually change it into the correct spellbook */ k_idx = lookup_kind(k_ptr->tval, k_ptr->sval); /* change the index */ table[i].index = k_idx; /* Get the actual kind */ k_ptr = &k_info[k_idx]; } }
In game, this is what happens:
(playing a ranger who uses nature magic)
I get a "Book of Nature Magic []" with the name of a book of a different spell realm in the []. I can cast spells from it as if it were the nature realm spellbook but the name is wrong (and I can't stand giving up on this piece of code when it's this close to working right).
Comment