..) I need some tips on how to make a character cast anti-invisibility spells when necessary. I have tried both Detect() and StateCheck() to no avail. It has been very frustrating thus far, especially when the enemy is ImpInvi and my casters are not doing anything about it...
I've never been sure precisely how STATE_IMPROVEDINVISIBILITY works--it's one of those things I really must test someday. Try Detect() and !See() in combination. I suspect the latter may ignore improved-invisible characters, since I've never known the AI to try and cast at one.
..) Is there any definite fix for the KIT.IDS issue?
Most respectable mods these days include a patch to fix this which you can copy (nobody really expects you to ask permission for this). Download any of my mods and take a look at the ALWAYS block at the top of the TP2--alternatively, somebody will hopefully post it here.
..) Tips on how to avoid lag due to big scripts will be welcomed too. I have no lag issues when there is no combat, due to the sequence of my scripts, but it becomes a slideframe show during combats.
Avoid setting tons of variables. These don't cause game lag as such, but they do make the script slower to respond.
Ensure the least likely triggers are at the top. For cast 'n' attack, this will usually be !GlobalTimerNotExpired, since a caster spends most of their time waiting between spells (save actual casting time during which scripts aren't parsed).