Jump to content


Photo

Toss your semi-useful WeiDU macros here


51 replies to this topic

#1 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9222 posts
  • Gender:Not Telling

Posted 24 June 2017 - 06:26 PM

It seems like everyone has a few macros that are fairly useful, but not quite useful enough to go bug Wisp for inclusion in WeiDU itself. I'd like to suggest a mega-thread where we can all dump anything that might be useful to others. This first post will be updated descripts and links to the (hopefully thousands, millions of) macros that get posted below.

 

Post 2, Ardanis -

 

  • ADD_SPELL_HEADER, ADD_ITEM_HEADER - Used to add abilities/headers to spells and items
  • CREATE_EFFECT - Create effects whole cloth
  • CREATE_SPELL - Create spells
  • update_item_descriptions_to_bgee - Updates vanilla item descriptions to EE format, i.e. stripping Usable By section, so that you don't have to provide two strings for vanilla and EE descriptions.

Post 3, CamDawg -

  • cd_extend_bg_area_script - Used to easily extend area scripts when writing a BG/BGEE/BGT/Tutu mod
  • spell_to_innate - Used to convert arcane or divine spells into innate abilties
  • kit.ids fixer - Not really a macro, but needed to fix kit.ids for non-EE, non-Fixpacked BG2 games
  • cd_equip_item - finds the specified item in the creature file and equips it to the appropriate slot
  • cd_equip_weapon - finds the first valid weapon and equips it
  • cd_equip_weapon_specific - equips the specified weapon
  • cd_no_pickpocket - Moves an item that should not be pickpocketed into an inventory slot that is impossible to pickpocket from.
  • CD_EXTEND-O-MATIC - Used to arbitrarily create new spell headers out to the specified minimum level.
  • CD_MISSING_SPELL_HEADERS - Used to 'backfill' missing spell headers

Post 4, Ardanis -

  • tooltips - Adding new tooltips for the items in a few quick strokes

 

Post 5, Angel

  • add_area_actor - A wrapper for fj_area_struct that simplifies even further the process of adding an actor to an area.
  • remove_all_area_actors - Removes all actors from an area; useful for repurposing an area.
  • add_simple_trap - Another wrapper for fj_area_struct that allow for quickly creating a trap in an area.
  • add_area_actors_from_2da - Uses a table to mass-add actors to an area.

Post 6, Angel

  • add_energy_drain - Adds level drain to items or spells in engines that support energy drain, and pseudo-energy drain for those that don't
  • add_magic_missile_immunity - Adds magic missile immunity to an item or spell

Post 8, Angel

 

  • prevent_spell_effect_stacking - Prevents a spell from stacking with itself

Post 9, subtledoctor

  • add_hla, remove_hla, replce_hla - Macros for non-destructively editing HLA tables

Post 10, Angel

  • replace_cre_script - find and replace a creature script

Post 11, k4thos

  • ADD_MAP_ICONS_EE - BAM v2 worldmap icon file patching (for EE games that use PVRZ based map icons)
  • ADD_WORLDMAP_TBL - Adds multiple areas and links to the worldmap and saves using BP-BGT Worldmap TBL files convention

Post 12, Angel

  • make_magical - Add magical flag, lore, and enchantment level to item

Post 16, argent77

  • TO_HEX_NUMBER -  A decimal to hexadecimal number converter
  • FIND_FREE_ANIM_SLOT - This function attempts to find a free creature animation slot in a given range

Edited by CamDawg, 20 July 2017 - 05:34 AM.

I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#2 Ardanis

Ardanis

    A very GAR character

  • Modders
  • 2551 posts
  • Gender:Male
  • Location:Saint-Petersburg, Russia

Posted 24 June 2017 - 06:39 PM

ADD_SPELL_HEADER
ADD_ITEM_HEADER
CREATE_EFFECT
Also CREATE_SPELL, but it's probably not a thing many would care about.

Parameters should be self-explanatory. Can also copy an existing one.
I had this for items as well, but I don't think I've got the code anywhere in close vicinity.
EDIT Here it is https://github.com/G.../lib/macros.tpa
Spoiler

 
update_item_descriptions_to_bgee
Updates vanilla item descriptions to EE format, i.e. stripping Usable By section, so that you don't have to provide two strings for vanilla and EE descriptions.
https://github.com/G...ription.tpa#L77
Spoiler


