Jump to content

Trouble with usability flags


Biubid_boy

Recommended Posts

Hello everyone.

 

I am trying to create a bard kit that is limited to only using weapons a thief can use, but I cannot seem to get it working correctly. Currently my kit is using the usability flag for the bounty hunter kit - 0x00080000 (Where are the usability flags for vanilla kits anyway?), but that has no effect on the weapons my PC can use. How can I restrict my kit's usability to that of a thief?

 

Thanks guys,

Mike.

Link to comment
I am trying to create a bard kit that is limited to only using weapons a thief can use, but I cannot seem to get it working correctly. Currently my kit is using the usability flag for the bounty hunter kit - 0x00080000 (Where are the usability flags for vanilla kits anyway?), but that has no effect on the weapons my PC can use. How can I restrict my kit's usability to that of a thief?

This is going to be surprisingly difficult to do.

 

There are basically two levels to unusability--class and kit values. The class unusability you can not change from the base class of the kit itself. Kit unusability can only do so much here--if an item is flagged as unusable by thief, odds are good that the bounty hunter/assassin/swashbuckler flags are not set as they're redundant.

 

Take, for example, the normal bastard sword (sw1h01.itm). It's flagged as unusable by thieves, but not bards, and no thief kit flags are set. Your new kit can't use an item if the bard or bounty hunter flag is set. Neither are, so the engine deems the weapon usable.

 

So, what you need to do is to add these redundant flags. You need to write a regexp that sets the BH flag of an item if the thief flag is set.

Link to comment
So, what you need to do is to add these redundant flags. You need to write a regexp that sets the BH flag of an item if the thief flag is set.

Mucking around with the thief flags is bad (they also have hardcoded effects), so you need to use a different 'redundant' kit (E.G. Berzerker), move Berzerker to Trueclass, and warn that incompatibilities with other kit mods are possible.

Link to comment

I tried scripting what you described in Weidu, but I'm having strange results. Some things are being disabled, some are not. Here is the code I have written.

 

//Gives the bezerker a trueclass usability flag to free a flag up (has no effect)
COPY_EXISTING ~kitlist.2da~ ~override~
 REPLACE_TEXTUALLY ~0x40000000~ ~0x00004000~

//This gives the kit thief weapons (but not bow) and bard armour choices 
COPY_EXISTING_REGEXP GLOB ~^.+\.itm~ ~override~	//loop through all items
 PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN	  // protects against invalid files
 READ_SHORT "0x1C" "type"
 READ_BYTE  "0x29" "usability_flags"
 READ_BYTE  "0x2f" "kit_flags"  
PATCH_IF (("%type%" = 17)  OR //Maces
		  ("%type%" = 21)  OR //Hammers
		  ("%type%" = 22)  OR //Morningstars
		  ("%type%" = 23)  OR //Flails
		  ("%type%" = 27)  OR //Crossbows
		  ("%type%" = 29)  OR //Spears
		  ("%type%" = 30)  OR //Halberds
		  ("%type%" = 31)  OR //Bolts
		  ("%type%" = 44)  OR //Clubs
	  ("%type%" = 25)  OR //Axes
		  ("%type%" = 15)  OR //Bows
		  ("%type%" = 30)  OR //Halbreds 
		  (("%usability_flags%" BAND 0x40000000) AND ( //Unusable by bard and is...
		  ("%type%" = 2)   OR //Armor
		  ("%type%" = 60)  OR //Leather Armor
		  ("%type%" = 61)  OR //Studded Leather Armor
		  ("%type%" = 62)  OR //Chain Mail
		  ("%type%" = 63)  OR //Splint Mail
		  ("%type%" = 64)  OR //Half plate
		  ("%type%" = 65)  OR //Full plate
		  ("%type%" = 66)  OR //Hide armor
		  ("%type%" = 67))))  //Robe
BEGIN WRITE_BYTE "0x2f" ("%kit_flags%" BOR 0b00000001) END
END
BUT_ONLY_IF_IT_CHANGES

 

What have I done wrong?

PS: Be gentle - its my first Weidu scripting attempt.

Link to comment
What have I done wrong?

PS: Be gentle - its my first Weidu scripting attempt.

Your usability_flags variable is being read from the wrong spot - you want the offset 0x1e. If you only read the first byte from it, your statement in the middle should probably* be:

((("%usability_flags%" BAND 0b01000000) = 0b01000000) AND ( //Unusable by bard and is...

 

*I am also new at this.

Link to comment
I tried your advice, Mike, but it just made my game freeze on the character creation loading screen. Can you think of anything else that might be incorrect?

Heh, I decided to try making it from scratch, and discovering why IT wasn't working made me realize why what I proposed didn't help. I had the endianness of the bytes in the usability mixed up in my head... the offset I should have given you was 0x21. Anyway, here's what I've got. I re-did it to encompass all items, and fixed the .2da patch to alter the Berserker, not the Barbarian.

 

//Gives the berserker a trueclass usability flag to free a flag up
COPY_EXISTING ~kitlist.2da~ ~override~
 REPLACE_TEXTUALLY ~0x00000001~ ~0x00004000~

//This gives the kit the usability of a bard restricted to thief weapons (and no bow)
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~	//loop through all items
 PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
READ_SHORT 0x1c item_type
READ_LONG  0x1e class_usability
READ_BYTE  0x2f kit_usability4

// disallow non-thief weapons, and bows
PATCH_IF (item_type = 0x05 OR // Arrows
		  item_type = 0x0f OR // Bows
		  item_type = 0x11 OR // Maces
		  item_type = 0x15 OR // Hammers
		  item_type = 0x16 OR // Morningstars
		  item_type = 0x17 OR // Flails
		  item_type = 0x19 OR // Axes
		  item_type = 0x1b OR // Crossbows
		  item_type = 0x1d OR // Spears
		  item_type = 0x1e OR // Halberds
		  item_type = 0x1f ) BEGIN  // Bolts
  WRITE_BYTE 0x2f (kit_usability4 BOR 0b00000001)
END ELSE BEGIN
  // patch all other items so berserker flag reflects that of bards
  PATCH_IF ((class_usability BAND 0b00000000000000000000000001000000) = 
								  0b00000000000000000000000001000000) BEGIN // not usable by bards
	WRITE_BYTE 0x2f (kit_usability4 BOR  0b00000001)
  END ELSE BEGIN // usable by bards
	WRITE_BYTE 0x2f (kit_usability4 BAND 0b11111110)
  END
END
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

Archived

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

×
×
  • Create New...