Jump to content

Possible to automate a script to change class requirements on all weapons?


Grand_Dracolich

Recommended Posts

Also, found the page for wspecial.2da. BG2 really has no penalties for not being proficient in a weapon? I definitely thought it had something like a -4 to-hit like 3rd edition has.

There are penalties, I think they're hard-coded. It's -2 for warriors, -4 or -5 for other classes. Something like that. Editing wspecial.2da just reinforces the penalties. I.e. if you make everything usable by everyone, increasing the penalty can help you use the profiency system to make "de facto" usability rules.

 

And then you can control your de facto usability rules by simply manipulating profs.2da, profsmax.2da, and weapprof.2da. Which can be a lot simpler than messing with item usability bits. (Look up the SET_2DA_ENTRY command for targeted edits.)

Link to comment

Alright, I think I've got the hang of most of this now:

 

ACTION_DEFINE_ASSOCIATIVE_ARRAY uniqueWeapons BEGIN
  wastaff => 1 // Staff of Arundel
  rods01 => 1 // Rod of Absorption
  rods02 => 1 // Rod of Lordly Might
  rods04 => 1 // Rod of Smiting
  rods06 => 1 // Rod of Reversal
  staf10 => 1 // Staff of Curing
  staf11 => 1 // Staff of the Magi
  staf12 => 1 // Staff of Power
  staf13 => 1 // Staff of Thunder and Lightning
  staf14 => 1 // Staff of the Woodlands
  sw2h10 => 1 // Carsomyr +5
  sw2h19 => 1 // Carsomyr +6
  
END

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~				//Iterate through all .itm files
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN						//If the file is properly formed
    READ_SHORT 0x1c type							//Read item type from header and store in type
    PATCH_IF (type == 0x05 || (type >= 0x0e && type <= 0x1f)) BEGIN		//If arrow, or between bullets and bolts (inclusive)
      TO_LOWER SOURCE_RES							//Make name lower-case
      PATCH_IF (NOT VARIABLE_IS_SET $uniqueWeapons(~%SOURCE_RES%~)) BEGIN	//Compare with items in array

        // make usable by all classes http://gibberlings3.net/iesdp/file_formats/ie_formats/itm_v1.htm#Header_Usability
        WRITE_BYTE 0x1e (THIS BAND 0b00111111)					//Mask out Bard,Cleric
        WRITE_BYTE 0x1f 0							//Mask out C/M,C/T,C/R,Fighter,F/D,F/M,F/C,F/M/C
        WRITE_BYTE 0x20 (THIS BAND 0b10000000)					//Mask out F/M/T,F/T,Mage,M/T,Paladin,Ranger,Thief
        WRITE_BYTE 0x21 (THIS BAND 0b10011111)					//Mask out Monk,Druid
        
        // make usable by some kits http://gibberlings3.net/iesdp/file_formats/ie_formats/itm_v1.htm#Header_KitUsability
        WRITE_BYTE 0x29 0							//Mask out Cleric kits, Druid kits, Barbarian, Wildmage
        WRITE_BYTE 0x2b 0							//Mask out Ranger kits, Thief kits, Bard kits
        WRITE_BYTE 0x2d (THIS BAND 0b01000000)					//Mask out all but "No kit"
        WRITE_BYTE 0x2f (THIS BAND 0b00001110)					//Mask out all but Wizard Slayer, Kensai and Cavalier
      END
    END
  END
  BUT_ONLY
I think I spotted and corrected a typo in Mike's code. If I understand it correctly, "type == 0x05 || (type >= 0x0d && type < 0x1f)" counts arrows, then "food" and up until crossbow bolts (but not including bolts).

 

I'm still not sure about a few things though. I'm not sure how the "No Kit" part of the kit usability section should be handled. In the above code, I just leave it unchanged. I also don't know if there are other items I'm missing from the exclusion list. Since I'm putting this together for a playthrough with Enhanced Edition, I don't know what other items I want to add to that list, as well. I think there are some other items in Rogue Rebalancing and Item Upgrades that are restricted to certain classes for the same reasons as the items in that list as well.

Link to comment

I think I spotted and corrected a typo in Mike's code. If I understand it correctly, "type == 0x05 || (type >= 0x0d && type

Good catch. I probably messed it all up while trying to change from

 

I'm still not sure about a few things though. I'm not sure how the "No Kit" part of the kit usability section should be handled. In the above code, I just leave it unchanged.

You shouldn't need to change any of the kit flags (unless you're trying to catch overzealous mod items). The way the engine works, if an item is unusable by a ranger, then no ranger kits will be able to use it. Vanilla items should only have a kit usability flag set if that item is available to the base class but restricted from the kit, which is behaviour you probably want to keep.

Link to comment

Noticed it when I picked through to make sure I understand everything that's going on in every line. :p

 

You shouldn't need to change any of the kit flags (unless you're trying to catch overzealous mod items). The way the engine works, if an item is unusable by a ranger, then no ranger kits will be able to use it. Vanilla items should only have a kit usability flag set if that item is available to the base class but restricted from the kit, which is behaviour you probably want to keep.

So, for example, if I set longswords so Clerics can use them, it would allow the Clerics of Lathander/Helm/Talos to use them, too?
Link to comment

So, for example, if I set longswords so Clerics can use them, it would allow the Clerics of Lathander/Helm/Talos to use them, too?

That's right, this is due to the fact that as the primary class restricts the kits from using the item, they kit it self doesn't (usually) have it flagged as restricted.

But you might want to or not still make sure, as there are other mods and some of them restrict these things harshly and some not so much.

Link to comment

