Jump to content

SCS & classic BG2 & mod : miscellaneous issues


Recommended Posts

Hi DavidW,

first of all, Thanks for this amazing mod.

After installing, on my classic BG2 modded game, "Initialise AI components" I have 2 warnings (in addition those reported in iwdification thread): SCRL07.spl not patched (linked to Item Revision mod), SPPR616.spl not patched (linked to IWDification mod) and the hidespl.2da array is cleared from all spells.

After looking a little bit, I have found the following things:

  • SCRL07.spl: in initial.tpa there is a condition (IR (SCRL07.spl) or vanilla(SCRL07.itm)) but the fonction always patch the vanilla .itm : should have been "COPY_EXISTING ~%object%~ override" instead of "COPY_EXISTING SCRL07.itm override" (line 81)
  • SPPR616.spl (the entropy shield on my installation): after looking to the modification done by SCS, it seems that the function entropy_shield_abjuration and ds_make_detectable try to clone opcode=142... but this opcode does not exist in the spell from Iwdification... so it fails. Replacing the clone opcode=142 by another one from the spell or adding an opcode=142 to the spell will do the trick.
  • hidespl.2da: The installation of the boneguard modify the pre-existing hidespl.2da and replaces it by an empty one - this is link to the difference of format for the hidespl.2da array between TobEx and EE games.

Edited 1: I found a typos in elemental_summoning.tpa : ACTION_IF iwd_arcane BEGIN...LESSER_EARTH=>32016       LESSER_AIR=>32017... should be LESSER_EARTH=>32017       LESSER_AIR=>32016

Edited 2: in fiend.tpa, if you install Infinity Animations b5 the animation IC_ICE_GOLEM do not exist : IA mod remove all IC_ from designations. It has to be renamed if IAb5 is installed ICE_GOLEM

Edited 3 as stated, for classic BG2, improved Abazigal Lair - component 8180 - does not work; the issue is linked to ambient sounds. ie : by adding new sounds, this component works. For exemple, - COPY_EXISTING "AM6000.wav" "override/AM6012B.wav" - and to use AM6012B instead of AM6000 solve this issue (it has to be done for all sounds even main sounds from AR6004); There is also a Typo in "CaveEntranceRocks" ambient_sound1 is written 3 times, should have been ambient_sound1, 2 and 3 ; in addition in classic BG2 those sounds are AM6000A1, 2,3 (instead of AM6000A, B, C)

Edited 4&5 :I found a typo and a strange bug in elemental_summoning.tpa :

  • typo : line 188 -- ACTION_IF FILE_EXISTS_IN_GAME "%scroll%itm" BEGIN is missing the dot between "%scroll%" and "itm"
  • strange bug : the creation of L6 iwd spell water elmement invocation, strangly, does not work when copy from air elemental -- level 17 to 20 can invoc air elemental instead of water elemental --- But this is not due to typos but more to a strange behaviour of the air elemental spell (you can't overide l17 to l20 SPAIR2 and SPAIR3... but does work for SPAIR1, don't ask me why). Using the earth elemental spell as base istead of air elemental spell solve the issue...
  • Addition : changing the cre animation of "CONJURE_LESSER_WATER_ELEMENTAL" spell for the "ELEMENTAL_WATER_SMALL" would fit better with the other lesser summons

Edited 6 : Incompatibility with atweaks -- in mage.tpa, lin 829, the macro launch : friendly_fiends; by changing fiends scripts, this function creates incompatibilities with atweaks. To install both, SCS and after atweak, in addition to put no_initial_change_fiend_summoning = 1 in stratagems.ini and not installing [Improved Fiends and Celestials] component, the line 829 has to be quote. In conclusion, partial compatibility could be obtained if a condition is added in SCS .ini to avoid that mage.tpa update fiends scripts.

Edited by TotoR
Link to comment

Hi DavidW,

I am back with a new bugs report!

stratagems\beholder\beholder.tpa: 'hellbeh1' is missing the make_behorlder patch.

Quote

        PATCH_IF (INDEX_BUFFER (hellbeh1))>=0 BEGIN
             PATCH_PRINT "Applying beholder changes to %SOURCE_RES%"
             LPF make_beholder END
        END

The change to colors of behorlders are not documented, witch is not an issue, but are not compatible with Infinity animation - Mostly for Death Tyrant

stratagems\caster_shared\triggers\minor_sequencer.2da: I may be wrong but for 'MONSTER_SUMMONING_LEVEL_2' and 'SOUND_BURST' category are set to '0' but all others are set to 'o'

stratagems\caster_shared\triggers\sslsequencer.2da and trigger.2da: the bard class is missing from the list... it is normal with vanilla but with iwdification and rr bards have access up to lv8 spells (even if there does not seem to be a lot of those bards in-game maybe none in fact)

the following files are empty:

  • stratagems\caster_shared\clericmage\ssl\cmraksh.ssl
  • stratagems\priest\ssl\generalblocks\gohostile.ssl
  • stratagems\mage\ssl\combatblocks\trap_the_soul.ssl
  • stratagems\mage\ssl\combatblocks\fleecloud_fm.ssl

stratagems\mage\ssl\combatblocks\fleecloud.ssl: I may be wrong, but the script action 'RunAwayFromNoLeaveArea' does not work with oBG2. Could be replace by 'RunAwayFrom'

stratagems\gameplay\shapeshift.tpa: druid shapeshift tokens are two-handed. in oBG2 this could create CTD with modded druids. Could be smart to make them one-handed for ennemy only.

Quote

    

DEFINE_ACTION_FUNCTION shapeshift_token_enemies BEGIN

   ACTION_DEFINE_ASSOCIATIVE_ARRAY shapeshift_enemy BEGIN
      ear=>nea
      fir=>nfi
      sal=>nsa
      wyv=>nwy
      spi=>nsp
      we1=>nw1
      we2=>nw2
      we3=>nw3
      brp=>nbr
      wol=>nwo
   END

   ACTION_PHP_EACH shapeshift_enemy AS old=>new BEGIN
     LAF clone_item STR_VAR item=~dw#sh%old% => dw#sh%new%~
                            editstring=~twohanded=>0 droppable=>0 delete_opcodes=>145~
     END
   END


END

 

stratagems\ganai\genai.tpa: There seem to be a missing trigger

Quote

        OUTER_SPRINT $patch_data(~match~) "trigger_name=Tran0906b"
        OUTER_SPRINT $patch_data(~trigger_name~) "DMWWFakeExitb"

 

stratagems\mage\mage.tpa: hamless typo, mage18d is ref twice in the list line 1163

stratagems\spellholditems\spellholditems.tpa: line 189, orc06.cre is equipped with a 2 handed weapon (xbow01) and a shield. This may cause CTD with oBG2. It could be replaced with a sling - FWIW, the orc06 has already sling proficiency...

Quote

        LAF clone_creature STR_VAR creature="orc06=>dw#spho2" editstring="remove_items=>leat01 add_items=>~chan04 slng01 shld03~" END

instead of: LAF clone_creature STR_VAR creature="orc06=>dw#spho2" editstring="remove_items=>leat01 add_items=>~chan04 xbow01 shld03~" END

stratagems\tactical_bg1\demoncult.tpa: if installed without 'improved fiends' component there are some missing resources.

Quote

   // needed spells
   COPY ~stratagems/fiend/resource/dw#demvt.spl~ override // tanar'ri vampiric touch
        ~stratagems/fiend/resource/dw#dmvta.spl~ override
        ~stratagems/fiend/resource/dw#dmvtb.spl~ override
 

stratagems\tactical_bg1\ssl\sealtent.ssl: it seems that there are typos as the CreateCreature 'object' ref dw#c3bt and dw#c3hb don't exist. dw#c3bt1, dw#c3bt2, dw#c3bt3, dw#c3hb1 and dw#c3hb2 seem to be the right ones

Quote

        CreateCreature("dw#c3bt1",[3758.979],13)
        CreateCreature("dw#c3bt2",[3720.1019],13)
        CreateCreature("dw#c3bt3",[3673.1032],13)
        CreateCreature("dw#c3hb1",[3781.958],13)
        CreateCreature("dw#c3hb2",[3646.1054],13)

 

some thoughts about druids shapeshift and bards:

  • It is good addition to have shapeshift druids (even without 'Improved shapeshifting' component installed) but they behave strangely vs vanilla druids: they can shapeshift every round without delay and limit. This is not possible for vanilla druids. Maybe making shapeshift less often and for a longer time would be less awkward.
  • Bards are poor fighters. It may be for the better to let them become range attacker with spells. Let them have the same IA as mage and make them stay away from the melee fight - however as there are so little bards, this may be useless...
  • It could be a great synergy if bards can use new songs from IWDification - but AFAIW they have to be created as there is no bard of high level in-game

stratagems\ds\ds.tph: 1 or 2 typos and some missing(SR, IWD) spells:

Quote

// Detectable Spells v 4.01
// August 2020 - DavidW
//
// Changes:
//    - we now keep our own local copy of stats.ids and splstate.ids data, to avoid having to run CLEAR_IDS_MAP a bazillion times
//  - removed the need for AUTO_EVAL_STRINGS
//  - restored this text!
//    - rather belatedly started a v4.xx chain (really 3.96 ought to have been 4.0, since it was rewritten pretty much from scratch, but I don't want to rewrite history by changing it now)

// Detectable Spells v3.96
//  January 2019 - David Wallace ('DavidW')
//
//  Changes:
//  - Now incorporate flexible handling of TOBEX stats using BGEE splstate baseline
//  - if filename has no .spl suffix, try looking it up in SPELL.ids (and skip if not found)
//  - general revamp of the interface to apply detection
//  - added function to apply it directly to an individual spell
//  - use new 'ds_sort_ids' (exported from SCS's function library 'sort_ids') to sort stats.ids, rather than native ds_sort_stats_ids.
//    (sort_ids preserves duplicates, inter alia helpful with CDTweaks proficiencies)

// Detectable Spells v3.95
// February 3rd, 2016 - Yaroslav "Ardanis/GeN1e" Kalyuzhnyy


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// The main function
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION detectable_spells
   INT_VAR fix_khelben=1