Example usage 1, by item:
Spoiler

Example usage 2, batch update (caution, only really useful if you've got a simple content mod and don't do any level 80 patching:
Spoiler

Edited by Ardanis, 24 June 2017 - 07:00 PM.

"Uguu~ Boku Ayu."

Before you start breaking wall tiles with your bare fists, ask yourself first - do you truly need it?

#3 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9222 posts
  • Gender:Not Telling

Posted 24 June 2017 - 06:50 PM

This one I wrote from frustration of trying to track down which areas have area scripts assigned, what they are, etc. when trying to write a mod for BG/BGEE/BGT/Tutu.

Spoiler

 
 
Invoked like so
 
 

LAF cd_extend_bg_area_script STR_VAR area = EVAL "%Ulcaster%" script = ~SUPERSECRETMOD/baf/et_3900~ END

 
 
This is using the excellent g3_xx_cpmvars libraries to set Ulcaster to the correct area. This will basically look in the area file, find the area script, assign one if none is assigned, and then EXTEND_TOP or _BOTTOM.
 
 
 
The classic kit.ids fixer; include this to fix kit.ids in an un-Fixpacked or non-EE game:
 

Spoiler

 

I wrote a lot for Fixpack for fixing creature inventories:

Spoiler


cd_equip_item simple finds the specified item in the creature file and equips it to the appropriate slot. cd_equip_weapon finds the first valid weapon and equips it; cd_equip_weapon_specific does the same but only with the item you specify. cd_no_pickpocket move an item that should not be pickpocketed into an inventory slot that is impossible to pickpocket from.

 

 

 

Fixpack also had to do a lot of fixes for spells with missing headers. Sometimes these were headers at the end of the spell (e.g. spell had headers through level 18, but was missing 19 and 20), other times they were missing low-level headers (e.g. spell had headers for 1, 10, 11, etc. but also needed 8 and 9). Enter CD_EXTEND-O-MATIC (patent pending) for the former case, and CD_MISSING_SPELL_HEADERS for the latter:

 

Spoiler

 

 

These will do rudimentary extensions; generally they'll nail it if the only thing that changes between headers is duration. For anything else, I usually had to follow up with a loop of ALTER_EFFECT. Fixpack has numerous examples of both in action. The EXTEND-O-MATIC in particular could probably be used to knock out a new Spell-50 mod pretty easily.

 

 

 

And finally, an old, old friend: spell_to_innate.

 

Spoiler

 

 

This is useful for converting arcane/divine spells into innate abilities, particularly for kits.


I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#4 Ardanis

Ardanis

    A very GAR character

  • Modders
  • 2551 posts
  • Gender:Male
  • Location:Saint-Petersburg, Russia

Posted 24 June 2017 - 07:04 PM

Adding new tooltips for the items in a few quick strokes. Usage example is inside the link

https://github.com/G...oltip_macro.tpa


"Uguu~ Boku Ayu."

Before you start breaking wall tiles with your bare fists, ask yourself first - do you truly need it?

#5 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 25 June 2017 - 10:47 PM

Add a new actor to an area. This is a simple wrapper around fj_area_struct that saves having to type a bunch of variables.

Spoiler


Clear all actors from an area. Useful if you want to give a generic house in BG1 some new purpose.

Spoiler


Add a simple trap to an area. Care should be taken that the trap form a long thin rectangle, or thieves may not be able to get close enough to disarm it. Another wrappper around fj_area_struct to save typing because I'm lazy. :-)

Spoiler


Batch-add new actors to an area from a table. Table takes the form <resref> <xpos> <ypos> <orientation>.  Uses add_area_actor().

Spoiler


#6 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 25 June 2017 - 11:37 PM

My version of the "extend-o-matic", written for two personal mods, one that makes healing spells scale with level and the other to make Flame Blade behave as the 3E version. I'll probably switch to CamDawg's since it is superior. This one only works with spells that have a single header and does not update them in any way.

 

EDIT: Forget mine, CamDawg's version is superior in every way.  It even has a much cooler name. ^^

 

Add a level-drain effect to an item or spell, and patch in a simulate for games that don't support opcode 216 (vanilla BG and IWD). The simulate lowers THAC0 by 2 and max. HP by 5 for 8 hours. Written for a personal mod to make Wraith Spiders more like their PnP version.

 

EDIT: Turns out that in BG2, the level drain icon is set by the engine when opcode 216 is used.  So, don't set it ourselves as it won't be removed.

Spoiler



Add magic missile immunity to an item or spell. Has to be given match_opcode to determine which effect header will be cloned.

First, have this in your ALWAYS block somewhere. This finds 'Magic Missile'-like spells in BG1, BG2 and IWD1.
('Improved Magic Missile' is from a personal mod of mine, it's a third level version that shoots up to 11 missiles. Yes, the magic missile projectile actually goes that high in the BG and IWD engines. ^^).

Spoiler


And the actual function:
Spoiler



Prevent a spell from stacking with itself. Does not work with vanilla BG1 since it lacks opcode 206, but it does work with IWD1. Has to be given a match_opcode to find a suitable header to clone.

 

EDIT: Use the improved version below, it plays nicer with IWD1 and EE games.


Edited by Angel, 19 July 2017 - 04:02 AM.


#7 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9222 posts
  • Gender:Not Telling

Posted 26 June 2017 - 06:05 AM

My version of the "extend-o-matic", written for two personal mods, one that makes healing spells scale with level and the other to make Flame Blade behave as the 3E version. I'll probably switch to CamDawg's since it is superior. This one only works with spells that have a single header and does not update them in any way.

 
Yeah, something similar was the prompting for me to make the post. I thought my BG area script extender was quite clever, shared it, and realized that others had already done it long ago and I had wasted time reinventing the wheel.
 

Prevent a spell from stacking with itself. Does not work with vanilla BG1 since it lacks opcode 206, but it does work with IWD1. Has to be given a match_opcode to find a suitable header to clone.

 

I'd like to offer two refinements here, if I may. Both IWD1 and the EEs have superior ways of handling spell stacking, namely the 'Remove effects by resource' opcode (IIRC 254 for IWD, and 321 for EEs). Put it first in the effects stack (timing mode 0, duration 0) and you'll have a vastly superior stacking solution for the engines that support it. Second, I'd set the default match_opcode to 142--Fixpack patches 20+ spells to not self-stack, and 142 works for all but three of them.


I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#8 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 26 June 2017 - 09:13 AM

 

Prevent a spell from stacking with itself. Does not work with vanilla BG1 since it lacks opcode 206, but it does work with IWD1. Has to be given a match_opcode to find a suitable header to clone.

 
I'd like to offer two refinements here, if I may. Both IWD1 and the EEs have superior ways of handling spell stacking, namely the 'Remove effects by resource' opcode (IIRC 254 for IWD, and 321 for EEs). Put it first in the effects stack (timing mode 0, duration 0) and you'll have a vastly superior stacking solution for the engines that support it. Second, I'd set the default match_opcode to 142--Fixpack patches 20+ spells to not self-stack, and 142 works for all but three of them.

 

Heh, you certainly may! I've only recently begun to extend my meddlings to IWD1, so I have yet to learn all the subtleties of it. (Not that I claim to know them for BG, mind you!)  As for the EE games, I have yet to touch them at all.  It's on my to-do list, just hesitant to spend more money on games I already own.  But knowing myself, I'll probably give in sooner or later. :-)

 

I checked IESDP and it looks like you got the codes exactly right, so here's the adapted version:

 

Spoiler

Edited by Angel, 26 June 2017 - 09:52 AM.


#9 subtledoctor

subtledoctor
  • Modders
  • 2144 posts
  • Gender:Male

Posted 27 June 2017 - 08:37 PM

Not sure if this actually counts, but I made a set of functions to create and customize HLA tables in a non-destructive manner:

 

https://github.com/U...ana/Modify_HLAs

 

Spoiler

 

Use is fairly simple, you just need to know the kit name of the kit you want to modify (the name in kitlist.2da), and the variables that you want to fill into the table:

LAF remove_hla STR_VAR kit_name = ~RANGER~ remove_ability = ~GA_SPCL922~ END

LAF add_hla STR_VAR kit_name = ~RANGER~ ability = ~GA_SPCL923~ num_allowed = ~20~ END

LAF replace_hla STR_VAR kit_name = ~RANGER~ remove_ability = ~GA_SPCL900~ ability = ~GA_SPCL922~ num_allowed = ~1~ excluded_by = ~GA_SPCL922~ END

The variables simply correspond to the column headings in the LUxyz.2da HLA tables... plus the added "remove_ability" variable in the remove_hla and replace_hla functions.

 

NOTE: this will insert my personal modding prefix into the player's game, regardless of which mod/modder actually uses these functions.  I think that is unavoidable; for different mods to work together with these functions the tables assigned to any given kit must not conflict with another game file (thus involving a modder prefix), and they should agree on a uniform system for assigning new, unique table names for each modified kit (thus, the same modder prefix).  So it's not vanity, just convenience.  The functions assign any modfied kit's HLAs to a table name constructed from "LU" plus "d5" plus the row number of the kit in LUABBR.2da.


Edited by subtledoctor, 27 June 2017 - 08:45 PM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#10 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 29 June 2017 - 11:17 AM

replace_cre_script, find and replace a creature script

 

Written out of frustration when trying to give ankhegs and winter wolves different scripts for their special attacks and finding that almost every single version of the critters had it in a different slot.

 

Spoiler

Edited by Angel, 16 July 2017 - 05:30 AM.


#11 K4thos

K4thos
  • Modders
  • 1057 posts
  • Gender:Male

Posted 06 July 2017 - 12:26 PM

1. Code for patching BAM v2 worldmap icons without overwriting. I've tried to keep variable names similar to mike's code for BAM v1 patching in case someone would like to merge both functions into 1 that supports both formats:

https://github.com/K...ap_icons_ee.tpa

The code can be easily adjusted to patch any BAM v2 file.

 

2. WMP file patching using BP-BGT Worldmap style TBL files (useful when you need to add more than 1 area or many links with custom travel times). The code can also patch classic and EE saves, remap icons (in case you use add_map_icons_ee.tpa too) and do other minor things (disabled by default)

https://github.com/K...orldmap_tbl.tpa

 

Earlier versions of these functions have been implemented in Lava's mods that add new areas to worldmap, so they can be used as a reference.



#12 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 16 July 2017 - 05:33 AM

Small one to quickly flag an item as magical.  Written mostly because I keep forgetting what the offsets in the item file are. :-)

 

Spoiler

 

Used like this, to make a magical version of the generic b1-4 "paw" that counts as a +1 weapon for things to hit:

COPY_EXISTING "b1-4.itm" "override/b1-4m1.itm"
  LAUNCH_PATCH_FUNCTION make_magical
    INT_VAR
    enchantment = 1
  END

Note that this by itself does not set to-hit and damage bonuses, use the built-in ALTER_ITEM_HEADER for that.


Edited by Angel, 16 July 2017 - 05:36 AM.


#13 Grammarsalad

Grammarsalad
  • Modders
  • 445 posts
  • Gender:Male

Posted 16 July 2017 - 08:02 AM

...

 

EDIT: Turns out that in BG2, the level drain icon is set by the engine when opcode 216 is used.  So, don't set it ourselves as it won't be removed.

Spoiler

 

...

Just a slight copy/paste typo.  "EFINE_PATCH_FUNCTION add_energy_drain" needs to be changed to "DEFINE_PATCH_FUNCTION add_energy_drain"



#14 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 19 July 2017 - 04:04 AM

Just a slight copy/paste typo.  "EFINE_PATCH_FUNCTION add_energy_drain" needs to be changed to "DEFINE_PATCH_FUNCTION add_energy_drain"


Heh, probably a typo when I was editing. Fixed.

#15 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6203 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 19 July 2017 - 04:42 AM

Heh, probably a typo when I was editing. Fixed.

Yeah, you typically won't get typos with Copy/Paste_edit scennarios, and typically in those one could also use the replace that's in Notepad to get rid of the edits problems too... but maybe that's just me.
Hmm, you could just use ~add energy drain~ instead of add_energy_drain ... ahh, whell.
Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users