Jump to content

Looking for help creating a patching script for spells


Recommended Posts

Hello everyone. I'm just starting to go heavily into Baldur's Gate modding and I wanted to create a simple patching script for spells. I looked at the tutorials for patching items, and while I had success in changing global effects through a patch, patching effects attached to abilities is getting slightly overwhelming.


I understand that the abilities use the same effects 'space' as the global effects, they're just referenced in a different fashion; with the ability entries holding the data of when their effects start and when another ability's effects end. What I want to know is how to adapt the effect patching script in the tutorial forums to go from patching global-effects to ability effects.


This is what I have so far, basing the code on this tutorial. Can someone know if I'm heading into the right direction? For now I just want to set all the durations greater than 7 to 7 because I want to attach them to contingencies fired by items.


READ_LONG 0x64 "abilities_offset"

READ_SHORT 0x68 "abilities_number"

READ_LONG 0x6A "effects_offset"

WHILE ("%abilities_number%" > 0) BEGIN

SET "abilities_number" = ("%abilities_number%" - 1)

READ_SHORT ("%abilities_offset%" + 0x1e + (0x38 * "%abilities_number%")) "ability_effects_number"

READ_SHORT ("%abilities_offset%" + 0x20 + (0x38 * "%abilities_number%")) "ability_effects_offset"

WHILE ("%effects_number%" > 0) BEGIN

SET "effects_number" = ("%effects_number%" - 1)

READ_LONG ("%effects_offset%" + 0x0e + (0x30 * "%effects_number%")) "duration"

PATCH_IF "%duration%" > 0x7 BEGIN

WRITE_LONG (("%effects_offset%" + 0x0e + (0x30 * "%effects_number%"))) 0x7





Link to comment

Try something like this.

READ_LONG  0x64 abilities_off
READ_SHORT 0x68 num_abilities
READ_LONG  0x6A effects_off
FOR (ability = 0; ability < num_abilities; ability += 1) BEGIN
READ_SHORT (abilities_off + 0x28 * ability + 0x1e) num_features
READ_SHORT (abilities_off + 0x28 * ability + 0x20) features_ind
FOR (effect = 0; effect < num_features; effect += 1) BEGIN
	READ_LONG (effects_off + 0x30 * (features_ind + effect) + 0x0e) duration
	PATCH_IF (duration > 7) BEGIN
		WRITE_LONG (effects_off + 0x30 * (features_ind + effect) + 0x0e) 7

Link to comment


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

  • Create New...