Jump to content

Adding/Changing Item Effects


grogerson

Recommended Posts

I've some time before DavidW released IWD-inBG2 v7, so I'm looking over BG1 Tweaks for an update. I want to make the six magic shields have a cycling glow on the shield panel, but I'd need to change three of them and add an effect to the other three.

 

Example (SHLD07.ITM):

Current effect code:

[size=3][b][i]Type: Set color (7)[/i][/b]
Target: Self (1)
Power: 0
[b][i]Color: Color index 66[/i][/b]
Location: Shield panel - 34
Timing mode: Instant/While equipped (2)
Dispel/Resistance: No dispel/bypass resistance (0)
Duration: 0
Probability 1: 100
Probability 2: 0
Unknown: 00 00 00 a4 14 24 00 04 h
# dice thrown/maximum level: 0
Dice size/minimum level: 0
Save type: ( No save )
Save bonus: 0
Unknown: 00 00 00 00 h[/size]

 

Desired effect code:

[size=3][b][i]Type: Set color glow pulse (9)[/i][/b]
Target: Self (1)
Power: 0
Unknown: 47 h
[b][i]Red: 55
Green: 55
Blue: 117[/i][/b]
Location: Shield panel - 34
[b][i]Cycle speed: 40[/i][/b]
Timing mode: Instant/While equipped (2)
Dispel/Resistance: No dispel/bypass resistance (0)
Duration: 0
Probability 1: 100
Probability 2: 0
Unknown: 00 00 00 a4 14 24 00 04 h
# dice thrown/maximum level: 0
Dice size/minimum level: 0
Save type: ( No save )
Save bonus: 0
Unknown: 00 00 00 00 h[/size]

 

The highlighted lines are what need to change. I've been looking over the WeiDU readme and I'm no closer to a solution than I was yesterday. Some direction in both adding and changing item effects would be greatly appreciated.

Link to comment

for your example: tested and shows properly in NI

 

tp2 code:

COPY_EXISTING ~shld07.itm~ ~override~
 LAUNCH_PATCH_MACRO ~wipt_item_reader~
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
  PATCH_IF ($wipt_r_opco("%idx%") = 7) AND ($wipt_r_par2("%idx%") = 34) BEGIN
LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 $wipt_w_par1("%idx%") = 1966552832 $wipt_w_par2("%idx%") = 2621474 END
  END
 END
BUT_ONLY

before you ask. the reason for the large numerical values for paramaters 1 & 2 is that the information you were needing to add (color values & glow pulse speed) go into various bits of the larger 4-byte field. DLTCEP has an implode/explode button which I used to enter the individual values and then combine into the larger so that the data could be written in the LONG format.

 

function code (can grab a copy from the BG Fixpack):

