Jump to content

SCS not compatible with multiclass kits...?


Recommended Posts

Background:

 

So, it turns out it is possible to have real kits for multiclasses - not just single-class kits 'Keepered onto multiclass characters. There are a number of reason why the former are superior to the latter, but for now let's just take it on faith that it's a good thing.

 

One issue is, the engine is not perfectly set up for multiclass kits. The biggest hurdle is, they use the trueclass CLAb table (clabfi01.2da, clabma01.2da, etc.) instead of the kit's table. Aquadrizzt has written a little function that allows anyone who can make a kit mod, to make a multiclass kit mod with now extra effort. It reads the mit's CLAB table and creates .EFF files mimicking for the various GA_ and AP_ spells, and adds those to opcode 177 effects in a spell in the trueclass CLAB, and the 177 effects are directed at the appropriate kits. It's clever, and the result is seamless and fun.

 

The issue:

 

Problem is, the SCS General AI component breaks down when spells with these 177 effects are present in clabfi01.2da etc. It looks like it ends up not applying the "core changes to CRE files" to any creature using the affected CLAB tables... and, since they are the trueclass tables, that means the core changes are not applied to a large number of creatures.

 

I find SCS harder to analyze than most mods. The .tp2 files for the AI component just says

 

LAF run STR_VAR files=genai END

...but I have no idea where the function resides, to go inspect it. I found it eventually, but the genai .tpa file just says:

 

LAM read_in_clab_spelldata
...and I have no idea where that function resides. Anyway I found that one too, and I think that might be where SCS is choking. But I'm having trouble parsing what's going on. The macro in question looks like this:

 

DEFINE_ACTION_MACRO ~read_in_clab_spelldata~ BEGIN
   LOCAL_SET i=0
   LOCAL_SET j=0
   LOCAL_SET colcount=0
   LOCAL_SET rowcount=0
   LOCAL_SET parameter1=0
   LOCAL_SET parameter2=0
   LOCAL_SET opcode=0
   LOCAL_SET offset_base=0
   LOCAL_SPRINT resource_here ""
   LOCAL_SPRINT resource ""
   LOCAL_SPRINT tempadd ""
   LOCAL_SPRINT tempremove ""
      SILENT
   COPY_EXISTING_REGEXP GLOB "clab.*\.2da" "%workspace%"
      COUNT_2DA_COLS colcount
      COUNT_2DA_ROWS colcount rowcount
      FOR (i=0;i<rowcount;i+=1) BEGIN
         FOR (j=0;j<colcount;j+=1) BEGIN
              READ_2DA_ENTRY i j colcount resource
              PATCH_MATCH "%resource%" WITH
              "GA_.*" BEGIN
                  INNER_PATCH_SAVE resource "%resource%" BEGIN
                     DELETE_BYTES 0x0 3
                  END
                  TO_UPPER resource
                  PATCH_IF !VARIABLE_IS_SET "RESREF_%resource%_LEVEL" && FILE_EXISTS_IN_GAME "%resource%.spl" BEGIN
                      INNER_ACTION BEGIN
                         COPY_EXISTING "%resource%.spl" "%workspace%"
                               LPF SPL_read_level RET "RESREF_%resource%_LEVEL"=value END
                               LPF SPL_read_spell_type RET "RESREF_%resource%_TYPE"=value END
                         BUT_ONLY
                      END
                  END
              END
              "AP_.*" BEGIN
                  INNER_PATCH_SAVE resource "%resource%" BEGIN
                     DELETE_BYTES 0x0 3
                  END
                  TO_UPPER resource
                  PATCH_IF !VARIABLE_IS_SET "RESREF_%resource%_KIT_EFFECTS_ADD" && FILE_EXISTS_IN_GAME "%resource%.spl" BEGIN
                      INNER_ACTION BEGIN
                        ACTION_IF FILE_EXISTS_IN_GAME "%resource%.spl" BEGIN
                         COPY_EXISTING "%resource%.spl" "%workspace%"
                            SPRINT tempadd ""
                            SPRINT tempremove ""
                            LPF return_offset STR_VAR entry_type=ability file_ext=SPL RET offset_base=value END
                                    GET_OFFSET_ARRAY2 fx_arr offset_base ITM_V10_HEAD_EFFECTS
                                    PHP_EACH fx_arr AS int=>offset_secondary BEGIN
                                       READ_SHORT offset_secondary opcode
                                       READ_LONG offset_secondary+0x4 parameter1
                                       READ_LONG offset_secondary+0x8 parameter2
                                       READ_ASCII offset_secondary+0x14 resource_here
                                       PATCH_IF "%resource_here%" STRING_EQUAL "" BEGIN
                                          SPRINT resource_here null
                                       END
                                       PATCH_MATCH "%opcode%" WITH
                                       172 177 BEGIN END
                                       DEFAULT
                                          SPRINT tempadd "%tempadd% add_effect_inline=>~parameter1=>%parameter1%  parameter2=>%parameter2% resource=>%resource_here% opcode=>%opcode%~"
                                          SPRINT tempremove "%tempremove% delete_effect=>~opcode=%opcode% and parameter2=%parameter2% and resource=%resource_here%~" // parameter1 intentionally left out
                                       END
                                    END
                         BUT_ONLY
                       END
                       OUTER_SPRINT "RESREF_%resource%_KIT_EFFECTS_ADD" "%tempadd%"
                       OUTER_SPRINT "RESREF_%resource%_KIT_EFFECTS_REMOVE" "%tempremove%"
                      END
                  END
              END
              DEFAULT
              END
         END
      END
   BUT_ONLY

