Author Topic: ADD_CRE_EFFECT  (Read 10512 times)

Offline DavidW

  • Planewalker
  • *****
  • Posts: 275
ADD_CRE_EFFECT
« on: September 04, 2010, 06:54:58 PM »
I just got rather badly burned by not realising that ADD_CRE_EFFECT doesn't work for v1 EFF files.

RTFM is a pretty reasonable response, since it is documented, but any chance this could at least be turned into an explicit FAIL? (i.e., if you try to use ADD_CRE_EFFECT on a wrong-effect creature, the install fails). That should take very little time to code and would prevent other people making my mistake. At the moment, the macro silently and fatally breaks v0 creatures when you use it on them. I'm probably not the only person who tends to work out the syntax of WEIDU commands at least in part from context, and who doesn't always do their homework.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1941
  • Gender: Male
    • The Fields of the Dead
Re: ADD_CRE_EFFECT
« Reply #1 on: September 04, 2010, 07:05:36 PM »
Fortunately, someone has written one for BG:TotSC.

Code: [Select]
DEFINE_PATCH_MACRO ~ADD_CRE_EFFECT_BG~ BEGIN
  PATCH_IF (SOURCE_SIZE > 0x2c8) BEGIN
    READ_LONG 0x2c4 ___#fx_off
    READ_LONG 0x2c8 ___#fx_num
   
    INSERT_BYTES ___#fx_off 0x30
   
    WRITE_SHORT (___#fx_off) opcode
    WRITE_BYTE (___#fx_off + 0x2) target
    WRITE_BYTE (___#fx_off + 0x3) power
    WRITE_LONG (___#fx_off + 0x4) parameter1
    WRITE_LONG (___#fx_off + 0x8) parameter2
    WRITE_BYTE (___#fx_off + 0xc) timing
    WRITE_BYTE (___#fx_off + 0xd) resist_dispel
    WRITE_LONG (___#fx_off + 0xe) duration
    WRITE_BYTE (___#fx_off + 0x12) probability1
    WRITE_BYTE (___#fx_off + 0x13) probability2
    WRITE_EVALUATED_ASCII (___#fx_off + 0x14) ~%resource%~ #8
    WRITE_LONG (___#fx_off + 0x1c) dicenumber
    WRITE_LONG (___#fx_off + 0x20) dicesize
    WRITE_LONG (___#fx_off + 0x24) savingthrow
    WRITE_LONG (___#fx_off + 0x28) savebonus
   
    //correcting effects number
    WRITE_LONG 0x2c8 (___#fx_num + 1)
   
    //correcting offsets
    PATCH_FOR_EACH ___#offset IN 0x2b8 0x2bc BEGIN //item slots offset and items offset
    READ_LONG ___#offset ___#current_off
    WRITE_LONG ___#offset (___#current_off + 0x30)
    END
   
    //reset vars
    SET opcode = 0
    SET target = 0
    SET power = 0
    SET parameter1 = 0
    SET parameter2 = 0
    SET timing = 0
    SET resist_dispel = 0
    SET duration = 0
    SET probability1 = 100
    SET probability2 = 0
    SPRINT resource ~%___#nil%~
    SET dicenumber = 0
    SET dicesize = 0
    SET savingthrow = 0
    SET savebonus = 0
    END
  END

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #2 on: September 04, 2010, 07:07:47 PM »
A better course of action would be to have ADD_CRE_EFFECT translate EFFv1 to EFFv2 before doing its patching, or is there a credible reason for charname.cre and a couple of other CRE files to use EFFV1?
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #3 on: September 04, 2010, 08:45:17 PM »
A better course of action would be to have ADD_CRE_EFFECT translate EFFv1 to EFFv2 before doing its patching, or is there a credible reason for charname.cre and a couple of other CRE files to use EFFV1?
BG/TotSC still uses v1 struct (TotSC knows v2 and should handle it in theory, but it mostly doesn't IIRC).

If the CRE effect flag thingie isn't 1, it could just fail (it's not like the built-in stuff doesn't also have limits about which versions to work with)? If it has mixed structs or is incorrectly flagged, you deserve what you get.

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #4 on: September 04, 2010, 09:59:01 PM »
A better course of action would be to have ADD_CRE_EFFECT translate EFFv1 to EFFv2 before doing its patching, or is there a credible reason for charname.cre and a couple of other CRE files to use EFFV1?
There is no credible reason I can think of to patch charbase.cre. I think it would be ok to enforce EFFv2 for any platform but BG1 (in which case I suppose it could use the alternative above).

Offline DavidW

  • Planewalker
  • *****
  • Posts: 275
Re: ADD_CRE_EFFECT
« Reply #5 on: September 05, 2010, 03:40:45 AM »
I'd strongly suggest not changing the EFF type of any existing file. Most TUTU/BGT creatures are v1, so this could end up making pretty wide-ranging changes, which in turn could break any mod that assumes a particular file is v1. I don't actually recall whether SCS does this, but it quite possibly does - EFF type is one of those things that one doesn't really expect other mods to change.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #6 on: September 05, 2010, 08:20:52 AM »
The thing about flat-out FAILing is that I'm bound to break one or two mods and the author are going to blame me for breaking their mod. Maybe I could fall back to Echon's macro if I call ADD_CRE_EFFECT and the CRE file uses EFFv1?
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline DavidW

  • Planewalker
  • *****
  • Posts: 275
Re: ADD_CRE_EFFECT
« Reply #7 on: September 05, 2010, 08:52:49 AM »
That would be ideal - my FAIL suggestion was just meant as a second-best if it wasn't possible to actually patch the v1.

(Those other mods that FAIL would break are actually broken already, most likely, since patching v1 creatures with ADD_CRE_EFFECT makes them crash the game when they appear. But you'd probably get blamed anyway.)

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: ADD_CRE_EFFECT
« Reply #8 on: September 05, 2010, 09:06:51 AM »
err... well, for several versions now, some mods have been checking and moving effects to v2 on Tutu/BGT automatically - Miloch can probably say better if the BWP uses it,but for a sample, BG1npc HAS BEEN USING
Code: [Select]
  //  Nythrun's Broken CRE Order and Effects Fix
DEFINE_PATCH_MACRO ~enforce_cre_order~ BEGIN
  PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
    READ_BYTE    0x0033 "eff"
    READ_LONG    0x02a0 "kso"
    READ_LONG    0x02a4 "ksc"
    READ_LONG    0x02a8 "smo"
    READ_LONG    0x02ac "smc"
    READ_LONG    0x02b0 "mso"
    READ_LONG    0x02b4 "msc"
    READ_LONG    0x02b8 "iso"
    READ_LONG    0x02bc "ilo"
    READ_LONG    0x02c0 "ilc"
    READ_LONG    0x02c4 "elo"
    READ_LONG    0x02c8 "elc"
    READ_ASCII   "kso" ~ks~ ELSE ~fail~ (0x0c * "ksc")
    READ_ASCII   "smo" ~sm~ ELSE ~fail~ (0x10 * "smc")
    READ_ASCII   "mso" ~ms~ ELSE ~fail~ (0x0c * "msc")
    READ_ASCII   "iso" ~is~ ELSE ~fail~ (0x50)
    READ_ASCII   "ilo" ~il~ ELSE ~fail~ (0x14 * "ilc")
    READ_ASCII   "elo" ~el~ ELSE ~fail~ ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
    DELETE_BYTES      0x02d4 (SOURCE_SIZE - 0x02d4)
    SET               "off" = 0x02d4
    WRITE_LONG        0x02a0 "off"
    PATCH_IF (~%ks%~ STR_CMP ~fail~) THEN BEGIN
      INSERT_BYTES    "off" (0x0c * "ksc")
      WRITE_ASCIIE    "off" ~%ks%~
    END ELSE BEGIN
      SET             "ksc" = 0x00
      WRITE_LONG      0x02a4 "ksc"
    END
    SET               "off" += (0x0c * "ksc")
    WRITE_LONG        0x02a8 "off"
    INSERT_BYTES      "off" (0x10 * 0x11)
    PATCH_IF ((~%sm%~ STR_CMP ~fail~) AND ("smc" = 0x11)) THEN BEGIN
      WRITE_ASCIIE    "off" ~%sm%~
    END ELSE BEGIN
      SET             "smc" = 0x11
      WRITE_LONG      0x2ac "smc"
      FOR ("i1" = 0x00; "i1" < 0x07; "i1" += 0x01) BEGIN
        WRITE_SHORT   ("off" + (i1 * 0x10)) "i1"
      END
      FOR ("i1" = 0x00; "i1" < 0x09; "i1" += 0x01) BEGIN
        WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x070) "i1"
        WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x076) 0x01
      END
      WRITE_SHORT     ("off" + 0x106) 0x02
    END
    SET               "off" += (0x10 * "smc")
    WRITE_LONG        0x02b0 "off"
    PATCH_IF (~%ms%~ STR_CMP ~fail~) THEN BEGIN
      INSERT_BYTES    "off" (0x0c * "msc")
      WRITE_ASCIIE    "off" ~%ms%~
    END ELSE BEGIN
      SET             "msc" = 0x00
      WRITE_LONG      0x02b4 "msc"
    END
    SET               "off" += (0x0c * "msc")
    WRITE_LONG        0x02c4 "off"
    PATCH_IF (~%el%~ STR_CMP ~fail~) THEN BEGIN
      INSERT_BYTES    "off" ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
      WRITE_ASCIIE    "off" ~%el%~
    END ELSE BEGIN
      SET             "elc" = 0x00
      WRITE_LONG      0x02c8 "elc"
    END
    SET               "off" += ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
    WRITE_LONG        0x02bc "off"
    PATCH_IF (~%il%~ STR_CMP ~fail~) THEN BEGIN
      INSERT_BYTES    "off" (0x14 * "ilc")
      WRITE_ASCIIE    "off" ~%il%~
    END ELSE BEGIN
       SET            "ilc" = 0x00
       WRITE_LONG     0x02c0 "ilc"
    END
    SET               "off" += (0x14 * "ilc")
    WRITE_LONG        0x02b8 "off"
    INSERT_BYTES      "off" 0x50
    PATCH_IF (~%is%~ STR_CMP ~fail~) THEN BEGIN
      WRITE_ASCIIE    "off" ~%is%~
    END ELSE BEGIN
      FOR ("i1" = 0x00; "i1" < 0x4c; "i1" += 0x02) BEGIN
        WRITE_SHORT   ("off" + "i1") 0xffff
      END
    END
    SET SOURCE_SIZE = ("off" + 0x50)
  END
END

DEFINE_PATCH_MACRO ~use_v2_eff~ BEGIN
  PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
    READ_BYTE  0x0033 "eff_type"
    WRITE_BYTE 0x0033 0x1
    PATCH_IF (("eff_type" & 0x1) = 0x0) THEN BEGIN
      READ_LONG  0x02c8 "elc"
      PATCH_IF ("elc" > 0x0) THEN BEGIN
        READ_LONG  0x02c4 "elo"
        READ_ASCII   "elo" ~efx~ (0x30 * "elc")
        PATCH_FOR_EACH "off1" IN 0x02a0 0x02a8 0x02b0 0x02b8 0x02bc BEGIN
          READ_LONG  "off1" "off2"
          WRITE_LONG "off1" (("off2" > "elo") ? ("off2" + ("elc" * (0x108 - 0x30))) : ("off2" < 0x2d4 ? 0x2d4 : "off2"))
        END
        DELETE_BYTES "elo" (0x030 * "elc")
        INSERT_BYTES "elo" (0x108 * "elc")
        SPRINT ~rfx~ ~~
        INNER_PATCH ~%efx%~ BEGIN
          FOR ("i1" = 0x0; "i1" < "elc"; "i1" += 0x1) BEGIN
            SET SOURCE_SIZE += 0xd8
            READ_SHORT   (("i1" * 0x30) + 0x00) "opcode"
            READ_BYTE    (("i1" * 0x30) + 0x02) "target"
            READ_BYTE    (("i1" * 0x30) + 0x03) "power"
            READ_LONG    (("i1" * 0x30) + 0x04) "parameter1"
            READ_LONG    (("i1" * 0x30) + 0x08) "parameter2"
            READ_BYTE    (("i1" * 0x30) + 0x0c) "timing_mode"
            READ_BYTE    (("i1" * 0x30) + 0x0d) "dispellability"
            READ_LONG    (("i1" * 0x30) + 0x0e) "duration"
            READ_BYTE    (("i1" * 0x30) + 0x12) "probability1"
            READ_BYTE    (("i1" * 0x30) + 0x13) "probability2"
            READ_ASCII   (("i1" * 0x30) + 0x14) ~resref~
            INNER_PATCH_SAVE ~rfx~ ~%rfx%~ BEGIN
              INSERT_BYTES  (("i1" * 0x108) + 0x00) 0x110
              WRITE_LONG    (("i1" * 0x108) + 0x10) "opcode"
              WRITE_LONG    (("i1" * 0x108) + 0x14) "target"
              WRITE_LONG    (("i1" * 0x108) + 0x18) "power"
              WRITE_LONG    (("i1" * 0x108) + 0x1c) "parameter1"
              WRITE_LONG    (("i1" * 0x108) + 0x20) "parameter2"
              WRITE_BYTE    (("i1" * 0x108) + 0x24) "timing_mode"
              WRITE_LONG    (("i1" * 0x108) + 0x28) "duration"
              WRITE_SHORT   (("i1" * 0x108) + 0x2c) "probability1"
              WRITE_SHORT   (("i1" * 0x108) + 0x2e) "probability2"
              WRITE_ASCIIE  (("i1" * 0x108) + 0x30) ~%resref%~
              WRITE_BYTE    (("i1" * 0x108) + 0x5c) "dispellability"
              WRITE_LONG    (("i1" * 0x108) + 0x80) (` 0x0)
              WRITE_LONG    (("i1" * 0x108) + 0x84) (` 0x0)
              WRITE_LONG    (("i1" * 0x108) + 0x88) (` 0x0)
              WRITE_LONG    (("i1" * 0x108) + 0x8c) (` 0x0)
              WRITE_LONG    (("i1" * 0x108) + 0xa4) (` 0x0)
              DELETE_BYTES  (("i1" * 0x108) + 0x08) 0x8
            END
          END
        END
        WRITE_ASCIIE "elo" ~%rfx%~
      END
    END
  END
END

  /* Apply Nythrun's Fixes to creatures we use */
  ACTION_FOR_EACH ~crefile~ IN ~%tutu_scripta%varicem.cre~
                               ~%tutu_scriptb%ullrush.cre~
                               ~%tutu_scriptbg%neb.cre~
                               ~%tutu_scriptd%ursword.cre~
                               ~%tutu_scriptf%twbax_a.cre~
                               ~%tutu_scripti%ronelit.cre~
                               ~%tutu_scriptm%oorlock.cre~
                               ~%tutu_scripto%grema03.cre~
                               ~%tutu_scripts%handal2.cre~
                               ~%tutu_var%alatos.cre~
                               ~%tutu_var%albert.cre~
                               ~%tutu_var%alvanh.cre~
                               ~%tutu_var%alyth.cre~
                               ~%tutu_var%amaran.cre~
                               ~%tutu_var%angelo.cre~
                               ~%tutu_var%ankheg.cre~
                               ~%tutu_var%arkush.cre~
                               ~%tutu_var%avarice.cre~
                               ~%tutu_var%bandit.cre~
                               ~%tutu_var%baresh.cre~
                               ~%tutu_var%bassil.cre~
                               ~%tutu_var%bayard.cre~
                               ~%tutu_var%bearbl.cre~
                               ~%tutu_var%bearbr.cre~
                               ~%tutu_var%bearca.cre~
                               ~%tutu_var%bearpo.cre~
                               ~%tutu_var%belt.cre~
                               ~%tutu_var%bently.cre~
                               ~%tutu_var%bjorni.cre~
                               ~%tutu_var%brage.cre~
                               ~%tutu_var%brielb.cre~
                               ~%tutu_var%brilla.cre~
                               ~%tutu_var%cadder.cre~
                               ~%tutu_var%calaha.cre~
                               ~%tutu_var%chase.cre~
                               ~%tutu_var%claird.cre~
                               ~%tutu_var%coksmth.cre~
                               ~%tutu_var%daitel.cre~
                               ~%tutu_var%dalton.cre~
                               ~%tutu_var%davaeo.cre~
                               ~%tutu_var%deathk.cre~
                               ~%tutu_var%delain.cre~
                               ~%tutu_var%delsvir.cre~
                               ~%tutu_var%deltan.cre~
                               ~%tutu_var%dopdur1.cre~
                               ~%tutu_var%drienn.cre~
                               ~%tutu_var%drizzt.cre~
                               ~%tutu_var%dryad.cre~
                               ~%tutu_var%durlagt.cre~
                               ~%tutu_var%durlyl.cre~
                               ~%tutu_var%dushai.cre~
                               ~%tutu_var%elmin2.cre~
                               ~%tutu_var%elmin5.cre~
                               ~%tutu_var%ender.cre~
                               ~%tutu_var%entill.cre~
                               ~%tutu_var%erdane.cre~
                               ~%tutu_var%faldor.cre~
                               ~%tutu_var%farmbr.cre~
                               ~%tutu_var%fear.cre~
                               ~%tutu_var%fearm.cre~
                               ~%tutu_var%fenrus.cre~
                               ~%tutu_var%fireb1.cre~
                               ~%tutu_var%flame.cre~
                               ~%tutu_var%galken.cre~
                               ~%tutu_var%galtok.cre~
                               ~%tutu_var%gatewa.cre~
                               ~%tutu_var%gellan.cre~
                               ~%tutu_var%gerde.cre~
                               ~%tutu_var%girba2.cre~
                               ~%tutu_var%gnoll.cre~
                               ~%tutu_var%gorion.cre~
                               ~%tutu_var%grael.cre~
                               ~%tutu_var%greywo.cre~
                               ~%tutu_var%hack.cre~
                               ~%tutu_var%hafiz.cre~
                               ~%tutu_var%halaca.cre~
                               ~%tutu_var%halbaz.cre~
                               ~%tutu_var%hurgan.cre~
                               ~%tutu_var%ike.cre~
                               ~%tutu_var%iron11.cre~
                               ~%tutu_var%isla.cre~
                               ~%tutu_var%jessup.cre~
                               ~%tutu_var%joia.cre~
                               ~%tutu_var%kaisha.cre~
                               ~%tutu_var%karoug.cre~
                               ~%tutu_var%keeper.cre~
                               ~%tutu_var%keldda.cre~
                               ~%tutu_var%kirinh.cre~
                               ~%tutu_var%korax.cre~
                               ~%tutu_var%krumm.cre~
                               ~%tutu_var%landri.cre~
                               ~%tutu_var%larze.cre~
                               ~%tutu_var%liia.cre~
                               ~%tutu_var%love.cre~
                               ~%tutu_var%lovem.cre~
                               ~%tutu_var%madarc.cre~
                               ~%tutu_var%marl.cre~
                               ~%tutu_var%meiala.cre~
                               ~%tutu_var%mendas.cre~
                               ~%tutu_var%mulahe.cre~
                               ~%tutu_var%mutami.cre~
                               ~%tutu_var%narlen.cre~
                               ~%tutu_var%niemai.cre~
                               ~%tutu_var%nobw2.cre~
                               ~%tutu_var%perdue.cre~
                               ~%tutu_var%petrin.cre~
                               ~%tutu_var%pheirk.cre~
                               ~%tutu_var%phlydi3.cre~
                               ~%tutu_var%poe.cre~
                               ~%tutu_var%pride.cre~
                               ~%tutu_var%pridem.cre~
                               ~%tutu_var%prost5.cre~
                               ~%tutu_var%pumberl.cre~
                               ~%tutu_var%rielta.cre~
                               ~%tutu_var%riggilo.cre~
                               ~%tutu_var%sarev1.cre~
                               ~%tutu_var%sarevo.cre~
                               ~%tutu_var%sarhed.cre~
                               ~%tutu_var%scar.cre~
                               ~%tutu_var%seniya.cre~
                               ~%tutu_var%serva2.cre~
                               ~%tutu_var%shoal.cre~
                               ~%tutu_var%silke.cre~
                               ~%tutu_var%skie.cre~
                               ~%tutu_var%slave.cre~
                               ~%tutu_var%taerom.cre~
                               ~%tutu_var%takiyah.cre~
                               ~%tutu_var%tamoko.cre~
                               ~%tutu_var%tarnes.cre~
                               ~%tutu_var%tarnor.cre~
                               ~%tutu_scriptbg%tazok.cre~
                               ~%tutu_var%tazok2.cre~
                               ~%tutu_var%tellan.cre~
                               ~%tutu_var%tenya.cre~
                               ~%tutu_var%thalan.cre~
                               ~%tutu_var%therel.cre~
                               ~%tutu_var%ulraun.cre~
                               ~%tutu_var%unshey.cre~
                               ~%tutu_var%vai.cre~
                               ~%tutu_var%vail.cre~
                               ~%tutu_var%volo.cre~
                               ~%tutu_var%winski.cre~
                               ~%tutu_var%winski2.cre~
                               ~%tutu_var%winthr2.cre~
                               ~%tutu_var%yago.cre~
                               ~%tutu_var%zombie.cre~
                               ~%tutu_var%zombiew.cre~
                               ~%tutu_var%ajanti.cre~
                               ~%tutu_var%ajanti4.cre~
                               ~%tutu_var%ajanti6.cre~
                               ~%tutu_var%alora.cre~
                               ~%tutu_var%alora6.cre~
                               ~%tutu_var%branwe.cre~
                               ~%tutu_var%branwe5.cre~
                               ~%tutu_var%coran.cre~
                               ~%tutu_var%coran5.cre~
                               ~%tutu_var%dynahe.cre~
                               ~%tutu_var%dynahe2.cre~
                               ~%tutu_var%dynahe4.cre~
                               ~%tutu_var%dynahe6.cre~
                               ~%tutu_var%edwin.cre~
                               ~%tutu_var%edwin2.cre~
                               ~%tutu_var%edwin4.cre~
                               ~%tutu_var%edwin6.cre~
                               ~%tutu_var%faldor.cre~
                               ~%tutu_var%faldor5.cre~
                               ~%tutu_var%garric.cre~
                               ~%tutu_var%garric2.cre~
                               ~%tutu_var%garric4.cre~
                               ~%tutu_var%garric6.cre~
                               ~%tutu_var%imoen1.cre~
                               ~%tutu_var%imoen2.cre~
                               ~%tutu_var%imoen4.cre~
                               ~%tutu_var%imoen6.cre~
                               ~%tutu_var%jaheir.cre~
                               ~%tutu_var%jaheir2.cre~
                               ~%tutu_var%jaheir4.cre~
                               ~%tutu_var%jaheir6.cre~
                               ~%tutu_var%kagain.cre~
                               ~%tutu_var%kagain2.cre~
                               ~%tutu_var%kagain4.cre~
                               ~%tutu_var%kagain6.cre~
                               ~%tutu_var%khalid.cre~
                               ~%tutu_var%khalid2.cre~
                               ~%tutu_var%khalid4.cre~
                               ~%tutu_var%khalid6.cre~
                               ~%tutu_var%kivan.cre~
                               ~%tutu_var%kivan4.cre~
                               ~%tutu_var%kivan6.cre~
                               ~%tutu_var%minsc.cre~
                               ~%tutu_var%minsc2.cre~
                               ~%tutu_var%minsc4.cre~
                               ~%tutu_var%minsc6.cre~
                               ~%tutu_var%montar.cre~
                               ~%tutu_var%montar2.cre~
                               ~%tutu_var%montar4.cre~
                               ~%tutu_var%montar6.cre~
                               ~%tutu_scriptbg%quayle.cre~
                               ~%tutu_var%quayle4.cre~
                               ~%tutu_var%quayle6.cre~
                               ~%tutu_var%safana.cre~
                               ~%tutu_var%safana4.cre~
                               ~%tutu_var%safana6.cre~
                               ~%tutu_var%sharte.cre~
                               ~%tutu_var%sharte4.cre~
                               ~%tutu_var%sharte6.cre~
                               ~%tutu_var%skie.cre~
                               ~%tutu_var%skie6.cre~
                               ~%tutu_var%tiax.cre~
                               ~%tutu_var%tiax4.cre~
                               ~%tutu_var%tiax6.cre~
                               ~%tutu_var%viconi.cre~
                               ~%tutu_var%viconi4.cre~
                               ~%tutu_var%viconi6.cre~
                               ~%tutu_scriptbg%xan.cre~
                               ~%tutu_var%xan4.cre~
                               ~%tutu_var%xan6.cre~
                               ~%tutu_var%xzar.cre~
                               ~%tutu_var%xzar2.cre~
                               ~%tutu_var%xzar4.cre~
                               ~%tutu_var%xzar6.cre~
                               ~%tutu_var%yeslic.cre~
                               ~%tutu_var%yeslic5.cre~
                               ~idemon02.cre~
                               ~imp01.cre~
                               ~mepsmo01.cre~ BEGIN
    ACTION_IF FILE_EXISTS_IN_GAME ~%crefile%~ THEN BEGIN
      COPY_EXISTING ~%crefile%~ ~override~
        LAUNCH_PATCH_MACRO ~enforce_cre_order~
        LAUNCH_PATCH_MACRO ~use_v2_eff~
        PATCH_IF FILE_EXISTS_IN_GAME ~fw0125.are~ BEGIN // Miloch's Fix buggered Tutu soundslots
          FOR (s1 = 0xa4; s1 < 0x234; s1 += 0x4) BEGIN
            READ_LONG s1 ss
            PATCH_IF (ss > 10000000) BEGIN WRITE_LONG s1 ~-1~ END
          END
        END
      BUT_ONLY_IF_IT_CHANGES
    END
  END


Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: ADD_CRE_EFFECT
« Reply #9 on: September 05, 2010, 09:24:34 AM »
Amd level1npcs does this for all creatures...

D:\ie_checkfiles\level1npcs-v1.3\level1npcs\subjunctive\nej2v691.tpa  | bgt.tpa | tut.tpa | ub.tpa


So the move to v2 effects on BG2 engine games  has been out in the field for several years now.


(This is for information, not to argue for or against things either way - I just know that some mods have adapted this, though I don't have time to roll through the full search right now, so the cat is out of the bag in terms of any mods that somehow expect the v1 eff structure on Tutu/BGT - the only more widespread mods on Tutu and BGT are the Fixpack and SCS. I don't have figures, but if you use BWP and the listed weidu.log entries posted here at PPG, it looks like pretty much "standard" for mod installs to have at least one of the two.)
« Last Edit: September 05, 2010, 09:31:12 AM by cmorgan »

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #10 on: September 05, 2010, 09:33:44 AM »
(Those other mods that FAIL would break are actually broken already, most likely, since patching v1 creatures with ADD_CRE_EFFECT makes them crash the game when they appear. But you'd probably get blamed anyway.)
See the weidu.lock and the "typo in the second part" checks. Nobody notices a mod not working, everybody notices a mod not installing; as such, adding sanity checks to WeiDU will result in people complaining to me until the check is removed.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #11 on: September 05, 2010, 09:57:46 AM »
Done. For testing purposes, INCLUDE this file to get the new version of ADD_CRE_EFFECT (don't release your mod this way, wait for WeiDU 221 to contain the new macro built-in).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #12 on: September 05, 2010, 11:23:45 AM »
Quote
Nobody notices a mod not working, everybody notices a mod not installing; as such, adding sanity checks to WeiDU will result in people complaining to me until the check is removed.
Since when you care for 'idiots', as you call them? If a bug becomes known, thanks to WeiDU refusing to install it, that means an author should fix the matter, rather than blame WeiDU, no?

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #13 on: September 05, 2010, 11:35:08 AM »
In the end, modders prefer complaining to me rather than fixing their mods (I recall that some people complained when ~Global("something","LOCAL,1)~ stopped compiling).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #14 on: September 05, 2010, 03:10:24 PM »
It should print some type of warning or message when falling back; if you aren't aware that the file being patched is using v1 EFFs, it's just going to silently drop some of your parameters (p3, lvl high-low, etc.)? Also, if you get moved up to v2, your level limits could end up as dice rolls (of course, nobody would be using level limits on CRE-attached EFFs).

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #15 on: September 07, 2010, 12:46:34 AM »
Most TUTU/BGT creatures are v1
In fact, BGT converted all CREs to v2 EFFs some time ago. Tutu really should have too when it moved BG1 to the BG2 engine. It's unlikely a mod like SCS would "expect" v1 format if it's compatible with both BGT and Tutu (unless it has different patches for both, which IMO is too much unnecessary maintenance). Otherwise it is as cmorgan says - many mods like L1NPCs that mess with CRE structures use a macro to convert to v2 EFFs already if it finds any that are v1.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 275
Re: ADD_CRE_EFFECT
« Reply #16 on: September 07, 2010, 02:43:30 AM »
I stand corrected on the v1 vs v2 thing - if this is already being modified by lots of mods, then SCS must be robust against it (and by inference, I suppose, I'm more careful at doing compatibility-friendly coding than I thought!)

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #17 on: September 10, 2010, 06:22:39 PM »
This macro doesn't update offsets properly, or rather it doesn't account for offset inconsistency. As a result, I got CTD after SCS2 patched Questpack's Hell dragon.

Code: [Select]
    //correcting offsets
//    PATCH_FOR_EACH ___#offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
    PATCH_FOR_EACH ___#offset IN 0x2b8 0x2bc BEGIN //item num and islot
      READ_LONG ___#offset ___#current_off
      WRITE_LONG ___#offset (___#current_off + 0x108)
    END
it needs to be changed to
Code: [Select]
    //correcting offsets
    PATCH_FOR_EACH ___#offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
//    PATCH_FOR_EACH ___#offset IN 0x2b8 0x2bc BEGIN //item num and islot
      READ_LONG ___#offset ___#current_off
      PATCH_IF ___#current_off >= ___#fx_off BEGIN
        WRITE_LONG ___#offset (___#current_off + 0x108)
      END
    END

Same actually goes for most every other macro as well, they assume that all files use correct order, whereas there's no guarantee to it.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #18 on: September 10, 2010, 07:22:48 PM »
Thanks for bringing this to my attention.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #19 on: November 19, 2010, 03:08:43 AM »
I need to write to a couple offsets that aren't specified currently. I don't know if they're even "used" but they're specified on in-game EFFs.
Quote
WRITE_LONG (__#fx_off + 0x84) targety
WRITE_LONG (__#fx_off + 0x88) restype
WRITE_EVALUATED_ASCII (__#fx_off + 0x8c) ~%effsource%~ #8
WRITE_LONG (__#fx_off + 0x9c) effslot
Bolded values added - also need to go in the //reset vars section... restype can be 0 by default whereas effslot probably -1. For that matter, casterx, castery, targetx and targety are almost always -1 by default. Projectile isn't there either, but I don't know if it's ever used in EFFs. Doesn't hurt to add it I guess (umm... WRITE_LONG at 0x98 I think... the IESDP is off by a few bytes for embedded EFFs).

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1053
Re: ADD_CRE_EFFECT
« Reply #20 on: November 19, 2010, 07:55:22 AM »
I need to write to a couple offsets that aren't specified currently. I don't know if they're even "used" but they're specified on in-game EFFs.
Quote
WRITE_LONG (__#fx_off + 0x84) targety
WRITE_LONG (__#fx_off + 0x88) restype
WRITE_EVALUATED_ASCII (__#fx_off + 0x8c) ~%effsource%~ #8
WRITE_LONG (__#fx_off + 0x9c) effslot
Bolded values added - also need to go in the //reset vars section... restype can be 0 by default whereas effslot probably -1. For that matter, casterx, castery, targetx and targety are almost always -1 by default. Projectile isn't there either, but I don't know if it's ever used in EFFs. Doesn't hurt to add it I guess (umm... WRITE_LONG at 0x98 I think... the IESDP is off by a few bytes for embedded EFFs).
I pushed this to Git. I didn't bother adding projectiles, however, as it doesn't strike me as being relevant for embedded EFFs. Edit: A quick test suggests the engine ignores the projectile field for embedded EFFs.
« Last Edit: November 19, 2010, 08:09:31 AM by Wisp »

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #21 on: November 22, 2010, 11:22:20 AM »
Cheers.

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #22 on: March 04, 2011, 03:07:18 PM »
This macro doesn't update offsets properly, or rather it doesn't account for offset inconsistency. As a result, I got CTD after SCS2 patched Questpack's Hell dragon.
Code: [Select]
    //correcting offsets
//    PATCH_FOR_EACH ___#offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
    PATCH_FOR_EACH ___#offset IN 0x2b8 0x2bc BEGIN //item num and islot
      READ_LONG ___#offset ___#current_off
      WRITE_LONG ___#offset (___#current_off + 0x108)
    END
it needs to be changed to
Code: [Select]
    //correcting offsets
    PATCH_FOR_EACH ___#offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
//    PATCH_FOR_EACH ___#offset IN 0x2b8 0x2bc BEGIN //item num and islot
      READ_LONG ___#offset ___#current_off
      PATCH_IF ___#current_off >= ___#fx_off BEGIN
        WRITE_LONG ___#offset (___#current_off + 0x108)
      END
    END
This actually seems to result in "nonstandard order" errors (e.g. in DLTCEP). I think this line:
Code: [Select]
      PATCH_IF ___#current_off >= ___#fx_off BEGINShould be this:
Code: [Select]
      PATCH_IF ___#current_off > ___#fx_off BEGINEmpirically, that fixes the problem anyway.

Edit: incidentally..
Quote
For that matter, casterx, castery, targetx and targety are almost always -1 by default.
They're still zero in the latest version (did Wisp's gitted changes ever take?).
« Last Edit: March 04, 2011, 03:09:17 PM by Miloch »

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_CRE_EFFECT
« Reply #23 on: March 04, 2011, 03:27:54 PM »
Done.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1053
Re: ADD_CRE_EFFECT
« Reply #24 on: March 04, 2011, 08:14:20 PM »
Having a fx macro that uses off > fx_off does not work on files where, e.g., num_itm != 0,  num_fx = 0, itm_off = fx_off and you insert an effect. The offsets will still be equal, but neither quantity is 0, so the file is broken.
« Last Edit: March 04, 2011, 08:22:12 PM by Wisp »

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: