Jump to content
CamDawg

Toss your semi-useful WeiDU macros here

Recommended Posts

As presently written, you can't specify a tra file for it. I'll poke it a bit and make it work.

Share this post


Link to post

Just wanted to say thanks for these everyone. Gradually getting back into IE modding and want to sharpen my little-used WeiDU skills. :thumbsup:

Share this post


Link to post

Out of curiosity, which of these are in the current WeiDU and which are not?

 

As for tossing my WeirDU macros here, I think you would think twice if you saw the "code"...

Share this post


Link to post

None of them... I meant for the thread to be an island of misfit macros that aren't quite useful enough for inclusion in WeiDU itself.

Share this post


Link to post

Patch and action function that fixes missing column entries in 2da files.

https://github.com/K4thos/IE-code-repository/blob/master/2da_missing_cols.tpa

 

Everything will be done automatically if used as:

LPF 2DA_MISSING_COLS END

Optionally following vars can be set:

INT_VAR
cols = minimum amount of columns that should have values (if not set function will automatically read max number of columns in file)
STR_VAR
2da = 2da file that should be patched, e.g. kitlist (not used in patch function)
entry = what entry should be set in missing columns (if not set function will automatically read default entry from loaded 2da, e.g. *)
Edited by K4thos

Share this post


Link to post

Another small one, turn a creature into a summoned creature. This sets the XP- and gold stats to zero, sets the flag to leave no corpse, sets affinity to "neutral", sets the creature's gender to "summoned" (or to the unlisted value 20 if Remove Summoning Cap from D0Tweaks is installed), and sets the unstealable and undroppable flags on all of the creature's items.

There is one parameter, power_level. This should only be set if this creature will be used with opcode #127, it is used to determine how many instances of this creature will be summoned. The number here will be written to 0x0018 in the creature file. For more details of this, check the description of opcode #127 on IESDP, but basically the higher this number is, the fewer instances of this monster will be created. Default is -1, which means no change.

 

DEFINE_PATCH_FUNCTION make_summon
  INT_VAR power_level = "-1"
BEGIN
  WRITE_LONG 0x0010 THIS | BIT1      // No corpse
  WRITE_LONG 0x0014 0                // XP
  WRITE_LONG 0x001c 0                // Gold
  WRITE_BYTE 0x0270 IDS_OF_SYMBOL("ea" "neutral")

  // Play nice with Remove Summoning Cap from D0Tweak
  PATCH_IF FILE_EXISTS "override/no_summoning_cap.d0"
  BEGIN
    WRITE_BYTE  0x0275 20       // D0Tweak alt. value
  END
  ELSE
  BEGIN
    WRITE_BYTE  0x0275 IDS_OF_SYMBOL("gender" "summoned")
  END

  // Add unstealable&undroppable flags to carried items
  GET_OFFSET_ARRAY itm_array CRE_V10_ITEMS
  PHP_EACH itm_array AS int => itm_offset
  BEGIN
    WRITE_LONG (itm_offset + 0x0010) (THIS | (BIT1 | BIT3))
  END

  // Handle power level if specified
  PATCH_IF (power_level >= 0)
  BEGIN
    WRITE_LONG  0x0018 power_level
  END
END 

 



Example of use, to make a summonable version of an ochre jelly:

COPY_EXISTING "jeloch01.cre" "override/jelochsu.cre"
  LAUNCH_PATCH_FUNCTION make_summon END
Edited by Angel

Share this post


Link to post

Another small one, turn a creature into a summoned creature

Could you(or anyone that knows how to..) update that to include the limitless summon feature, so it can detect if that added gender exists and then set the gender to that instead in case it does. Edited by Jarno Mikkola

Share this post


Link to post

 

Another small one, turn a creature into a summoned creature

Could you update that to include the limitless summon feature, so it can detect if the added gender exists and then set the gender to that instead in case it does.

 

 

If you mean the one from d0tweak, it doesn't actually get added to gender.ids (something I intend to addres sometime). The one from Tweaks Anthology does things differently and only works on EE games.

 

EDIT: Okay, done.

Edited by Angel

Share this post


Link to post

Okay, this one is the result of my first, very careful prodding into the inner workings of Baldur's Gate Trilogy. Unlike EET, BGT resets the chapter count and empties the journal on transition to BG2. If you want your BG1 quest to do the same, this function can help you.

 

