# SpellFinder Methods to find and compare spell images - - - ## SpellFinder constants The spell icons come straight from the game cache. Every spellbook is an enum listing one item per spell, and each of those items carries the spell's name and icons as params: - `SPELLBOOK_ENUMS` are the enums of the standard, ancient, lunar and arceuus spellbooks. - `JEWELLERY_ENCHANT_ENUM` is the standard spellbook's jewellery enchantment menu, with the `Lvl-1` to `Lvl-7 Enchant` spells and its `Back` button. - `SPELL_NAME_PARAM` is the param holding the spell's name. - `SPELL_SPRITE_PARAMS` are the params holding the large and the small castable icon. - - - ## ESpell.Spellbook ```pascal function ESpell.Spellbook(): Integer; ``` Index of the spellbook `spell` belongs to in `SPELLBOOK_ENUMS`: `0` standard, `1` ancient, `2` lunar and `3` arceuus. `ESpell.UNKNOWN` gives `-1`. - - - ## ESpell.CacheName ```pascal function ESpell.CacheName(): String; ``` The spell's name the way the game cache has it, lowercased and without apostrophes or dashes so `Fenkenstrain's` and `Lvl-1` compare to `FENKENSTRAINS` and `LVL1`. - - - ## SpellFinder.Resolve ```pascal procedure TSpellFinder.Resolve(); ``` Internal method that reads every spellbook enum out of the cache and fills `SpriteIDs` with the icons of each {ref}`ESpell`, matched by name within its own spellbook. The ape atoll teleports of the standard and arceuus spellbooks share a name, which is why the spellbook matters. A spell the cache no longer has, like the removed `BOUNTY_TELEPORT`, is left at `-1`. It runs once, the first time a spell image is needed. - - - ## SpellFinder.GetImages ```pascal function TSpellFinder.GetImages(spell: ESpell): array [0..1] of TImage; ``` The large and the small icon of `spell`, as the magic tab draws them when the spell can be cast. They are read from the game cache the first time they are asked for and kept in memory after that. A spell the cache has no icons for gives `nil` images, which {ref}`SpellFinder.Find` skips.