Jump to content

BG2 Modder Resource - Effect Batch Macros


Recommended Posts

The BG2 Fixpack uses a number of macros for so-called immunity batch patching; for example, an item that provides immunity to hold is also supposed to block combat feedback that says 'Held' as well as the hold portrait icons and the spinny-head animation that plays on held creatures. I posted a lot of details on this before, but v11 has completely re-done how these are handled, added some additional batches out of the gate, and makes the process a lot more extensible. The old post should be considered deprecated as of this posting.

The current library can be found in the current Github repo of the BG2 Fixpack, specifically here (raw). Active development is on the v11 branch, which will eventually become the master. For now, the most updated library is the linked v11 library.

Despite the backend changes, all of the macros work in the same fashion as they did before. They will search through the effects on the target resource, find the relevant one, and then clone that effect into a full-fledged immunity. For example, the cd_immunity_charm macro will find the immunity to charm effect (opcode 101 with parameter2 equal to 5) and then duplicate that effect into everything that charm immunity should provide: prevent the portrait icons for charm, dire charm, and domination; prevent the strings 'Charmed', 'Dire Charmed', and 'Dominated'; prevent the visual effect spnwchrm.vvc; and display the mind shield portrait icon. Since these effects get cloned from the main immunity their timing, power, duration, saves, susceptibility to dispel/bypass magic resistance, targeting, etc. will match the original immunity. Because of this, any errors in the original immunity will be propagated into the other effects, so double-check your original effect before you run these macros.

These effects will only be added if they don't exist already, and some effects are ignored in special cases (i.e. only joinable NPCs have their portrait icons exposed, so monster weapons that can't drop don't care about preventing, removing, and/or setting portrait icons). While most of these address immunities, there are some other goodies included.

These macros can be used in two ways--you could include the library with your mod and then apply these as the mod gets installed, or you could run these on your mod items and use the now-patched files, eliminating the need for inclusion of the library with your mod. In both cases you'll need to at least include the effect that the macro needs to use as a key, e.g. running the Immunity to Sleep routine on an item/spell/creature won't do anything if an immunity to sleep effect is not already present. These macros are relevant for BG2, Tutu, BGT, and BG2EE games. A typical usage would be something like:

INCLUDE ~MyMod/lib/bg2fp_effect_batches.tpa~

COPY ~MyMod/itm/item1.itm~ ~override~
  LPF cd_apply_batch STR_VAR array_name = cd_immunity_confusion_arrays END // rounds out confusion protection

The function used is always cd_apply_batch (save for elven sleep/charm resistance, see below); what differentiates the process is the set of arrays referenced in array_name. Technical details, as well as how to create and use your own arrays to make your own batch patches, follow in the next post.

 

Free Action - cd_immunity_free_action_arrays
Free action is complicated in the best of circumstances, requiring about 50 effects or so to get right. This macro keys off of an immunity to haste, slow, paralyzation, movement rate change, entangle, web, grease, or hold and will turn them into full blown free action: immunities to all of the above, curing existing hold/paralyzation/etc. and their related portrait icons, setting movement to normal, and adding a free action icon. Always follow this with the immunity arrays for Entangle, Grease, Haste, Hold, Slow, and Web. If the Fixpack's OBC 'Change Free Action to Protect Against Stun' component is installed, this will also extend free action to prevent stun and rshould be followed with the Immunity - Stun array. Otherwise, stun immunity will be removed.

 

Full Blindness - cd_full_blindness_opcode_arrays, cd_full_blindness_eff_arrays

These arrays turns an item or spell with a blindness effect into full blindness by also causing the blinded portrait icon and the 'blinded' string. For spells which cause blindness with blind.eff via opcode 177 (e.g. Holy Smite), use cd_full_blindness_eff_arrays instead.

 

Full Dispel Magic - cd_full_dispel_arrays or cd_full_dispel_novis_arrays

