Knowable Spell Hooks


Each character in the game has a list of 'Knowable' spells. This is a list of spells that he might be allowed to add to his spellbook later in the game. For example, a Magic User of Level 4 might be allowed to have the 'Ice to Popcorn' spell in his 'Knowable' list. The spell is not yet in his spellbook and he cannot yet see this spell during play, but it is there in his 'Knowable' list. Later in the game he might come across a scroll named “Scroll of Munchies” which, when 'SCRIBE'ed, will add the 'Ice to Popcorn' spell to the character's spellbook. The player would then be able to see the spell, MEMORIZE it, and cast it on the nearby Ice Monster, thereby creating a tasty snack. In general, a character cannot add spells to his spellbook unless they are in his 'Knowable' list


During the 'Character Creation Process we call these Hooks so that you, the Designer, can modify the character being created. Later in the game these Hooks are called when a character increases his level and might be eligible to add spells his list of 'Knowable' spells.








Hook – “KnowableSpells”

This hook is called when the player is asked to select the initial spell complement for a newly created character or when the character increases his level and might be eligible to add spell to his list of 'Knowable' spells.

Search Order

  1. The character's class

  2. The spell

Context

  1. Class of created character

  2. The spell

  3. The character

Parameters



This hook is called for every defined spell. That can be a lot of spells so you probably don't want your scripts to be very long.



First we call the 'Class' scripts. If the result is an empty string then we call any 'Spell' scripts.

The final script result is examined and if it is non-empty then it is used as the percentage chance of success. For example, if the result is “85”, then the spell acquisition will succeed 85 times out of 100. Your script should probably contain something like this:



if ( hookParameter[8] > hookParameter[7] ) probability = 100



If the final result is empty, then the chance of success will be 100 percent.

If the final result is zero, then the spell is not displayed.



Hook – “KnowableSpellsMinMax”

This hook is called when the player is asked to select the initial spell complement for a newly created character or when a character gains an additional level and has the opportunity to know additional spells.

Search Order

  1. The character's class

Context

  1. Class of created character

  2. The character

Parameters



This hook is called to determine the minimum number and maximum number of spells that the character can learn at each spell level and the number of spells that the character can learn at each spell level with a probability of 100 percent.



The hook should supply a result in hook parameters [7], [8], and [9]. Hook parameter [7] is initially set to 3 and should be modified to the desired minimum. Hook parameter [8] is initially set to 5 and should be modified to the desired maximum. Hook parameter [9] is initially set to 1 and should be modified to the desired number of spell that the character can acquire with 100 percent probability (called the 'certainty').



First we call the 'Class' scripts and use the (possibly modified) hook parameters. The final results will be limited to reasonable integers:



maximum = max(maximum, 0)

minimum = max(minimum, 0)

certainty = min (certainty, 0)

certainty = max(certainty, 100)

and the maximum will be limited so that it is not less than the minimum:

maximum = max(maximum, minimum)



The spells are presented to the player in passes (simplified a little bit):

  1. The player can select up to maximum number of spells but cannot select the same spell twice. If he attempts to select a spell and fails, the spell is no longer available for selection.

  2. If the player has acquired fewer than minimum spells at any level then all the remaining spells at that level are again made available and the player can continue to select spells until he has the minimum. Again, he cannot select the same spell twice and any spell that he selects and fails to acquire is removed from the list of available spells.

  3. Repeat step 2 until the player has selected minimum spells at every level.