This function is called on a .dlg file, that is, a dialog that has already been compiled. If called on a game that is not BGT, it will do exactly nothing.

 

But if the game is BGT, it will loop through the transitions defined in the dialog, extract all the journal entries, then edit aram00.bcs (the transition script BGT uses to get the party into BG2) and tack on EraseJournalEntry instructions for all the journal entries found.

 

 

 

DEFINE_ACTION_FUNCTION erase_journal_entries_on_bg2_transition
  STR_VAR
  dialog    = "dummy"
BEGIN
  ACTION_IF GAME_IS "bgt" AND FILE_EXISTS_IN_GAME "aram00.bcs"
  BEGIN
    COPY_EXISTING - "%dialog%.dlg" "%MOD_FOLDER%/work"
      GET_OFFSET_ARRAY trans_array 0x0014 4 0x0010 4 0 0 0x0020
      PHP_EACH trans_array AS int => trans_offset
      BEGIN
        PATCH_IF (LONG_AT (trans_offset) & BIT4)
    BEGIN
      READ_SLONG (trans_offset + 0x0008) strref
      PATCH_IF strref > 0
      BEGIN
        DEFINE_ASSOCIATIVE_ARRAY journal_entries
        BEGIN
          "%strref%" => "1"
        END
      END
    END
      END

    COPY_EXISTING "aram00.bcs" "override"
    DECOMPILE_AND_PATCH
    BEGIN
      PHP_EACH journal_entries AS strref => int
      BEGIN
        REPLACE_TEXTUALLY CASE_SENSITIVE EXACT_MATCH
    ~SetGlobal("A6StartARAM00","ARAM00",10)~
    ~SetGlobal("A6StartARAM00","ARAM00",10)
     EraseJournalEntry(%strref%)~
      END
    END
  END
END

 

 

 

An example of how it is used, from one of my own mods:

COMPILE "%MOD_FOLDER%/bg1/caths_peril/dialog/mh#cath.d"

LAUNCH_ACTION_FUNCTION erase_journal_entries_on_bg2_transition
  STR_VAR
  dialog        = "mh#cath"
END
 

Note, this is as yet untested (although I see no reason why it won't work) as my test game has not reached the point of transition to BG2 yet. (Getting there, party is currently raiding Durlag's Tower.) EDIT: It's no longer untested; it works!

 

The function will only work on compiled dialog files (.dlg) that already exist in the game. It will not work on dialog files that haven't been compiled (.d). Neither does it work on scripts, compiled (.bcs) or not (.baf).

Edited by Angel

Share this post


Link to post

One suggestion for make_summon would be to add the undroppable flags to inventory items.

Share this post


Link to post

One suggestion for make_summon would be to add the undroppable flags to inventory items.

 

Good suggestion, will do!

 

EDIT: Done!

Edited by Angel

Share this post


Link to post

Another small one, turn a creature into a summoned creature. This sets the XP- and gold stats to zero, sets the bit to leave no corpse, sets affinity to "neutral", and sets the creature's gender to "summoned".

 

There is one parameter, power_level. This should only be set if this creature will be used with opcode #127, it is used to determine how many instances of this creature will be summoned. The number here (default 1) will be written to 0x0018 in the creature file.

 

 

 

DEFINE_PATCH_FUNCTION make_summon
  INT_VAR   power_level   = 1
BEGIN
  WRITE_LONG 0x0010 THIS | BIT1      // No corpse
  WRITE_LONG 0x0014 0                // XP
  WRITE_LONG 0x0018 power_level
  WRITE_LONG 0x001c 0                // Gold
  WRITE_BYTE 0x0270 IDS_OF_SYMBOL("ea" "neutral")

  // Play nice with Remove Summoning Cap from D0Tweak
  PATCH_IF FILE_EXISTS "override/no_summoning_cap.d0"
  BEGIN
    WRITE_BYTE  0x0275 20       // D0Tweak alt. value
  END
  ELSE
  BEGIN
    WRITE_BYTE  0x0275 IDS_OF_SYMBOL("gender" "summoned")
  END

  // Add unstealable&undroppable flags to carried items
  GET_OFFSET_ARRAY itm_array CRE_V10_ITEMS
  PHP_EACH itm_array AS int => itm_offset
  BEGIN
    WRITE_LONG (itm_offset + 0x0010) (THIS | (BIT1 | BIT3))
  END
