Jump to content

FS animation: patching items to colorglow solid


Kulyok

Recommended Posts

So, Erephine has done a superb job and created a great FS ("flaming sword") animation.

 

Which I am happily going to (ab)use in the next Xan version(and hopefully, others may benefit, too).

 

However, for this animation to work correctly, an item should have colorglow solid effect in place. I guess just like SW1H13.itm(Moonblade) and SW1H11.itm have, these three lines.

 

Several other blades in the unmodded game(I do not want to touch mod items; dixi) do not have this effect, and I need assign it to them. Namely to

SW1H61.itm

SW1H60.itm

SW1H53.itm

(and SW1H98, but that's just silly)

(And maybe more - I couldn't do a search, since I couldn't find a tutorial on how to search in DLTCEP :( )

 

To patch them, what code should I use - how should I go about it? I admit, PATCH_BYTE is not my strongest side, and I am rather afraid to blow up someone's install as a result.

Link to comment

Serching for all items that use a specific opcode in DLTCEP is easy.

Start DLTCEP.

Click the 'Items' button on the search panel.

Select the opcode button.

Enter the opcode you want to search for (if you are only searching for a single opcode, set both boxes to the same value).

Select Search.

 

 

As for patching an equipping effect into an item, something similar to this should do it (this (probably) adds two equipping effects):

// poison immunity for 'dead' trolls

COPY_EXISTING ~trolldie.itm~ ~override~

READ_LONG 0x64 "abil_off"

READ_SHORT 0x68 "abil_num"

READ_LONG 0x6a "fx_off"

READ_SHORT 0x70 "fx_num"

SET "new_fx" = 2

FOR (index = 0 ; index < abil_num ; index = index + 1) BEGIN

READ_SHORT (0x20 + "%abil_off%" + ("%index%" * 0x38)) "abil_fx_idx"

WRITE_SHORT (0x20 + "%abil_off%" + ("%index%" * 0x38)) ("%abil_fx_idx%" + "%new_fx%")

END

WRITE_SHORT 0x70 ("%fx_num%" + "%new_fx%")

INSERT_BYTES ("%fx_off%" + ("%fx_num%" * 0x30)) 0x30

WRITE_SHORT ("%fx_off%" + ("%fx_num%" * 0x30)) 101 // immunity to effect

WRITE_BYTE ("%fx_off%" + 0x02 + ("%fx_num%" * 0x30)) 1 // target self

WRITE_LONG ("%fx_off%" + 0x08 + ("%fx_num%" * 0x30)) 25 // poison

WRITE_BYTE ("%fx_off%" + 0x0c + ("%fx_num%" * 0x30)) 2 // instant/while equipped

WRITE_BYTE ("%fx_off%" + 0x12 + ("%fx_num%" * 0x30)) 100 // probability 1

INSERT_BYTES ("%fx_off%" + ("%fx_num%" * 0x30)) 0x30

WRITE_SHORT ("%fx_off%" + ("%fx_num%" * 0x30)) 173 // reduced damage from poison

WRITE_BYTE ("%fx_off%" + 0x02 + ("%fx_num%" * 0x30)) 1 // target self

WRITE_LONG ("%fx_off%" + 0x04 + ("%fx_num%" * 0x30)) 100 // damage

WRITE_BYTE ("%fx_off%" + 0x0c + ("%fx_num%" * 0x30)) 2 // instant/while equipped

WRITE_BYTE ("%fx_off%" + 0x12 + ("%fx_num%" * 0x30)) 100 // probability 1

BUT_ONLY_IF_IT_CHANGES

 

 

Note, like most tp2 code, the code is stolen from the fixpack (and hence from Cam).

:(

 

 

EDIT: The forum has removed the nice indentation :/ Also, you'd probably want to check for an existing colouring effect and patch that instead if it exists. Coding this is left as an exercise to the reader.

Link to comment

First, thank you.

 

I understand that I can look for items that have a specific opcode - specific effect, but what if it is a specific value of an already existing paperdoll animation ID (FS-Flame Sword, in my case)? Would it be possible to do such a search for me, whether in DLTCEP or NI?

 

I smell a WHILE cycle loop here... :( But indeed - Fixpack code seems like the best place to start.

Link to comment

Ash, sorry, I misunderstood. You can't perform that search in DLTCEP, nor NI, that I know of.

 

However, WeiDU can throw out a list for you. Something similar to this should do it:

 

COPY_EXISTING_REGEXP ~.*\.itm~ ~override~
 PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files
READ_ASCII 0xx0022 "animation" (2)
PATCH_IF ("FS" STRING_COMPARE_CASE "%animation%" = 0) BEGIN
  PATCH_PRINT %SOURCE_RES%
END
 END
 BUT_ONLY_IF_IT_CHANGES

 

 

But indeed - Fixpack code seems like the best place to start.

 

Fixpack is almost always the best place to start. It also has a handy second purpose of actually being a mod, as well as a place to steal code from :(

Link to comment

In NI you can just select the equipped appearance line, click find, and search "selected attribute" FS. But if you want a search in two arguments (i.e. is a flameblade animation and doesn't have a colorglow effect) you'd want a WeiDU proglet.

 

I don't think sblade, sw1h11, and sw1h98 are ever used in BG2. blakblad, bonedag, morsword, rodsword, sw1h60, and sw1h61 probably ought to be changed to use the longsword animation if you're going to change the FS animation. Which leaves fblade, miscb3, sw1h24, and sw1h13 (if that's what you're using for Xan :( )

Link to comment

"sw1h13" has an "unremovable" flag for some reason, so I am using O#XanMB.itm - in case someone overwrites or whatnot.

 

Okay, thank you - I think the first steps are clear.

 

(If I have more questions, I will of course pop here again - but you already knew that, didn't you.)

Link to comment

I've used the search function and got the whole list of items to fix - at last. :(

 

 

I've been reading and trying to understand Fixpack's code, and I've just realized this thing:

 

FS animation functions correctly only when the item has colorglow_solid effect. This is true for every BG2 item.

 

But then applying colorglow_solid on all items with FS animation would be a fix, right? Then maybe, probably, it belongs to the Fixpack, after all?

 

(If I am mistaken, tell me so. But for the moment, it does sound logical - though there's still a matter of a few TUTU swords).

Link to comment
FS animation functions correctly only when the item has colorglow_solid effect. This is true for every BG2 item.

 

How so? Color Glow Solid doesn't work on the paperdoll .bam, and the animated avatar FS .bam in BG2 is exactly the same as the longsword animation?

 

I don't follow :(

Link to comment

See this thread:

http://forums.spellholdstudios.net/index.p...27210&st=20

 

If you want to fully enjoy it, SOME of the flame sword .ITM files will have to be tweaked, since they have no constant lighting (COLOR GLOW PULSE, without a solid glow) and this will look odd as the flame turns 'dark' in between the flashes at night.

 

(I mean, I hope Erephine knows it.)

Link to comment

My main concern is that they weigh about a megabyte and a half, but, yes, it might just work.

 

If not, the players will have to be content with my inexpert fumbling, which, um, may lead to trouble.

Link to comment

I'm sure you can handle it.

 

If you'd rather not, I can cobble together something. Obviously the colors would have to be filled in :(

ACTION_IF !(FILE_MD5 ~override/wqlfsa1.bam~ bd2384cb6d70f12c7a64ba0679425b96) THEN BEGIN

 COPY ~filepath/erephines_flamesword~ ~override~

 ACTION_FOR_EACH ~item~ IN ~blakblad~ ~bonedag~ ~morsword~ ~rodsword~ BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%item%.itm~) THEN BEGIN
  COPY_EXISTING ~%item%.itm~ ~override~
	PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN
	  WRITE_ASCII 0x22 ~S1~
	END
  BUT_ONLY
END
 END

 ACTION_FOR_EACH ~item~ IN ~fblade~ ~miscb3~ ~sw1h24~ ~sw1h60~ ~sw1h61~ BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%item%.itm~) THEN BEGIN
  COPY_EXISTING ~%item%.itm~ ~override~
	PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN
	  READ_LONG  0x64 "ho"
	  READ_SHORT 0x68 "hc"
	  READ_LONG  0x6a "eo"
	  READ_SHORT 0x70 "ge"
	  SET "blade" = (~%SOURCE_RES%~ STRING_EQUAL ~fblade~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~miscb3~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h24~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h60~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h61~ ? 0x00000000 : 0x00)
	  SET "grip"  = (~%SOURCE_RES%~ STRING_EQUAL ~fblade~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~miscb3~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h24~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h60~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h61~ ? 0x00000000 : 0x00)
	  SET "minor" = (~%SOURCE_RES%~ STRING_EQUAL ~fblade~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~miscb3~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h24~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h60~ ? 0x00000000 :
					 ~%SOURCE_RES%~ STRING_EQUAL ~sw1h61~ ? 0x00000000 : 0x00)
	  FOR ("i1" = 0x00; "i1" < ("ge" * 0x30); "i1" += 0x30) BEGIN
		READ_SHORT  ("eo" + "i1" + 0x00) "op"
		PATCH_IF (("op" = 0x08) OR ("op" = 0x09)) THEN BEGIN
		  READ_LONG ("eo" + "i1" + 0x08) "lc"
		  PATCH_IF		  ("lc" = 0x10) THEN BEGIN
			WRITE_LONG ("eo" + "i1" + 0x04) "blade"
			SET "blade" = 0x00
		  END ELSE PATCH_IF ("lc" = 0x14) THEN BEGIN
			WRITE_LONG ("eo" + "i1" + 0x04) "grip"
			SET "grip"  = 0x00
		  END ELSE PATCH_IF ("lc" = 0x15) THEN BEGIN
			WRITE_LONG ("eo" + "i1" + 0x04) "minor"
			SET "minor" = 0x00
		  END
		END
	  END
	  PATCH_IF ("blade" != 0x00) THEN BEGIN
		INSERT_BYTES ("eo" + (0x30 * "ge") + 0x00) 0x30
		WRITE_SHORT  ("eo" + (0x30 * "ge") + 0x00) 0x08
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x02) 0x01
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x04) "blade"
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x08) 0x10
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x0c) 0x02
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x12) 0x64
		SET "ge" += 0x01
	  END
	  PATCH_IF ("grip" != 0x00) THEN BEGIN
		INSERT_BYTES ("eo" + (0x30 * "ge") + 0x00) 0x30
		WRITE_SHORT  ("eo" + (0x30 * "ge") + 0x00) 0x08
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x02) 0x01
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x04) "grip"
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x08) 0x14
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x0c) 0x02
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x12) 0x64
		SET "ge" += 0x01
	  END
	  PATCH_IF ("minor" != 0x00) THEN BEGIN
		INSERT_BYTES ("eo" + (0x30 * "ge") + 0x00) 0x30
		WRITE_SHORT  ("eo" + (0x30 * "ge") + 0x00) 0x08
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x02) 0x01
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x04) "minor"
		WRITE_LONG   ("eo" + (0x30 * "ge") + 0x08) 0x15
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x0c) 0x02
		WRITE_BYTE   ("eo" + (0x30 * "ge") + 0x12) 0x64
		SET "ge" += 0x01
	  END
	  PATCH_IF (("blade" != 0x00) OR ("grip" != 0x00) OR ("minor" != 0x00)) THEN BEGIN
		WRITE_SHORT 0x70 "ge"
		FOR ("i1" = 0x00; "i1" < (0x38 * "hc"); "i1" += 0x38) BEGIN
		  WRITE_SHORT ("ho" + "i1" + 0x20) "ge"
		  READ_SHORT  ("ho" + "i1" + 0x1e) "ec"
		  SET "ge" += "ec"
		END
	  END
	END
  BUT_ONLY
END
 END

END

Link to comment

... You went and did the job for me. It feels like a birthday present.

 

"Thank you" is a huge understatement. I'll go look at the colors - but what does the first line, with FILE_MD5, mean? It looks scary...

Link to comment

Archived

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

×
×
  • Create New...