Jump to content



Recommended Posts

Has anyone here ever created a mod that pushes WEAPPROF.2DA to the associated ITM files ?


Suppose I want my Druids to use Axes. I can use Near Infinity to change the 0 to 1-5 in WEAPPROF.2DA, however as stated by Mike1072 in topic 24766: "weapprof.2da ... doesn't affect item usability (which) is stored on a per item basis inside the .itm file." That means I need to edit the ITM files for every axe, and un-check the "Druid" in the "Unusable by" section.


So I'm just wondering if anyone has an automated process that reads WEAPPROF.2DA, detects a zero / non-zero on each row for each class, and updates the related ITMs ... in this example, enabling "Druid" for all ITMs with Category "Axes (25)" ?


P.S. ... or perhaps Weapon proficiency = "proficiencyaxe - 92" ?

Link to comment

I suppose someone could write a function like that. I never bothered because it wasn't something I had to do often and special code is required to make sure you don't accidentally give mages the ability to wield Carsomyr. I used the strategy of only enabling use of a weapon if it was also usable by certain other classes.

Link to comment

Actually, I'm thinking the other direction - using WEAPPROF.2DA to drive a mass update of the ITM usabilty flags.


I'm no modder myself. :worship: I depend on Near Infinity and Shadow Keeper to make my little tweaks. The difficulty is that some classes or kits are always limited by one mod or another, and what one mod gives another takes away. (Level 1 NPCs comes close, so would Ashes of Embers, but not quite.) So after all my modding is done, if I want to enable a disabled proficiency (or vice versa) in any column, I have to edit every single ITM with that proficiency with NI to change the usability flags.


So I thought, why not just press a button and let WEAPPROF.2DA drive all that tedious work ? (If the mass update could also add or remove the "Not Usable By" entries in the item descriptions, that would be icing on the cake.) So that's why I'm inquiring if anyone has actually built such a tool and just never thought of posting it ... or for that matter, if anyone out there would consider it a worthy challenge ?

Link to comment

No, I understood what you are suggesting. I'm just saying, as long as you're writing a function in Weidu to change one thing, why not have that funciton change both simultaneously? Why have one read the other? I have a component in my mod that allows clerics to use crossbows... it's relatively simple:

- edit a few entries in weapprof.2da

- run a routine to find any mod-added clerics and edit those entries in weapprof.2da

- run a routine on all crossbows that unchecks the flag that restricts clerics from using them


Now, there are certainly reasons to have one of those be dependent on the other:

1) For end-users, editing a table in NI is easier than modifying Weidu code. So basing the code on the entries in weapprof would allow modding novices more control over weapon usability.

2) A better guarantee of consistency, less likely that the two will be out of sync. Sure. But then, they would only be out of sync if the coding is sloppy.


Further, there is a danger here: Weidu stuff can only make changes when it is installed, whereas editing things in NI affects your game mod-stream. So, novice users might mod their game, play a few hours, then edit weapprof.2da to make some adjustments, then go back to playing... and now things will be out of sync. So it's not an ideal/foolproof method.

Link to comment

