Jump to content

[code] Functions to extract effects to subspells, and rearrange effect blocks


DavidW

Recommended Posts

I've written two functions for the FP, both in %MOD_FOLDER%/lib/dw_functions.tph.

permute_effects is a patch function: here's its documentation.

Quote

For the current itm/spl file, take the effect stack for an ability
and permute the order of the effects. The permutation is controlled by
the string "permutation", which should be a comma-separated list of nonnegative integers.
If the list has N elements it should contain 0... N-1, in some order.

Assuming that the ability has at least that many effects, the first N will be permuted into
the order given by the permutation. (If not, we give a warning.)

'ability' determines which ability is permuted. (If ability=-1, we permute all abilities.)

extract_effects_as_subspell is an action function:

Quote

Take some subset of a spell or item's effects and extract them as a subspell.
Inputs: 'resource' (e.g., AX1H10.itm) is the spell/item to be edited.
'subspell' is the name of the subspell to be created. 'extract' is a comma-separated
list of nonnegative integers specifying which effects are to be extracted.

Effects extracted should all have the same probability, the same saving throw (if any)
and should not include damage with save-for-half.

On an item, the integer 'ability' indicates which ability is patched (0 by default). On a 
spell the default assumption is that the effect block is the same at every level, but if
you set keep_spell_levels=1, the effect blocks are extracted on a per-level basis.

If the 'subspell' spell already exists, it is not recreated. (So be careful if reusing to
make sure effects really are identical.)

Please use freely (and let me know if you find bugs; one of the reasons I code this way is so that the nastier bugs stay in central places and can be fixed centrally).

Link to comment
22 hours ago, DavidW said:

(and let me know if you find bugs; one of the reasons I code this way is so that the nastier bugs stay in central places and can be fixed centrally).

  • This should be WRITE_LONG
  • This should be WRITE_BYTE
    • Alternatively, leave it at zero/default (unlike ITM files, this field should be irrelevant for SPL files...)
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...