Items and spells that dispel magic often miss many of the subsidiary effects. This will key off of a dispel magic effect (opcode 58) and add cures for feeblemind and deafness, destruction of illusionary creatures, and will purge all of the redundant magical weapon destruction codes (these are destroyed by the main dispel effect). The regular variant of the array will also provide a 'Dispel Effects' string and the normal animation; for spells such as dead magic zones where you don't want graphics and strings repeating endlessly, the novis variant will do everything the main variant does sans the string and animation.

 

Full Stun - cd_full_stun_arrays

These arrays key off of a stun effect on an item or spell and add the stun portrait icon and the 'Stunned' string.

 

Immunity to Blindness - cd_immunity_blindness_arrays

This will key off of an immunity to the blindness effect and prevent the blind icon as well as the 'Blind' and 'Blinded' strings.

 

Immunity to Charm - cd_immunity_charm_arrays

This will key off of an immunity to the charm effect and prevent charm, dire charm, and dominated icons; prevent 'Charmed', 'Dire Charmed', and 'Dominated' strings; prevent the common charm visual spnwchrm.vvc; and add a mind shield portrait icon.

 

Immunity to Confusion - cd_immunity_confusion_arrays

This will key off of an immunity to the confusion effect and prevent rigid thinking, confused, and chaos icons; prevent 'Confused' and 'Rigid Thinking' strings; and prevent the common charm visual spconfus.vvc.

 

Immunity to Deafness - cd_immunity_deafness_arrays

This will key off of an immunity to the deafness effect and prevent the deaf icon as well as the 'Deaf' string.

 

Immunity to Disease, Poison, and Poison Damage - cd_immunity_disease_arrays, cd_immunity_poison_arrays, cd_immunity_poison_resistance_arrays (respectively)

These three are listed together since there is an unfortunate amount of overlap between disease and poison. There are both poison (25) and disease (78) opcodes that provide damage over time, but there are also ways to inflict poison-type damage. As such, these three are meant to provide for three circumstances: something that protects against disease should just use cd_immunity_disease_arrays, which will turn immunity to the disease opcode (78) into protection from the disease icon as well as the 'Diseased' and 'Stricken by a foul disease' strings. Items that just protect against poison (i.e. the Periapt of Proof against Poison) should just use cd_immunity_poison_arrays, which keys off an immunity to poison and prevents the poison and bleeding icons, prevents the 'Poison' and 'Poisoned' strings, and uses the protection from poison icon. Items which protect against both disease and poison, such as the Ring of Gaxx, should run all three macros. cd_immunity_poison_resistance_arrays simply adds 100% reduction from poison damage, but only if the item/spell/creature already has immunities to both disease (78) and poison (25).

Immunity to Entangle - cd_immunity_entangle_arrays
This will key off of an immunity to the entangle effect and prevent the entangled icon. Since entanglement spells typically provide subsidiary penalties (i.e. movement rates and AC penalties) most entangle spells are explicitly blocked--otherwise the target would get immunity to entangle, but still get other penalties.

 

Immunity to Fear - cd_immunity_fear_arrays

This will key off of an immunity to either horror (24), morale modifier (23), or morale break modifier (106). It will add immunities to all three of these as well as curing existing fear, prevent and remove the panic icon, display the resist fear icon, disable the 'Panic' string, prevent the horror spinny-head animation, and reset morale.

 

Immunity to Feeblemind - cd_immunity_feeblemind_arrays

This will simply prevent the feeblemind icon if an immunity to the feeblemind effect is found.

 

Immunity to Grease - cd_immunity_grease_arrays

This will simply prevent the grease icon if an immunity to the grease effect is found.

 

Immunity to Haste - cd_immunity_haste_arrays

This will key off an immunity to the haste effect and will prevent the 'Hasted' string as well as the haste icon. Since most haste spells include other effects (i.e. fatigue), explicit spell protections against common haste spells are also added.

 

Immunity to Hold - cd_immunity_hold_special_arrays or cd_immunity_hold_arrays

