Jump to content


Photo

BG2 modder resource - providing immunities, elven sleep/charm resistance, and more


7 replies to this topic

#1 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9015 posts
  • Gender:Not Telling

Posted 01 August 2013 - 07:20 AM

Attached to this post is a collection of macros, developed primarily for the BG2 Fixpack, to assist modders with item/spell/creature development. These were originally developed to fix a number of resources in the game that provided incomplete immunities--e.g. an item that provided immunity to sleep wouldn't prevent a sleep portrait icon, or a free action item would still allow strings such as 'held' to be applied. The macros are written such that you apply them to an item, creature, or spell and the macro will detect and adjust its patching accordingly.

All of the macros work in the same fashion. 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 cd_immunity_sleep 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 (once released) BG2EE games. A typical usage would be something like:

INCLUDE ~MyMod/lib/bg2fp_effect_batches.tpa~

COPY ~MyMod/itm/item1.itm~ ~override~
  LAUNCH_PATCH_MACRO ~cd_immunity_confusion~

Finally, the macro listing, and what existing effects they key off of:

cd_elven_sleep_charm
This one is different from the rest in that it should only be run on items or spells which cause sleep or charm effects. 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.)

cd_fear_removal
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, see the cd_immunity_fear macro below.

cd_full_blindness
This macro turns a blindness effect into full blindness by adding the blinded portrait icon and displays the 'blinded' string.

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

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

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

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

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

cd_immunity_disease
cd_immunity_poison
cd_immunity_poison_resistance

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 the cd_immunity_disease macro, which will turn immunity to the disease opcode (78) into protection from the nauseated 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 the cd_immunity_poison macro, 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. The cd_immunity_poison_resistance simply adds 100% reduction from poison damage, but only if the item/spell/creature already has immunities to both disease (78) and poison (25).

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

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

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

cd_immunity_free_action
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. This macro, in turn, will cycle through other relevant macros to fully flesh out its effects: cd_immunity_entangle, cd_immunity_grease, cd_immunity_haste, cd_immunity_hold, cd_immunity_slow, and cd_immunity_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 run the cd_immunity_stun macro. Otherwise, stun immunity will be removed.

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

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

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

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

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

cd_immunity_kill_target
This will simply prevent the 'Vorpal Hit' and 'Death' strings if an immunity to kill target (13) effect is found. Immunity to the slay effect (55) is handled by the cd_immunity_slay macro.

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

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

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

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

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

cd_immunity_slay
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 the cd_immunity_kill_target macro.

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

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

cd_immunity_spell_level
This is a very broad macro. It will detect any sort of immunity to spell levels and add all relevant protections by level, so you could run this against an item that provides immunity to 1st level spells as well as something like globe of invulnerability and both will be patched correctly. 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.

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

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

Attached Files


Edited by CamDawg, 01 August 2013 - 11:11 AM.
typos

I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#2 lynx

lynx
  • Modders
  • 2864 posts
  • Gender:Male
  • Location:Ljubljana, Slovenija

Posted 01 August 2013 - 10:22 AM

Nice! Code reuse and consistency, yay.

This thread should be stickied.
GemRB - IE anywhere.
Mages needed! Looking for Planescape: Torment testers
Market android version IS NOT SUPPORTED ANYMORE: reported bugs will be ignored! Still looking for builders ...

#3 subtledoctor

subtledoctor
  • Modders
  • 1996 posts
  • Gender:Male

Posted 20 March 2016 - 06:25 PM

WOW.  Just stumbled on this while looking around for the best way to implement some immunity HLAs. 

 

Is this stuff more or less up-to-date?  Will this work with the newest versions of the EE games?  Can we simply make a spell with, say, Hold immunity and then just

COPY ~mymod/immunities/d5freeac.spl~ ~override~
   LPM cd_immunity_free_action

...instead of mucking around forever in NI?  Because, again... WOW.


Edited by subtledoctor, 20 March 2016 - 06:26 PM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#4 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 5974 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 20 March 2016 - 11:01 PM

Seems like it, you of course need to include the .tp2 into your files, but it's really easy.


Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.

Here's how to install all the stable mods you ever really could want to Infinity Engine games.


#5 subtledoctor

subtledoctor
  • Modders
  • 1996 posts
  • Gender:Male

Posted 21 March 2016 - 02:29 AM

Seems to be working, I'm just using it to create spells, then I'll ship the final result. This is phenomenally useful.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#6 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9015 posts
  • Gender:Not Telling

Posted 21 March 2016 - 05:24 AM

I think I've written cd_immunity_casting_failure since, and I suspect the elven charm/sleep resistance is missing PW: Sleep protection, but otherwise these should be good. I should probably externalize the string protections so that these can be run against IWDEE and BGEE as well.


I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#7 subtledoctor

subtledoctor
  • Modders
  • 1996 posts
  • Gender:Male

Posted 21 March 2016 - 03:01 PM

I should probably externalize the string protections so that these can be run against IWDEE and BGEE as well.

 

Oh, yeah, that's a good idea.  Good thing I'm doing HLAs, they only need strings for BG2 :)


Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#8 Angel

Angel
  • Members
  • 45 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 28 March 2016 - 02:09 AM

Very nice indeed, and I'm applying these to my own personal mod right now.





Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users