END

 

Then, after reading that data and a bunch of other data, SCS does this:

 

         PATCH_PRINT "Applying kit/proficiency/script features to %filename%"
         PATCH_TRY
               LPF genai STR_VAR filename file_ext=CRE arguments="all conditional fix_thac0" END
         WITH DEFAULT
               PATCH_WARN "Failed to apply general-AI patch to %filename% (error message %ERROR_MESSAGE%)"
               LPF warning STR_VAR warning="Failed to apply general-AI patch to %filename% (error message %ERROR_MESSAGE%)"  END
         END

That is the error message we've seen, so I think this narrows down the problem... but I still don't know what the problem is. Jarno has suggested that SCS doesn't like that the 177 effects in the multiclass spells set parameter2 to 9. I'm not sure if that's it... but I will note that mod kits end up with unusual values in parameter1 in that case, and the "read_in_clab_spelldata" macro specifically says "// parameter1 intentionally left out."

 

So, I have a few questions to try to nail this down, if anyone understands this code better than me.

 

1) Why is "parameter1 intentionally left out" in the "read_in_clab_spelldata" macro?

 

2) What is this feature actually doing? Applying CLAB effects hidden inside 177 effects to enemy creatures? How many of these are there, really? Maybe a brute-force temporary solution for players who want to use both mods could be simply excluding 177 effects from this process? So, edit the SCS macro like so:

 

               PATCH_MATCH "%opcode%" WITH
               172 /*177*/ BEGIN END
               DEFAULT
                 SPRINT tempadd "%tempadd% add_effect_inline=>~parameter1=>%parameter1%  parameter2=>%parameter2% resource=>%resource_here% opcode=>%opcode%~"
                 SPRINT tempremove "%tempremove% delete_effect=>~opcode=%opcode% and parameter2=%parameter2% and resource=%resource_here%~" // parameter1 intentionally left out
               END

 

?

 

3) Obviously the ideal is to have all such effects applied to creatures, if possible... maybe a better solution (if still temporary and brute-force) is to try to specifically exclude only 177 effects with parameter2 = 9? So:

 

               READ_SHORT offset_secondary opcode
               READ_LONG offset_secondary+0x4 parameter1
               READ_LONG offset_secondary+0x8 parameter2
               READ_ASCII offset_secondary+0x14 resource_here
               PATCH_IF "%resource_here%" STRING_EQUAL "" BEGIN
                  SPRINT resource_here null
               END
               PATCH_MATCH "%opcode%" WITH
               172 177 BEGIN END
               DEFAULT
                 PATCH_IF NOT (parameter2 = 9) BEGIN
                   SPRINT tempadd "%tempadd% add_effect_inline=>~parameter1=>%parameter1%  parameter2=>%parameter2% resource=>%resource_here% opcode=>%opcode%~"
                   SPRINT tempremove "%tempremove% delete_effect=>~opcode=%opcode% and parameter2=%parameter2% and resource=%resource_here%~" // parameter1 intentionally left out
                 END
               END

 

Link to comment

Sorry to bother, but is the following

 

"MnG had been INCLUDEing the QD_multi function in an ALWAYS block in the .tp2, so the functions would be available generally. This means CLABFI01.2da would get the QD_multi entries when any part of the mod is installed. I changed this, so that the QD_multi functions are only invoked when the "multiclass kits" component is installed"

still valid as of MnG v3.7.1 (latest version)? Because SCS has just thrown at me those famous warnings even if I didn't install the multiclass kits component......

Link to comment

Have you installed some other mod that uses the QDMulti functions?

 

Also, I have to backtrack a bit: I have recently installed the MnG multiclass kits (and everything else, as well as other similar mods like Faiths & Powers and Tome & Blood) and SCS did not throw any errors. So we might have misdiagnosed the problem.

 