BEGIN
    // make sure stats.ids is properly set
   LAF ds_stat_entries END
   // load current contents of stats.ids and splstate.ids
     LAF ds_load_ids STR_VAR ids=stats RET_ARRAY ds_ids_map_stats=ids_map END
    LAF ds_load_ids STR_VAR ids=splstate RET_ARRAY ds_ids_map_splstate=ids_map END
   // process main tables
   ACTION_FOR_EACH table_name IN ds_simple ds_142_variable ds_other_clone buff_misc BEGIN
      LAF ds_process_table INT_VAR complain=0 STR_VAR table=EVAL ".../ds-inline/%table_name%.2da" RET_ARRAY ds_ids_map_stats ds_ids_map_splstate END
   END
   ACTION_FOR_EACH table_name IN BUFF_PRO_WEAPONS BUFF_PRO_DAMAGE BUFF_PRO_SPELLS BUFF_PRO_EFFECTS BUFF_ENHANCEMENT STATE_ENRAGED BEGIN
      LAF ds_process_table INT_VAR complain=0 STR_VAR table=EVAL ".../ds-inline/%table_name%.2da" default_stat=EVAL "%table_name%" RET_ARRAY ds_ids_map_stats ds_ids_map_splstate END
   END
   ACTION_IF fix_khelben BEGIN
      LAF ds_fix_khelben END
   END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// The data
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// The bulk of entries are simple 142-clones
//////////////////////////////////////////////////////////////////////////////////////////////////////////

<<<<<<<< .../ds-inline/ds_simple.2da
resource                                stat
CLERIC_ARMOR_OF_FAITH                   ARMOR_OF_FAITH
CLERIC_CHAOTIC_COMMANDS                 CHAOTIC_COMMANDS
CLERIC_CHAOTIC_COMMANDS                 CLERIC_CHAOTIC_COMMANDS
BARBARIAN_RAGE                          BARBARIAN_RAGE
BERSERKER_RAGE                          BERSERKER_RAGE
MINSC_BERSERK                           MINSC_BERSERK
ASSASSIN_POISON                         POISON_WEAPON
KENSAI_KIA                              KENSAI_KIA
SPDWD02                                 DEFENSIVE_STANCE
ARCHER_CALL_SHOT                        ARCHER_CALL_SHOT
WIZARD_CHAOS_SHIELD                     SPLSTATE:CHAOS_SHIELD
WIZARD_IMPROVED_CHAOS_SHIELD            IMPROVED_CHAOS_SHIELD
SPCL542A                                SKALD_SONG
SPCL751A                                JESTER_SONG
POTN21                                  POTION_OF_CLARITY
POTN33                                  POTION_OF_MAGIC_BLOCKING
SCRL07                                  SCROLL_OF_PROTECTION_FROM_MAGIC
SCRL09                                  SCROLL_OF_PROTECTION_FROM_UNDEAD
WIZARD_PROTECTION_FROM_PETRIFICATION    PROTECTION_FROM_PETRIFICATION
POTN38                                  PROTECTION_FROM_PETRIFICATION
CAVALIER_REMOVE_FEAR                    RESIST_FEAR
CLERIC_REMOVE_FEAR                      RESIST_FEAR
WIZARD_RESIST_FEAR                      RESIST_FEAR
SPRA303                                 PROTECTION_FROM_NORMAL_MISSILES
WIZARD_PROTECTION_FROM_NORMAL_MISSILES  PROTECTION_FROM_NORMAL_MISSILES
WIZARD_PROTECTION_FROM_NORMAL_WEAPONS   PROTECTION_FROM_NORMAL_WEAPONS
WIZARD_TENSERS_TRANSFORMATION           TENSERS_TRANSFORMATION
SUN_SOUL_GREATER_SUN                    RED_FIRESHIELD
TALOS_STORMSHIELD                       STORM_SHELL
CLERIC_DOOM                             DOOM
CLERIC_FAERIE_FIRE                      FAERIE_FIRE
CLERIC_BARKSKIN                         BARKSKIN
CLERIC_MISCAST_MAGIC                    MISCAST_MAGIC
CLERIC_DEATH_WARD                       DEATH_WARD
CLERIC_DEATH_WARD                       SPLSTATE:DEATH_WARD
CLERIC_HOLY_POWER                       HOLY_POWER
WIZARD_GLITTERDUST                      GLITTERDUST
WIZARD_FIRE_SHIELD_BLUE                 BLUE_FIRESHIELD
WIZARD_EMOTION_HOPELESSNESS             HOPELESSNESS
WIZARD_GREATER_MALISON                  MALISON
WIZARD_MINOR_MALISON                     MALISON
SPWI413A                                OTILUKES_RESILIENT_SPHERE
WIZARD_FIRE_SHIELD_RED                  RED_FIRESHIELD
WIZARD_PROTECTION_FROM_THE_ELEMENTS     WIZARD_PROTECTION_FROM_THE_ELEMENTS
WARRIOR_HARDINESS                       HARDINESS
WIZARD_PROTECTION_FROM_MAGIC_ENERGY     WIZARD_PROTECTION_FROM_MAGIC_ENERGY
WIZARD_SPELL_IMMUNITY_ABJURATION        SI_ABJURATION
WIZARD_SPELL_IMMUNITY_CONJURATION       SI_CONJURATION
WIZARD_SPELL_IMMUNITY_DIVINATION        SI_DIVINATION
WIZARD_SPELL_IMMUNITY_ENCHANTMENT       SI_ENCHANTMENT
WIZARD_SPELL_IMMUNITY_ILLUSIONIST       SI_ILLUSION
WIZARD_SPELL_IMMUNITY_INVOCATION        SI_EVOCATION
WIZARD_SPELL_IMMUNITY_NECROMANCY        SI_NECROMANCY
WIZARD_SPELL_IMMUNITY_ALTERATION        SI_TRANSMUTATION
CLERIC_FREE_ACTION                      CLERIC_FREE_ACTION
POTN45                                  CLERIC_FREE_ACTION
CLERIC_DEFENSIVE_HARMONY                CLERIC_DEFENSIVE_HARMONY
CLERIC_PROTECTION_FROM_EVIL_10_FOOT     PROTECTION_FROM_EVIL
CLERIC_PROTECT_FROM_EVIL                PROTECTION_FROM_EVIL
WIZARD_PROTECTION_FROM_EVIL             PROTECTION_FROM_EVIL
PALADIN_PROTECTION_FROM_EVIL            PROTECTION_FROM_EVIL
SPCL233                                 PROTECTION_FROM_EVIL
CLERIC_REGENERATE                       CLERIC_REGENERATION
BHAAL1B                                 CLERIC_REGENERATION
CLERIC_TRUE_SIGHT                       TRUE_SIGHT
WIZARD_TRUE_SIGHT                       TRUE_SIGHT
KOA_TRUE_SIGHT_NO_VIS                   TRUE_SIGHT
INQUIS_TRUE_SIGHT                       TRUE_SIGHT
HELM_TRUE_SIGHT                         TRUE_SIGHT
LATHANDER_BOON                          LEVEL_DRAIN_IMMUNITY
WIZARD_PROTECTION_FROM_ENERGY           WIZARD_PROTECTION_FROM_ENERGY
WIZARD_IMPROVED_ALUCRITY                WIZARD_IMPROVED_ALACRITY
SPWISH17                                WIZARD_IMPROVED_ALACRITY
WIZARD_GLITTERDUST                      CANNOT_TURN_INVISIBLE
CLERIC_FAERIE_FIRE                      CANNOT_TURN_INVISIBLE
CLERIC_ALICORN_LANCE                    CANNOT_TURN_INVISIBLE

WIZARD_SHIELD                           WIZARD_SHIELD
>>>>>>>>


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// These all use opcode 142, but have variable values. Most are legacy.
////
//// The protection_from_weapons spells, being mutually incompatible, can share slots
//// The Fire Shield effects have a legacy detection that shares WIZARD_FIRE_SHIELD
//// The SI spells have a legacy detection that shares WIZARD_SPELL_IMMUNITY
//// Many offensive powers share a (partly legacy) opcode; so do many strength powers; so do many defensive
//// powers
//////////////////////////////////////////////////////////////////////////////////////////////////////////

<<<<<<<< .../ds-inline/ds_142_variable.2da
resource                                stat                                 stat_value
WIZARD_MANTLE                           WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 1
WIZARD_IMPROVED_MANTLE                  WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 2
WIZARD_ABSOLUTE_IMMUNITY                WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 3
WIZARD_PROTECTION_FROM_MAGIC_WEAPONS    WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 4
PROTECTION_MAGIC_WEAPON_NOEFF           WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 4
WIZARD_WRAITH_FORM                        WIZARD_PROTECTION_FROM_MAGIC_WEAPONS 5
WIZARD_FIRE_SHIELD_RED                  WIZARD_FIRE_SHIELD                   1
WIZARD_FIRE_SHIELD_BLUE                 WIZARD_FIRE_SHIELD                   2
CLERIC_AURA_OF_FLAMING_DEATH            WIZARD_FIRE_SHIELD                   1
SUN_SOUL_GREATER_SUN                    WIZARD_FIRE_SHIELD                   1
WIZARD_SPELL_IMMUNITY_ABJURATION        WIZARD_SPELL_IMMUNITY                1
WIZARD_SPELL_IMMUNITY_CONJURATION       WIZARD_SPELL_IMMUNITY                2
WIZARD_SPELL_IMMUNITY_DIVINATION        WIZARD_SPELL_IMMUNITY                3
WIZARD_SPELL_IMMUNITY_ENCHANTMENT       WIZARD_SPELL_IMMUNITY                4
WIZARD_SPELL_IMMUNITY_ILLUSIONIST       WIZARD_SPELL_IMMUNITY                5
WIZARD_SPELL_IMMUNITY_INVOCATION        WIZARD_SPELL_IMMUNITY                6
WIZARD_SPELL_IMMUNITY_NECROMANCY        WIZARD_SPELL_IMMUNITY                7
WIZARD_SPELL_IMMUNITY_ALTERATION        WIZARD_SPELL_IMMUNITY                8
WIZARD_TENSERS_TRANSFORMATION           OFFENSIVE_MODIFIER                   1
CLERIC_CALL_UPON_FAITH                   OFFENSIVE_MODIFIER                   1
CLERIC_CHAMPIONS_STRENGTH               OFFENSIVE_MODIFIER                   1
BARBARIAN_RAGE                          OFFENSIVE_MODIFIER                   1
BERSERKER_RAGE                          OFFENSIVE_MODIFIER                   1
MINSC_BERSERK                           OFFENSIVE_MODIFIER                   1
LATHANDER_BOON                          OFFENSIVE_MODIFIER                   1
MONK_STUNNING_BLOW                      OFFENSIVE_MODIFIER                   2
WARRIOR_DEATHBLOW                       OFFENSIVE_MODIFIER                   2
WARRIOR_POWER_ATTACK                    OFFENSIVE_MODIFIER                   2
BLADE_OFFENSIVE_SPIN                    OFFENSIVE_MODIFIER                   2
 (remove BLADE_DEFENSIVE_SPIN from offensive mod)                                                                             