Run these two arrays in tandem, the special array preceding the regular one. This will turn an immunity to one of the three hold effects (109, 175, or 185) into full-blown immunity. The macro will add immunities to hold (175) and paralyze (109); however, if there is not already an immunity to opcode 185 (special hold) one will not be added. Opcode 185 is generally used by spells for special situations and spells/items/creatures should, in general, not be immune. The macro will also prevent the hold icon, prevent the 'Held' string, and disable two common animations for hold effects, spmindat.vvc and spflayer.vvc.

 

Immunity to Invisibility - cd_immunity_invisibility_arrays

This will simply prevent the 'Invisible' string if an immunity to invisibility effect is found.

 

Immunity to Invisibility Detection - cd_immunity_invisible_detection_arrays

This will simply prevent the 'Dispel Invisible' string if an immunity to detect invisibility effect is found. This will help prevent invisible creatures used for various hacks and other tomfoolery from revealing themselves.

 

Immunity to Kill Target - cd_immunity_kill_target_arrays

This will simply prevent the 'Vorpal Hit', 'Death', and 'Undead Destroyed' strings if an immunity to kill target (13) effect is found. Immunity to the slay effect (55) is handled by cd_immunity_slay_arrays instead.

 

Immunity to Level Drain - cd_immunity_level_drain_arrays

This will key off an an immunity to level drain effect and prevent the level drain icon, display a negative plane protection icon, and prevent the strings 'One Level Drained', 'Two Levels Drained', 'Three Levels Drained', 'Four Levels Drained', and 'Five Levels Drained'.

 

Immunity to Petrification - cd_immunity_petrification_arrays

This will simply prevent the 'Petrified' string if an immunity to petrification (134) effect is found. Note that paralyze (109) is handled by cd_immunity_hold_arrays.

 

Immunity to Psionics - cd_immunity_psionics_arrays

This macro will key off of an explicit immunity to any of the 17 psionic spells in BG2 and make sure that all 17 are covered: spin542 (psionic disintegrate), spin543 (psionic inflict pain), spin544 (psionic superior invisibility), spin545 (psionic life drain), spin546 (psionic inertial barrier), spin547 (psionic project force), spin774 (psionic maze), spin775 (psionic mind blast), spin804 (psionic emotion: kill), spin834 (psionic blast), spin909 (psionic ego whip), spin910 (psionic domination), spin911 (psionic ballistic), spin912 (psionic detonate), spin959 (ulitharid psionic blast), spin974 (psionic blast), and spin975 (mind flayer domination). There is one special psionic (spin727) that is used to provide a warning in the BG2 sewers that is excluded from protection.

 

Immunity to Polymorph - cd_immunity_polymorph_arrays

This will add explicit protections from Polymorph Other, Sphere of Chaos, and wild surge: polymorph to any immunity to polymorph effects.

 

Immunity to Silence - cd_immunity_silence_arrays

This macro will key off an immunity to silence and prevent the silenced icon as well as the 'Silence' and 'Silenced' strings.

 

Immunity to Slay - cd_immunity_slay_arrays

This will simply prevent the dying icon if an immunity to slay (55) effect is found. Immunity to the kill effect (13) is handled by cd_immunity_kill_target_arrays instead.

 

Immunity to Sleep - cd_immunity_sleep_arrays

This will key off of an immunity to either sleep (39) or the power word: sleep (217) opcodes. It will provide immunity to both as well as preventing the sleep icon and the 'Sleep' string.

 

Immunity to Slow - cd_immunity_slow_arrays

This will key off an immunity to the slow effect and will prevent the slow icon. Since slow is generally accompanied by a lot of related effects, explicit immunities to common slow spells are also included.

 

Immunity to Spell Level - cd_immunity_spell_level_1_arrays through cd_immunity_spell_level_9_arrays

Broken out as nine arrays, these will detect any sort of immunity to spell levels and add all relevant protections by level. This mainly addresses area-of-effect spells which typically bypass these immunities (skull trap working against globes of invulnerability is probably the best-known example of this) by adding explicit immunities to these spells. The level 4 array is currently empty but can be run anyway.

 

