Yeah, I only just figured out WHILE loops a week or so ago, too. 2005 has been a long WHILE coming, let me tell you.
Okay, so these bits are from the Sensible Weapon Restrictions for Mods component that
the bigg made, so I can't lay any claim to them.
BEGIN ~Sensible weapon restrictions for MODS~
PRINT ~Patching all weapon files, this may take a minute or two.~
COPY_EXISTING_REGEXP GLOB ~.*\.itm~ ~override~
This is copying all the item files.READ_SHORT "0x1c" "type"
READ_BYTE "0x1e" "usab1"
READ_BYTE "0x1f" "usab2"
READ_BYTE "0x20" "usab3" //
All of these READ_BYTEs are setting up variables, so we can check their values.READ_BYTE "0x21" "usab4"
READ_BYTE "0x26" "stre"
READ_BYTE "0x29" "ukit1"
READ_BYTE "0x2b" "ukit2"
READ_BYTE "0x2d" "ukit3"
READ_BYTE "0x2f" "ukit4"
READ_BYTE "0x31" "weapprof"
READ_BYTE "0x2c" "dex"
SET "patchdone" = "0"
//bastard swords
WHILE ((("%patchdone%"="0") AND (("%usab2%" BAND "0b00001000") = "0b00000000")) AND ("%weapprof%" = "0x59")) BEGIN
// usable by fighter (so no tricky weapon like SOTM) AND is a bastard sword
usability 2 is the byte where the restriction for the fighter class is. The 5th bit. Check out the BAND, BOR, BXOR stuff in the WeiDU readme. Basically, though, if the fifth bit is check (i.e. fighters can't use the weapon), it's a special weapon like the staff of the magi, or carsomyr. Don't think a Cleric of Sune could use those, either. The weapprof bit is checking what value that's set to. 89d or 59h is bastard sword, meaning we apply our custom restrictions for the bastard sword. WRITE_BYTE "0x1e" ("%usab1%" BAND "0b00111111") //alignment restrictions are left because they make sense roleplay-wise
The first bit in this byte is the one to regulate cleric restriction. You'll want to set it to 0 to allow clerics to use it. WRITE_BYTE "0x1f" ("%usab2%" BAND "0b00000000")
WRITE_BYTE "0x20" ("%usab3%" BAND "0b10000000")
// The rest of this jazz, honestly, isn't really needed if you just want to make weapons usable by the Cleric of Sune. WRITE_BYTE "0x21" ("%usab4%" BAND "0b10011111") //as do racial limitations
WRITE_BYTE "0x29" ("%ukit1%" BAND "0b00000000")
WRITE_BYTE "0x2b" ("%ukit2%" BAND "0b00000010") // beast master
WRITE_BYTE "0x2d" ("%ukit3%" BAND "0b00000000")
WRITE_BYTE "0x2f" ("%ukit4%" BAND "0b00000000")
WRITE_BYTE "0x26" "13" //str & dex
WRITE_BYTE "0x2c" "8"
SET "patchdone" = "1"
Oh, except this bit. You'll want to keep this.END