KENSAI_KIA                              OFFENSIVE_MODIFIER                   2
INVOKE_COURAGE                          OFFENSIVE_MODIFIER                   3
WARRIOR_GREATER_DEATHBLOW               OFFENSIVE_MODIFIER                   3
WARRIOR_CRITICAL_STRIKE                 OFFENSIVE_MODIFIER                   3
ROGUE_ASSASINATION                      OFFENSIVE_MODIFIER                   4
ASSASSIN_POISON                         OFFENSIVE_MODIFIER                   4
WARRIOR_WHIRLWIND                       OFFENSIVE_MODIFIER                   4
WARRIOR_GREATER_WHIRLWIND               OFFENSIVE_MODIFIER                   5
WARRIOR_SMITE                           OFFENSIVE_MODIFIER                   5
MONK_QUIVERING_PALM                     OFFENSIVE_MODIFIER                   5
CLERIC_BATTLEFATE                       OFFENSIVE_MODIFIER                   5
WIZARD_TENSERS_TRANSFORMATION           STRENGTH_MODIFIER                    1
WIZARD_STRENGTH                         STRENGTH_MODIFIER                    2
CLERIC_STRENGTH_OF_ONE                  STRENGTH_MODIFIER                    2
CLERIC_HOLY_POWER                       STRENGTH_MODIFIER                    3
CLERIC_CHAMPIONS_STRENGTH               STRENGTH_MODIFIER                    3
CLERIC_DRAW_UPON_HOLY_MIGHT             STRENGTH_MODIFIER                    4
INNATE_DRAW_UPON_HOLY_MIGHT             STRENGTH_MODIFIER                    4
CLERIC_RIGHTEOUS_MAGIC                  STRENGTH_MODIFIER                    6
BHAAL2A                                 STRENGTH_MODIFIER                    4
DGRIGHT                                 STRENGTH_MODIFIER                    6
CLERIC_STRENGTH_OF_STONE                STRENGTH_MODIFIER                    7
CLERIC_BARKSKIN                         DEFENSIVE_MODIFIER                   1
BLADE_DEFENSIVE_SPIN                    DEFENSIVE_MODIFIER                   2
WIZARD_ARMOR                            DEFENSIVE_MODIFIER                   3
WIZARD_SHIELD                           DEFENSIVE_MODIFIER                   2
WIZARD_GHOST_ARMOR                      DEFENSIVE_MODIFIER                   4
WIZARD_SPIRIT_ARMOR                     DEFENSIVE_MODIFIER                   5
CLERIC_GLOBE_OF_BLADES                  CLERIC_BLADE_BARRIER                 1
NPC_BLADE_BARRIER                       CLERIC_BLADE_BARRIER                 1
CLERIC_BLADE_BARRIER                    CLERIC_BLADE_BARRIER                 2
MELIS02                                 CLERIC_BLADE_BARRIER                 2
>>>>>>>>

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// These work better associated to other opcodes
////
//// Insect plague is better attached to the insect overlay
//// Spell Deflection/Turning/Trap/SpellShield and Physical Mirror are best indexed to the actual effects
//// Also true for Mislead etc - though these are dangerous to detect this way and maintained only on
//// legacy grounds
//// Some NPC fire shield effects also need detection directly on the condition
//////////////////////////////////////////////////////////////////////////////////////////////////////////

<<<<<<<< .../ds-inline/ds_other_clone.2da
resource                           stat                           stat_value           match_opcode
BALSHLD                            RED_FIRESHIELD                 1                    232
BALSHLD                            WIZARD_FIRE_SHIELD             1                    232
CLERIC_SUMMON_INSECTS              CLERIC_INSECT_PLAGUE           1                    215
CLERIC_INSECT_PLAGUE               CLERIC_INSECT_PLAGUE           2                    215
CLERIC_CREEPING_DOOM               CLERIC_INSECT_PLAGUE           3                    215
WIZARD_MINOR_SPELL_DEFLECTION      WIZARD_SPELL_DEFLECTION        1                    201
SPRA302                            WIZARD_SPELL_DEFLECTION        1                    201
SPELL_DEFLECTION_NO_VISUAL         WIZARD_SPELL_DEFLECTION        2                    201
WIZARD_SPELL_DEFLECTION            WIZARD_SPELL_DEFLECTION        2                    201
CLERIC_SHIELD_OF_THE_ARCHONS       CLERIC_SHIELD_OF_THE_ARCHONS   1                    201
DGARCHON                           CLERIC_SHIELD_OF_THE_ARCHONS   1                    201
WIZARD_SPELL_TURNING               WIZARD_SPELL_TURNING           2                    200
BEHOLDER_SPELL_TURNING             WIZARD_SPELL_TURNING           1                    200
WIZARD_MINOR_SPELL_TURNING         WIZARD_SPELL_TURNING           1                    200
WIZARD_SPELL_TRAP                  WIZARD_SPELL_TRAP              1                    259
WIZARD_SPELL_SHIELD                SPELL_SHIELD                   1                    226
CLERIC_PHYSICAL_MIRROR             CLERIC_PHYSICAL_MIRROR         1                    197
WIZARD_MISLEAD                     WIZARD_MISLEAD                 1                    236
WIZARD_PROJECT_IMAGE               WIZARD_MISLEAD                 2                    236
WIZARD_SIMULACRUM                  WIZARD_MISLEAD                 3                    236
>>>>>>>>

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// These are standard markups (from SoD, with DW amendments for IWD) of combat buffs
////
//// Most are just straightforward 142s
//////////////////////////////////////////////////////////////////////////////////////////////////////////

<<<<<<<< .../ds-inline/BUFF_PRO_DAMAGE.2da
resource
SUN_SOUL_GREATER_SUN
TALOS_STORMSHIELD
CLERIC_AURA_OF_FLAMING_DEATH
CLERIC_RESIST_FIRE
CLERIC_PROTECTION_FROM_FIRE
CLERIC_PROTECTION_FROM_LIGHTNING
CLERIC_RESIST_ACID_AND_CORROSION
CLERIC_DIVINE_SHELL

WIZARD_PROTECTION_FROM_FIRE
WIZARD_PROTECTION_FROM_COLD
WIZARD_FIRE_SHIELD_BLUE
WIZARD_FIRE_SHIELD_RED
WIZARD_PROTECTION_FROM_ELECTRICITY
WIZARD_PROTECTION_FROM_ACID
WIZARD_PROTECTION_FROM_MAGIC_ENERGY
WIZARD_PROTECTION_FROM_THE_ELEMENTS
WIZARD_PROTECTION_FROM_ENERGY
POTN02
POTN18
POTN22
POTN31
POTN35
>>>>>>>>

<<<<<<<< .../ds-inline/BUFF_PRO_WEAPONS.2da
resource
SPRA303
WIZARD_PROTECTION_FROM_NORMAL_MISSILES
WIZARD_WRAITH_FORM
WIZARD_PROTECTION_FROM_NORMAL_WEAPONS
WIZARD_PROTECTION_FROM_MAGIC_WEAPONS
WIZARD_MANTLE
WIZARD_IMPROVED_MANTLE
WIZARD_ABSOLUTE_IMMUNITY
>>>>>>>>

<<<<<<<< .../ds-inline/BUFF_PRO_SPELLS.2da
resource
WIZARD_SPELL_IMMUNITY_ABJURATION
WIZARD_SPELL_IMMUNITY_CONJURATION
WIZARD_SPELL_IMMUNITY_DIVINATION
WIZARD_SPELL_IMMUNITY_ENCHANTMENT
WIZARD_SPELL_IMMUNITY_ILLUSIONIST
WIZARD_SPELL_IMMUNITY_INVOCATION
WIZARD_SPELL_IMMUNITY_NECROMANCY
WIZARD_SPELL_IMMUNITY_ALTERATION
WIZARD_GLOBE_OF_INVULNERABILITY
WIZARD_MINOR_GLOBE_OF_INVULNERABILITY
>>>>>>>>

<<<<<<<< .../ds-inline/BUFF_PRO_EFFECTS.2da
resource
CLERIC_REMOVE_FEAR
CLERIC_FREE_ACTION
CLERIC_DEATH_WARD
CLERIC_CHAOTIC_COMMANDS
WIZARD_RESIST_FEAR
POTN21
POTN45
>>>>>>>>

<<<<<<<< .../ds-inline/BUFF_ENHANCEMENT.2da
resource
BHAAL2A
CLERIC_DRAW_UPON_HOLY_MIGHT
CLERIC_STRENGTH_OF_ONE
CLERIC_STRENGTH_OF_STONE
CLERIC_HOLY_POWER
CLERIC_CHAMPIONS_STRENGTH
CLERIC_CHAOTIC_COMMANDS
CLERIC_RIGHTEOUS_MAGIC
CLERIC_BLADE_BARRIER
NPC_BLADE_BARRIER
CLERIC_AURA_OF_FLAMING_DEATH
WIZARD_STRENGTH
WIZARD_FIRE_SHIELD_BLUE
WIZARD_FIRE_SHIELD_RED
WIZARD_TENSERS_TRANSFORMATION
POTN03
POTN04
POTN05
POTN06
POTN07
POTN09
POTN12
POTN41
>>>>>>>>

<<<<<<<< .../ds-inline/STATE_ENRAGED.2da
resource
BARBARIAN_RAGE
BERSERKER_RAGE
MINSC_BERSERK
OHRRAGE
>>>>>>>>

<<<<<<<< .../ds-inline/buff_misc.2da
resource                      stat                          match_opcode
CLERIC_SHIELD_OF_THE_ARCHONS  BUFF_PRO_SPELLS               201
SPRA302                       BUFF_PRO_SPELLS               201
WIZARD_MINOR_SPELL_DEFLECTION BUFF_PRO_SPELLS               201
WIZARD_SPELL_DEFLECTION       BUFF_PRO_SPELLS               201
WIZARD_SPELL_SHIELD           BUFF_PRO_SPELLS               226
WIZARD_MINOR_SPELL_TURNING    BUFF_PRO_SPELLS               200
WIZARD_SPELL_TURNING          BUFF_PRO_SPELLS               200
WIZARD_SPELL_TRAP             BUFF_PRO_SPELLS               259
WIZARD_MINOR_SPELL_TURNING    BUFF_PRO_SPELLS               201 // these are for SR
WIZARD_SPELL_TURNING          BUFF_PRO_SPELLS               201 //
WIZARD_SPELL_TRAP             BUFF_PRO_SPELLS               201 //
POTN33                        BUFF_PRO_SPELLS               102
CLERIC_PHYSICAL_MIRROR        BUFF_PRO_WEAPONS              197
WIZARD_DETECT_INVISIBILITY    DETECT_INVISIBILITY           193 // SR only
>>>>>>>>

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// These are special cases where the duration needs to override the clone
//////////////////////////////////////////////////////////////////////////////////////////////////////////