If I could write a WeiDU mod (which I can't), I could build on subtledoctor's example. The mod would ask, "Do you want to allow Clerics to use Axes ? "N" or 1, 2, 3, 4, or 5 stars." It would then edit the Axe / Cleric entry in WEAPPROF.2DA, edit the usability on all ITM files with PROFICIENCYAXE, and edit their "Not Usable By" descriptions. (I wouldn't automatically do the same for multi-classes or mod-added kits, as there might be exceptions to the rule.)


It would then ask, "Do you want to allow Clerics to use Bastard Swords ?" and so on, stepping through all the weapon types and the 4 fighting styles, for every class, multi-class, and mod-added role in the table. That's hundreds of questions to answer (1,200 combinations for me after a few common "tweak" mods), and hundreds more if you have lots of mod-added kits and/or weapon types. I completely agree with Fiann that this could be accomplished by repeating subtledoctor's Clerics/Crossbows logic as many times as necessary.

(I suppose the mod could offer shortcuts. "Do you want to allow all Clerics, their multi-classes, and kits to use all melee weapons ?" would cover many weapons and many columns at one shot. Such shortcuts would reduce the number of questions, at the risk of making undesired changes that would then have to be corrected manually. That's why I'm in favor of the detailed level.)


Getting back to starting with WEAPPROF.2DA and running a mass update based on the table, I totally agree with subtledoctor's points about about ease of use, detailed control, and consistency. I'm not as concerned about mid-game changes, because if I enable (or disable) a weapon, l still have to run the update program for it to take effect, which keeps everything in sync. I also agree with Mike1072 that a mod that gives Mages two-handed swords should probably re-restrict Carsomyr to Paladins, and likewise for certain other special restricted items. (If it doesn't, the user can still manually restrict those items, or at least follow the honor system.)


Which do you suppose would be less effort for an experienced modder, coding an interactive mod with 1,200 questions that runs a relatively small update after each answer, or coding a mass update program that runs off the table entries from top to bottom ?

Link to comment

That last part might have sounded more like a "request" than intended - I was just wondering how much effort it would entail.


Returning to subtledoctor's Clerics/Crossbows mod, I have another idea.


I have a component in my mod that allows clerics to use crossbows... it's relatively simple:

- edit a few entries in weapprof.2da

- run a routine to find any mod-added clerics and edit those entries in weapprof.2da

- run a routine on all crossbows that unchecks the flag that restricts clerics from using them


subtledoctor's last section of code updates the ITM files. It sounds like (I hope I'm right about this) the code uses the Weapon Proficiency field to find all Crossbows, and then the Unusable By field (and perhaps even the Unuseable By 1, 2, 3, and 4 as well) to locate and then edit the usability flag for each Cleric type for each Crossbow item.


If that's so, then maybe all I really need Is that last section of code. If he could share that piece of code as a stand-alone executable, and explain how to modify the affected class(es) and weapon proficiency in the code and save it (which I could probably do), then perhaps I could use it to enable my Druids to use Axes (or any other desired change) ?


That alone would be a huge time-saver, compared with locating and editing every affected ITM file every time! Your thoughts ?

Link to comment

I believe this should be enough.

BACKUP ~Druids/backup~
BEGIN ~Allow druids to use axes~
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
    READ_SHORT 0x1c item_type
    PATCH_IF (item_type == 0x19) BEGIN // axe
      WRITE_BYTE 0x1f (THIS & `16) // make usable by fighter/druids
      WRITE_BYTE 0x21 (THIS & `64) // make usable by druids
PS LOL, definitely wasn't... fixed.
Link to comment

If you don't care about editing the descriptions, it can be simpler. I think the following should work, just delete the %type% lines for any items you *don't* want to be usable by druids.


(EDIT - ninja'd!)

COPY_EXISTING_REGEXP GLOB ~.*\.itm~ ~override~
    READ_BYTE    ~0x1f~ ~fight~ //reads the byte containing the fighter usability flag
    PATCH_IF ((~%fight%~ BAND ~0b00100000~) = ~0b00000000~) BEGIN // if *usable* by fighter/mages (excluding scrolls and wands for now)
      READ_BYTE    ~0x1e~ ~class1~
      READ_BYTE    ~0x1f~ ~class2~
      READ_BYTE    ~0x21~ ~class3~
      READ_SHORT   ~0x1c~ ~type~ //reads the byte containing item type
      PATCH_IF (~%type%~ = ~5~) OR       //arrow
               (~%type%~ = ~14~) OR       //bullet
               (~%type%~ = ~15~) OR       //bow
               (~%type%~ = ~16~) OR       //dagger
               (~%type%~ = ~17~) OR       //mace
               (~%type%~ = ~18~) OR       //slings
               (~%type%~ = ~19~) OR       //small swords
               (~%type%~ = ~20~) OR       //large swords
               (~%type%~ = ~21~) OR       //hammer
               (~%type%~ = ~22~) OR       //morningstars
               (~%type%~ = ~23~) OR       //flails
               (~%type%~ = ~24~) OR       //darts
               (~%type%~ = ~25~) OR       //axe
               (~%type%~ = ~26~) OR       //quarterstaff
               (~%type%~ = ~27~) OR       //crossbows
               (~%type%~ = ~28~) OR       //hand-to-hand
               (~%type%~ = ~29~) OR       //spear
               (~%type%~ = ~30~) OR       //halberd
               (~%type%~ = ~31~) OR       //bolts
               (~%type%~ = ~44~) OR       //clubs
               (~%type%~ = ~57~) OR       //greatswords
               (~%type%~ = ~69~) OR       //bastard swords
               (~%type%~ = ~30~) BEGIN    //halberd
        WRITE_BYTE    ~0x1f~ (~%class2%~ BAND ~0b11101111~) // fighter/druids
        WRITE_BYTE    ~0x21~ (~%class3%~ BAND ~0b10111111~) // druids
Link to comment

In the name of Lathander the Morninglord (I'm Neutral Good myself), what have I gotten myself into ?


Okaaaay ... I was an Assembler programmer back in the 1990's, so between these samples and the other sites referenced, I think I actually understand some of the logic (and yes, I do get that x19 = 25). I might actually try my hand at this ...


A couple of follow-up questions, if you please:


How does one identify the byte (e.g. 0x21 = Druids) for the usability flag for each alignment, race, class, and kit ? In the example above, I'd imagine that Totemic Druids (or Priests of Talos in the case of Clerics) would (or could) have their own WRITE_BYTE statement ?


Also, can you point me to an online course on "WeiDU Programming for Newbies" ? :-)

Link to comment

ITM File Format contains all you need to know about ITM files.


WeiDU Documentation has detailed information on every WeiDU command, plus a few tutorials. There are also tutorials listed here. A few may be out of date. There isn't really a single tutorial series that provides a complete introduction to WeiDU scripting. It's more about figuring out the basics and following tutorials that apply to what you want to do, then consulting the WeiDU docs to learn about other commands and how they work. If you're trying to do something in particular, like "allow druids to use axes", and you're stuck, posting in Modding Q&A is probably the best bet to get some help.


Per your question about kits, the game treats items that are unusable by a class as also unusable by kits of that class. Most of the time, items will not be flagged as unusable by both the kit and the parent class, because that will interfere with dual classes. Swords are set to be unusable by mages, but usable by fighter/mages. They are also set to be usable by invokers. This means a regular invoker cannot use swords (because mages cannot), but invokers who dual class to fighter can.

Link to comment



So in a completely different place and time and context I was having a discussion about item use vs. item proficiency, and how to handle it in our upcoming mod, and suddenly I remembered there's a thread about editing usability to match weapprof.2da, over at G3. And I started thinking, "hey, that would actually be pretty useful for us." And then, even though I decried the idea in the G3 thread, it suddenly occurred to me how it can be done. So I'm going to do it! Genius man. Your idea is genius, it just took me a bit to realize it.


Now, this is a lot more easily done with the new EE 2.0 opcode 319. It can be done on the old engine by using the vanilla kit & class usability flags, but using equipping effects with opcode 319 is probably less complicated, more reliable, AND lets to determine usability on a per-kit basis... even for mod kits and other kits that don't have their own usability flag!


So, anyway, thanks for the inspiration.

Link to comment


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

  • Create New...