Jump to content

[Solved] Need help with some CLONE_EFFECT issues


subtledoctor

Recommended Posts

My code:

LAF RES_NUM_OF_SPELL_NAME
  STR_VAR
    spell_name = ~CLERIC_PROTECT_FROM_EVIL~
  RET
    spell_res 
    spell_num
END
 
COPY_EXISTING ~%spell_res%.spl~ ~override/d5_%spell_num%.spl~ 
 
COPY_EXISTING_REGEXP GLOB ~.*\.spl~ ~override~
  READ_SHORT 0x68 abilities
  PATCH_IF ( abilities > 0 ) BEGIN
    LPF CLONE_EFFECT
      STR_VAR
        match_resource=EVAL ~%spell_res%~
        resource=EVAL ~d5_%spell_num%~
    END
  END
BUT_ONLY
The error message when I run it on IWDEE:

WARNING: no effects added to #BARD-1.SPL

WARNING: no effects added to #BARD1.SPL

WARNING: no effects added to #BARD2.SPL

WARNING: no effects added to #BARD3.SPL

WARNING: no effects added to #BARD4.SPL

WARNING: no effects added to #BARD5.SPL

WARNING: no effects added to #BARD6.SPL

WARNING: no effects added to #BELTYN.SPL

WARNING: CLONE_EFFECT does not support file type SPL

ERROR: cannot convert abil_num or %abil_num% to an integer

ERROR: [#BONECIR.SPL] -> [override/#BONECIR.SPL] Patching Failed (COPY) (Not_found)

Stopping installation because of error.

It runs through the first 8 spells just fine (correctly adding no effects because they have none that match the match_resource), then chokes on #bonecir.spl - which differs from the earlier 8 in no meaningful way - citing a variable that doesn't exist in my .tp2

 

What am I not seeing here?

 

EDIT - oh I get it: abil_num must be a variable inside the CLONE_EFFECT macro itself. So, the macro written by CamDawg is choking on something in the format of a spell added to IWDEE that grew out of IWDification, made by Camdawg. Oh the irony!

 

Maybe I can try to edit the macro? I have a copy lying around from before it was included in Weidu. If I provide my own copy in a .tpa and INCLUDE it in my .tp2, will the mod use my altered one, or the one inside the Weidu binary?

 

Here's a guess: the ALTER/CLONE/DELETE_EFFECT macros include this:

PATCH_IF ("%SOURCE_FILE%" STRING_COMPARE_REGEXP "^.+\.spl" = 0) BEGIN
  READ_SHORT  0x68 abil_num ELSE 0
END
...
PATCH_IF (SOURCE_SIZE >= min_size) BEGIN // sanity check
  FOR (index = (0 - check_globals) ; index < abil_num ; ++index) BEGIN // we start at -1 for global effects
Is the regexp maybe not catching spells whose filenames begin with "#"...? In which case the macro never READs abil_num, and then chokes later when it runs the FOR loop.

 

Still, if it was that, then it shouldn't have got through the first 8 spells... could it possibly relate to the fact that "#bonecir" is 8 characters long??

Link to comment

Whatever you include in TP2 will overwrite what's shipped with WeiDU. You can also find what WeiDU uses in its github repository.

 

As for debugging, if you don't see an immediate problem, fill it with PATCH_PRINTs to locate the line of code it breaks over, then dance from there.

Link to comment

CLONE_EFFECT just chokes on #BONECIR.SPL. No idea why... but, I'm pretty sure that's a new IWDEE-only spell and it's irrelevant to my current goal.

 

So, it might be easier to simply circumvent the problem by skipping that spell. Or any of those spells (I just looked at the "#___.spl" spells and none of them matter for my purposes.

 

So, is there a way to craft the ~.*\.spl~ regexp in such a way that it skips over anything that begins with "#" ?

Link to comment

I got it working by hacking CLONE_EFFECT to re-set the variable "abil_num" by reading offset 0x68 a second time... this would make the macro break on .CRE files but now it works for all .SPL files, and I figure that's okay since this particular mod only runs CLONE_EFFECT on .SPL files. So I can INCLUDE my hacked version for this limited purpose.

 

Anyway, now the mod runs CLONE_EFFECT through the regexp for every spell in my array. That means it is checking every effect in every extended header, 375,000 times. The Weidu installer has been running on my Core i7 MacBook Pro for a solid ten minutes now, and it looks like it's about halfway done. I don't think players can suffer staring at the Terminal for ~20-25 minutes just to install a BG2 mod these days... (though, that's certainly what I used to do, way back when!)

 

Gotta find a way to cut down this process...

Link to comment
WARNING: CLONE_EFFECT does not support file type SPL

This warning message is only displayed when the signature of the file isn't recognized. The function does support SPL files, detecting their signature of 'SPL '. The files it's choking on probably have the wrong signature, like 'SPL' without the space.

 

Maybe you could try modifying the signatures of the files instead of altering the CLONE_EFFECT function, and see if that fixes things.

Link to comment

This warning message is only displayed when the signature of the file isn't recognized. The function does support SPL files, detecting their signature of 'SPL '. The files it's choking on probably have the wrong signature, like 'SPL' without the space.

 

Maybe you could try modifying the signatures of the files instead of altering the CLONE_EFFECT function, and see if that fixes things.

Got it. Yes, good idea - I have to check where the signature resource is recorded/contained, but assuming it's moddable, I can simply fix the bugged .spl file(s) before running the macro.

Link to comment

Next question for any Weidu wizards hanging around: I would like to do something a little tricky with CLONE_EFFECT.

 

Basically, I'd like to:

1) run through REGEXP GLOB ~.*\.spl~ and check for any spell using opcode 206 in its effects (so far so easy with CLONE_EFFECT INT_VAR match_opcode)

2) take the "STR_VAR match_resource=" value of any such effects (also no problem)

3) run NUM_NAME_OF_SPELL_RES on that match_respurce value (this is the tricky bit)

