Jump to content

regexp issue


kreso

Recommended Posts

Is it doable with CLONE, just if I add SET ~loops~ = 0 at the beggining and SET ~loops~ = (loops + 1)?

Weidu documentation says something about CLONE insert point, but I can't get it to work, regardless of value. If I understood Wisp, the problem is insertion of the new effect *before* the existing one.

Can it be made so that new effect is added *after*; and would it fix the issue?

Link to comment

Do you really need to be looping at all? If all you are trying to do is clone each effect that uses opcode 40, you can accomplish that just with CLONE_EFFECT.

I did exactly that.

That works correctly, but installs with warnings and while it's installing, you'll see "Warning - no effects added to *.itm/spl" for each time the opcode isn't cloned.

Link to comment

Okay, so you want to change the secondary type of each ability that has at least one effect matching a specific opcode.

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    READ_LONG  0x64 abilities_offset
    READ_SHORT 0x68 num_abilities
    READ_LONG  0x6a effects_offset
    FOR (ability = 0; ability < num_abilities; ability += 1) BEGIN
      READ_SHORT (abilities_offset + 0x38*ability + 0x1e) num_features
      READ_SHORT (abilities_offset + 0x38*ability + 0x20) features_ind
      FOR (effect = 0; effect < num_features; effect += 1) BEGIN
        READ_SHORT (effects_off + 0x30 * (features_ind + effect) + 0x00) opcode
        PATCH_IF (opcode == 0x40) BEGIN
          WRITE_BYTE (abilities_offset + 0x38*ability + 0x19) 13 // secondary type
          SET effect = num_features // exit loop
        END
      END
    END
  END
  BUT_ONLY

* not tested for correctness

 

The patch for spells would be identical, except you would be copying .spl files and the 3 lines with an 0x38 would need to have those changed to 0x28 to match the smaller size of spell headers.

Link to comment

Modifying the code you were trying to use earlier, this should create one effect using opcode 221 for every one effect using opcode 40.

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    LPF CLONE_EFFECT
      INT_VAR
        match_opcode = 40
        opcode = 221  
        timing = 1
        parameter1 = 9
        savingthrow = 0
        parameter2 = ~sectype_k1#Haste~
    END
  END
  BUT_ONLY
Link to comment

 

Modifying the code you were trying to use earlier, this should create one effect using opcode 221 for every one effect using opcode 40.

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    LPF CLONE_EFFECT
      INT_VAR
        match_opcode = 40
        opcode = 221  
        timing = 1
        parameter1 = 9
        savingthrow = 0
        parameter2 = ~sectype_k1#Haste~
    END
  END
  BUT_ONLY

This is pretty much what I've done in the beggining; this is what I've started with:

 

COPY_EXISTING_REGEXP GLOB ~.*\.spl~ ~override~
PATCH_IF (SOURCE_SIZE > 0x71)
LPF CLONE_EFFECT INT_VAR match_opcode = 40 opcode = 221 parameter2 = %customsectype% END
BUT_ONLY_IF_IT_CHANGES

 

It works fine (i.e. 221 effect isn't added numerous times); but prints warnings as it goes through the files. Each that doesn't get patched, displays a warning. That's why I wanted to try a different way of doing it.

Link to comment

And that is the correct code. Yeah, the warnings are there in case the mod maker can't perceive the fact that the file might not have been edited, but you know the fact, that the opcode=40 is kinda rare thing.

And yeah, there's no reason to put in the timing, parameter1 or savingthrow because they are cloned from the original effect, not set independently from it.. well the save could be different. Aka, the icehead of the flail of ages hit, thus it's effect to remove the haste.

Link to comment

Wisp said that he'll alter CLONE macro so it doesn't print warnings anymore.

Technically, I did not say that. I said I would add the option of running CLONE_EFFECT without the warning. (Specifically, you'll have to set the INT_VAR silent to 1).

Link to comment

 

Wisp said that he'll alter CLONE macro so it doesn't print warnings anymore.

Technically, I did not say that. I said I would add the option of running CLONE_EFFECT without the warning. (Specifically, you'll have to set the INT_VAR silent to 1).

 

Will do, in any case. Ty.

Link to comment

Archived

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

×
×
  • Create New...