WeiDUorg / weidu

WeiDU is a program used to develop, distribute and install modifications for games based on the Infinity Engine.
http://www.weidu.org
GNU General Public License v2.0
89 stars 20 forks source link

ADD_KIT/COPY_KIT: Add support for multiclass kits installed at kitlist slots >= 256 #157

Open Argent77 opened 5 years ago

Argent77 commented 5 years ago

Since true multiclass kits in EE 2.0+ games are not affected by the engine's kit limitation I'm planning for ADD_KIT_EX to add multiclass kits at kitlist.2da slots >= 256 and reserve slots 1-255 exclusively for single-class kits. The gap between installed single-class and multiclass kits can be filled with placeholder rows consisting of the table's default value.

However, that would also require WeiDU's own kit functions ADD_KIT and COPY_KIT to detect and replace these placeholders when kits are installed. Would it be feasible to implement this feature?

First requested here.

Example implementation for ADD_KIT_EX (including test mod).

FredrikLindgren commented 5 years ago

Based on a quick skim of the code, it would mostly be a matter of replacing general-purpose code for reading, counting lines and appending with special-purpose equivalents. It should be technically possible, and since ADD_KIT is fairly peripheral, the probability of running into weird architectural limitations should be low.

Argent77 commented 4 years ago

Following up on this request, I have added this feature in an extra branch of ADD_KIT_EX. It seems to work quite well and the resulting kitlist.2da doesn't look as messy as I feared. The example mod included in the library can be used for quick tests.

A hypothetical kitlist.2da would look like this after installing the first true multiclass kit:

2DA V1.0
*
     ROWNAME     LOWER  MIXED  HELP   ABILITIES  PROFICIENCY  UNUSABLE    CLASS  KITIDS
0    RESERVE     *      *      *      *          *            *           *      *
1    BERSERKER   25298  25329  24284  CLABFI02   29           0x00000001  2      0x00004001
2    *           *      *      *      *          *            *           *      *
3    *           *      *      *      *          *            *           *      *
...
254  *           *      *      *      *          *            *           *      *
255  *           *      *      *      *          *            *           *      *
256  XX_SPY      71376  71375  71377  *          62           0x00040000  9      0x00004100

Afterwards, new single-class kits will replace placeholder entries one after another, starting at slot 2. Multiclass kits are appended at slot 256, 257, and so on.

This strategy would allow mods to utilize the full range of 256 kit slots for single-class kits. Based on some tests it looks like the range of available multiclass kit slots is practically unlimited. It certainly exceeds the TobEx limit of 1280 slots. Even kit slots beyond 4096, which would result in KITIDS values of 0x5000 or higher, seem to work fine.

What would be required of ADD_KIT and COPY_KIT to be compatible:

Potential compatibility issues (I can think of so far):

What's your opinion about this feature?

FredrikLindgren commented 4 years ago

It looks absolutely neat! The tweak-mod point seems like the only real (potential) problem. The other two do not cause lasting problems and can be solved by upgrading.

Just FYI, I'm currently working on the low-hanging fruit so I can release a new WeiDU in the near future. I'm thinking it is probably best to add this after next WeiDU (in the interest of getting out it reasonably close to "now"). Do you agree?

FredrikLindgren commented 4 years ago

These padding lines are only added for EE-type games, right? The code behaves like old ADD/COPY_KIT on the original engine?

Argent77 commented 4 years ago

These padding lines are only added for EE-type games, right? The code behaves like old ADD/COPY_KIT on the original engine?

Yes, that's right. More specifically, only for EE 2.0+ games. (Although EE 1.x games support multiclass kits, they are not available during character generation.)