Immunity to Spell School - cd_immunity_abjuration, cd_immunity_alteration, cd_immunity_conjuration, cd_immunity_evocation, cd_immunity_necromancy

Similar to the Immunity to Spell Level, above, these eight arrays will detect an immunity to a specific spell school and add explicit protections from area-of-effect spells in that school. Since there are no spells in their schools which fall into this category cd_immunity_divination, cd_immunity_enchantment, and cd_immunity_illusion are not enabled.

 

Immunity to Stun - cd_immunity_stun_arrays

This will key off an immunity to stun (45) or power word: stun (210). It will prevent both opcodes as well as prevent the stun icon and the 'Stun' and 'Stunned' strings.

 

Immunity to Web - cd_immunity_web_arrays

This will key off an immunity to web and will prevent the webbed icon and the 'Held' string. Since web generally uses the paralyze opcode (109) to freeze its target, immunity to paralyze is also added.

 

Remove Fear - cd_fear_removal_arrays

This removes all effects of fear, but does not provide an ongoing immunity to fear effects. This macro keys off of an effect with opcode 161 (fear removal) and adds a removal of the panic icon. On EE games, this macro will also add explicit removal of the Horror spell (spin105 and spwi205) to remove the spinny-head animation. For immunity to fear, use cd_immunity_fear_arrays instead.

 

Transformation Arrays - cd_spell_transformation_arrays and cd_spell_transformation_human_arrays

For shapeshifting abilities, such as a druid's innate shifts or those provided through spells such as Polymorph Self or Shape Change, many actions are required to keep cruft from previous transformation from accruing. Both arrays will clear out all abilities from previous polymorphs (allowing you to add the new ones without interference). The return-to-human arrays (cd_spell_transformation_human_arrays) also clear out any special paws as well as restoring all of the normal buttons (talk, spellcasting, etc.) that shifting back to human provides.

 

Elven Sleep/Charm Resistance - cd_elven_sleep_charm_resistance function

Unlike the other arrays listed here, this one is a standalone function and is invoked as so:

COPY ~MyMod/itm/MyItem.itm~ ~override~
  LPF cd_elven_sleep_charm_resistance END

This one is different from the rest in that it should only be run on items or spells which cause sleep or charm effects, and only ones to which (half-)elves should resist. This will add all of the effects needed to allow elves (90%) and half-elves (30%) their normal chance to resist charm or sleep. It will detect the sleep or charm effect and add effects to call the relevant EFFs, adjusted for the probabilities and targeting of the underlying charm/sleep effect. Please note that, while the effects are added, they will not actually provide immunity for elves and half-elves unless another source, such as the BG2 Fixpack, provides the EFF files. (You are welcome, of course, to include the EFF files in your own mod--grab all of the cdelfxxx.eff files from the bg2fixpack/copy folder.)

Link to comment

OK, so the technical details and how to make your own batches. The cd_apply_batch function requires a macro name. That macro, in turn, needs to define three arrays for the function:

cd_immunity_batches_key
If any effect in this array is present on the item/creature/spell being patched, it will proceed with adding extra effects and deleting effects, as defined by the next two arrays. If you have multiple effects defined here, you can require that all or just one of them need to be matched (see all_or, below).

cd_immunity_batches_extras
This array contains all of the subsidiary effects that should accompany the effects in the key area.

cd_immunity_batches_deletes
If the keys are matched correctly, any effect matching this array will be deleted. For example, Free Action, if detected correctly, will delete immunity to stun and its associated effects.

If the key is found and matched, the function will then proceed back through the file being patched and add--if they are not present--all of the effects not found in the _key and _extras arrays. It will also, only with a key effect matched, delete any effects listed in the _deletes array. Here's a very simple example, the Immunity to Grease arrays:

DEFINE_PATCH_MACRO ~cd_immunity_grease_arrays~ BEGIN
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_key BEGIN
    101,  "-10", 158, "same",  "-10",  "-10", "same" => 1 // immunity to grease
  END
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_extras BEGIN END // nothing w/o cosmetic
  PATCH_IF cosmetic = 1 BEGIN
    DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_extras BEGIN
      169, "-10", 145, "same", "-10", "-10", "same" => 1 // prevent grease icon
    END
  END
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_delete BEGIN END // nothing to delete
END

