The Window Height function gets called once the window is initialized (meaning when it is created). When initialized, it has no actor set in it by default, meaning maxItems doesn't return the number of skills.
The solution to your problem is to modify the window height (and y position I suppose) each time it sets an actor. Don't forget that there is only one window skill for every actor in battle, so of course the number of skills is going to vary each time, meaning different height (and y?). I believe it can be achieve inside the Window_SkillList.prototype.setActor function:
Code:
Window_SkillList.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this.refresh();
this.resetScroll();
this.setNewHeight(); // Be sure to make the change after it sets the new actor.
}
};
Window_SkillList.prototype.setNewHeight = function() {
this.height = 36 + this.maxItems() * 36;
// y position adjustment?
}
Also a line is by default 36 pixels, and you need to add the default padding (portion of the window with no content) which is 36. So to have the exact height for the number of skills, the formula would be: return (36 + this.maxItems() * 36);
EDIT: I haven't tested the code. Also, I never used the default battle since I also create from scratch my own battle plugins. So this is all based on a quick glance at the default code of RPG Maker, not on experience and knowledge of the default battle lol.