<<<<<<<< .../ds-inline/special.2da
resource                     stat                           match_opcode              duration
WIZARD_WARDING_WHIP          WIZARD_KHELBENS_WARDING_WHIP   215                       7
INQUIS_TRUE_SIGHT            CANNOT_TURN_INVISIBLE          221                       7
SPCL232D                     CANNOT_TURN_INVISIBLE          221                       7
CLERIC_TRUE_SIGHT            CANNOT_TURN_INVISIBLE          221                       7
SPPR505D                     CANNOT_TURN_INVISIBLE          221                       7
SPPR950                      CANNOT_TURN_INVISIBLE          221                       7
WIZARD_TRUE_SIGHT            CANNOT_TURN_INVISIBLE          221                       7
SPWI609D                     CANNOT_TURN_INVISIBLE          221                       7
>>>>>>>>

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// The functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Process a table of DS instructions
//// possible columns are:
//// - resource (the thing being patched; compulsory; can be a spell.ids ref, a full resource name, or the
////   resref of a spell or item. If the latter, and if both resref.spl and resref.itm exist, spl is default)
//// - stat (the stat being assigned; defaults to the default_stat variable)
//// - stat_value (the value assigned to the stat; defaults to 1)
//// - match_opcode (the opcode to clone; defaults to 142)
//// - match_parameter2 (a restriction on which opcode is cloned; defaults to -1, clone all)
//// - match_resource (a restriction on which opcode is cloned; defaults to SAME, clone all)
//// columns can be in any order, but first row must be column headers. Other columns are ignored
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_process_table
   INT_VAR complain=0
           default_opcode=142
   STR_VAR table=""
           default_stat=""
   RET_ARRAY ds_ids_map_stats ds_ids_map_splstate