A note on how to read these:

  • Format of all arrays are opcode, parameter1, parameter2, resref, timing, duration, order placement (same, first, or last).
  • Timing, duration, and order placement are only used for new effect writes, not for matching.
  • Use -10 in a field (or "same" in string fields) if the match value for that field doesn't matter.
  • Always map the effect to one (=> 1)

In this case, the function looks for just one key:

101,  "-10", 158, "same",  "-10",  "-10", "same" => 1 // immunity to grease

...an effect with opcode 101 and parameter2 set to 158, aka immunity to grease. None of the other parameters on the effect matter since they're all set to -10/same. If that key is found, then the effects from cd_immunity_batches_extras get added (in this case, it's empty unless cosmetic = 1) and the effects from cd_immunity_batches_delete get deleted.

Note that since it's a macro, you can conditionally define your arrays, like the grease icon being keyed off cosmetic = 1 above. The free action batch will remove stun immunity unless a particular component from the Fixpack is installed. The Fixpack has all kinds of examples for perusal of different scenarios.

 

The actual cd_apply_batch function also has some built-in functionality you can use. All built-in variables are:

 

debug (integer, default 0)

A value of 1 will spit out a list via PATCH_PRINT of resources that were altered by the macro (preformatted to conveniently drop directly into a COPY_EXISTING), which is useful for narrowing your scope when using this in a COPY_EXISTING_REGEXP. A value of 2 will output the same plus some more info (how many effects added/deleted), and 3 will provide the same as 2 but will also provide feedback as the function processes.

 

force_cosmetic (integer, default -1)

A value of 0 or 1 can be used to override the natural setting of the cosmetic variable. cosmetic is an internal variable, set to 1 for all spells, droppable items, and joinable NPCs. Fixpack, in turn, uses it to add cosmetic effects (pretty much anything to do with portrait icons) to the arrays as needed. From the Immunity to Grease example, above, the grease portrait icon is only prevented when cosmetic is set to 1. The plyspid.itm patch in Fixpack is an example where force_cosmetic is utilized, as are the patches to Imoen's Belt.

bonus_var_1, bonus_var_2, bonus_var_3 (integer, default -1)
If you wanted to set variable just during one instance of the function, three are available to be passed on to your array sets.

 

array_name (string, default "same")

The name of the macro that defines your cd_immunity_batches_key, cd_immunity_batches_extras and cd_immunity_batches_deletes arrays.

all_or (string, default "or")

Your _key array will normally proceed through the _extras and _deletes arrays if just one key is found (1 or 2 or ... X). By setting this to "all" instead, all effects listed in keys must be found for the _extras and _deletes to be processed (1 and 2 and ... X).

Link to comment

Real nice work, I integrated them into my custom item pack right away. Well, currently there are only two items that use them, my Green Dragon Scale (poison immunity) and my Mutamin's Cloak (prevents petrification), but I am adding a couple more. Currently working out the details of the Cloak of Arachnida. :-)

Link to comment

At a quick scan I couldn't determine was it the second, forth, first or the third link you got there that goes to the actual resource... could you "fix" that ... I know I am lazy for not actually reading the text, but.

:crazy::laugh::devlook::evilplan:

The point being that setting the resource above from the talk might be useful, as using it for the first will be harder than say the twentieth time .. there you just need a quick link, and onwards and down you go.

Edited by Jarno Mikkola
Link to comment

I'm having an issue with cd_spell_transformation_human_arrays. I'm creating a priest spell that polymorphs the caster into a shambling mound. The spell disables casting, but grants an innate that ends the spell, transforming the caster back into their original form and gives them back their casting ability. I'm running the macro as I create the innate from SPIN124. I notice that, helpfully, the macro creates a number of 279 effects. However, when I install it in BG2EE, the resource contains SPWI491. Unaltered, the innate does not re-enable casting for characters using my spell. I notice that if I remove SPWI491 from the resource, the innate re-enables the correct buttons.

