Jump to content

WeiDU question


Galactygon

Recommended Posts

Or just use an array instead of a 2da, as mentioned on PPG. You are already sort of doing that it seems with SPRINT, but ACTION_DEFINE_ASSOCIATIVE_ARRAY would no doubt be quicker than looping through a 2da.

Link to comment

Right now, I am having trouble with STRING_MATCHES_REGEXP. Basically,

"%projectl_tablecount_itm_pro_spl% is an item waiting to be patched."

is being printed every time it reads another row, even if the filename in the first column is an .itm or .pro rather than a .spl.

 

DEFINE_PATCH_MACRO ~GIVE_PROJECTILE_VALUES_FROM_TABLE~ BEGIN
PATCH_IF (SOURCE_SIZE > 0) BEGIN
	COUNT_2DA_ROWS 3 "projectl_tablecount"
END
FOR ( x=0; x < projectl_tablecount; x+=1 ) BEGIN
	READ_2DA_ENTRY x 0 3 projectl_tablecount_itm_pro_spl
	READ_2DA_ENTRY x 1 3 projectl_tablecount_new_projectl
	READ_2DA_ENTRY x 2 3 projectl_tablecount_what_to_patch
	PATCH_IF ( FILE_EXISTS_IN_GAME "%projectl_tablecount_itm_pro_spl%" ) BEGIN
		PATCH_IF ("%SOURCE_FILE%" STRING_MATCHES_REGEXP "^.+\.itm") BEGIN
			PATCH_PRINT "%projectl_tablecount_itm_pro_spl% is an item waiting to be patched."
		END ELSE
		PATCH_IF ("%SOURCE_FILE%" STRING_MATCHES_REGEXP "^.+\.pro") BEGIN
			PATCH_PRINT "%projectl_tablecount_itm_pro_spl% is a projectile waiting to be patched."
		END ELSE
		PATCH_IF ("%SOURCE_FILE%" STRING_MATCHES_REGEXP "^.+\.spl") BEGIN
			PATCH_PRINT "%projectl_tablecount_itm_pro_spl% is a spell waiting to be patched."
		END
	END
END
END

 

-Galactygon

Link to comment
If say I have some veriable set to some string, and I would like to get rid of the file extension, how would I go about truncating it by 4 characters?

 

You probably want SNPRINT.

 

As SPRINT, but only the first N characters are stored in the variable, where N is the result of evaluating the value. This works somewhat like snprintf(). Thus:

SPRINT "author" "Jason"

SNPRINT 3 "myvar" "1:%author%"

 

... assigns 1:J to myvar.

Link to comment

Thanks Taimon, that works.

 

I have been tinkering with MAKE_BIFF, and unfortunately, I haven't found any samples of code from people like Nythrun. So I have to work off of the readme, and having trouble getting this to work.

MAKE_BIFF LC_Sound BEGIN
~override/LCA_M.*.wav~
~override/LCA_P.*.wav~
~override/LCE_M.*.wav~
~override/LCE_P.*.wav~
END

 

-Galactygon

Link to comment

It works well. Do I have to mention ~override~ each time I list a regexp?

MAKE_BIFF LC_Sound BEGIN
~override~ ~AFT_.*.wav~
~override~ ~ARE_.*.wav~
~override~ ~EFF_.*.wav~
~override~ ~LC[A-Z]_.*.wav~
END

 

Is there a DELETE feature in WeiDU that I can use to delete the files I biffed, or do I have to run a seperate .bat each time?

 

-Galactygon

Link to comment
It works well. Do I have to mention ~override~ each time I list a regexp?

Yes.

 

Is there a DELETE feature in WeiDU that I can use to delete the files I biffed, or do I have to run a seperate .bat each time?

Not that I know of.

If you don't want to use a separate batch file, I would do this:

1. copy all the files you want to biff in a separate directory (LC_Sounds).

2. biff all the files in there

3. use some shell/batch code in AT_NOW to traverse the files in LC_Sounds and delete the ones with the same name in override

For Windows probably something like:

AT_NOW ~cd LC_Sounds && (for %f in (*) do del "..\override\%f") && cd ..~

4. delete LC_Sounds (AT_NOW ~del \S LC_Sounds~)

 

However, how are you going to handle uninstall?

 

The bigg has posted some biffing code at SHS.

Link to comment

I am having trouble understanding BANDs.

 

A snippet from G3 BG2 tweaks removes the lawful flag from a certain item:

WRITE_BYTE 0x1e ("%use%" BAND 0b11101111) // removes lawful flag

 

In IESDP, offset 0x1e (usability), has 8 bits, and each has 4 bytes. The lawful flag is the 5th bit (or bit 4), byte 1. I can see a pattern that it's the 5th character from the left, and that's pretty much it. Does the "0b" say that it sets the byte to zero? What if I wish to eliminate humans to use that item?

 

What I really want to do is go in and make a list of all potions in the game, ignoring plot-specific potions.

DEFINE_ACTION_MACRO ~dispel_magic_potions~ BEGIN
	OUTER_SET potion_num_of_types = 0
	  COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
			READ_SHORT 0x1c "itm_type"
			PATCH_IF ( itm_type = 9 ) BEGIN
					 READ_LONG 0x18 "itm_flags"
					 PATCH_IF (BAND stuff would go here) BEGIN
							  do some stuff
					 END
			END
	  BUT_ONLY_IF_IT_CHANGES
END

 

-Galactygon

Link to comment
In IESDP, offset 0x1e (usability), has 8 bits, and each has 4 bytes.
4 bytes and each has 8 bits :).
The lawful flag is the 5th bit (or bit 4), byte 1. I can see a pattern that it's the 5th character from the left, and that's pretty much it.
It is reversed in binary, so the 5th bit from the right.
Does the "0b" say that it sets the byte to zero?
0b tells WeiDU it's in binary (bitwise) format, as opposed to 0x which is hexadecimal.
What if I wish to eliminate humans to use that item?
Then you want to read the 4th usability byte (0x21) and clear the 4th bit from the right (0b11110111). You don't need to READ_LONG, just READ_BYTE since you know which byte it is. When you read it into your variable, the BAND tells it to make no changes to the bits BANDed with 1, but to clear the one BANDed with 0 when you WRITE it back.
Link to comment

Archived

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

×
×
  • Create New...