So - in the interest of getting as much physics changes as possible done in a single hit - I think a good place to start is with the question:
When should we be able to assign which skills?Currently, the detection for this is quite a mess, for sure. However, we'll leave it to me on tidying up how it works behind the scenes, and focus more on the end results - what should or shouldn't be possible to do? We also won't worry about what exactly happens when the skill is assigned for now - just whether it can be assigned or not.
Let's look at what current checks are applied to assigning the various skills. Note that everything mentioned here is based off the code
with gimmicks (except zombies) removed.
In general, the approach when a skill assignment is attempted is:
1. First, find two lemmings (Lemming1 and Lemming2) - this will generally be the highest-priority and second-highest-priority lemming. Which lemmings are eligible (and prioritized or deprioritized) may be modified by things such as directional select; we will leave /that/ for another discussion.
2. If one of the two lemmings is a zombie, change the marked lemmings so that both Lemming1 and Lemming2 point to the non-zombie. (If both are zombies, stop trying to assign the skill.
3. If both lemmings are zombies, the assignment fails altogether.
4. Proceed to the skill-specific assignment code.
Note: Not all skill-specific code does actually check Lemming2. It will be specifically mentioned if it does.
Note: All skills also (obviously) have a check "does the remaining skillset have at least 1 of the skill being assigned". I won't specifically mention this during the steps.
1. Mark Lemming1 as "SelectedLemming" if it is currently performing one of these actions: Walking, Shrugging, Blocking, Platforming, Building, Stacking, Bashing, Mining, Digging.
2. If Lemming1 was not doing one of those, and Lemming2 is, mark Lemming2 as "SelectedLemming".
3. If we have a SelectedLemming, assigning Walker to it succeeds.
1. Check that Lemming1 doesn't already have the skill in question. If the skill in question is Floater or Glider, check it doesn't have the other one of those two either.
2. Check that Lemming1 is not performing one of these actions: Ohnoing, Exploding, Drowning, Burning, Splatting, Exiting. (Exception: Drowning is not checked for assigning Swimmer)
3. If both of the above checks passed, assigning the permanent skill to Lemming1 succeeds.
Bug noticed when writing topic: The "Exploding" state is only checked for in a Bomber explosion, not a Stoner explosion. The "Ohnoing" state is correctly checked for both skills.
1. Check that Lemming1 is not performing one of these actions: Ohnoing, Exploding, Drowning, Burning, Splatting, Exiting.
2. If the above check passed, assigning Bomber / Stoner to Lemming1 succeeds.
Bug noticed when writing topic: Like with the permanent skills, the "Exploding" state is only properly checked for with Bomber explosions. This one is more noticable - try assigning a Bomber or another Stoner, to a Stoner, on the exact frame of the explosion (click in the upper-left corner of the explosion graphic when assigning).
1. Check that Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Building, Stacking, Bashing, Mining, Digging.
2. Check that no blocker field already exists at Lemming1's position.
3. If both of the above checks passed, assigning Blocker to Lemming1 succeeds.
1. Check that Lemming1 is performing one of these actions: Walking, Shrugging, Building, Stacking, Bashing, Mining, Digging.
2. Check that at least one pixel in the area the first brick would cover is currently non-solid and so are the two pixels immediately above the 2nd and 3rd pixels of the brick (relative to the lemming's position / direction).
3. If these checks fail for Lemming1, perform them for Lemming2.
4. Whichever lemming (if either) they succeeded for first, gets successfully assigned Platformer.
1. Check that Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Bashing, Mining, Digging, or whichever one out of Building / Stacking is not currently being assigned.
2. If that check fails for Lemming1, perform it for Lemming2.
3. Whichever lemming (if either) passed the check is successfully assigned Builder.
1. Check that Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Building, Stacking, Mining, Digging.
2. If that failed, check if Lemming2 is. Whichever lemming it passed for (if any) is now "SelectedLemming".
3. If the pixel at 4 pixels in front of SelectedLemming and 5 pixels above SelectedLemming (by foot position) is steel or an incorrect one way, the assign fails (in the case of steel, a sound is also played).
4. If all of the above passed, SelectedLemming is successfully assigned a basher.
I know the steel check is weird. It's mostly a carry-over from vanilla Lemmix and probably needs improvement. The check during the actual bashing action is, IIRC, much better.
1. Check that Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Building, Stacking, Bashing, Digging.
2. If that failed, check if Lemming2 is. Whichever lemming it passed for (if any) is now "SelectedLemming".
3. If the pixel where SelectedLemming is standing is steel, the assign fails (a sound is played).
4. If the pixel 4 pixels in front and 5 above (like with the basher's checks) is an incorrect one way (but NOT if it's steel), the assign fails.
5. If all of the above passed, SelectedLemming is successfully assigned a digger.
And you thought the basher's checks were weird...
1. If the pixel where Lemming1 is standing is steel, the assignment fails (no sound is played this time).
2. Check if Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Building, Stacking, Bashing, Mining.
3. If that failed, check if Lemming2 is performing one of those actions and not standing on steel.
4. Whichever lemming the checks succeeded for becomes a digger successfully.
No, you're not interpreting that wrong. If Lemming1 is standing on steel, then the assignment will fail for Lemming2 too, even if Lemming2 isn't standing on steel. However, while these false negatives can occur, false positives cannot (as far as I can tell) - the assignment will never succeed on a lemming that is standing on steel. My only guess as to why is that it's something that slipped through from vanilla Lemmix, and since it's so obscure, never got noticed.
1. Check if Lemming1 is performing one of these actions: Walking, Shrugging, Platforming, Building, Stacking, Bashing, Mining, Digging, Jumping, Falling, Floating, Swimming, Gliding, Fixing.
2. If not, check if Lemming2 is.
3. Whichever the checks succeeded for first, the Cloner gets assigned successfully to that lemming.
I could swear I remember making it impossible to assign a Cloner to a Digger too, but the current code - and indeed, the results from testing the latest version - contradict that.
There's some areas where there's obvious room for improvement - the first of course being fixing the bugs with permanent skills / bombers / stoners assigning to in-explosion stoners - but I'd also like to get input from anyone else who has ideas too. Fire away!