Odd behavior of racial ability adjustments for low scores
So, I was checking to make sure that some stuff I wrote for the con penalty when getting raised at level 1 didn't do something weird to characters with a racial con penalty, and came across a different weird bug instead.
It's clear that the game is trying to make all racial penalties bottom out at 3. If you roll a 3, and then choose a race with a -2 penalty, it won't actually apply the -2. This intention isn't actually correct, because as far as I can tell, only intelligence has an exception like this (because you need 3 int to speak, and gain class levels, I think). But also, the math isn't even correct. If your unadjusted stat is 4, then it will accidentally cap the penalty to -1. But if your unadjusted stat is 3, it will still give the -2, and if it's below 3 it will give a bigger penalty than normal.
I was going to fix this, but my question is how I should do so. Should I try to test for strict rules, and if they're not enabled actually implement the game's intention of clamping base ability scores at 3? Or should I just implement the actual rules, because essentially no one is going to have scores that low anyway?
Latter option sounds fine in principle. The only thing I'd verify is that it doesn't cause any NPCs to instantly die as a result (particularly in the vanilla non Co8 game, where stats are wack sometimes).
Shouldn't make anyone instantly die. There's a separate mechanism that makes sure that regardless of how low your con penalty goes, you still have at least 1 hp/hd. Also, the only value that's correctly clamped right now is 4->3. Everything else will be the same or better with the actual rule (since I don't think any monster races are actually implemented in the vanilla game).
Doesn't cloudkill kill with 0 con? I have a vague recollection of undead with 0 con stats, but I could be mistaken.
Having 0 con is supposed to make you die instantly. That's separate from the number of HP you have from the -5 penalty that would theoretically give you. If it were the penalty to your HP that killed you, you'd die at 1 con, anyway, because that's also -5.
I don't know what exactly is in the protos for undead, but the rules for those are supposed to be that they don't have a con score at all, and not having a score is different than having a score of 0. For one, not having a score results in an associated modifier of 0 (no bonus nor penalty). But it also has other effects depending on the ability score. I think this is implemented in ToEE via the Q_Critter_Has_No_Con_Score query, although I don't remember what exactly looks at that.
Anyhow, if you had a base con of 2, and a racial penalty of -2, the current code would turn that into a -3 penalty, so you'd have -1 con. And the game wouldn't actually kill you, because I don't think it actually monitors your con and kills you if it ever notices it going to 0 or below. You can actually get in that situation via raise dead, because if you have a -2 racial con penalty, it will think it's okay for you to be raised when your con is (4-2) ==> 3, which gets modified to (2-2) ==> -1.