Jump to content

ALTER_EFFECT and a range of "match_" values


subtledoctor

Recommended Posts

Say (hypothetically?) I'd like to do a blanket patch of spell durations. Something like, for every spell with a duration between 13 and 60, change the duration to 12. I'm not sure of the best way to represent that range.

 

Right now I have this:

FOR (old_short = 13; old_short < 60; ++old_short) BEGIN
    LPF ALTER_EFFECT INT_VAR silent = 1 match_duration = %old_short% duration = 12 END
 END

That is simple, but horrendously inefficient.

 

Thoughts?

Link to comment

For this kind of work, I use homemade functions, in the old school way. Did you try something like below?

DEFINE_PATCH_FUNCTION ~GW_MODIF_DURATION~
    INT_VAR GW_duration_min = "-1"
            GW_duration_max = "-1"
            GW_new_duration = "-1"   // -1 = no change
BEGIN

PATCH_IF (GW_new_duration > 0) AND (GW_duration_min > 0) AND (GW_duration_min > 0) BEGIN
    PATCH_IF (GW_duration_max  >=  GW_duration_min) BEGIN
        READ_LONG  0x64 abil_off
        READ_SHORT 0x68 abil_num
        READ_LONG  0x6a fx_off
        FOR (i = 0 ; i < abil_num ; ++i) BEGIN
            READ_SHORT (abil_off + 0x1e + 0x28*i) "abil_fx_num"
            READ_SHORT (abil_off + 0x20 + 0x28*i) "abil_fx_idx"
            FOR (j = 0 ; j < abil_fx_num ; ++j) BEGIN
                READ_LONG  (fx_off + 0x0e + (0x30 * (j + abil_fx_idx))) old_duration        // Duration to check
                PATCH_IF ("%old_duration%" >= GW_duration_min) AND ("%old_duration%" <= GW_duration_max) AND ("%old_duration%" != GW_new_duration) BEGIN
                    WRITE_LONG (fx_off + 0x0e + (0x30 * (j + abil_fx_idx))) GW_new_duration
                END
           END
        END
    END
END

END // of DEFINE_PATCH_FUNCTION

Edit:written from scratch, so I did not test it. ;)

Edit2: fixed!

Link to comment

How about:

GET_OFFSET_ARRAY header SPL_V10_HEADERS
PHP_EACH header AS int => index BEGIN
  GET_OFFSET_ARRAY2 effect index SPL_V10_HEAD_EFFECTS
  PHP_EACH effect AS int => offset BEGIN
    READ_LONG offset+0xe duration0
    SET duration= duration0>12 ? duration0<60 ? 12 : duration0 : duration0
    WRITE_LONG offset+0xe "%duration%"
  END
END

Link to comment

Archived

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

×
×
  • Create New...