In any event, when I could replicate the errors, I solved it by editing lib_macro.tpa as described above - just comment out "177" in line 374. Did you try that?

Link to comment

I am sure it was mentioned in some other discussion and I have forgotten it, but what exactly is the reason for SCS - dealing with AI and scripts for enemies - to be necessarily installed after mods that add multiclass kits? Those kits are normally for PC or joinable NPCs and not for enemies.

Is it not simply possible to change install orders?

Link to comment

Have you installed some other mod that uses the QDMulti functions?

It's Faiths & Powers that is causing the issue now (I didn't install all the components, just some paladin kits....). Could you do something similar to what you did for MnG so that the QD_multi functions are only invoked when needed? Anyway, why didn't SCS throw any errors at you? This is really odd.... For the record, I'm speaking of BG:EE v2.5 beta....

Edited by Luke
Link to comment

I just installed FnP and MnG on BGEE v2.4 and SCS gave me no errors. Tons of multiclass kits, no problem.

 

Re: changing the order - off the top of my head that seems too simplistic. Some mods that offer multiclass kits also offer single-class kits, in the same component. Maybe those single-class kits are not geared toward AI either... I mean, basically no kit mods are intended for the AI, so by that logic all kit mods can be installed after SCS.

 

BUT some rule tweak mods want to be installed after any/all kit mods. And SCS might be designed to be installed after those tweak mods. This kind of thing just seems to invite catch-22 dependencies/conflicts, like the bad old days. Better to know what one's mod does, and what it needs, and design for it to be ordered according to that. That design can then easily take into account and adjust for whatever mods are designed to be installed earlier.

 

And speaking of adjusting, Luke try editing lib_macro.tpa in SCS before installing. Line 374, change "177" to "/*177*/" ... worked like a charm for me the last time I replicated your issue. I didn't get through the whole game but everything seemed fine as far as the Bandit Camp.

Link to comment

And speaking of adjusting, Luke try editing lib_macro.tpa in SCS before installing. Line 374, change "177" to "/*177*/" ... worked like a charm for me the last time I replicated your issue. I didn't get through the whole game but everything seemed fine as far as the Bandit Camp.

Ok, will try.... -> It's not working for me....

Edited by Luke
Link to comment

Well then, the problem may have nothing to do with multiclass kits at all. I'm afraid this might need info from someone who understand SCS better. The fact that I can reliably install SCS with those mods without errors, but you cannot, suggests that it might be related to some other aspect of your install...

Edited by subtledoctor
Link to comment

Here we go again..... SETUP-STRATAGEMS.DEBUG is so filled with warnings (5.4 MB) that I can't even upload it here.....

You do know that .zip'ping it will cut a .txt file into tiny piece and allow a VERY large original file size. This is because the text encoding is removed from the file during the build of the archive. Just like that 144kb file became 5.28kb file, the further the file goes on, the better the rate in this case.
Link to comment

If you're only adding paladin kits from FnP, you can edit the main .tp2 file, near the very top, add a double slash (" // ") at the beginning of this line:

INCLUDE ~faiths_and_powers/lib/qd_multiclass.tpa~
Just to try and see if it helps. Again this is weird because I have IR, SR4b15, DR, FnP, MnG, and SCS, with no errors.

 

One difference I see: I didn't use the SR Mirror Image Fix or Remove Hidden Spells or Update Spellbooks of Joinable NPCs. But that's a long shot...

Link to comment

 

Here we go again..... SETUP-STRATAGEMS.DEBUG is so filled with warnings (5.4 MB) that I can't even upload it here.....

Just like that 144kb file became 5.28kb file, the further the file goes on, the better the rate in this case.

I'm terribly sorry, but if I zip that 5.4 MB file, then it becomes a 418 KB file -> still too large.....

Edited by Luke
Link to comment

I'm terribly sorry, but if I zip that 5.4 MB file, then it becomes a 418 KB file -> still too large.....

That happens when you use too much of the forum space as a whole, for example, if you go and remove the files from this post of yours, you'll have enough space... as there's more than 416kb's in it.

@Jarno Mikkola, I've attached my WeiDU.log, Stratagems.debug and SFO_warnings.txt. Please, have a look at them....

:p

 

I myself have 16 Mb's still left(I think we start at 30 MB's at start), so ...

Link to comment

If you're only adding paladin kits from FnP, you can edit the main .tp2 file, near the very top, add a double slash (" // ") at the beginning of this line:

INCLUDE ~faiths_and_powers/lib/qd_multiclass.tpa~
Just to try and see if it helps.

It worked, thanks!

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