BEGIN
    // load IDS, if not already done
    ACTION_IF !VARIABLE_IS_SET $ds_ids_map_stats("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=stats RET_ARRAY ds_ids_map_stats=ids_map END
    END
    ACTION_IF !VARIABLE_IS_SET $ds_ids_map_splstate("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=splstate RET_ARRAY ds_ids_map_splstate=ids_map END
    END

   COPY - "%table%" override
        // remove comments
        REPLACE_TEXTUALLY "//.*" ""
        // read in the data
        PATCH_FOR_EACH column IN resource stat stat_value match_opcode match_parameter2 match_resource duration BEGIN
           SET EVAL "%column%_col"=0 - 1
        END
        COUNT_2DA_COLS colcount
        READ_2DA_ENTRIES_NOW ds_table_data colcount
        // get the column entries
        FOR (this_col=0;this_col<colcount;this_col +=1) BEGIN
           READ_2DA_ENTRY_FORMER ds_table_data 0 this_col colname
           PATCH_MATCH "%colname%" WITH
           resource stat stat_value match_opcode match_parameter2 match_resource duration BEGIN
              SET EVAL "%colname%_col" = this_col
           END
           DEFAULT
           END
        END
        PATCH_IF (resource_col>=0) BEGIN
           // go through the table
           FOR (this_row=1;this_row<ds_table_data;this_row +=1) BEGIN
              READ_2DA_ENTRY_FORMER ds_table_data this_row resource_col resource
              SET match_opcode=default_opcode
              SET match_parameter2="-1"
              SET stat_value=1
              SPRINT stat "%default_stat%"
              SPRINT match_resource "SAME"
              SET duration="-1"
              PATCH_FOR_EACH entry IN stat stat_value match_opcode match_parameter2 match_resource duration BEGIN
                 PATCH_IF (EVAL "%entry%_col")>=0 BEGIN
                    READ_2DA_ENTRY_FORMER ds_table_data this_row EVAL "%entry%_col" temp
                    SPRINT EVAL "%entry%" "%temp%"
                 END
              END
              INNER_ACTION BEGIN
                 LAF ds_make_detectable INT_VAR complain match_opcode match_parameter2 stat_value STR_VAR id=EVAL "%stat%" resource match_resource RET_ARRAY ds_ids_map_stats ds_ids_map_splstate END
              END
           END
        END ELSE BEGIN
           PATCH_WARN "DS warning: %table% lacks a 'resource' column"
        END
   BUT_ONLY
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// The core function
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_make_detectable
   INT_VAR match_opcode="142"
           match_parameter2="-1"
           stat_value=1
           complain=1
   STR_VAR id=""
           resource=""
           match_resource="SAME"
   RET_ARRAY ds_ids_map_stats
             ds_ids_map_splstate
BEGIN
        // load IDS, if not already done
      ACTION_IF !VARIABLE_IS_SET $ds_ids_map_stats("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=stats RET_ARRAY ds_ids_map_stats=ids_map END
      END
      ACTION_IF !VARIABLE_IS_SET $ds_ids_map_splstate("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=splstate RET_ARRAY ds_ids_map_splstate=ids_map END
      END


   // identify the resource
   ACTION_IF !"%resource%" STRING_CONTAINS_REGEXP  "\." BEGIN // it's a full resource
      OUTER_SPRINT filespec "%resource%"
   END ELSE BEGIN
   // check for a suffix
      OUTER_SPRINT suffix ""
      OUTER_INNER_PATCH_SAVE resource "%resource%" BEGIN
         REPLACE_EVALUATE "^\(.*\):\(.*\)$" BEGIN
          SPRINT suffix "%MATCH2%"
         END
         "%MATCH1%"
      END
      OUTER_SET spell_num=IDS_OF_SYMBOL (spell "%resource%")
      ACTION_IF spell_num>=0 BEGIN
         LAF RES_NAME_OF_SPELL_NUM INT_VAR spell_num RET spell_res END
         ACTION_IF FILE_EXISTS_IN_GAME "%spell_res%%suffix%.spl" BEGIN
             OUTER_SPRINT filespec "%spell_res%%suffix%.spl"
         END
      END ELSE BEGIN
         ACTION_IF FILE_EXISTS_IN_GAME "%resource%%suffix%.spl" BEGIN
            OUTER_SPRINT filespec "%resource%%suffix%.spl"
         END ELSE
         ACTION_IF FILE_EXISTS_IN_GAME "%resource%%suffix%.itm" BEGIN
            OUTER_SPRINT filespec "%resource%%suffix%.itm"
         END
      END
   END
   // if we succeeded in finding filespec...
   ACTION_IF VARIABLE_IS_SET filespec BEGIN
   // get the data for the stat
      LAF ds_resolve_stat STR_VAR id RET stat_param stat_opcode RET_ARRAY ds_ids_map_stats ds_ids_map_splstate END
   // patch
      ACTION_IF stat_opcode>=0 BEGIN // return value of -1 means we can't patch this (probably because TOBEX is missing)
        COPY_EXISTING "%filespec%" override
              LPF DELETE_EFFECT INT_VAR match_opcode=stat_opcode match_parameter2=stat_param END // clear out any previous version
              LPF CLONE_EFFECT INT_VAR silent=!complain multi_match=1 match_opcode match_parameter2 opcode=stat_opcode parameter1=stat_value parameter2=stat_param special=(opcode=328) STR_VAR match_resource END
        BUT_ONLY
      END

   END ELSE BEGIN
          ACTION_IF complain BEGIN
            WARN "DS tried to add detectable data to %resource%%suffix%, but there is no such resource"
          END
   END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_set_vars RET is_tobex enhanced_edition BEGIN
   OUTER_SET is_tobex=FILE_EXISTS "tobex.dll"
   OUTER_SET enhanced_edition=GAME_IS "BGEE BG2EE EET IWDEE"
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// having already checked it's not, add an entry to a 2da

DEFINE_ACTION_FUNCTION ds_add_entry
  INT_VAR min=0
  STR_VAR id="" file=""
  RET stat_ind
BEGIN
 ACTION_CLEAR_ARRAY ds_2da_array
 COPY_EXISTING "%file%.ids" override
  READ_2DA_ENTRIES_NOW ds_2da_array 2
  FOR (i=0;i<ds_2da_array;i+=1) BEGIN
      READ_2DA_ENTRY_FORMER ds_2da_array i 0 this_val
      SET $ds_2da_array("%this_val%")=1
  END
 BUT_ONLY
 OUTER_SET stat_ind=min
 OUTER_WHILE VARIABLE_IS_SET $ds_2da_array("%stat_ind%") BEGIN
    OUTER_SET stat_ind +=1
 END
 APPEND "%file%.ids" "%stat_ind% %id%"
END


//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_PATCH_FUNCTION ds_add_entry
  INT_VAR min=0
  STR_VAR id="" file=""
  RET stat_ind
BEGIN
   INNER_ACTION BEGIN
      LAF ds_add_entry INT_VAR min STR_VAR id file RET stat_ind END
   END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_PATCH_FUNCTION ds_resolve_stat STR_VAR id="" RET stat_ind stat_param stat_opcode stat_type RET_ARRAY ds_ids_map_stats ds_ids_map_splstate
BEGIN
   // initialise
   INNER_ACTION BEGIN
      LAF ds_set_vars RET is_tobex enhanced_edition END
        // load IDS, if not already done
      ACTION_IF !VARIABLE_IS_SET $ds_ids_map_stats("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=stats RET_ARRAY ds_ids_map_stats=ids_map END
      END
      ACTION_IF !VARIABLE_IS_SET $ds_ids_map_splstate("DS_IDS_MAP_LOADED") BEGIN
        LAF ds_load_ids STR_VAR ids=splstate RET_ARRAY ds_ids_map_splstate=ids_map END
      END

   END
   
   // see if it's forced
   SET enforce_splstate=0

   INNER_PATCH "%id%" BEGIN
      REPLACE_EVALUATE "^\(.*\):\(.*\)$" BEGIN
         PATCH_IF "%MATCH1%" STRING_EQUAL_CASE "splstate" BEGIN
            SPRINT id "%MATCH2%"
            SET enforce_splstate=1
         END ELSE BEGIN
            SET enforce_splstate=0
            PATCH_WARN "unrecognised naming convention for state '%id%' in DS"
         END
      END
      ""
   END
   // first, see if it's in stats.ids
   TO_UPPER id
   PATCH_IF VARIABLE_IS_SET $ds_ids_map_stats("%id%") BEGIN
    SET check_stats=$ds_ids_map_stats("%id%")
   END ELSE BEGIN
    SET check_stats="-1"
   END
   SET check_stats = IDS_OF_SYMBOL (stats "%id%")
   PATCH_IF (!enforce_splstate && ( check_stats >=89 && (check_stats<=134 || check_stats>=156) && ( check_stats<256 || is_tobex ) )) BEGIN
       SET stat_ind=check_stats
       SPRINT stat_type stats
       PATCH_IF stat_ind>387 BEGIN
             SET stat_opcode=318
             SET stat_param=stat_ind + 0x10000
       END ELSE
       PATCH_IF stat_ind<=134 && stat_ind>=89 BEGIN
             SET stat_opcode=233
             SET stat_param=stat_ind
       END ELSE
       PATCH_IF stat_ind>=156 BEGIN
             SET stat_opcode=282
             SET stat_param=stat_ind - 156
       END ELSE BEGIN // you shouldn't be able to get here
             SET stat_opcode=0 - 1
             SET stat_param = 0 - 1
       END
   END ELSE BEGIN
   // if it's not in stats.ids, check if we're EE or not
       PATCH_IF enhanced_edition BEGIN
           // is it in SPLSTATE?
           PATCH_IF VARIABLE_IS_SET $ds_ids_map_splstate("%id%") BEGIN
               // if it's there already, just use it
               SET stat_ind = $ds_ids_map_splstate("%id%")
           END ELSE BEGIN
               // get a new value
               LPF ds_add_entry STR_VAR id file=splstate RET stat_ind END
               SET $ds_ids_map_splstate("%id%")=stat_ind
           END
           SPRINT stat_type splstate
           SET stat_opcode=328
           SET stat_param=stat_ind
       END ELSE BEGIN
          // if we're not ToBEx, quit
          PATCH_IF is_tobex BEGIN
             // get a new value
             LPF ds_add_entry INT_VAR min=401 STR_VAR id file=stats RET stat_ind END
             SET $ds_ids_map_stats("%id%")=stat_ind
             SPRINT stat_type stats
             SET stat_opcode=318
             SET stat_param=stat_ind + 0x10000
          END ELSE BEGIN
             SPRINT stat_type null
             SET stat_opcode="-1"
             SET stat_param="-1"
             SET stat_ind="-1"
          END
       END
   END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_resolve_stat STR_VAR id=""
RET stat_ind stat_param stat_opcode stat_type
RET_ARRAY ds_ids_map_stats ds_ids_map_splstate
BEGIN
   OUTER_INNER_PATCH "" BEGIN
      LPF ds_resolve_stat STR_VAR id RET stat_ind stat_param stat_opcode stat_type RET_ARRAY ds_ids_map_stats ds_ids_map_splstate END
   END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//// make sure the required entries in stats.ids are present
//////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_stat_entries BEGIN

LAF ds_set_vars RET is_tobex enhanced_edition END
// first, fix issue with Paladin_protection_from_evil

COPY_EXISTING spell.ids override
ACTION_IF !FILE_CONTAINS_EVALUATED ("override/spell.ids" "4213[ %TAB%]+PALADIN_PROTECTION_FROM_EVIL") BEGIN
         APPEND "spell.ids" "4213 PALADIN_PROTECTION_FROM_EVIL"
      END

ACTION_CLEAR_ARRAY stats_array
ACTION_DEFINE_ASSOCIATIVE_ARRAY stats_array BEGIN
WEAPON_ENCHANTMENT => 109
CLERIC_ARMOR_OF_FAITH => 110
WIZARD_SPELL_DEFLECTION => 116
PROTECTION_FROM_EVIL => 117
TRUE_SIGHT => 118
CLERIC_CHAOTIC_COMMANDS => 119
CLERIC_INSECT_PLAGUE => 120
CLERIC_BLADE_BARRIER => 121
CLERIC_PHYSICAL_MIRROR => 122
CLERIC_SHIELD_OF_THE_ARCHONS => 123
CLERIC_REGENERATION => 124
WIZARD_FIRE_SHIELD => 125
WIZARD_PROTECTION_FROM_MAGIC_ENERGY => 126
WIZARD_MISLEAD => 127
WIZARD_PROTECTION_FROM_MAGIC_WEAPONS => 128
WIZARD_SPELL_TURNING => 129
WIZARD_PROTECTION_FROM_THE_ELEMENTS => 130
CLERIC_FREE_ACTION => 131
WIZARD_KHELBENS_WARDING_WHIP => 132
CLERIC_DEFENSIVE_HARMONY => 133
EXTRAPROFICIENCY20 => 134
SCRIPTINGSTATE1 => 156
WING_BUFFET => 156
SCRIPTINGSTATE2 => 157
DEATH_WARD => 157
SCRIPTINGSTATE3 => 158
LEVEL_DRAIN_IMMUNITY =>158
SCRIPTINGSTATE4 => 159
OFFENSIVE_MODIFIER => 159
SCRIPTINGSTATE5 => 160
DEFENSIVE_MODIFIER =>  160
SCRIPTINGSTATE6 => 161
STRENGTH_MODIFIER => 161
WIZARD_SPELL_IMMUNITY => 162
WIZARD_PROTECTION_FROM_ENERGY => 163
WIZARD_SPELL_TRAP => 164
WIZARD_IMPROVED_ALACRITY => 165
MELEE_THACO_BONUS => 166
MELEE_DAMAGE_BONUS => 167
MISSILE_DAMAGE_BONUS => 168
DISABLE_CIRCLE => 169
FIST_THACO_BONUS => 170
FIST_DAMAGE_BONUS => 171
CLASS_STRING_OVERRIDE_MIXED => 172
CLASS_STRING_OVERRIDE_LOWER => 173
PREVENT_SPELL_PROTECTION_EFFECTS => 174
IMMUNITY_TO_BACKSTAB => 175
LOCKPICKINGMTPBONUS => 176
MOVESILENTLYMTPBONUS => 177
TRAPSMTPBONUS => 178
PICKPOCKETMTPBONUS => 179
HIDEINSHADOWSMTPBONUS => 180
DETECTILLUSIONSMTPBONUS => 181
SETTRAPSMTPBONUS => 182
PREVENT_AI_SLOWDOWN => 183
EXISTANCE_DELAY_OVERRIDE => 184
ANIMATION_ONLY_HASTE => 185
NO_PERMANENT_DEATH => 186
IMMUNE_TO_TURN_UNDEAD => 187
LEVELDRAIN => 200
WING_BUFFET => 156
LEVEL_DRAIN_IMMUNITY => 158
OFFENSIVE_MODIFIER => 159
DEFENSIVE_MODIFIER => 160
STRENGTH_MODIFIER => 161
WIZARD_PROTECTION_FROM_PETRIFICATION => 176
WIZARD_SPELL_SHIELD => 177
WIZARD_RESIST_FEAR => 178
WIZARD_PROTECTION_FROM_NORMAL_MISSILES => 179
WIZARD_GREATER_MALISON => 180
WIZARD_PROTECTION_FROM_NORMAL_WEAPONS => 181
WIZARD_TENSERS_TRANSFORMATION => 182
END

// handle the problematic 176-182 stats

ACTION_IF !enhanced_edition && !is_tobex BEGIN
    // on non-ToBEx, non-EE installs, give them duplicate
    // names to match EE usage (this facilitates automated
    // hot-swapping of code)
       ACTION_DEFINE_ASSOCIATIVE_ARRAY stats_array BEGIN
           PROTECTION_FROM_PETRIFICATION => 176
           SPELL_SHIELD => 177
           RESIST_FEAR => 178
           PROTECTION_FROM_NORMAL_MISSILES => 179
           MALISON => 180
           PROTECTION_FROM_NORMAL_WEAPONS => 181
           TENSERS_TRANSFORMATION => 182
       END
END ELSE BEGIN
    // on EE/ToBEx installs, add markers to show they are problematic
    // (else I look at stats.ids and make the mistake of trusting it)
       ACTION_DEFINE_ASSOCIATIVE_ARRAY stats_array BEGIN
           PROTECTION_FROM_PETRIFICATION_DONOTUSE => 176
           SPELL_SHIELD_DONOTUSE => 177
           RESIST_FEAR_DONOTUSE => 178
           PROTECTION_FROM_NORMAL_MISSILES_DONOTUSE => 179
           MALISON_DONOTUSE => 180
           PROTECTION_FROM_NORMAL_WEAPONS_DONOTUSE => 181
           TENSERS_TRANSFORMATION_DONOTUSE => 182
       END
END

COPY_EXISTING "stats.ids" override
   REPLACE_TEXTUALLY "[0-9]+ +DMWW_SLOT_[0-9]+\(%WNL%\|%LNL%\|%MNL%\)" "\1"
ACTION_PHP_EACH stats_array AS name => code BEGIN
      ACTION_IF !FILE_CONTAINS_EVALUATED ("override/stats.ids" "%code%[ %TAB%]+%name%") BEGIN
         APPEND "stats.ids" "%code% %name%"
      END
END

 LAF ds_sort_ids STR_VAR ids=stats END
END

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Sort an IDS file into numerical order (copy of function in stratagems/sfo/general/lib_general.tpa, with new ds-localised helper function
/////  and some EVALs to function in a non-AUTO_EVAL_STRINGS environment)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_sort_ids STR_VAR ids="" BEGIN
   ACTION_CLEAR_ARRAY ids_entries
   OUTER_SET max=0
   COPY_EXISTING "%ids%.ids" override
       READ_2DA_ENTRIES_NOW ids_array 2
       // top row is either 'IDS V1.0', or a single row entry, or blank
       PATCH_IF INDEX_BUFFER ("IDS *V1.0")>=0 BEGIN
          SPRINT top_row "IDS V1.0"
       END ELSE BEGIN
          COUNT_2DA_ROWS 1 rowcount_1
          PATCH_IF rowcount_1=ids_array BEGIN
             SPRINT top_row " "
          END ELSE BEGIN
             READ_2DA_ENTRY 0 0 1 top_row
          END
       END
       FOR (i=0;i<ids_array;i+=1) BEGIN
          READ_2DA_ENTRY_FORMER ids_array i 0 num
          PATCH_IF IS_AN_INT num BEGIN
             SET max= num>max ? num : max
             READ_2DA_ENTRY_FORMER ids_array i 1 val
             PATCH_IF "%val%" STRING_COMPARE_CASE DMWW_UNUSED_FOR_DELETION BEGIN
               PATCH_IF VARIABLE_IS_SET $ids_entries("%num%") BEGIN
                SPRINT temp $ids_entries("%num%")
                SPRINT $ids_entries("%num%") "%temp% %val%"
               END ELSE BEGIN
                SPRINT $ids_entries("%num%") "%val%"
               END
             END
          END
       END
   BUT_ONLY
   COPY ".../ds-inline/blank" "override/%ids%.ids"
       INSERT_2DA_ROW 0 2 "DW_SORT_IDS_PLACEHOLDER"
       SET rowcount=0
       FOR (num=0;num<=max;num+=1) BEGIN
          PATCH_IF VARIABLE_IS_SET $ids_entries("%num%") BEGIN
             SPRINT list $ids_entries("%num%")
             WHILE "%list%" STRING_COMPARE "" BEGIN
                LPF ds_return_first_entry STR_VAR list RET entry list END
                SPRINT check "%num%--%entry%"
                PATCH_IF !VARIABLE_IS_SET EVAL "%check%" BEGIN
                  INSERT_2DA_ROW rowcount 2 "%num% %entry%"
                  SET rowcount+=1
                  SPRINT EVAL "%check%" ""
                END
             END
          END
       END
       REPLACE_TEXTUALLY "DW_SORT_IDS_PLACEHOLDER" "%top_row%"
END

DEFINE_PATCH_FUNCTION ds_return_first_entry
   STR_VAR list=""
   RET entry
       list
BEGIN
   PATCH_IF "%list%" STRING_EQUAL "" BEGIN // return nothing if list is empty
      SPRINT list ""
      SPRINT entry ""
   END ELSE
   PATCH_IF INDEX (" " "%list%")<0 BEGIN // only one entry
      SPRINT entry "%list%"
      SPRINT list ""
   END ELSE BEGIN
    INNER_PATCH_SAVE list "%list%" BEGIN
      REPLACE_EVALUATE "\([^ ]*\) \(.*\)"
      BEGIN
         SPRINT entry "%MATCH1%"
      END
      "%MATCH2%"
    END
   END
END

<<<<<<<< .../ds-inline/blank
>>>>>>>>

 

//////////////////////////////////////////////////////////////////////////////////////
//  Legacy code (adapted from Ardanis DS v3)                                     //////////////
//////////////////////////////////////////////////////////////////////////////////////

// Warding Whip can be broken by older versions of DS. Check it up.
//
// If broken, but in a recognizable shape, we try to fix it first, before resorting to replacement with a backup file.
//
// While it likely is possible to write sufficiently sophisticated code to reanimate the file even if it has
// suffered the most dire kind of abuse, I feel that's rather excessive to do so.

DEFINE_ACTION_FUNCTION ds_fix_khelben BEGIN

COPY_EXISTING ~spwi705.spl~ override
  READ_LONG  0x64 ab_off
  READ_SHORT 0x68 ab_num
  READ_LONG  0x6a ef_off
  fubar=0

  // check if the file is ok
  repair=0
  total=0
  FOR (i=0;i<ab_num;i+=1) BEGIN
    READ_SHORT ab_off+i*0x28+0x1e ef_num
    total+=ef_num
  END
  total+=SHORT_AT 0x70
  PATCH_IF SOURCE_SIZE != ef_off+total*0x30 BEGIN
    repair=1
    PATCH_PRINT ~Detectable Spells: SPWI705.SPL is broken, attempting to repair the file~
  END

  PATCH_IF repair BEGIN

    // calculate the number of effects
    total=0
    size = SOURCE_SIZE - ef_off
    WHILE (size - 0x30) >= 0 BEGIN
      total +=1
      size -=0x30
    END
    PATCH_IF size > 0 && size < 0x30 BEGIN
      fubar=1
      PATCH_PRINT ~Detectable Spells: SPWI705.SPL is broken in unknown manner, restoring from a backup~
    END

    // check if the first effect in each header is the expected 233/1/132
    PATCH_IF fubar=0 BEGIN
      FOR (i=0;i<ab_num;i+=1) BEGIN
        READ_SHORT ab_off+i*0x28+0x20 ef_ind
        READ_SHORT ef_off+ef_ind*0x30 opcode
        READ_LONG ef_off+ef_ind*0x30+4 par1
        READ_LONG ef_off+ef_ind*0x30+8 par2
        PATCH_IF (opcode!=233 || par1!=1 || par2!=132) //
              && (opcode!=233 || par1!=0 || par2!=116) //
              && (opcode!=233 || par1!=0 || par2!=129) //
              && (opcode!=282 || par1!=0 || par2!=5)   //
              && (opcode!=282 || par1!=0 || par2!=7)   //
              && (opcode!=282 || par1!=0 || par2!=21)  //
        BEGIN
          fubar=1
          PATCH_PRINT ~Detectable Spells: SPWI705.SPL is broken in unknown manner, restoring from a backup~
        END
      END
    END

    // write the real number of effects per header
    PATCH_IF fubar=0 BEGIN
      FOR (i=0;i<ab_num;i+=1) BEGIN
        READ_SHORT ab_off+i*0x28+0x20 ef_ind
        PATCH_IF i+1 < ab_num BEGIN // if not the last header
          READ_SHORT ab_off+i*0x28+0x48 next_ind
          number = next_ind - ef_ind
          total -= number
        END ELSE BEGIN // if the last
          number = total
        END
        WRITE_SHORT ab_off+i*0x28+0x1e number
      END
    END

    // now kill off the shit
    PATCH_IF fubar=0 BEGIN
      delta=0
      FOR (i=0;i<ab_num;i+=1) BEGIN
        READ_SHORT ab_off+i*0x28+0x1e ef_num
        READ_SHORT ab_off+i*0x28+0x20 ef_ind
        ef_ind +=delta
        WRITE_SHORT ab_off+i*0x28+0x20 ef_ind
        local_delta=0
        FOR (k=0;k<ef_num;k+=1) BEGIN
          READ_SHORT ef_off+(k+ef_ind+local_delta)*0x30 opcode
          READ_LONG ef_off+(k+ef_ind+local_delta)*0x30+4 par1
          READ_LONG ef_off+(k+ef_ind+local_delta)*0x30+8 par2
          PATCH_IF (opcode=233 && par1=1 && par2=132) //
                || (opcode=233 && par1=0 && par2=116) //
                || (opcode=233 && par1=0 && par2=129) //
                || (opcode=282 && par1=0 && par2=5)   //
                || (opcode=282 && par1=0 && par2=7)   //
                || (opcode=282 && par1=0 && par2=21)  //
          BEGIN
            DELETE_BYTES ef_off+(k+ef_ind+local_delta)*0x30 0x30
            delta -=1
            local_delta -=1
          END
        END
        WRITE_SHORT ab_off+i*0x28+0x1e ef_num+local_delta
      END
      PATCH_PRINT ~Detectable Spells: SPWI705.SPL has been successfully repaired~
    END

  END // PATCH_IF repair=1
BUT_ONLY

ACTION_IF fubar BEGIN
  COPY_EXISTING ~spwi705.spl~ override
    READ_ASCII 0x0 data (0x64)
  BUT_ONLY
 
  CREATE SPL "spwi705"
    WRITE_ASCIIE 0x0 "%data%"
    WRITE_SHORT 0x68 1
    WRITE_LONG 0x6a 0x9a
    INSERT_BYTES 0x72 0x28
    WRITE_SHORT 0x72 2
    WRITE_SHORT (0x72+2) 2
    WRITE_ASCII (0x72+4) "SPWI705B"
    WRITE_BYTE (0x72 + 0xc) 1
    WRITE_SHORT (0x72 + 0x10) 1
    WRITE_SHORT (0x72 + 0x12) 7
    WRITE_SHORT (0x72 + 0x22) 1
    WRITE_SHORT (0x72 + 0x24) 1
    WRITE_SHORT (0x72 + 0x26) 221
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=230 parameter1=8 parameter2=1 timing=1 duration=0 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=215 parameter1=0 parameter2=1 timing=0 duration=3 target=2 power=7 resist_dispel=2
                           STR_VAR resource=~spattck1~ END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=139 parameter1=40690 parameter2=0 timing=1 duration=0 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=240 parameter1=0 parameter2=28 timing=1 duration=0 target=2 power=7 resist_dispel=2 END
    
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=230 parameter1=8 parameter2=1 timing=4 duration=7 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=177 parameter1=0 parameter2=2 timing=3 duration=7 target=2 power=7 resist_dispel=2
                           STR_VAR resource=~spattck1~ END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=139 parameter1=40690 parameter2=0 timing=4 duration=7 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=240 parameter1=0 parameter2=28 timing=4 duration=7 target=2 power=7 resist_dispel=2 END

    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=230 parameter1=8 parameter2=1 timing=4 duration=13 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=177 parameter1=0 parameter2=2 timing=3 duration=13 target=2 power=7 resist_dispel=2
                           STR_VAR resource=~spattck1~ END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=139 parameter1=40690 parameter2=0 timing=4 duration=13 target=2 power=7 resist_dispel=2 END
    LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode=240 parameter1=0 parameter2=28 timing=4 duration=13 target=2 power=7 resist_dispel=2 END


END

END // end of function

//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

// Since SCS occupies one of DS slots for weapons, I see no reason not to include it

DEFINE_ACTION_FUNCTION ds_detectable_weapon_enchantment BEGIN

LAF ds_resolve_stat STR_VAR id=~WEAPON_ENCHANTMENT~ END

COPY_EXISTING_REGEXP GLOB ~.*\.itm~ override
PATCH_TRY
PATCH_IF SOURCE_SIZE>0x71 BEGIN
 LPF ~FJ_SPL_ITM_REINDEX~ END

 
  READ_LONG  0x64 ab_off
  READ_SHORT 0x68 ab_num

  weapon=0
  FOR (i=0;i<ab_num;i+=1) BEGIN
    READ_BYTE ab_off+i*0x38 typ
    READ_BYTE ab_off+i*0x38+2 loc
    PATCH_IF (typ=1 || typ=2) && loc=1 BEGIN
      weapon=1
    END
  END

  PATCH_IF weapon BEGIN
    READ_LONG  0x60 ench
    READ_LONG  0x6a ef_off
    READ_SHORT 0x70 global
    exists=0
    FOR (i=0;i<global;i+=1) BEGIN
      READ_SHORT ef_off+i*0x30 opc
      READ_LONG ef_off+i*0x30+4 p1
      READ_LONG ef_off+i*0x30+8 p2
      PATCH_IF opc=233 && p2=109 BEGIN
        PATCH_IF p1 !=ench BEGIN
          WRITE_LONG ef_off+i*0x30+4 ench
        END
        i=global
        exists=1
      END
    END

    PATCH_IF exists=0 BEGIN
      INSERT_BYTES ef_off 0x30
      WRITE_SHORT ef_off 233
      WRITE_BYTE ef_off+2 1
      WRITE_LONG ef_off+4 ench
      WRITE_LONG ef_off+8 109
      WRITE_BYTE ef_off+0xc 2
      WRITE_LONG ef_off+0x12 100

      FOR (i=0;i<ab_num;i+=1) BEGIN
        WRITE_SHORT ab_off+i*0x38+0x20 THIS+1
      END

      WRITE_SHORT 0x70 global+1
    END

  END // PATCH_IF weapon=1
END
WITH DEFAULT
    PATCH_WARN "Detectable Spells has had to skip file %SOURCE_FILE% (error message was: %ERROR_MESSAGE%). Installation will continue, but there may be instabilities."
END
BUT_ONLY

END // end of function


//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

// Tightly based on Nythrun's ~fj_spl_itm_reindex~ patch

DEFINE_PATCH_FUNCTION ~FJ_SPL_ITM_REINDEX~ BEGIN

PATCH_IF !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.spl~) BEGIN
  hs = 0x28
  WRITE_LONG 0xc ~-1~ //Identified name
  WRITE_LONG 0x54 ~-1~ //Identified description
  PATCH_FOR_EACH tz IN 0x44 0x48 0x58 0x5c BEGIN
    WRITE_LONG tz 0
  END
END ELSE PATCH_IF !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.itm~) BEGIN
  hs = 0x38
END
READ_LONG 0x64 hf //Extended header offset
READ_SHORT 0x68 hc //Extended header count
READ_LONG 0x6a fb //Feature block table offset
READ_SHORT 0x70 fc //Feature block count
PATCH_IF ((hf > fb) AND (hc > 0)) BEGIN
  READ_ASCII hf ~eh~ ELSE ~fail~ (hs * hc)
  PATCH_IF (~%eh%~ STRING_EQUAL ~fail~) BEGIN
    WHILE ((~%eh%~ STRING_EQUAL ~fail~) AND (hc > 0)) BEGIN
      READ_ASCII hf ~eh~ ELSE ~fail~ (hs * hc)
      hc -= 1
    END
  END
  DELETE_BYTES hf (hs * hc)
  hf = 0x72
  WRITE_LONG 0x64 hf
  WRITE_SHORT 0x68 hc
  fb = (0x72 + (hs * hc))
  WRITE_LONG 0x6a fb
  PATCH_IF !(~%eh%~ STRING_EQUAL ~fail~) BEGIN
    INSERT_BYTES hf (hs * hc)
    WRITE_ASCIIE hf ~%eh%~
  END
END ELSE PATCH_IF ((hf != 0x72) AND (hc = 0)) BEGIN
  hf = 0x72
  WRITE_LONG 0x64 hf
END
FOR (i1 = 0; i1 < (hs * hc); i1 += hs) BEGIN
  WRITE_SHORT (hf + i1 + 0x20) fc
  READ_SHORT (hf + i1 + 0x1e) cx
  fc += cx
END
PATCH_IF (SOURCE_SIZE > (0x72 + (hs * hc) + (0x30 * fc))) BEGIN
  DELETE_BYTES (0x72 + (hs * hc) + (0x30 * fc)) (SOURCE_SIZE - (0x72 + (hs * hc) + (0x30 * fc)))
END

// added by Ardanis
WRITE_SHORT 0x6e 0

END // end of function

//////////////////////////////////////////////////////////////////////////////////////
//// Softcoded version of WEIDU LOOKUP_IDS, because we don't want to have to keep clearing
//// the IDS map
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION ds_load_ids
    STR_VAR ids=""
    RET_ARRAY ids_map
BEGIN
  ACTION_IF FILE_EXISTS_IN_GAME "%ids%.ids" BEGIN
    COPY_EXISTING "%ids%.ids" "override"
        READ_2DA_ENTRIES_NOW _ds_ids_entries 2
        FOR (row=0;row<_ds_ids_entries;++row) BEGIN
            READ_2DA_ENTRY_FORMER _ds_ids_entries row 0 val
            PATCH_IF IS_AN_INT val BEGIN
                READ_2DA_ENTRY_FORMER _ds_ids_entries row 1 var
                SET $ids_map("%var%")=val
            END
        END
    BUT_ONLY
  END
  OUTER_SET $ids_map("DS_IDS_MAP_LOADED")=1
END

ds_scs.tpa:

Quote

// assumes core DS library loaded

DEFINE_ACTION_FUNCTION ds_scs BEGIN

   ACTION_FOR_EACH tablename IN scs_extra scs_extra_2 BEGIN
      LAF ds_process_table INT_VAR complain=0 STR_VAR table=".../ds-inline/%tablename%.2da" END
   END
   ACTION_IF demivrgvs BEGIN
       LAF ds_process_table INT_VAR complain=0 STR_VAR table=".../ds-inline/scs_sr.2da" END
       LAF ds_process_table INT_VAR complain=0 STR_VAR table=".../ds-inline/scs_holysmite_sr.2da" END
   END ELSE BEGIN
       LAF ds_process_table INT_VAR complain=0 STR_VAR table=".../ds-inline/scs_holysmite_nosr.2da" END
   END

   ACTION_FOR_EACH table_name IN PRIORITY_BREACH PRIORITY_DISPEL DO_NOT_TARGET_SPELLS
                                 PRO_SPELLS_LEVEL_FIVE_MINUS PRO_SPELLS_LEVEL_SIX_SEVEN_EIGHT SPELL_PROTECTION
   BEGIN
      LAF ds_process_table INT_VAR complain=0 STR_VAR table=".../ds-inline/%table_name%.2da" default_stat="%table_name%" END
   END


END

/////////////////////////////////////////////////////////////
//// The data
///////////////////////////////////////////////////////////

// these are a few tweaks to the SoD detections, plus a couple of specific SCS ones and third-party ones

<<<<<<<< .../ds-inline/scs_extra.2da
resource                                     stat
CLERIC_DEFENSIVE_HARMONY                     BUFF_ENHANCEMENT
CLERIC_BLESS                                 BUFF_ENHANCEMENT
WIZARD_MIRROR_IMAGE                          BUFF_PRO_WEAPONS
CLERIC_CHANT:D                               BUFF_ENHANCEMENT
CLERIC_RIGHTEOUS_WRATH_OF_THE_FAITHFUL:A     BUFF_ENHANCEMENT
CLERIC_RIGHTEOUS_WRATH_OF_THE_FAITHFUL:B     ALLIED_RIGHTEOUS_WRATH_OF_THE_FAITHFUL
FL#TAS02                                     POISON_WEAPON      //  ASSASSIN_POISON_WEAPON (RR version)
WIZARD_ANTIMAGIC_SHELL                         SCROLL_OF_PROTECTION_FROM_MAGIC
>>>>>>>>

<<<<<<<< .../ds-inline/scs_sr.2da
resource                              stat                     duration
WIZARD_FLESH_TO_STONE                 TURNING_TO_STONE         7
WIZARD_FLESH_TO_STONE                 DO_NOT_TARGET_SPELLS     7
SPPR609E                              DO_NOT_REMOVE_BLINDNESS  -1
WIZARD_TRUE_STRIKE                    TRUE_STRIKE              -1
WIZARD_MIND_BLANK                     MIND_BLANK               -1 // SR version (there's also an IWD version)
>>>>>>>>

<<<<<<<< .../ds-inline/scs_extra_2.2da
resource                              stat                  match_opcode       duration
WIZARD_TIME_STOP                      TIME_STOP             231                18
SPWISH17                              TIME_STOP             231                36
>>>>>>>>

<<<<<<<< .../ds-inline/scs_holysmite_nosr.2da
resource                              stat                    match_opcode       match_resource
CLERIC_HOLY_SMITE                     DO_NOT_CURE_BLINDNESS   177                CDBLIND
>>>>>>>>

<<<<<<<< .../ds-inline/scs_holysmite_sr.2da
resource                              stat                    match_opcode
CLERIC_HOLY_SMITE                     DO_NOT_CURE_BLINDNESS   74
CLERIC_HOLY_SMITE:E                   DO_NOT_CURE_BLINDNESS   74
>>>>>>>>

 


// these are all SCS-specific new classes for detection

<<<<<<<< .../ds-inline/PRIORITY_BREACH.2da
resource
WIZARD_PROTECTION_FROM_MAGIC_WEAPONS
WIZARD_MANTLE
WIZARD_IMPROVED_MANTLE
WIZARD_ABSOLUTE_IMMUNITY
POTN35 // magic shielding
WIZARD_PROTECTION_FROM_MAGIC_ENERGY
CLERIC_CHAOTIC_COMMANDS
CLERIC_DIVINE_SHELL
CLERIC_SHIELD_OF_LATHANDER
CLERIC_GREATER_SHIELD_OF_LATHANDER
CLERIC_IMPERVIOUS_SANCTITY_OF_MIND
WIZARD_MIND_BLANK
CLERIC_UNDEAD_WARD // a little situational, but we'll assume the player knows what they're doing
>>>>>>>>

<<<<<<<< .../ds-inline/PRIORITY_DISPEL.2da
resource
WIZARD_PROTECTION_FROM_MAGIC_WEAPONS
WIZARD_WRAITH_FORM
WIZARD_MANTLE
WIZARD_IMPROVED_MANTLE
WIZARD_ABSOLUTE_IMMUNITY
POTN35  // magic shielding
WIZARD_PROTECTION_FROM_MAGIC_ENERGY
CLERIC_CHAOTIC_COMMANDS
POTN04 // these are all Giant Strength
POTN05
POTN06
POTN07
POTN12
WIZARD_HASTE
WIZARD_ADVANCED_HASTE
CLERIC_DIVINE_SHELL
CLERIC_SHIELD_OF_LATHANDER
CLERIC_GREATER_SHIELD_OF_LATHANDER
CLERIC_IMPERVIOUS_SANCTITY_OF_MIND
WIZARD_MIND_BLANK
>>>>>>>>


<<<<<<<< .../ds-inline/DO_NOT_TARGET_SPELLS.2da
resource                  match_opcode         duration
WIZARD_ANTIMAGIC_SHELL    142                  -1
SCRL07                    142                  -1
WIZARD_IMPRISONMENT       215                  4
DEMILICH_TRAP_SOUL        215                  4
WIZARD_MAZE               215                  4
PSIONIC_MAZE              215                  4
>>>>>>>>

<<<<<<<< .../ds-inline/PRO_SPELLS_LEVEL_FIVE_MINUS.2da
resource                                  match_opcode
SPRA302                                   201
WIZARD_MINOR_SPELL_DEFLECTION             201
WIZARD_MINOR_GLOBE_OF_INVULNERABILITY     142
WIZARD_SPELL_SHIELD                       226
WIZARD_MINOR_SPELL_TURNING                200
WIZARD_MINOR_SPELL_TURNING                201  // this allows for DS
WIZARD_SPELL_IMMUNITY_ABJURATION          142
WIZARD_SPELL_IMMUNITY_CONJURATION         142
WIZARD_SPELL_IMMUNITY_DIVINATION          142
WIZARD_SPELL_IMMUNITY_ENCHANTMENT         142
WIZARD_SPELL_IMMUNITY_ILLUSIONIST         142
WIZARD_SPELL_IMMUNITY_INVOCATION          142
WIZARD_SPELL_IMMUNITY_NECROMANCY          142
WIZARD_SPELL_IMMUNITY_ALTERATION          142
>>>>>>>>

<<<<<<<< .../ds-inline/PRO_SPELLS_LEVEL_SIX_SEVEN_EIGHT.2da
resource                                  match_opcode
WIZARD_SPELL_DEFLECTION                   201
WIZARD_SPELL_TURNING                      200
WIZARD_SPELL_TURNING                      201
POTN33                                    102
WIZARD_GLOBE_OF_INVULNERABILITY           142
>>>>>>>>

<<<<<<<< .../ds-inline/SPELL_PROTECTION.2da
resource                                  match_opcode
WIZARD_MINOR_SPELL_DEFLECTION             201
WIZARD_MINOR_SPELL_TURNING                200
WIZARD_MINOR_SPELL_TURNING                201
WIZARD_SPELL_IMMUNITY_ABJURATION          142
WIZARD_SPELL_DEFLECTION                   201
WIZARD_SPELL_TURNING                      200
WIZARD_SPELL_TURNING                      201
WIZARD_SPELL_TRAP                         259
WIZARD_SPELL_TRAP                         201
>>>>>>>>

 

Edited 01:

There is a typo in finmel.ssl:

Spoiler

Should be:

   Action(SpellRESTimer,"mels545",slowsymbol|150|50)

instead of

    Action(SpellRESTimer,"spwi545",slowsymbol|150|50)

 

In sarevok.tpa, edits=patch_data is missing:

Spoiler

      END
      LAF clone_creature STR_VAR creature= ~%bg1_skeleton_warrior%=>dw#angsk~ edits=patch_data END
      MAKE_PATCH
         add_items=>~%tutu_var%arow04(x20) %tutu_var%bow01~
         enforce_charclass=>is_bg1
      END
      LAF clone_creature STR_VAR creature=~%bg1_skeleton_warrior%=>dw#diask~ edits=patch_data END
      MAKE_PATCH
         replace_items=>~%tutu_var%staf01~
         enforce_charclass=>is_bg1
      END
      LAF clone_creature STR_VAR creature= ~%bg1_skeleton_warrior%=>dw#semsk~ edits=patch_data END

in c3assassin.tpa, CreateCreatureOffscreen can't use DV

Spoiler

   LAF swap_text STR_VAR files="%tutu_var%molkar.dlg" swaps=~HALACAN=>HALACA~ END // CreateCreatureOffscreen only use the ResName of the Cre and not the DV
   LAF swap_text STR_VAR files="%tutu_var%lamalh.dlg" swaps=~MANEIRA=>MANEIR~ END // CreateCreatureOffscreen only use the ResName of the Cre and not the DV
   LAF swap_text STR_VAR files="%tutu_var%lamalh.dlg" swaps=~NATALKA=>NTNATALK~ END // NTotSC compatibility

Edited 02:

in golbur01.ssl, there is a missing check:

Spoiler

IF
    See(NearestEnemyOf(Myself))
    Global("FIN_TIME_STOP_RUNNING","GLOBAL",0)
    !GlobalTimerNotExpired("BurningManFearTimer","LOCALS")
THEN
    RESPONSE #100
        ReallyForceSpell(NearestEnemyOf(Myself),BURNING_MAN_KEENING)
        SetGlobalTimer("BurningManFearTimer","LOCALS",24)
END

in drake.ssl, there seem to be a typo:

Spoiler

IF TRIGGER
   TargetBlock(EnemiesInOrderShort)
   Range(scstarget,10)
   TriggerBlock(Enemy|Disabled)
   CheckStatGT(scstarget,4,NUMBEROFATTACKS)
   !HasItem("eneblade",scstarget)
   !HasItem("melfmet",scstarget)
   !GlobalTimerNotExpired("invis","LOCALS") // no more than 1/3 rds
THEN DO
     Combine()
     Action(SpellMyself,WIZARD_INVISIBILITY|100|50)
     SetGlobalTimer("invis","LOCALS",30)
     SetGlobalTimer("inviswander","LOCALS",7)
END

IF TRIGGER
   TargetBlock(EnemiesInOrderShort)
   Range(scstarget,10)
   HPPercentLT(Myself,50)
   TriggerBlock(Enemy|Disabled)
   !HasItem("eneblade",scstarget)
   !HasItem("melfmet",scstarget)
   !GlobalTimerNotExpired("invis","LOCALS") // no more than 1/3 rds
THEN DO
     Action(SpellMyself,WIZARD_INVISIBILITY|100|50)
     SetGlobalTimer("invis","LOCALS",30)
     SetGlobalTimer("inviswander","LOCALS",7)
END

In abazigal_enclave.tpa, I may have spot a typo:

Spoiler

DEFINE_ACTION_FUNCTION abazigal_wheels BEGIN

    // Wheels compatibility
    
    LAF clone_creature STR_VAR creature=~bazliz03=>dw#viliz~ editstring=~script_override=>dw#vilat script_class=>"None" gender=>EXTRA6~ END
    LAF clone_creature STR_VAR creature=~eyesek01=>dw#visek eyeegl01=>dw#viegl~     editstring=~script_override=>dw#vilat script_class=>"eyesek01" gender=>EXTRA7~ END


END

Spoiler

   // convert LHS exit to AR6008 exit; redo blocked entrance

   MAKE_PATCH
      match=>"trigger_name=Tran6008"
      trigger_dest=>AR6008
      trigger_entrance=>Exit6012
   END
   LAF edit_area STR_VAR area=ar6012 editstring="patch_trigger=>patch_data" END
   MAKE_PATCH
      match=>"trigger_name=Info6008"
      trigger_name=>"DMWWFYExit"
      trigger_script=>"dw#anado"
   END
   LAF edit_area STR_VAR area=ar6012 editstring="patch_trigger=>patch_data" END
   LAF install STR_VAR location=resource file="dw#anado.baf" END

 

Anyway, thank you for this amazing mod.

Edited by TotoR
Link to comment

As a reminder, Some of those typos seem present in v35.1:

On 3/27/2022 at 11:06 PM, TotoR said:

stratagems\mage\ssl\combatblocks\fleecloud.ssl: I may be wrong, but the script action 'RunAwayFromNoLeaveArea' does not work with oBG2. Could be replace by 'RunAwayFrom'

On 3/27/2022 at 11:06 PM, TotoR said:

the following files is empty:

  • stratagems\mage\ssl\combatblocks\fleecloud_fm.ssl

 

On 3/27/2022 at 11:06 PM, TotoR said:

stratagems\gameplay\shapeshift.tpa: druid shapeshift tokens are two-handed. in oBG2 this could create CTD with modded druids. Could be smart to make them one-handed for ennemy only.

 

On 3/27/2022 at 11:06 PM, TotoR said:

stratagems\ganai\genai.tpa: There seem to be a missing trigger

 

On 3/27/2022 at 11:06 PM, TotoR said:

There is a typo in finmel.ssl:

 

On 3/27/2022 at 11:06 PM, TotoR said:

In sarevok.tpa, edits=patch_data is missing:

 

On 3/27/2022 at 11:06 PM, TotoR said:

in golbur01.ssl, there is a missing check:

 

On 3/27/2022 at 11:06 PM, TotoR said:

in drake.ssl, there seem to be a typo:

 

On 3/27/2022 at 11:06 PM, TotoR said:

In abazigal_enclave.tpa, I may have spot a typo:

 

Edited by TotoR
Link to comment

Thanks - not sure how I missed this post previously.

3 minutes ago, TotoR said:

stratagems\mage\ssl\combatblocks\fleecloud.ssl: I may be wrong, but the script action 'RunAwayFromNoLeaveArea' does not work with oBG2. Could be replace by 'RunAwayFrom'

That's not a bug: some EE-only script instructions get swapped out automatically when SSL scripts are compiled on oBG2. (Look at the script_ee_to_vanilla function in sfo2e/lib_script.tpa).

13 minutes ago, TotoR said:

the following files is empty:

  • stratagems\mage\ssl\combatblocks\fleecloud_fm.ssl

Fixed; not sure how that happened.

 

14 minutes ago, TotoR said:

stratagems\gameplay\shapeshift.tpa: druid shapeshift tokens are two-handed. in oBG2 this could create CTD with modded druids. Could be smart to make them one-handed for ennemy only.

Can you clarify the bug you have in mind?

 

17 minutes ago, TotoR said:

stratagems\ganai\genai.tpa: There seem to be a missing trigger

Fixed, thanks.

 

19 minutes ago, TotoR said:

There is a typo in finmel.ssl:

That's actually a change in the latest version of Ascension not mirrored in SCS. (Since I wrote that latest version you'd have thought I'd have noticed, but no...) Fixed

 

26 minutes ago, TotoR said:

in drake.ssl, there seem to be a typo:

Fixed, thanks.

23 minutes ago, TotoR said:

In sarevok.tpa, edits=patch_data is missing:

Thanks, fixed.

24 minutes ago, TotoR said:

in golbur01.ssl, there is a missing check:

Thanks, fixed.

31 minutes ago, TotoR said:

In abazigal_enclave.tpa, I may have spot a typo:

I agree with the typo in the second edit in abazigal_wheels. The rest looks correct to me; can you say why you think it's wrong?

Link to comment
27 minutes ago, DavidW said:

That's not a bug: some EE-only script instructions get swapped out automatically when SSL scripts are compiled on oBG2. (Look at the script_ee_to_vanilla function in sfo2e/lib_script.tpa).

  Thank you for the intel

11 minutes ago, DavidW said:
43 minutes ago, TotoR said:

stratagems\gameplay\shapeshift.tpa: druid shapeshift tokens are two-handed. in oBG2 this could create CTD with modded druids. Could be smart to make them one-handed for ennemy only.

Can you clarify the bug you have in mind?

Some mods add druids with shield that create CTD when the druid equipe the token with oBG2. creating One-handed token could be a solution here.

 

15 minutes ago, DavidW said:
48 minutes ago, TotoR said:

In abazigal_enclave.tpa, I may have spot a typo:

I agree with the typo in the second edit in abazigal_wheels. The rest looks correct to me; can you say why you think it's wrong?

For Tran6008: ar6012.are, there is no trigger_name=Tran6001 the only trigger is Tran6008

For bazliz03=>dw#viliz: the Script use by Wheel for dw#viliz.cre is dw#vilat.bcs and not dw#viliz.bcs (witch does not exists)

Link to comment
3 hours ago, TotoR said:

For Tran6008: ar6012.are, there is no trigger_name=Tran6001 the only trigger is Tran6008

That's true for the original ar6012.are. But if you look earlier in the code, I start by copying ar6004 over ar6012. And ar6004 does have Tran6001 (and Info6001).

3 hours ago, TotoR said:

For bazliz03=>dw#viliz: the Script use by Wheel for dw#viliz.cre is dw#vilat.bcs and not dw#viliz.bcs (witch does not exists)

Got it. I was focusing on swapping "" for "none" (which I don't think is needed) and didn't notice the swap of dw#viliz for dw#vilat. 

3 hours ago, TotoR said:

Some mods add druids with shield that create CTD when the druid equipe the token with oBG2. creating One-handed token could be a solution here.

OK, that's probably sensible.

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