At first I thought that the effect will only re-enable button use if it was removed by the spell in the resource key. However, when I clone the 279 effects and put my own spell in the resource key, it still does not work. I might be doing something wrong, or there might be something else going on, but I figured I would bring it up in case it is a real issue.

Edited by Grammarsalad
Link to comment

I'm having an issue with cd_spell_transformation_human_arrays. I'm creating a priest spell that polymorphs the caster into a shambling mound. The spell disables casting, but grants an innate that ends the spell, transforming the caster back into their original form and gives them back their casting ability. I'm running the macro as I create the innate from SPIN124. I notice that, helpfully, the macro creates a number of 279 effects. However, when I install it in BG2EE, the resource contains SPWI491. Unaltered, the innate does not re-enable casting for characters using my spell. I notice that if I remove SPWI491 from the resource, the innate re-enables the correct buttons.

 

At first I thought that the effect will only re-enable button use if it was removed by the spell in the resource key. However, when I clone the 279 effects and put my own spell in the resource key, it still does not work. I might be doing something wrong, or there might be something else going on, but I figured I would bring it up in case it is a real issue.

I'm not sure I completely follow. If it's for the shift into shambling mound, you want cd_spell_transformation_arrays instead. The only thing that should always be done in the shift away from human form is clearing out the abilities from other transformations, and that includes spwi491 and other return-to-human abilities. If you don't clear them out before granting a new one, you'll have them accumulating, like the old bug with the ranger tracking ability. Just make sure the granting of the return-to-human innate is the last effect.

Link to comment

 

I'm having an issue with cd_spell_transformation_human_arrays.

Let us see your code and sort it out ... we can't help you if you don't give us things to see with our eyes.

Sure...

 

 

 

I'm having an issue with cd_spell_transformation_human_arrays. I'm creating a priest spell that polymorphs the caster into a shambling mound. The spell disables casting, but grants an innate that ends the spell, transforming the caster back into their original form and gives them back their casting ability. I'm running the macro as I create the innate from SPIN124. I notice that, helpfully, the macro creates a number of 279 effects. However, when I install it in BG2EE, the resource contains SPWI491. Unaltered, the innate does not re-enable casting for characters using my spell. I notice that if I remove SPWI491 from the resource, the innate re-enables the correct buttons.

 

At first I thought that the effect will only re-enable button use if it was removed by the spell in the resource key. However, when I clone the 279 effects and put my own spell in the resource key, it still does not work. I might be doing something wrong, or there might be something else going on, but I figured I would bring it up in case it is a real issue.

I'm not sure I completely follow. If it's for the shift into shambling mound, you want cd_spell_transformation_arrays instead. The only thing that should always be done in the shift away from human form is clearing out the abilities from other transformations, and that includes spwi491 and other return-to-human abilities. If you don't clear them out before granting a new one, you'll have them accumulating, like the old bug with the ranger tracking ability. Just make sure the granting of the return-to-human innate is the last effect.

Sorry if I'm unclear. The spell is similar to druid shape change in that it gives the character an innate to end the spell early if they like (regaining the use of their spell buttons via 279)

 

This is the relevant code:

 

//cancel innate
COPY_EXISTING ~SPIN124.spl~ ~override/%spell_res%A.spl~
  LPF cd_apply_batch STR_VAR array_name = cd_spell_transformation_human_arrays END //
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END  //removes my spell
  LPF ALTER_EFFECT INT_VAR match_opcode = 279 STR_VAR match_resource = ~SPWI491~ resource = EVAL ~~ END  //These are 279 effects created by the macro.  I have to clear out the resource for them to work.