DEFINE_PATCH_MACRO ~wipt_item_reader~ BEGIN
PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files
 DEFINE_ARRAY h_entry BEGIN un  in  ri   fl1  fl2  fl3  fl4  it   u1   u2   u3   u4   ia   ml   ms   msb  k1   mi   k2   md   k3   mw   k4   mc   wp   mch  pr   st   ii   lo   gi   we   ud   id   di   en   END
 DEFINE_ARRAY h_offst BEGIN 0x8 0xc 0x10 0x18 0x19 0x1a 0x1b 0x1c 0x1e 0x1f 0x20 0x21 0x22 0x24 0x26 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f 0x30 0x31 0x32 0x34 0x38 0x3a 0x42 0x44 0x4c 0x50 0x54 0x58 0x60 END
 DEFINE_ARRAY h_SoWrt BEGIN 4   4   8	1	1	1	1	2	1	1	1	1	2	1	1	1	1	1	1	1	1	1	1	1	1	1	4	2	8	2	8	4	4	4	8	4	END
 DEFINE_ARRAY h_AsciL BEGIN 0   0   8	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	8	0	8	0	0	0	8	0	END
 DEFINE_ARRAY h_Bit   BEGIN 0   0   0	1	1	1	1	0	1	1	1	1	0	0	0	0	1	0	1	0	1	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	END
 FOR(hi=0;hi<36;hi+=1)BEGIN
  SET $wipt_Off($h_entry("%hi%")) = $h_offst("%hi%") //set offset for entry
  SET $wipt_SoW($h_entry("%hi%")) = $h_SoWrt("%hi%") //set size of write for entry
  SET $wipt_AcL($h_entry("%hi%")) = $h_AsciL("%hi%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
  SET $wipt_Bit($h_entry("%hi%")) = $h_Bit("%hi%")   //set whether entry should be written in bit format
  PATCH_IF ($h_SoWrt("%hi%") = 1) BEGIN
READ_BYTE $wipt_Off($h_entry("%hi%")) $wipt_r($h_entry("%hi%"))
  END
  PATCH_IF ($h_SoWrt("%hi%") = 2) BEGIN
READ_SHORT $wipt_Off($h_entry("%hi%")) $wipt_r($h_entry("%hi%"))
  END
  PATCH_IF ($h_SoWrt("%hi%") = 4) BEGIN
READ_LONG $wipt_Off($h_entry("%hi%")) $wipt_r($h_entry("%hi%"))
  END
  PATCH_IF ($h_SoWrt("%hi%") = 8) AND ($h_AsciL("%hi%") = 8) BEGIN
READ_ASCII $wipt_Off($h_entry("%hi%")) $wipt_r($h_entry("%hi%")) (8) NULL
  END
  PATCH_IF ($h_SoWrt("%hi%") = 8) AND ($h_AsciL("%hi%") = 32) BEGIN
READ_ASCII $wipt_Off($h_entry("%hi%")) $wipt_r($h_entry("%hi%")) (32) NULL
  END
 END
//begin ability to access abilities and effects
 SET wipt_abil_size = 0x38
 SET wipt_fx_size = 0x30
 DEFINE_ARRAY h_entry BEGIN abil_off abil_num fx_off eqfx_idx eqfx_num END
 DEFINE_ARRAY h_offst BEGIN 0x64	 0x68	 0x6a   0x6e	 0x70	 END
 DEFINE_ARRAY h_SoWrt BEGIN 4		2		4	  2		2		END
 DEFINE_ARRAY h_AsciL BEGIN 0		0		0	  0		0		END
 DEFINE_ARRAY h_Bit   BEGIN 0		0		0	  0		0		END
 FOR(hmi=0;hmi<5;hmi+=1)BEGIN
  SET $wipt_Off($h_entry("%hmi%")) = $h_offst("%hmi%") //set offset for entry
  SET $wipt_SoW($h_entry("%hmi%")) = $h_SoWrt("%hmi%") //set size of write for entry
  SET $wipt_AcL($h_entry("%hmi%")) = $h_AsciL("%hmi%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
  SET $wipt_Bit($h_entry("%hmi%")) = $h_Bit("%hmi%")   //set whether entry should be written in bit format
  PATCH_IF ($h_SoWrt("%hmi%") = 2) BEGIN
READ_SHORT $h_offst("%hmi%") $wipt($h_entry("%hmi%"))
  END
  PATCH_IF ($h_SoWrt("%hmi%") = 4) BEGIN
READ_LONG $h_offst("%hmi%") $wipt($h_entry("%hmi%"))
  END
 END
 SET wipt_total_fx = %wipt_eqfx_num%
//begin ability to read and edit Equipping effects
 FOR(el1=%wipt_eqfx_idx%;el1<%wipt_eqfx_num%;el1+=1)BEGIN
  SET wipt_fx_location=(%wipt_fx_off% + (%el1%*%wipt_fx_size%))
  DEFINE_ARRAY e_entry BEGIN opco targ powr par1 par2 tmod resi dura pro1 pro2 reso diet dies savt savb END
  DEFINE_ARRAY e_offst BEGIN 0x0  0x2  0x3  0x4  0x8  0xc  0xd  0xe  0x12 0x13 0x14 0x1c 0x20 0x24 0x28 END
  DEFINE_ARRAY e_SoWrt BEGIN 2	1	1	4	4	1	1	4	1	1	8	4	4	4	4	END
  DEFINE_ARRAY e_AsciL BEGIN 0	0	0	0	0	0	0	0	0	0	8	0	0	0	0	END
  DEFINE_ARRAY e_Bit   BEGIN 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	END
  FOR(ei=0;ei<15;ei+=1)BEGIN
SET $wipt_Off($e_entry("%ei%")"%el1%") = %wipt_fx_location% + $e_offst("%ei%") //set offset for entry
SET $wipt_SoW($e_entry("%ei%")"%el1%") = $e_SoWrt("%ei%") //set size of write for entry
SET $wipt_AcL($e_entry("%ei%")"%el1%") = $e_AsciL("%ei%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
SET $wipt_Bit($e_entry("%ei%")"%el1%") = $e_Bit("%ei%")   //set whether entry should be written in bit format
PATCH_IF ($e_SoWrt("%ei%") = 1) BEGIN
 READ_BYTE $wipt_Off($e_entry("%ei%")"%el1%") $wipt_r($e_entry("%ei%")"%el1%")
END
PATCH_IF ($e_SoWrt("%ei%") = 2) BEGIN
 READ_SHORT $wipt_Off($e_entry("%ei%")"%el1%") $wipt_r($e_entry("%ei%")"%el1%")
END
PATCH_IF ($e_SoWrt("%ei%") = 4) BEGIN
 READ_LONG $wipt_Off($e_entry("%ei%")"%el1%") $wipt_r($e_entry("%ei%")"%el1%")
END
PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 8) BEGIN
 READ_ASCII $wipt_Off($e_entry("%ei%")"%el1%") $wipt_r($e_entry("%ei%")"%el1%") (8) NULL
END
PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 32) BEGIN
 READ_ASCII $wipt_Off($e_entry("%ei%")"%el1%") $wipt_r($e_entry("%ei%")"%el1%") (32) NULL
END
  END //end array loop
 END //end loop through equiping effects
//begin ability to read and edit ability headers
 FOR(al1=0;al1<%wipt_abil_num%;al1+=1)BEGIN
  SET wipt_abil_location=(%wipt_abil_off% + (%al1%*%wipt_abil_size%))
  DEFINE_ARRAY a_entry BEGIN attack id_req useloc useico target tarnum range projec speed thac0b dsides dthrow damagb damagt charge chardp flagb1 flagb2 proani ohand bhand thrust arrow bolt other END
  DEFINE_ARRAY a_offst BEGIN 0x0	0x1	0x2	0x4	0xc	0xd	0xe   0x10   0x12  0x14   0x16   0x18   0x1a   0x1c   0x22   0x24   0x26   0x27   0x2a   0x2c  0x2e  0x30   0x32  0x34 0x36  END
  DEFINE_ARRAY a_SoWrt BEGIN 1	  1	  1	  8	  1	  1	  2	 2	  2	 2	  2	  2	  2	  2	  2	  2	  1	  1	  2	  2	 2	 2	  2	 2	2	 END
  DEFINE_ARRAY a_AsciL BEGIN 0	  0	  0	  8	  0	  0	  0	 0	  0	 0	  0	  0	  0	  0	  0	  0	  0	  0	  0	  0	 0	 0	  0	 0	0	 END
  DEFINE_ARRAY a_Bit   BEGIN 0	  1	  0	  0	  0	  0	  0	 0	  0	 0	  0	  0	  0	  0	  0	  0	  1	  1	  0	  0	 0	 0	  0	 0	0	 END
  FOR(ai=0;ai<25;ai+=1)BEGIN
SET $wipt_Off($a_entry("%ai%")"%al1%") = %wipt_abil_location% + $a_offst("%ai%") //set offset for entry
SET $wipt_SoW($a_entry("%ai%")"%al1%") = $a_SoWrt("%ai%") //set size of write for entry
SET $wipt_AcL($a_entry("%ai%")"%al1%") = $a_AsciL("%ai%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
SET $wipt_Bit($a_entry("%ai%")"%al1%") = $a_Bit("%ai%")   //set whether entry should be written in bit format
PATCH_IF ($a_SoWrt("%ai%") = 1) BEGIN
 READ_BYTE $wipt_Off($a_entry("%ai%")"%al1%") $wipt_r($a_entry("%ai%")"%al1%")
END
PATCH_IF ($a_SoWrt("%ai%") = 2) BEGIN
 READ_SHORT $wipt_Off($a_entry("%ai%")"%al1%") $wipt_r($a_entry("%ai%")"%al1%")
END //end short read compare write
PATCH_IF ($a_SoWrt("%ai%") = 4) BEGIN
 READ_LONG $wipt_Off($a_entry("%ai%")"%al1%") $wipt_r($a_entry("%ai%")"%al1%")
END //end long read compare write
PATCH_IF ($a_SoWrt("%ai%") = 8) AND ($a_AsciL("%ai%") = 8) BEGIN
 READ_ASCII $wipt_Off($a_entry("%ai%")"%al1%") $wipt_r($a_entry("%ai%")"%al1%") (8) NULL
END
PATCH_IF ($a_SoWrt("%ai%") = 8) AND ($a_AsciL("%ai%") = 32) BEGIN
 READ_ASCII $wipt_Off($a_entry("%ai%")"%al1%") $wipt_r($a_entry("%ai%")"%al1%") (32) NULL
END
  END
//begin ability to read and edit ability effects
  DEFINE_ARRAY a_entry BEGIN abilfx_num abilfx_idx END
  DEFINE_ARRAY a_offst BEGIN 0x1e	   0x20	   END
  DEFINE_ARRAY a_SoWrt BEGIN 2		  2		  END
  DEFINE_ARRAY a_AsciL BEGIN 0		  0		  END
  DEFINE_ARRAY a_Bit   BEGIN 0		  0		  END
  FOR(ami=0;ami<2;ami+=1)BEGIN
SET $wipt_Off($a_entry("%ami%")"%al1%") = %wipt_abil_location% + $a_offst("%ami%") //set offset for entry
PATCH_IF (%ami% = 0) BEGIN
 READ_SHORT %wipt_abil_location% + $a_offst("%ami%") $wipt_abilfx_num("%al1%")
END
PATCH_IF (%ami% = 1) BEGIN
 READ_SHORT %wipt_abil_location% + $a_offst("%ami%") $wipt_abilfx_idx("%al1%")
END
  END
  SET wipt_total_fx+=$wipt_abilfx_num("%al1%")
  FOR(el2=$wipt_abilfx_idx("%al1%");el2<($wipt_abilfx_idx("%al1%")+$wipt_abilfx_num("%al1%"));el2+=1)BEGIN
SET wipt_abilfx_location=(%wipt_fx_off% + (%el2%*%wipt_fx_size%))
DEFINE_ARRAY ae_entry BEGIN opco targ powr par1 par2 tmod resi dura pro1 pro2 reso diet dies savt savb END
DEFINE_ARRAY ae_offst BEGIN 0x0  0x2  0x3  0x4  0x8  0xc  0xd  0xe  0x12 0x13 0x14 0x1c 0x20 0x24 0x28 END
DEFINE_ARRAY ae_SoWrt BEGIN 2	1	1	4	4	1	1	4	1	1	8	4	4	4	4	END
DEFINE_ARRAY ae_AsciL BEGIN 0	0	0	0	0	0	0	0	0	0	8	0	0	0	0	END
DEFINE_ARRAY ae_Bit   BEGIN 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	END
FOR(aei=0;aei<15;aei+=1)BEGIN
 SET $wipt_Off($ae_entry("%aei%")"%el2%") = %wipt_abilfx_location% + $ae_offst("%aei%") //set offset for entry
 SET $wipt_SoW($ae_entry("%aei%")"%el2%") = $ae_SoWrt("%aei%") //set size of write for entry
 SET $wipt_AcL($ae_entry("%aei%")"%el2%") = $ae_AsciL("%aei%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
 SET $wipt_Bit($ae_entry("%aei%")"%el2%") = $ae_Bit("%aei%")   //set whether entry should be written in bit format
 PATCH_IF ($ae_SoWrt("%aei%") = 1) BEGIN
  READ_BYTE $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%")
 END //end byte read compare write
 PATCH_IF ($ae_SoWrt("%aei%") = 2) BEGIN
  READ_SHORT $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%")
 END //end short read compare write
 PATCH_IF ($ae_SoWrt("%aei%") = 4) BEGIN
  READ_LONG $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%")
 END //end long read compare write
 PATCH_IF ($ae_SoWrt("%aei%") = 8) AND ($ae_AsciL("%aei%") = 8) BEGIN
  READ_ASCII $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%") (8) NULL
 END
 PATCH_IF ($ae_SoWrt("%aei%") = 8) AND ($ae_AsciL("%aei%") = 32) BEGIN
  READ_ASCII $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%") (32) NULL
 END
END
  END
 END //end ability header read
END
END//end function define
DEFINE_PATCH_FUNCTION ~wipt_item_writer~ BEGIN
PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files
 DEFINE_ARRAY h_entry BEGIN un  in  ri   fl1  fl2  fl3  fl4  it   u1   u2   u3   u4   ia   ml   ms   msb  k1   mi   k2   md   k3   mw   k4   mc   wp   mch  pr   st   ii   lo   gi   we   ud   id   di   en   END
 DEFINE_ARRAY h_offst BEGIN 0x8 0xc 0x10 0x18 0x19 0x1a 0x1b 0x1c 0x1e 0x1f 0x20 0x21 0x22 0x24 0x26 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f 0x30 0x31 0x32 0x34 0x38 0x3a 0x42 0x44 0x4c 0x50 0x54 0x58 0x60 END
 DEFINE_ARRAY h_SoWrt BEGIN 4   4   8	1	1	1	1	2	1	1	1	1	2	1	1	1	1	1	1	1	1	1	1	1	1	1	4	2	8	2	8	4	4	4	8	4	END
 DEFINE_ARRAY h_AsciL BEGIN 0   0   8	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	8	0	8	0	0	0	8	0	END
 DEFINE_ARRAY h_Bit   BEGIN 0   0   0	1	1	1	1	0	1	1	1	1	0	0	0	0	1	0	1	0	1	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	END
 FOR(hi=0;hi<36;hi+=1)BEGIN
  SET $wipt_Off($h_entry("%hi%")) = $h_offst("%hi%") //set offset for entry
  SET $wipt_SoW($h_entry("%hi%")) = $h_SoWrt("%hi%") //set size of write for entry
  SET $wipt_AcL($h_entry("%hi%")) = $h_AsciL("%hi%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
  SET $wipt_Bit($h_entry("%hi%")) = $h_Bit("%hi%")   //set whether entry should be written in bit format
  PATCH_IF (VARIABLE_IS_SET $wipt_w($h_entry("%hi%")) ) BEGIN
PATCH_IF ($h_SoWrt("%hi%") = 1) BEGIN
 WRITE_BYTE $wipt_Off($h_entry("%hi%")) $wipt_w($h_entry("%hi%"))
END
PATCH_IF ($h_SoWrt("%hi%") = 2) BEGIN
 WRITE_SHORT $wipt_Off($h_entry("%hi%")) $wipt_w($h_entry("%hi%"))
END
PATCH_IF ($h_SoWrt("%hi%") = 4) BEGIN
 WRITE_LONG $wipt_Off($h_entry("%hi%")) $wipt_w($h_entry("%hi%"))
END
PATCH_IF ($h_SoWrt("%hi%") = 8) AND ($h_AsciL("%hi%") = 8) BEGIN
 WRITE_ASCIIE $wipt_Off($h_entry("%hi%")) $wipt_w($h_entry("%hi%")) (8)
END
PATCH_IF ($h_SoWrt("%hi%") = 8) AND ($h_AsciL("%hi%") = 32) BEGIN
 WRITE_ASCIIE $wipt_Off($h_entry("%hi%")) $wipt_w($h_entry("%hi%")) (32)
END
  END
 END
//begin ability to access abilities and effects
//pre-set by using wipt_item_reader which will be a requirement
//  SET wipt_abil_size = 0x38
//  SET wipt_fx_size = 0x30
 DEFINE_ARRAY h_entry BEGIN abil_off abil_num fx_off eqfx_idx eqfx_num END
 DEFINE_ARRAY h_offst BEGIN 0x64	 0x68	 0x6a   0x6e	 0x70	 END
 DEFINE_ARRAY h_SoWrt BEGIN 4		2		4	  2		2		END
 DEFINE_ARRAY h_AsciL BEGIN 0		0		0	  0		0		END
 DEFINE_ARRAY h_Bit   BEGIN 0		0		0	  0		0		END
 FOR(hmi=0;hmi<5;hmi+=1)BEGIN
  SET $wipt_Off($h_entry("%hmi%")) = $h_offst("%hmi%") //set offset for entry
  SET $wipt_SoW($h_entry("%hmi%")) = $h_SoWrt("%hmi%") //set size of write for entry
  SET $wipt_AcL($h_entry("%hmi%")) = $h_AsciL("%hmi%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
  SET $wipt_Bit($h_entry("%hmi%")) = $h_Bit("%hmi%")   //set whether entry should be written in bit format
  PATCH_IF ($h_SoWrt("%hmi%") = 2) BEGIN
READ_SHORT $h_offst("%hmi%") $wipt($h_entry("%hmi%"))
  END
  PATCH_IF ($h_SoWrt("%hmi%") = 4) BEGIN
READ_LONG $h_offst("%hmi%") $wipt($h_entry("%hmi%"))
  END
 END
//pre-set by using wipt_item_reader which will be a requirement
//  SET wipt_total_fx = %wipt_eqfx_num%
//begin ability to read and edit Equipping effects
 FOR(el1=%wipt_eqfx_idx%;el1<%wipt_eqfx_num%;el1+=1)BEGIN
  SET wipt_fx_location=(%wipt_fx_off% + (%el1%*%wipt_fx_size%))
  DEFINE_ARRAY e_entry BEGIN opco targ powr par1 par2 tmod resi dura pro1 pro2 reso diet dies savt savb END
  DEFINE_ARRAY e_offst BEGIN 0x0  0x2  0x3  0x4  0x8  0xc  0xd  0xe  0x12 0x13 0x14 0x1c 0x20 0x24 0x28 END
  DEFINE_ARRAY e_SoWrt BEGIN 2	1	1	4	4	1	1	4	1	1	8	4	4	4	4	END
  DEFINE_ARRAY e_AsciL BEGIN 0	0	0	0	0	0	0	0	0	0	8	0	0	0	0	END
  DEFINE_ARRAY e_Bit   BEGIN 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	END
  FOR(ei=0;ei<15;ei+=1)BEGIN
SET $wipt_Off($e_entry("%ei%")"%el1%") = %wipt_fx_location% + $e_offst("%ei%") //set offset for entry
SET $wipt_SoW($e_entry("%ei%")"%el1%") = $e_SoWrt("%ei%") //set size of write for entry
SET $wipt_AcL($e_entry("%ei%")"%el1%") = $e_AsciL("%ei%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
SET $wipt_Bit($e_entry("%ei%")"%el1%") = $e_Bit("%ei%")   //set whether entry should be written in bit format
PATCH_IF (VARIABLE_IS_SET $wipt_w($e_entry("%ei%")"%el1%") ) BEGIN
 PATCH_IF ($e_SoWrt("%ei%") = 1) BEGIN
  WRITE_BYTE $wipt_Off($e_entry("%ei%")"%el1%") $wipt_w($e_entry("%ei%")"%el1%")
 END
 PATCH_IF ($e_SoWrt("%ei%") = 2) BEGIN
  WRITE_SHORT $wipt_Off($e_entry("%ei%")"%el1%") $wipt_w($e_entry("%ei%")"%el1%")
 END
 PATCH_IF ($e_SoWrt("%ei%") = 4) BEGIN
  WRITE_LONG $wipt_Off($e_entry("%ei%")"%el1%") $wipt_w($e_entry("%ei%")"%el1%")
 END
 PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 8) BEGIN
  WRITE_ASCIIE $wipt_Off($e_entry("%ei%")"%el1%") $wipt_w($e_entry("%ei%")"%el1%") (8)
 END
 PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 32) BEGIN
  WRITE_ASCIIE $wipt_Off($e_entry("%ei%")"%el1%") $wipt_w($e_entry("%ei%")"%el1%") (32)
 END
END //end variable is set
  END //end array loop
 END //end loop through equiping effects
//begin ability to read and edit ability headers
 FOR(al1=0;al1<%wipt_abil_num%;al1+=1)BEGIN
  SET wipt_abil_location=(%wipt_abil_off% + (%al1%*%wipt_abil_size%))
  DEFINE_ARRAY a_entry BEGIN attack id_req useloc useico target tarnum range projec speed thac0b dsides dthrow damagb damagt charge chardp flagb1 flagb2 proani ohand bhand thrust arrow bolt other END
  DEFINE_ARRAY a_offst BEGIN 0x0	0x1	0x2	0x4	0xc	0xd	0xe   0x10   0x12  0x14   0x16   0x18   0x1a   0x1c   0x22   0x24   0x26   0x27   0x2a   0x2c  0x2e  0x30   0x32  0x34 0x36  END
  DEFINE_ARRAY a_SoWrt BEGIN 1	  1	  1	  8	  1	  1	  2	 2	  2	 2	  2	  2	  2	  2	  2	  2	  1	  1	  2	  2	 2	 2	  2	 2	2	 END
  DEFINE_ARRAY a_AsciL BEGIN 0	  0	  0	  8	  0	  0	  0	 0	  0	 0	  0	  0	  0	  0	  0	  0	  0	  0	  0	  0	 0	 0	  0	 0	0	 END
  DEFINE_ARRAY a_Bit   BEGIN 0	  1	  0	  0	  0	  0	  0	 0	  0	 0	  0	  0	  0	  0	  0	  0	  1	  1	  0	  0	 0	 0	  0	 0	0	 END
  FOR(ai=0;ai<25;ai+=1)BEGIN
SET $wipt_Off($a_entry("%ai%")"%al1%") = %wipt_abil_location% + $a_offst("%ai%") //set offset for entry
SET $wipt_SoW($a_entry("%ai%")"%al1%") = $a_SoWrt("%ai%") //set size of write for entry
SET $wipt_AcL($a_entry("%ai%")"%al1%") = $a_AsciL("%ai%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
SET $wipt_Bit($a_entry("%ai%")"%al1%") = $a_Bit("%ai%")   //set whether entry should be written in bit format
PATCH_IF (VARIABLE_IS_SET $wipt_w($a_entry("%ai%")"%al1%") ) BEGIN
 PATCH_IF ($a_SoWrt("%ai%") = 1) BEGIN
  WRITE_BYTE $wipt_Off($a_entry("%ai%")"%al1%") $wipt_w($a_entry("%ai%")"%al1%")
 END
 PATCH_IF ($a_SoWrt("%ai%") = 2) BEGIN
  WRITE_SHORT $wipt_Off($a_entry("%ai%")"%al1%") $wipt_w($a_entry("%ai%")"%al1%")
 END //end short read compare write
 PATCH_IF ($a_SoWrt("%ai%") = 4) BEGIN
  WRITE_LONG $wipt_Off($a_entry("%ai%")"%al1%") $wipt_w($a_entry("%ai%")"%al1%")
 END //end long read compare write
 PATCH_IF ($a_SoWrt("%ai%") = 8) AND ($a_AsciL("%ai%") = 8) BEGIN
  WRITE_ASCIIE $wipt_Off($a_entry("%ai%")"%al1%") $wipt_w($a_entry("%ai%")"%al1%") (8)
 END
 PATCH_IF ($a_SoWrt("%ai%") = 8) AND ($a_AsciL("%ai%") = 32) BEGIN
  WRITE_ASCIIE $wipt_Off($a_entry("%ai%")"%al1%") $wipt_w($a_entry("%ai%")"%al1%") (32)
 END
END //end variable is set
  END
//begin ability to read and edit ability effects
  DEFINE_ARRAY a_entry BEGIN abilfx_num abilfx_idx END
  DEFINE_ARRAY a_offst BEGIN 0x1e	   0x20	   END
  DEFINE_ARRAY a_SoWrt BEGIN 2		  2		  END
  DEFINE_ARRAY a_AsciL BEGIN 0		  0		  END
  DEFINE_ARRAY a_Bit   BEGIN 0		  0		  END
  FOR(ami=0;ami<2;ami+=1)BEGIN
SET $wipt_Off($a_entry("%ami%")"%al1%") = %wipt_abil_location% + $a_offst("%ami%") //set offset for entry
PATCH_IF (%ami% = 0) BEGIN
 READ_SHORT %wipt_abil_location% + $a_offst("%ami%") $wipt_abilfx_num("%al1%")
END
PATCH_IF (%ami% = 1) BEGIN
 READ_SHORT %wipt_abil_location% + $a_offst("%ami%") $wipt_abilfx_idx("%al1%")
END
  END
//pre-set by using wipt_item_reader which will be a requirement
//   SET wipt_total_fx+=$wipt_abilfx_num("%al1%")
  FOR(el2=$wipt_abilfx_idx("%al1%");el2<($wipt_abilfx_idx("%al1%")+$wipt_abilfx_num("%al1%"));el2+=1)BEGIN
SET wipt_abilfx_location=(%wipt_fx_off% + (%el2%*%wipt_fx_size%))
DEFINE_ARRAY ae_entry BEGIN opco targ powr par1 par2 tmod resi dura pro1 pro2 reso diet dies savt savb END
DEFINE_ARRAY ae_offst BEGIN 0x0  0x2  0x3  0x4  0x8  0xc  0xd  0xe  0x12 0x13 0x14 0x1c 0x20 0x24 0x28 END
DEFINE_ARRAY ae_SoWrt BEGIN 2	1	1	4	4	1	1	4	1	1	8	4	4	4	4	END
DEFINE_ARRAY ae_AsciL BEGIN 0	0	0	0	0	0	0	0	0	0	8	0	0	0	0	END
DEFINE_ARRAY ae_Bit   BEGIN 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	END
FOR(aei=0;aei<15;aei+=1)BEGIN
 SET $wipt_Off($ae_entry("%aei%")"%el2%") = %wipt_abilfx_location% + $ae_offst("%aei%") //set offset for entry
 SET $wipt_SoW($ae_entry("%aei%")"%el2%") = $ae_SoWrt("%aei%") //set size of write for entry
 SET $wipt_AcL($ae_entry("%aei%")"%el2%") = $ae_AsciL("%aei%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
 SET $wipt_Bit($ae_entry("%aei%")"%el2%") = $ae_Bit("%aei%")   //set whether entry should be written in bit format
 PATCH_IF (VARIABLE_IS_SET $wipt_w($ae_entry("%aei%")"%el2%") ) BEGIN
  PATCH_IF ($ae_SoWrt("%aei%") = 1) BEGIN
   WRITE_BYTE $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_w($ae_entry("%aei%")"%el2%")
  END //end byte read compare write
  PATCH_IF ($ae_SoWrt("%aei%") = 2) BEGIN
   WRITE_SHORT $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_w($ae_entry("%aei%")"%el2%")
  END //end short read compare write
  PATCH_IF ($ae_SoWrt("%aei%") = 4) BEGIN
   WRITE_LONG $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_w($ae_entry("%aei%")"%el2%")
  END //end long read compare write
  PATCH_IF ($ae_SoWrt("%aei%") = 8) AND ($ae_AsciL("%aei%") = 8) BEGIN
   WRITE_ASCIIE $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_r($ae_entry("%aei%")"%el2%") (8)
  END
  PATCH_IF ($ae_SoWrt("%aei%") = 8) AND ($ae_AsciL("%aei%") = 32) BEGIN
   WRITE_ASCIIE $wipt_Off($ae_entry("%aei%")"%el2%") $wipt_w($ae_entry("%aei%")"%el2%") (32)
  END
 END //end variable is set
END
  END
 END
END
END//end function define
//Used code from miloch to create the function...
DEFINE_PATCH_FUNCTION ~wipt_new_eqfx~ BEGIN
LAUNCH_PATCH_MACRO ~wipt_item_reader~
SET wipt_insert_loc = (%wipt_fx_off% + (%wipt_fx_size% * %wipt_eqfx_num%))
INSERT_BYTES %wipt_insert_loc% %wipt_fx_size%
SET wipt_fx_location=%wipt_insert_loc%
DEFINE_ARRAY e_entry BEGIN opco targ powr par1 par2 tmod resi dura pro1 pro2 reso diet dies savt savb END
DEFINE_ARRAY e_offst BEGIN 0x0  0x2  0x3  0x4  0x8  0xc  0xd  0xe  0x12 0x13 0x14 0x1c 0x20 0x24 0x28 END
DEFINE_ARRAY e_SoWrt BEGIN 2	1	1	4	4	1	1	4	1	1	8	4	4	4	4	END
DEFINE_ARRAY e_AsciL BEGIN 0	0	0	0	0	0	0	0	0	0	8	0	0	0	0	END
DEFINE_ARRAY e_Bit   BEGIN 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	END
FOR(ei=0;ei<15;ei+=1)BEGIN
 SET $wipt_Off($e_entry("%ei%")) = %wipt_fx_location% + $e_offst("%ei%") //set offset for entry
 SET $wipt_SoW($e_entry("%ei%")) = $e_SoWrt("%ei%") //set size of write for entry
 SET $wipt_AcL($e_entry("%ei%")) = $e_AsciL("%ei%") //set ascii length 0 = non-ascii; 8 = file name ascii; 32 = name & variable ascii
 SET $wipt_Bit($e_entry("%ei%")) = $e_Bit("%ei%")   //set whether entry should be written in bit format
 PATCH_IF (VARIABLE_IS_SET $wipt_n($e_entry("%ei%")) ) BEGIN
  PATCH_IF ($e_SoWrt("%ei%") = 1) BEGIN
WRITE_BYTE $wipt_Off($e_entry("%ei%")) $wipt_n($e_entry("%ei%"))
  END
  PATCH_IF ($e_SoWrt("%ei%") = 2) BEGIN
WRITE_SHORT $wipt_Off($e_entry("%ei%")) $wipt_n($e_entry("%ei%"))
  END
  PATCH_IF ($e_SoWrt("%ei%") = 4) BEGIN
WRITE_LONG $wipt_Off($e_entry("%ei%")) $wipt_n($e_entry("%ei%"))
  END
  PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 8) BEGIN
WRITE_ASCIIE $wipt_Off($e_entry("%ei%")) $wipt_n($e_entry("%ei%")) (8)
  END
  PATCH_IF ($e_SoWrt("%ei%") = 8) AND ($e_AsciL("%ei%") = 32) BEGIN
WRITE_ASCIIE $wipt_Off($e_entry("%ei%")) $wipt_n($e_entry("%ei%")) (32)
  END
 END //end variable is set
END //end array loop
WRITE_SHORT %wipt_Off_eqfx_num% (%wipt_eqfx_num% + 1)
FOR (i1 = 0; i1 < %wipt_abil_num%; i1 += 1) BEGIN //Update 1st effect indices
 PATCH_IF ($wipt_abilfx_idx("%i1%") > %wipt_eqfx_idx%) BEGIN //If ability after eq effects
  WRITE_SHORT $wipt_Off_abilfx_idx("%i1%") ($wipt_abilfx_idx("%i1%") + 1) //Increase 1st effect index by 1
 END
END
END //end function define

there is support also in the functions for adding in new equipping effects. hopefully you can understand how to do it. else provide an example and I'll work one out for you.

 

information which will help to understand how to use the function:

 

//define variables so that people know what they are:

 

//define header entries

/* pattern: variable = description

un = unidentified name

in = identified name

ri = replacement item

fl1 = flag bit 1

fl2 = flag bit 2

fl3 = flag bit 3

fl4 = flag bit 4

it = item type

u1 = usability bit 1

u2 = usability bit 2

u3 = usability bit 3

u4 = usability bit 4

ia = item animation

ml = minimum level

ms = minimum strength

msb = minimum strength bonus

k1 = kit bit 1

mi = minimum intelligence

k2 = kit bit 2

md = minimum dexterity

k3 = kit bit 3

mw = minimum wisdom

k4 = kit bit 4

mc = minimum constitution

wp = weapon proficiency

mch = minimum charisma

pr = price

st = stack

ii = inventory icon

lo = lore to id

gi = ground icon

we = weight

ud = unidentified description

id = identifed description

di = description icon

en = enchantment

*/

 

//define ability entries

/* pattern: variable = description

attack = attack type

id_req = id required to use

useloc = use location

useico = use icon

target = target type

tarnum = target number

range = range

projec = projectile type

speed = speed

thac0b = thac0 bonus

dsides = dice sides

dthrow = dice thrown

damagb = damage bonus

damagt = damage type

charge = charges

chardp = charge depletion

flagb1 = flag bit 1

flagb2 = flag bit 2

proani = projectile animation

ohand = overhand

bhand = backhand

thrust = thrust

arrow = is arrow?

bolt = is bolt?

other = is other type of missile?

*/

 

//define effect entries

/* pattern: variable = description

opco = opcode

targ = target

powr = power

par1 = parameter 1

par2 = parameter 2

tmod = timing mode

resi = resistance

dura = duration

pro1 = probability 1

pro2 = probability 2

reso = resource

diet = dice thrown

dies = dice sides

savt = saving throw

savb = saving bonus

*/

 

/* Variable patterns and other useful variables available by having used the macro

NOTE: In the following var refers to one of the listed variables above AND index refers to the index # of the given ability or effect

For header

wipt_Off_var = the offset that that var was read from and can have a new value written to

wipt_SoW_var = the size of write for that var entry (byte, short, long, ascii)

wipt_AcL_var = the ascii length for that var 0=non-ascii;8=file name ascii;32=object name & script variable ascii

wipt_Bit_var = used to determine if the var can or should utilze the bitwise operators

For read values from the header

wipt_r_var = the value that was read from the offset of the given var

 

For effects (equipping and ability)

wipt_Off_var_index = the offset that that var was read from and can have a new value written to

wipt_SoW_var_index = the size of write for that var entry (byte, short, long, ascii)

wipt_AcL_var_index = the ascii length for that var 0=non-ascii;8=file name ascii;32=object name & script variable ascii

wipt_Bit_var_index = used to determine if the var can or should utilze the bitwise operators

wipt_total_fx = total number of effects both equipping and ability

wipt_eqfx_idx = starting index number for equipping effects

wipt_eqfx_num = number of equipping effects

wipt_fx_off = offset of start of effects

wipt_abilfx_idx_index = starting index number for effects of the given ability index

wipt_abilfx_num_index = number of effects for the given ability index

wipt_fx_size = total size in bytes for one complete effect entry

For read values from the effects

wipt_r_var_index = the value that was read from the offset of the given var in the given effect index

 

For ability headers

wipt_Off_var_index = the offset that that var was read from and can have a new value written to

wipt_SoW_var_index = the size of write for that var entry (byte, short, long, ascii)

wipt_AcL_var_index = the ascii length for that var 0=non-ascii;8=file name ascii;32=object name & script variable ascii

wipt_Bit_var_index = used to determine if the var can or should utilze the bitwise operators

wipt_abil_off = offset of start of ability headers

wipt_abil_num = number of ability headers

wipt_abil_size = total size in bytes for one complete ability entry

For read values from the ability headers

wipt_r_var_index = the value that was read from the offset of the given var in the given ability index

 

When using the patch function ~wipt_item_writer~ you assign your values to any variable listed above for the patch macro ~wipt_item_reader~

Follow these patterns:

wipt_w_var = values to be written to header entries

wipt_w_var_index = values to be written to the ability or effect entries

 

When using the patch function ~wipt_new_eqfx~ you assign your new values in the following manner:

wipt_n_var = new values to be written to the new equipping effect entry

*/

////////////////////////////////////////////////////////

 

 

Link to comment

Thanks, plainab, that's what I was looking for. But that's a lot to digest! Generic .tp2 code, followed by the codes called macro, followed by the definitions you used, adds up to a nice puzzle.

 

Luckily I have the next two weeks off (unluckily it's without pay). I'll see what I can do.

 

One question right now, do I run this for all six BG1 magic shields or can I get all six in one pass?

Link to comment

if your changes are identical you can do one pass for sure

 

if your changes are different, you could fudge a single pass by having additional patch statements which look for the specific file name before doing the actual work.

 

else do the easy route and do all six individually LOL

 

EDIT: it's not that hard to figure out the function once you get into it. I've a lot of things in the fixpack which modify items and decided rather than writing similar code and having copy/paste errors that I'd make a function to read the entire file and then to write to it as necessary.

Link to comment

if your changes are identical you can do one pass for sure

...

else do the easy route and do all six individually LOL

Considering the mods out there, though few, in the end it will need to cover any and all magic shields. With that in mind, I've looked over the Tweaks components for some possible help.

 

 

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for magic shields
 READ_SHORT 0x18 "flag"   ELSE 0
 READ_SHORT 0x1C "type"   ELSE 0
//  READ_LONG  0x6a "fx_off" ELSE 0
 PATCH_IF (
		 ("%type%" = 12) AND // shield
		   (
   	  ("%flag%" =  6)	// magic
		 )
	   ) BEGIN
 INCLUDE ~magicshields/lib/shields.tpa~
 LAUNCH_PATCH_MACRO ~wipt_item_reader~

 

I'll be testing what you've posted above with this change. Will I need the READ_LONG line I've commented out>

Link to comment

O.o confusing...

 

1. wipt_item_reader reads ALL offsets of the item file (at least the known ones) you call that first and foremost then check for necessary values of the variables you want before doing any work.

 

2. while i understand that you want it to cover as many magic shields as possible, the changes will probably be different i.e. you are going from a set color to a glowing magic type of color BUT you won't want to do the same color for all of them. hence you'll need to do each differently. most mods that supply a magic shield either come preset with colors schemes they want OR copy an existing one. in which case if this tweak is before, the changes are transferred. if this tweak after, then you'll need to either not support it, specifically support it, or blindly support but give it the same color/glowing scheme as another shield.... different bland colored magic shields are better than same fancy colored magic shields...

 

3. i don't know what your shields.tpa file is doing. it too may be out of place or redundant

 

here is how i'd do it for an unknown list of magic shields:

 

INCLUDE ~magicshields/lib/wipt.tph~ //call up the macro/function stuff so it can be used
COPY_EXISTING ~^.+\.itm$~ ~override~
LAUNCH_PATCH_MACRO ~wipt_item_reader~
PATCH_IF (%wipt_r_it% = 12) /*shields*/ AND ( %wipt_r_fl1% BAND 0b01000000 = 0b01000000) /*magic bit set*/ BEGIN
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
  PATCH_IF ($wipt_r_opco("%idx%") = 7) AND ($wipt_r_par2("%idx%") = 34) BEGIN
LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 $wipt_w_par1("%idx%") = 1966552832 $wipt_w_par2("%idx%") = 2621474 END
  END
 END
END
BUT_ONLY

but this would give EVERY magic shield the same color/glow for the same part and only if that part was pre-colored. you could try a randomizing scheme of some kind for the colors, but I wouldn't know how you'd combine the values together to get the specific entry to write in the format that the function can take.

 

hmm... well i suppose you could after getting the values actually do your own write. the 4 byte field gets broken down into 4 individual byte fields for this specific effect

 

this might then cause different colors tho some possibly crappy combos:

 

INCLUDE ~magicshields/lib/wipt.tph~ //call up the macro/function stuff so it can be used
COPY_EXISTING ~^.+\.itm$~ ~override~
LAUNCH_PATCH_MACRO ~wipt_item_reader~
PATCH_IF (%wipt_r_it% = 12) /*shields*/ AND ( %wipt_r_fl1% BAND 0b01000000 = 0b01000000) /*magic bit set*/ BEGIN
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
  PATCH_IF ($wipt_r_opco("%idx%") = 7) AND ($wipt_r_par2("%idx%") = 34) BEGIN
LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR END
//parameter 1 is split into 4 bytes for opcode 9
WRITE_BYTE ($wipt_Off_par1("%idx%") + 0) 0 //first byte is always 0
WRITE_BYTE ($wipt_Off_par1("%idx%") + 1) RANDOM (0 255) //random red
WRITE_BYTE ($wipt_Off_par1("%idx%") + 2) RANDOM (0 255) //random green
WRITE_BYTE ($wipt_Off_par1("%idx%") + 3) RANDOM (0 255) //random blue
//parameter 2 is split into 2 short words
WRITE_SHORT ($wipt_Off_par2("%idx%") + 0) 34 //location to be colored
WRITE_SHORT ($wipt_Off_par2("%idx%") + 2) RANDOM (0 255) //random speed
  END
 END
END
BUT_ONLY

 

Link to comment

1. wipt_item_reader reads ALL offsets of the item file (at least the known ones) you call that first and foremost then check for necessary values of the variables you want before doing any work.

So I've noticed from studying it. I hope you'll give me a little latitude, though, since I've little coding experience and have only used or modified that created by others. The one question I had earlier you answer below.

 

2. while i understand that you want it to cover as many magic shields as possible, the changes will probably be different i.e. you are going from a set color to a glowing magic type of color BUT you won't want to do the same color for all of them. hence you'll need to do each differently. most mods that supply a magic shield either come preset with colors schemes they want OR copy an existing one. in which case if this tweak is before, the changes are transferred. if this tweak after, then you'll need to either not support it, specifically support it, or blindly support but give it the same color/glowing scheme as another shield.... different bland colored magic shields are better than same fancy colored magic shields...

I'm always presuming BG1 Tweaks will go last, after all item adding mods. To avoid mod items either the search must be restricted to SHLD01.itm to SHLD19.itm (all would have the same color) or each shield must be called and handled separately. I'd have to install and check the magic shields of the other mods and see if they use any color cycle effect.

 

As for the colors, I've been experimenting using DLTCEP (thanks for mentioning it). I'm not sure what you mean by "bland" and "fancy", but I find a muted color cycle better than a brilliant one (i.e. green 0/150/0 or orange 150/50/0 over red 255/0/0 or yellow 255/255/0).

 

3. i don't know what your shields.tpa file is doing. it too may be out of place or redundant

 

here is how i'd do it for an unknown list of magic shields:

...but this would give EVERY magic shield the same color/glow for the same part and only if that part was pre-colored. you could try a randomizing scheme of some kind for the colors, but I wouldn't know how you'd combine the values together to get the specific entry to write in the format that the function can take.

 

hmm... well i suppose you could after getting the values actually do your own write. the 4 byte field gets broken down into 4 individual byte fields for this specific effect

 

this might then cause different colors tho some possibly crappy combos...

The shields.tpa is the file containing the macros. I may have improperly named it, since you name it wipt.tph. I'll follow your lead on this and rename it.

 

For now let's focus on vanilla BG1 shields only. My intent is to make the shield panel cycle. You say "only if that part was pre-colored." Only three give the panel a color. What of the other three? That would require adding an effect to them. Does the wipt_item_reader add it if it is absent?

 

Edit: The mass check/change method failed to work, though it ran. I got it to work by calling each shield individually, but found the three without an effect existing for the shield panel were not changed. wipt.tph doesn't add effects if missing. I also found that a negative number from DLTCEP caused WeiDU to read an error.

 

How do I add an effect to the three shields without a shield panel color?

Link to comment

I've done some looking across the sites and fora, and have found only one tutorial on item editing - Cam's. Unfortunately he gave no example that adds an ability or effect to an existing item, though he states in the tutorial it can be done. I'll play around with it and see what I can do, but I'd like something already done to work from. If anyone knows a mod that does it, or tutorial that actually explains how to do it, please let me know.

Link to comment

the macro/functions can do it. there is a third one defined in the file for just such a purpose. It is designed to add ONE and only ONE effect at a time.

 

correct the copy line as necessary, this is just to show how to use it:

COPY_EXISTING ~somefile.itm~ ~override~
//note wipt_new_eqfx function calls the wipt_item_reader as part of it so is unnecessary to do so
LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR wipt_n_opco = 9 wipt_n_par1 = 1966552832 wipt_n_par2 = 2621474 END
BUT_ONLY

this will add a new effect with the values that you are changing on the other effects. you'll need to add in entries for all the other values since this is a completely new effect. this here tho should give you a start in understanding how the WIPT tool works

 

btw wipt = Weidu Item Patching Tool

 

 

 

***********************************

EDIT: i should also mention that weidu does have some built in macro/functions to do similar. whether they work or not, idk

ADD_ITEM_EFFECT: adds an extended effect to an item. This is a PATCH macro and function. Syntax is the same as of ADD_SPELL_EFFECT Additionally: SET type to the type of header to which the effect should be added or 99 for all types. Defaults to 3 (magic).

ADD_ITEM_EQEFFECT: adds an equipping effect to an item. This is a PATCH macro and function. Syntax is the same as of ADD_SPELL_EFFECT

I couldn't get them to work myself and so incorporated the ability into the tool
Link to comment

FYI in the post a few up where I have code following this text

this might then cause different colors tho some possibly crappy combos:
I missed something in the editing which would cause a possible issue. it would make changes but not show properly in game..... left off the opcode change by accident. so the line
LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR END

should actually be

LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 END

 

 

 

 

*******************

guess there is a window of opportunity allowed for editing posts

Link to comment

the macro/functions can do it. there is a third one defined in the file for just such a purpose. It is designed to add ONE and only ONE effect at a time.

...

this will add a new effect with the values that you are changing on the other effects. you'll need to add in entries for all the other values since this is a completely new effect. this here tho should give you a start in understanding how the WIPT tool works

Thanks again. Just did some work with it. Your line:

LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR wipt_n_opco = 9 wipt_n_par1 = 1966552832 wipt_n_par2 = 2621474

didn't work. I had to make it consistent with the ~wipt_item_writer~ call:

LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR $wipt_n_opco("%idx%") = 9 $wipt_n_par1("%idx%") = 9830400 $wipt_n_par2("%idx%") = 2621474 END

It added a new effect, but did nothing to set it up - all attributes are set to zero. I've some ideas I'll try to set the new effect.

 

btw wipt = Weidu Item Patching Tool

Nice to know. I like to know proper naming (personal thing).

 

EDIT: i should also mention that weidu does have some built in macro/functions to do similar. whether they work or not, idk

ADD_ITEM_EFFECT: adds an extended effect to an item. This is a PATCH macro and function. Syntax is the same as of ADD_SPELL_EFFECT Additionally: SET type to the type of header to which the effect should be added or 99 for all types. Defaults to 3 (magic).

ADD_ITEM_EQEFFECT: adds an equipping effect to an item. This is a PATCH macro and function. Syntax is the same as of ADD_SPELL_EFFECT

I couldn't get them to work myself and so incorporated the ability into the tool

Unfortunately the WeiDU readme doesn't include them in section 8. Module Packaging: TP2 Files. Or anywhere else in it I can see. I'd like to see theBigg at least include the basics on these in the section 8 table. There may be something in a tutorial somewhere, so I'll look around for it.

 

*****************

 

It's working completely now! Here's part of the tp2, one example for each problem dealt with.

 

 

BEGIN ~Glowing Magic Shields~
INCLUDE ~magicshields/lib/wipt.tph~
COPY_EXISTING ~shld02.itm~ ~override~
 LAUNCH_PATCH_MACRO ~wipt_item_reader~
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
   PATCH_IF ($wipt_r_opco("%idx%") = 7) AND ($wipt_r_par2("%idx%") = 34) BEGIN
  LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 $wipt_w_par1("%idx%") = 38400 $wipt_w_par2("%idx%") = 2621474 END
   END
 END
 BUT_ONLY

COPY_EXISTING ~shld04.itm~ ~override~ // need to add effect, then change to shield panel color cycle
 LAUNCH_PATCH_MACRO ~wipt_item_reader~
   LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR $wipt_n_opco("%idx%") = 9 $wipt_n_par1("%idx%") = 9830400 $wipt_n_par2("%idx%") = 2621474 END
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
   PATCH_IF ($wipt_r_opco("%idx%") = 0) AND ($wipt_r_par2("%idx%") = 0) BEGIN
  LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 $wipt_w_par1("%idx%") = 9830400 $wipt_w_par2("%idx%") = 2621474 END
   END
 END
 BUT_ONLY

 

Thanks, plainab. You've been a great help.

Link to comment
didn't work. I had to make it consistent with the ~wipt_item_writer~ call:
been a while since i used it and couldn't remember if it needed the same structure or not.

 

glad you got it working tho.

 

 

Unfortunately the WeiDU readme doesn't include them in section 8. Module Packaging: TP2 Files. Or anywhere else in it I can see.
what i quoted was from the readme. it's all the way near the bottom down in the tutorials stuff. what i do is open the readme in a web browser and use ctrl+f and then search for a term and cycle thru all the instances till I get to one that talks about what i want to do.

 

 

EDIT: wait what? you got it working like that? here is something that works and installed properly from the BG fixpack

// ----------------------------------------------------------------------------
//~Add 'Display Special Effects Icon #142' to equipping effects for ring23~
// ----------------------------------------------------------------------------
COPY_EXISTING ~ring23.itm~ ~override~
LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~ INT_VAR wipt_n_opco = 142 wipt_n_targ = 1 wipt_n_tmod = 2 wipt_n_par2 = 35 wipt_n_pro1 = 100 END
BUT_ONLY

as you can see I did not have to use the array structure. Not sure why you needed to... *grabs your code and tests*

Link to comment

COPY_EXISTING ~shld04.itm~ ~override~ // need to add effect, then change to shield panel color cycle
 LAUNCH_PATCH_MACRO ~wipt_item_reader~
LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR $wipt_n_opco("%idx%") = 9 $wipt_n_par1("%idx%") = 9830400 $wipt_n_par2("%idx%") = 2621474 END
 FOR (idx=0;idx<%wipt_eqfx_num%;idx+=1) BEGIN
PATCH_IF ($wipt_r_opco("%idx%") = 0) AND ($wipt_r_par2("%idx%") = 0) BEGIN
	  LAUNCH_PATCH_FUNCTION ~wipt_item_writer~ INT_VAR $wipt_w_opco("%idx%") = 9 $wipt_w_par1("%idx%") = 9830400 $wipt_w_par2("%idx%") = 2621474 END
END
 END
 BUT_ONLY

this one fails big time. when ran just as above it adds a new effect at the bottom of the list with all 0's and it replaces the AC modifier opcode at the top of the list with the necessary data.

 

I've corrected and tested. this works. installs on saga, creates a new effect complete with proper data.

COPY_EXISTING ~shld04.itm~ ~override~ // need to add effect, then change to shield panel color cycle
LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR wipt_n_opco = 9 wipt_n_par1 = 9830400 wipt_n_par2 = 2621474 END
 BUT_ONLY

not sure why it didn't work for you

 

 

EDIT: just on a side note. you may want to check the timing of the effect itself. if that value is left at 0 and then the duration field is left at 0 it won't do anything in game. you need to set timing to 2 which = while equipped so you need to add wipt_n_tmod = 2

Link to comment

...this one fails big time. when ran just as above it adds a new effect at the bottom of the list with all 0's and it replaces the AC modifier opcode at the top of the list with the necessary data.

It actually places one at the bottom (all zeros) and one at the top with the proper data. In other words, I've two new effect slots.

 

I've corrected and tested. this works. installs on saga, creates a new effect complete with proper data.

COPY_EXISTING ~shld04.itm~ ~override~ // need to add effect, then change to shield panel color cycle
LAUNCH_PATCH_FUNCTION ~wipt_new_eqfx~  INT_VAR wipt_n_opco = 9 wipt_n_par1 = 9830400 wipt_n_par2 = 2621474 END
 BUT_ONLY

not sure why it didn't work for you

I even checked it in-game. The color cycling is there. Considering the above, I'll check it out.

 

EDIT: just on a side note. you may want to check the timing of the effect itself. if that value is left at 0 and then the duration field is left at 0 it won't do anything in game. you need to set timing to 2 which = while equipped so you need to add wipt_n_tmod = 2

After several installs and uninstalls, it sets the effect to Instant/While equipped. I'll try it on an install without TotSC just to make sure.

 

********************************************

 

Your new code helps (only one new effect is added), but comes up short. Timing mode, target and probability 1 are all zero. I added wipt_n_targ, wipt_n_tmod and wipt_n_pro1 calls and values. Checked in game, it now works fully, and with less code.

Link to comment

Archived

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

×
×
  • Create New...