4) populate the "STR_VAR resource=" value of the clone macro with the EVAL %spell_num% result of the NUM_NAME macro.

 

In essence, I want to modify any and all spells using opcode 206 targeting "SPPR###" to add an identical effect targeting "1###" (and clone any effects targeting "SPWI###" to also target "2###", etc.)

 

Maybe... do you think it would be possible to insert the NUM_NAME_OF_SPELL_RES macro *into* a modified version of CLONE_EFFECT to generate and use the %spell_num% variable there?

 

Or any thoughts on ways to achieve the result that I haven't considered? All ideas welcome!

Link to comment

One of the things that is frustrating is that SNPRINT can isolate the first few digits in a string, but most files are differentiated by their *last* digits, not their first ones.

 

If I could pull out the .spl res from match_resource (call it %match_res%), would it be possible to do something like

SNPRINT +4 spl_prefix %match_res%
SPRINT spl_num %match_res%
   REPLACE_TEXTUALLY ~%spl_prefix%~ ~~
...and then run CLONE_EFFECT with

STR_VAR
   match_resource = EVAL ~%match_res%~
   resource = EVAL ~1%spell_num%~
END
I don't know if/how you can run REPLACE on strings in variables... and this doesn't get you anything that NUM_NAME_OF_SPELL_RES doesn't, but it's more limited and maybe it could save some processor cycles? (Ultimately, this is all about saving processor cycles.)
Link to comment

. I don't think players can suffer staring at the Terminal for ~20-25 minutes just to install a BG2 mod these days...

Tell you what. Go to SHS forums, download TheBig World setup. Install every quest/spell/item/NPC/game altaration mod there is. Run SCS "smarter AI" over that.

25 min is nothing, believe me. :D

Link to comment

The way this is now, it works perfectly, but it takes a full hour. It hit my processor so hard, I start it with 25% battery, and my laptop would have died before it finished if I didn't plug it in. For a Weidu mod in 2015, that's just not gonna fly. (I don't go in for the BWS mega-modding - so much of that stuff is so crappy...)

 

As described above, I figure I can just loop through all spells once, instead of 400 times, and apply the spell copy renaming formula ( RES --> prefix + NUM ) simultaneously with the CLONE_EFFECT process. I'm good enough that I can see how it might be done, but I'm not good enough to sit down and bang out the Weidu code. Yet. Maybe tonight I'll take a stab at pulling apart the CLONE_EFFECT macro and see how close I can get.

 

If I can get this bit figured out, then my sphere system will be in solid 1.0, ready-to-release condition. Or at least, solid public beta condition.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...