I have to do that last ALTER_EFFECT because, while the macro creates the 279 effects, it puts SPWI491 in the resource key (and so, the effect doesn't work for my innate--i.e. button use is not restored with SPWI491 in the resource key but button use is restored once I clear it)

 

This is the entire spell if its important:

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//____________________________________________________________Nature's Wrath____________________________________________________________________________//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//Projectile
//VVC
//bam
//animations
//3d animation
//cre
COPY ~Spells/data/new_spells/priest_6/SMOUNDSU.cre~ ~override~   //adds resistances (which, apparently, are only in IWDEE???)
        SAY NAME1 @73700002
        SAY NAME2 @73700002
//sounds
COPY ~spells/spheres/spells/death/#EFF_P04.wav~ ~override~ //
//effs
//itm
COPY ~Spells/data/new_spells/priest_6/B4-32M3.itm~ ~override~   //
    LPF cd_apply_batch STR_VAR array_name = cd_immunity_free_action_arrays END
//itm bam
COPY ~Spells/data/new_spells/priest_6/ISHAPE07.BAM~ ~override~   //
//eff for text notification
COPY ~Spells/data/new_spells/priest_6/B4-32M3.eff~ ~override~   //
  SAY 0x1c @73700003   //Entangled Notification
//Spell itself
ADD_SPELL ~Spells/data/new_spells/priest_6/b_Pr601.spl~ 1 6 ~CLERIC_NATURES_WRATH~ //
        SAY NAME1 @51401
        SAY NAME2 @51401
        SAY UNIDENTIFIED_DESC @51402
SAY DESC @51402


//to clear earlier versions of the spell
LAF RES_NUM_OF_SPELL_NAME
  STR_VAR spell_name = ~CLERIC_NATURES_WRATH~
  RET spell_res
END
COPY_EXISTING ~%spell_res%.spl~ ~override~
  LPF CLONE_EFFECT
      INT_VAR match_opcode = 172 STR_VAR match_resource = ~B_PR601~ resource = EVAL ~%spell_res%A~ END
  LPF ALTER_EFFECT
      INT_VAR match_opcode = 172 STR_VAR match_resource = ~B_PR601~ resource = EVAL ~%spell_res%~ END
  LPF ALTER_EFFECT
      INT_VAR match_opcode = 171 STR_VAR resource = EVAL ~%spell_res%A~ END
//Just in case
LPF cd_apply_batch STR_VAR array_name = cd_spell_transformation_arrays END


//add icons and projectile


/* NEED TO CREATE UNIQUE SPELL ICON
COPY_EXISTING ~%spell_res%.spl~ ~override~
  LPF ALTER_SPELL_HEADER INT_VAR STR_VAR icon = EVAL  ~%spell_res%B~ END
COPY ~spells/spheres/spells/charm/b_c201a.bam~ ~override/%spell_res%a.bam~
COPY ~spells/spheres/spells/charm/b_c201b.bam~ ~override/%spell_res%b.bam~
COPY ~spells/spheres/spells/charm/b_c201c.bam~ ~override/%spell_res%c.bam~
//add bams to spl
COPY_EXISTING ~%spell_res%.spl~ ~override~
  WRITE_EVALUATED_ASCII 0x003a ~%spell_res%C~
*/
//cancel ability
COPY_EXISTING ~SPIN124.spl~ ~override/%spell_res%A.spl~
  LPF cd_apply_batch STR_VAR array_name = cd_spell_transformation_human_arrays END //
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END  //
  LPF ALTER_EFFECT INT_VAR match_opcode = 279 STR_VAR match_resource = ~SPWI491~ resource = EVAL ~~ END  //


//Other polymorphy spells...
ACTION_IF FILE_EXISTS_IN_GAME ~spinhum.spl~ BEGIN
COPY_EXISTING ~spinhum.spl~ ~override~
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%A~ END
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END
END
ACTION_IF FILE_EXISTS_IN_GAME ~spwi491.spl~ BEGIN
COPY_EXISTING ~spwi491.spl~ ~override~
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%A~ END
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END
END
ACTION_IF FILE_EXISTS_IN_GAME ~spin122.spl~ BEGIN
COPY_EXISTING ~spin122.spl~ ~override~
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%A~ END
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END
END
ACTION_IF FILE_EXISTS_IN_GAME ~spin123.spl~ BEGIN
COPY_EXISTING ~spin123.spl~ ~override~
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%A~ END
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END
END
ACTION_IF FILE_EXISTS_IN_GAME ~spin124.spl~ BEGIN
COPY_EXISTING ~spin124.spl~ ~override~
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%A~ END
  LPF CLONE_EFFECT INT_VAR match_opcode = 172 multi_match = 1 STR_VAR resource = EVAL ~%spell_res%~ END
END
//finally, polymorph immunity (other possible created spells)
INCLUDE ~spells/lib/poly_list.tpa~
Edited by Grammarsalad
Link to comment

Ah, I get it now. It's cloning the removal (172) of spwi491, so that gets left over as cruft in the resulting 279s it generates. In turn, that makes the 279 opcodes fail outright. Adjust the arrays as follows:

// human transform array - clears out special abilities from all forms
DEFINE_PATCH_MACRO ~cd_spell_transformation_human_arrays~ BEGIN
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_key BEGIN
    279, "-10",     7,        "", 1, 0, "same" => 1 // enable talk button
    279, "-10",     2,        "", 1, 0, "same" => 1 // enable select spell button
    279, "-10",     3,        "", 1, 0, "same" => 1 // enable quick spell 1 button
    279, "-10",     4,        "", 1, 0, "same" => 1 // enable quick spell 2 button
    279, "-10",     5,        "", 1, 0, "same" => 1 // enable quick spell 3 button
    172, "-10", "-10", "spin160", 1, 0, "same" => 3 // remove spell x3
    172, "-10", "-10", "spinhum", 1, 0, "same" => 1 // remove spell
    172, "-10", "-10", "spwi491", 1, 0, "same" => 1 // remove spell
    172, "-10", "-10", "spin122", 1, 0, "same" => 1 // remove spell
    172, "-10", "-10", "spin123", 1, 0, "same" => 1 // remove spell
    172, "-10", "-10", "spin124", 1, 0, "same" => 1 // remove spell
  END
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_extras BEGIN
    111, "-10", "-10", "wolfm", 0, 0, "first" => 1 // add item
    112, "-10", "-10", "wolfm", 1, 0, "last"  => 1 // remove item
  END
  DEFINE_ASSOCIATIVE_ARRAY cd_immunity_batches_delete BEGIN
    112, "-10", "-10", "same", "-10", "-10", "same" => 1 // remove spell
  END
END

I've swapped "same" for "" in the resource field of the 279s. This should force the macro to clear those fields when it generates the 279s.

Link to comment

Cool. Thanks!

Edit:

Another bonus: that helped me to understand the function a little better. I was messing with the second "same" but it looks like that is for effect location.

 

Edit2: of course, i would have got that had i actually read the second post! :p

Edited by Grammarsalad
Link to comment

A bit off-topic, but, might it not be better to code some of the transformation's effects (disabled casting, stat bonuses, the like) as equipping effects in the claw/fist item? Then all the "return to human form" ability has to do is, shapeshift human + remove claw/fist.

That can be done with this code. I've been fiddling with it for the last few days. Good Fun! I'm rewriting a lot of my spell stuff around this (as i slowly eeify it). I'll upload the results on github when it's in a presentable state

 

Edit: i really like this idea. It seems 'cleaner'. I think I'm going to use it

Edited by Grammarsalad
Link to comment

A bit off-topic, but, might it not be better to code some of the transformation's effects (disabled casting, stat bonuses, the like) as equipping effects in the claw/fist item? Then all the "return to human form" ability has to do is, shapeshift human + remove claw/fist.

For new spells, yes, it's easier to tie as many effects as possible to the paw. However, even if you update the existing 'legacy' polymorphs to also use paws you're still going to need most of the effects from the array. You can't tie adding/removing abilities to the paw, for example, but you could tie in the button disables. Most of the complications from polymorphing come when you start mixing and matching between the spells, which is why it's always good to have as much of a reset as possible with the spells.

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...