END

 

 

Example of use, to make a summonable version of an ochre jelly:

COPY_EXISTING "jeloch01.cre" "override/jelochsu.cre"
  LAUNCH_PATCH_FUNCTION make_summon END
Oh, this is great! Any chance for a 'shawdowed' option (i.e. like shades or shadow monsters in iwdee)? Edited by Grammarsalad

Share this post


Link to post

Another small one, turn a creature into a summoned creature.

This is GOLD. Gonna make good use of this.

 

Anyone know of a macro that is the obverse of SNPRINT - instead of retaining the first x characters of a string, I want to remove the first x characters and keep the rest. (Basically I want to automate switching out the modder prefix for a different one.)

Share this post


Link to post

(Basically I want to automate switching out the modder prefix for a different one.)

REPLACE_TEXTUALLY ...

Share this post


Link to post

 

(Basically I want to automate switching out the modder prefix for a different one.)

REPLACE_TEXTUALLY ...

 

Maybe I'm just not seeing how to do that. Maybe I'm not good with regexp (okay, I know I'm no good with regexp...)

 

Here's what I'm looking to do:

 

Given this:

CLERIC_SANCTUARY                       , 1 => Shadow
MAZZY_HASTE                            , 2 => Exploration
b_c302 /*cloak of darkness*/           , 3 => Shadow
WIZARD_SHADOW_DOOR                     , 4 => Shadow
d5sh501 /*SR summon shadows*/          , 5 => Shadow
spsd02 /*shadowstep*/                  , 5 => Shadow

Do this:

ACTION_PHP_EACH spellsphere AS spl => sph BEGIN 
    COPY_EXISTING - ~spell.ids~ ~faiths_and_powers/backup~
      COUNT_REGEXP_INSTANCES ~%spl%~ ids_exists
    ACTION_IF (ids_exists) THEN BEGIN
      LAF RES_NUM_OF_SPELL_NAME 
        STR_VAR 
          spell_name = EVAL ~%spl%~ 
        RET 
          spell_res
          spell_num
      END
      ACTION_IF FILE_EXISTS_IN_GAME ~%spell_res%.spl~ BEGIN 
        COPY_EXISTING ~%spell_res%.spl~ ~override~ 
          READ_SHORT 0x1c spell_type
          READ_LONG 0x34 spell_lvl
        BUT_ONLY
        OUTER_TEXT_SPRINT the_spell ~%spell_res%~
      END
    END
    ELSE BEGIN
      ACTION_IF FILE_EXISTS_IN_GAME ~%spl%.spl~ BEGIN 
        COPY_EXISTING ~%spl%.spl~ ~override~ 
          READ_SHORT 0x1c spell_type
          READ_LONG 0x34 spell_lvl
        BUT_ONLY
        OUTER_TEXT_SPRINT the_spell ~%spl%~
      END
    END  
    COPY_EXISTING ~%the_spell%.spl~ ~override/d5f_____.spl~
      ....

So, this can capture anything with an IDS reference (so SPPR___.spl, SPWI___.spl, SPCL___.spl, or SPIN___.spl) or spells added by Grammarsalad (b_C____.spl) or any other random RES I decide to toss into the array (like SPSD___.spl)... and I want them all to have a nice uniform replacement name of "d5f____.spl."

 

Given that the spell itself is the thing being copied... what would the REPLACE_TEXTUALLY patch actually act on?

 

Something like REPLACE_TEXTUALLY would actually be great because I could convert:

SPPR => d5fP___

SPWI => d5fW___

SPCL => d5fC___

SPIN => d5fN___

SPSD => d5fS___

b_C => d5fB___

d5 => d5f5___

 

etc. That would be very pleasing to review in NI or the like. Right now I'm just using an incrementing integer to keep the d5f___ filenames unique, but that means the resulting filenames have zero relation to the underlying cloned spells.

 

Is there a way to squeeze an OUTER_INNER_PATCH in there somewhere?

 

Edited by subtledoctor

Share this post


Link to post
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...