Did some more tests with that bug to determine whether there is a hard level cap in DF. Encountered two new bugs that are probably related to the original one.
Built an automatic system for turning dwarves into sexy shoeless gods of war in Fortress Mode:
WWWWWW
.^#DAW
WWWWWW
W - wall
. - floor
^ - pressure plate set to trigger on civilians with dwarf weight
# - grate over a three-z-level fall with 10 wooden training spears at the bottom
D - door, locked, external
A - armor stand
The first dwarf to train in this contraption, whom I will call 'Test Subject', was fully clad in iron armor, wielding an iron shield and an obsidian sword. He fell onto the spears at an average rate of five times a day. He received only minor bruises with each fall, with no injuries that could cause infection.
Within 20 days of training, the Test Subject has fallen approximately 100 times. According to DFHack, his skill level was 3000, which is the same as Legendary+2985; further experience gain does not cause his skill level to increase. His skill levels in Armor User and Dodger have increased several levels, owing to the fact that he gets hit by the spears.
By the end of this training his stats were the same as in the beginning: "mighty and slow to heal".
Put him in the same squad with a Dabbling dwarf, whom I will call 'Rookie'. The Rookie was "agile and flimsy" before training began. When the two sparred, the Rookie seemed to gain skill experience rapidly: with every hit dealt by the Test Subject, the Rookie gained(on average) 7000 XP per hit for Fighter, Shield User and Swordsdwarf. No exceptional attribute gain is seen, but his attributes become significantly higher("inexhaustible, very agile, very strong, flimsy") than the Test Subject's by the time he hits level 80.
Made the Rookie train in the Shaft of Enlightenment until he hit level 1600. Made the pair spar again. The Rookie occasionally managed to block and parry the Test Subject's attacks, but could not land a single hit on the Test Subject; this implies that the 1400 levels of difference in skill levels still matter as far as combat calculations are concerned.
Made the Rookie train in the Shaft of Enlightenment until he hit level 3000. The moment he did, I stopped the training; since the Test Subject has fallen onto the spears many times after hitting the 3000 level cap, I assumed that, if there is no real experience cap, the Test Subject would be significantly better at fighting than the Rookie.
Triggered a loyalty cascade by making the Rookie massacre a caravan. Sent the Test Subject into the Rookie's vicinity. They parried and blocked each other's strikes for three pages, then the Rookie landed the first blow, fracturing a bone in the Test Subject's shield arm, after which the Test Subject's death was inevitable. I assumed that their skills layouts were therefore equal, and Rookie's victory happened due to a combination of luck and superior attributes.
Later, I sent a human vampire adventurer, with approximately 2130 levels in Shield User and Swordsman skill as well as 3000 levels in Fighter skill, wielding a bronze two-handed sword and a masterwork iron shield, to kill the Rookie. After a long time of blocking and parrying and the Rookie occasionally landing a hit on the vampire, he repeatedly succeeded to do so; this suggests that, at equal Fighter levels, superior attributes and size provide a bigger advantage than 700 levels of difference in weapon skill and Shield User.
During that last step of testing, another unusual effect was noticed: punching, kicking, biting, scratching or hitting the Rookie with any other kind of weapon while he holds a shield granted my character approximately 8000 experience per hit to the relevant skills, even when the attacks were blocked. This did not happen when his shield arm was broken.
Additional testing was performed to determine the extent of these effects. Testing was performed against a Legendary+2985 dwarf in full copper armor, with 10 wooden shields held in his right hand, dubbed Captain America. The test subject was an unarmored adventurer with Legendary+453 Shield User and Spearman skills.
Hitting Captain America granted between 1000 and 15000 experience points with no clear correlation between the attacker's skill level and experience gain. No attribute gain was observed during testing.
My test subject did not enjoy his newly developed skills for long, however, since Captain America always proceeded to land a debilitating hit, rendering the adventurer slower than he was, and then slowly and painfully beat his new toy to a pulp.
Summary:
1) Experience is capped at level 3000(Legendary+2985, X/300500 in Adventure Mode). Gaining experience beyond that level does not yield any significant benefits.
2) In case of extreme(500 or something like that) level differences between the weapon skills of two fighting parties, the party with lower weapon skill level receives thousands of XP every time they are hit by the more experienced party; that skill increase does not seem to increase their attributes.
This effect is possible to replicate in Adventure Mode: the human vampire adventurer mentioned above was able to raise bandits to Legendary levels in just a few hits. Punching and biting them instead did
not cause XP gain, which means that this effect does not depend solely on the Fighter skill.
3) Performing attacks against a shield-wielding enemy with enormously high Shield User skill will grant the attacker thousands of experience points per hit, even when their attacks are blocked. Unlike the Shaft of Enlightenment, this can be used to raise Striker, Biter, Kicker, Wrestler, and Misc. Object User skills. It does
not apply to ranged combat, however. XP gained from this effect does not increase one's attributes.
If you intend to exploit this bug in adventure mode, you are heavily advised to put armor on before you go against such a foe: anyone trained at the Shaft has an extremely high Fighter skill, which allows them to bypass your(comparatively low) Shield User skill with no effort whatsoever.
One of the ways to exploit it in Fortress Mode would be to train one of your dwarves in a Shaft of Enlightenment, then make sure they are sentenced to a beating. They would block every hit landed on them, giving the sheriff thousands of XP per hit; even with a mere 10 punches, the sheriff would become a Legendary Striker by the time they're done "punishing" the offender. UPD: Tested this, didn't work: the offender's Shield User skill wasn't even used; apparently, you can't block justice itself. The sheriff has beaten the "criminal" to death and walked away with no significant skill gain.