Dependencies: lib_2da, lib_anon, lib_array, lib_fn, lib_ids, lib_ini, lib_sfo, lib_struct, lib_sugar, lib_tools
Functions from unidentified sources: definalise_hidespl
Functions specifically aimed at editing .spl files.
spl_cd_scroll_name(spell_resref:s)=(scroll_resref:s) dimorphic
Given a (wizard or priest) spell resref, assign it Cam's standard scroll name, i.e. CDIDxyz for SPPRxyz, CDIAxyz for SPWIxyz
spl_copy(tv:i, allow_missing:b, debug:b=1, is_ids:b="-1", standard_icons:b=1, create_scroll:b=1, spl:s, path:s, location:s, locbase:s, source_path:s, source_location:s, source_locbase:s, icon_base_name:s, icon_path:s, icon_location:s, icon_locbase:s, edits:f)=(value:s, scroll:s, spell_resref:s, scroll_resref:s) action
General copier for spl files.
'spl' is a list of k=>v pairs. Each spell k.spl is copied to v.spl. source_path/source_location/source_locbase and path/location/locbase respectively define the locations of k.spl and v.spl, with an empty path interpreted as the override in both cases. (If k is missing, we whine unless allow_missing=1.) The function 'edits' is applied to each file during copy. You can use the anonymous function construct; if you do, the spl will be read into the struct 'm' beforehand and written back afterward.
Alternately, spl can be a list of strings k..., in which case k.spl is copied to k.spl as above.
If the dest file is an ids entry (determined heuristically unless is_ids is set) then we add it to spell.ids, use it as a resref,
add icons in the standard format (unless standard_icons=1) and (unless create_scroll=0) build a scroll. In this case, we use icon_path, icon_location, icon_locbase (if set)
to determine where the spell icons are, and copy them over if they're in the format
If tv=1, we prepend "_" onto each k and v on BGTUTU installs.
If debug=1, we try to debug the anonymous function to detect any nonexistent field writes.
Returns the resref of the last spell created (value; synonym:spell_resref), and its scroll (scroll; synonym:scroll_resref) if any. (Only really useful if you're copying to an ids, and only if you're only doing it once.)
spl_deabbreviate(spell:s)=(resref:s, type:s, level:s) dimorphic
Take either a spell resref, or a spell ids name, or an abbreviated spell ids name (without the WIZARD_/CLERIC_ prefix). Return the spell resref, the level, and the type (innate/priest/wizard)
spl_edit(tv:i, allow_missing:b, debug:b=1, edit_strrefs_in_place:b, spl:s, path:s, location:s, locbase:s, edits:s)=() action
General editor for spl files. spl is a list of resrefs, each with location defined by path/location/locbase, or in override/a game file if all are blank. Each is copied, and edits is applied as a patch function. You can use the anonymous function construct; if you do, the spl will be read into the struct 'm' beforehand and written back afterward.
If tv=1, we prepend "_" onto each k and v on BGTUTU installs.
If debug=1, we try to debug the anonymous function to detect any nonexistent field writes.
spl_enforce_school(preloaded:b, sounds_colors:b=1, struct:s, arguments:s)=(struct:a) dimorphic
Forces a spell to fit the rules for the specified school, or the current school if none is specified, adjusting casting colors, casting sounds, and for wizard spells, barred schools. Barred schools are read in from data_loc_shared/mageschools.tpa, or use the BG2/IWD defaults if it doesn't exist.
If preloaded=1, assume that the array 'unusable_array' already contains the unusuable spell types (good for batch application). If sounds_colors=0, don't do the sounds and colors.
Note that this also works on items (i.e., scrolls), though the sounds/colors bit is skipped.
spl_make(debug:b=1, is_ids:b="-1", standard_icons:b=1, create_scroll:b=1, spl:s, edits:f, location:s, locbase:s, path:s, icon_location:s, icon_locbase:s, icon_path:s, icon_base_name:s)=(value:s, scroll:s, spell_resref:s, scroll_resref:s) dimorphic
General maker for spl files.
We create a new spell 'spl'.spl, location specified by path/location/locbase, or 'override' if all are blank. The function 'edits' is applied to the file after creation. You can use the anonymous function construct; if you do, the spl will be read into the struct 'm' beforehand and written back afterward.
If spl is an ids entry (determined heuristically unless is_ids is set) then we add it to spell.ids, use it as a resref, add icons in the standard format (unless standard_icons=1) and (unless create_scroll=0) build a scroll.
If debug=1, we try to debug the anonymous function to detect any nonexistent field writes.
Returns the resref of the spell, and its scroll if any.
spl_make_scroll(price:i="-1", spell_resref:s, scroll_resref:s, icon:s="%spell_resref%A", name_function:s="spl_cd_scroll_name", price_table:s="MOD_FOLDER/sfo/data/scroll_prices.2da")=(scroll_resref:s) dimorphic
Given a (wizard or priest) spell, generate a scroll for that spell, using CamDawg's naming conventions by default
spl_make_summoning_2da(filename:s, monsters:s, anim_hit:s="msumm1h", anim_area:s="msumm1x")=() action
Given a list of monsters, a filename of a 2da (omitting '2da'), and an optional choice of anim_hit and anim_area animations (defaulting to 'msumm1h' and 'msumm1x'), make a standard-format summoning 2da
spl_remap_level_9_wizard_spells()=() action
Move the spells in the SPWI926-SPWI949 range into the SPWI0xyz range.
spl_resolve_ids(level:i="", ids:s, type:[wizard|priest|innate|class|1|2|3|4])=(resref:s) dimorphic
Given an ids entry (WIZARD_THIS_SPELL, etc) find its id number, if necessary adding it to spell.ids. Need to supply the spell type and the level.
spl_resref_to_type_level(resref:s)=(type:s, level:s) dimorphic
Take a spell resref of a spell in spell.ids. Return its type (priest/innate/class/wizard) and level (assuming it fits standard conventions, and using 1 for innate and class).
These should not be called from outside the library itself.
spl_free_ids_slot_for_l9_remap(start_slot:i=2050)=(value:s, ids:s) patch