Having a hard time figuring out how that's supposed to work. The way Mike's script works, it takes the highest allowed proficiency and sets every weapon proficiency to that. That would be bad for Berserkers, Archers, Cavaliers and Kensai. The former two because they can only put more than one point in certain weapons, the latter three because they still shouldn't be able to use certain weapons.

 

The first case is already taken care of, I think. It checks if the value in the cell is 0 before updating it to the new value, so we don't end up changing the Archer's 1s into 5s for example. How should the second case be handled? Have an exclusion list like in the item script that checks the name of the kit? Have it put values manually?

Link to comment

The sad fact is, it's hard to get this stuff exactly right by painting with a broad brush. Changing item usability is fairly quick and easy (assuming, as discussed above, you just want to open things up to different classes but you don't mean to mess with particular kit characteristics).

 

But messing with weapon proficiencies... that gets to be a pain.

 

My mod takes it pretty far: grandmastery arrives at the 4th star instead of the 5th, and then I adopt a simple tiered system wherein fighters can get up to 4 stars, rangers/paladins/barbarians can get 3 stars, rogues can get 2 stars, and clerics and wizards can only get 1 (clerics get a 2nd star in a favored weapon but that's neither here nor there).

 

Then I carve out some exceptions, like Stalkers can go 1 star further than normal with short swords, assassins can go 1 star further with daggers, skalds with axes, etc. I also make clubs and crossbows universal, allowing anyone to get proficiency.

 

Those changes - just the ones to weapprof.2da take up about 1,000 lines in my Weidu script. Someone like Mike could probably do in less... but it still boils down to a ton of hand-picked adjustments.

Link to comment

If it's possible to pick out the name at the top of a column (I don't know if that's off of the 2da), the cleanest option might be an exclusion list like for the items. It would also probably be easy enough to add support for mod kits, because it would just be adding names to the list.

 

Also, in the two for loops in Mike's weapprof.2da script that iterate through rows, why does rows start at 8?

Link to comment

Well, as someone lacking any programming knowledge or experience (except a class in college on logic and computability - Boolos and Jeffries stuff), I have no idea how to create such an exclusion list. But yeah it's probably possible. Depends on precisely what you want to do.

 

Edits in weapprof.2da start in row 9 (depending on how you count) because rows 1-8 are the general proficiencies from BG1, which are unused in BG2/BGEE unless you apply the BG2Tweaks component to use them. You want to edit entries from row 9 (Bastard Sword) to row 32 (Two-Weapon Fighting Style).

Link to comment

Well, as someone lacking any programming knowledge or experience (except a class in college on logic and computability - Boolos and Jeffries stuff), I have no idea how to create such an exclusion list. But yeah it's probably possible. Depends on precisely what you want to do.

Like in Mike's script above. You have a list of things, if the current item you're on is in that list, don't do anything to it. If I understand correctly, the names of the kits are in the 2DA. It should be doable if I can read those names as data.

 

Edits in weapprof.2da start in row 9 (depending on how you count) because rows 1-8 are the general proficiencies from BG1, which are unused in BG2/BGEE unless you apply the BG2Tweaks component to use them.

Ah, got it! Thanks!
Link to comment

...which are unused in BG2/BGEE unless you apply the BG2Tweaks component to use them.

Actually they are not used even then as the GUI doesn't allow you to put points to them, what the Tweak does is set all the weapons to use a fewer proficiencies, and then assigns a new name to those profs so it looks like the original BG1's values are in use, while the system was just switched a bit around, to use less over all types. The evidence is in the bg_style_profs.tpa file, like in this bit:

DEFINE_MACRO_ACTION ~tb#tutu_weapprof~ BEGIN
  // Bow 59h
  // Spiked Weapons 5ah
  // Small Sword 5bh
  // Large Sword 5ch
  // Axe 5dh
  // Blunt Weapons 5eh
  // Missile Weapons 5fh
  // Spear 60h

  COPY_EXISTING ~stats.ids~ ~override~
    REPLACE_TEXTUALLY ~^89 .*~ ~89 PROFICIENCYBOW~
    REPLACE_TEXTUALLY ~^90 .*~ ~90 PROFICIENCYSPIKEDWEAPONS~
    REPLACE_TEXTUALLY ~^91 .*~ ~91 PROFICIENCYSMALLSWORD~
    REPLACE_TEXTUALLY ~^92 .*~ ~92 PROFICIENCYLARGESWORD~
    REPLACE_TEXTUALLY ~^93 .*~ ~93 PROFICIENCYAXE~
    REPLACE_TEXTUALLY ~^94 .*~ ~94 PROFICIENCYBLUNTWEAPONS~
    REPLACE_TEXTUALLY ~^95 .*~ ~95 PROFICIENCYMISSILEWEAPONS~
    REPLACE_TEXTUALLY ~^96 .*~ ~96 PROFICIENCYSPEAR~
    FOR (i = 97; i <= 107; i+=1) BEGIN
      REPLACE_TEXTUALLY ~^%i% .*~ ~%i% UNASSIGNED%i%~
    END
    PATCH_IF tb#tutu_realloc_style BEGIN
      FOR (i = 111; i <= 114; i+=1) BEGIN
        REPLACE_TEXTUALLY ~^%i% .*~ ~%i% UNASSIGNED%i%~
      END
    END  

Here's the original content of the file which is replaced:

 

89 PROFICIENCYBASTARDSWORD

90 PROFICIENCYLONGSWORD

91 PROFICIENCYSHORTSWORD

92 PROFICIENCYAXE

93 PROFICIENCYTWOHANDEDSWORD

94 PROFICIENCYKATANA

95 PROFICIENCYSCIMITARWAKISASHININJATO

96 PROFICIENCYDAGGER

97 PROFICIENCYWARHAMMER

Link to comment

Archived

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

×
×
  • Create New...