Author Topic: [SUG] Infinite Skills hotkey  (Read 1038 times)

0 Members and 1 Guest are viewing this topic.

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
[SUG] Infinite Skills hotkey
« on: May 18, 2023, 06:15:54 AM »
I'm attempting to implement a hotkey which sets the skill count of the current level to infinite-of-each (types remain the same).

It's easy enough to make the count change happen (barring a few wierd bugs when backskipping). The real problem I'm having is that it isn't as simple as just "set the skills to infinite, and then change them back later if you want" because if the level provides 5 of something, you set it to infinite and then use 6, what should happen when you press the hotkey again?

I can think of 5 possibilities:

1) Once applied, the skill count stays infinite until the level is restarted. Pressing the hotkey again doesn't change the count again at all. This is easiest to achieve and probably makes the most sense.

2) The count resets to the originally available count. This might seem to make sense, but if a player is already halfway through the level having used an infinite count to get there, then the original count becomes fairly meaningless. They might as well just continue with the infinite count.

3) The count resets to the originally available count, and restarts the level. Better, but might seem a bit jarring.

4) The count resets to the originally available count, minus the skills used, and any minus counts just show as zero. This option is slightly better than the second option, but would be the most difficult to manage code-wise and is fairly pointless seeing as we have a "used skills count" which would be far more useful in this scenario.

5) Keep the count at infinite, and toggle the used skills count on. This one also makes pretty good sense having considered the middle 3 options, but has the potential to be the most confusing.

Option 1 is my favourite. I think that if a user has chosen to switch on infinite skills, they've committed to playing the rest of the level with that option enabled, and so it should remain active until the level is either completed or restarted. The only problem with it is if the player accidentally hits the key without meaning to.

Another complication is replays: ideally, toggling infinite skills should be written into the replay so that any replays used with an infinite count on would make sense to the viewer, and wouldn't be broken by simply watching them without infinite skills.

Also, any levels played with infinite skills on shouldn't count towards level records, for obvious reasons. This would need to be managed as well. I think SLX might just be too complex an engine to deal with a feature like this.

I could do with some feedback on this. Do people think it's worth implementing the feature at all? What would you expect to happen if you pressed the hotkey again? Would you use it if it was there? I'm currently about 70:30 in favour of just chalking it up to "it's a good idea, and fun to do, but probably isn't worth the trouble."
« Last Edit: May 18, 2023, 06:21:05 AM by WillLem »

Offline Simon

  • Administrator
  • Posts: 3871
    • View Profile
    • Lix
Re: [SUG] Infinite Skills hotkey
« Reply #1 on: May 18, 2023, 10:53:13 AM »
More possibilities:

101. Erase the extra assignments (those that have become illegal due to the reinstantiated cap from deactivating infinite mode) from the replay, and roll back physics updates to before you used the first extra. This works even when you don't write into the replay the action of making infinite skills. If there exist now-illegal assignments, roll back to before the first illegal assignment.

It's possible to have junk assignments from insert mode. (If you only have 5 platformers available for the whole level and have assigned them all, then go back and insert platformer assignments before they have been ''used," then the future assignments will now fail. The junk assignments are those failing future assignments.) But those are a separate design problem anyway. Might as well still treat the first illegal assignment as to where we roll back, it should be fine.

102. Create one extra savestate on entering the sandbox, and revert to that savestate. Does NL save everything on savestate or does NL still merely bookmark a physics update (= a single number) and call that a savestate?

-- Simon
« Last Edit: May 18, 2023, 11:02:06 AM by Simon »

Offline jkapp76

  • Posts: 377
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #2 on: May 18, 2023, 02:02:22 PM »
I don't know if I'd use this feature much, but I think option 1 seems okay.

Super Lemmini used to have a pretty cool "R" logo that swelled and animated in the right screen corner to let people know you were watching a replay. This was a nice touch. You could adopt this idea and add a different letter "?" to let the viewer know infinite skills is enabled. You could go full modern and add things like "Pause" and "FFWD" too.
« Last Edit: May 18, 2023, 02:39:46 PM by jkapp76 »
...Jeremy Kapp

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #3 on: May 18, 2023, 06:56:11 PM »
Super Lemmini used to have a pretty cool "R" logo that swelled and animated in the right screen corner to let people know you were watching a replay

Yes, I like that as well. As soon as I can figure out how to draw stuff to the screen in real-time (not as easy as you might think - I'm currently struggling with those Visual SFX you requested!), this will likely replace the current "R" marker on the panel. And yes, a visual cue for "infinite skills mode" (if implemented) would be good as well.



There is in fact way more complexity around the Infinite Skills hotkey than I originally anticipated. For example, if a player beats a level which normally requires at least 1 Miner, but uses infinite skills and therefore doesn't use Miners (because the infinite count allows other skills to be used instead), this gives an inaccurate "Skills You Can't Live Without" reading for that level in the player's records. Not to mention that it would mess with the records in general, due to its potential for allowing otherwise impossible results.
« Last Edit: May 22, 2023, 12:32:17 AM by WillLem »

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #4 on: May 22, 2023, 12:43:38 AM »
Reading back over Simon's comments today:

101. Erase the extra assignments (those that have become illegal due to the reinstantiated cap from deactivating infinite mode) from the replay, and roll back physics updates to before you used the first extra

I like this idea. The infinite skills action needs to be written to the replay for various reasons*, so un-toggling it could just delete that action (and that action only). Then, any legal assignments following it would play out as normal.

*backstepping even once cancels it, presumably because backstepping uses the replay up until that point, also it means replays can be shared with the infinite skills toggle written into them

102. Create one extra savestate on entering the sandbox, and revert to that savestate

I think this could be the answer, the more I think about it.

So, toggling Infinite Skills ON would do the following:

1) Set skills counts to infinity-of-each
2) Write the action into the replay
3) Create a Savestate (S) at that frame
4) Set variable 'InfiniteSkills' to "true"

Whilst 'InfiniteSkills' is "true":

1) No player records are observed
2) The level cannot be "completed", but the player can finish the level
3) We might need a different text in the postview screen prompting the player to try the level again without infinite skills, maybe

Toggling Infinite Skills to OFF does the following:

1) Play resets to Savestate (S)
2) The infinite skills action is deleted from the current replay (all legal actions following this play out as normal)
3) Variable 'InfiniteSkills' is set to "false"

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #5 on: March 17, 2024, 01:59:00 AM »
Made some small progress on this today.

I can set infinite skills and write the hotkey press to the replay, all good. The problem is reading it from the replay: it isn't entirely clear how the codebase interprets replay data and converts it into in-game actions; it seems to be different for different things, which means there isn't a model train I can jump on.

Maybe Nuke... but this is written as a skill action. Spawn Interval changes are too complex to use as a guide. Urgh, need sleep :sleep: I'll come back to this some other time.

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #6 on: March 17, 2024, 02:59:10 PM »
Had another look at this today and made a bit more significant progress.

The replay item is now written and read correctly. However, only the hotkey actually sets the skill count to infinite: replay items currently don't achieve this by themselves: replay items rely on a bool flag, which works when manually backskipping past the infinite skills action, but not when loading a saved replay into a fresh game instance. This will need to be addressed.

Meanwhile, pressing the hotkey again after setting infinite skills jumps back to the original infinite skills action: perfect! Currently, a bool flag is used to reset the original skill count (minus any skills used) and prevent the skills getting set to infinite again.

However, it would be far better to actively delete the infinite skills replay item instead. Note to self: see // Infinite Skills bookmarks for a possible way to achieve this. Bool flags are weak and problematic. The replay item should always set the skill count to infinity, and there should only ever be one (although, multiple nuke items can be written into a replay and this doesn't seem to matter...)

That way, playing back a replay with an infinite skills item will set the count to infinite: that's what we want. If a player uses the hotkey in-game and then later cancels by pressing it again, the replay item(s) should be deleted altogether.

Getting somewhere with it slowly. A walk and some quality time with my better half is what's needed for the rest of today.

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #7 on: March 18, 2024, 12:08:09 PM »
OK, this is looking good.

The infinite skills hotkey method now checks for an existing Infinite Skills replay event prior to the current frame as its first and foremost priority.

If it finds one (and, it only cares about the very first if there are multiple existing events for any reason), it then:
  • Logs the Infinite Skills event frame
  • Skips back to that frame
  • Deletes all future existing Infinite Skills replay events (important, so that the state isn't triggered again by a future event)
  • Resets all skill counts to (the original count - any skills used (N.B. all skill assignments are preserved))
  • Sets the InfiniteSkillsMode flag to false
If it doesn't find one, it then:
  • Sets all skill counts to infinite
  • Sets the InfiniteSkillsMode flag to true
  • Records the event in the replay
Meanwhile, if an event is found whilst playing back a replay, the skill counts are all set to infinite and the InfiniteSkillsMode flag is set to true.

Also, toggling Infinite Skills on doesn't cancel the existing replay - so, if at any point a player wants to go back and reactivate Infinite Skills after deactivating it, all future skill assignments will play out as normal. And of course, if the mode is toggled off, assignments made beyond the original skill count being exhausted simply won't play out (but will be preserved in the replay).



Next steps:

1) Check for InfiniteSkillsMode when setting level records. If true, count the level as attempted but not passed, and do not save any user records for lems saved, time, skill counts, etc. If false, proceed as normal.

2) Check for InfiniteSkillsMode in postview. Display the text "This level was played in Infinite Skills mode - Go back and try again some other time" (or something similar) in place of the usual "You saved every lemming on that level, etc".

3) The Infinite Skills replay events are currently not displayed in the replay editor form, despite everything to do with replays working correctly elsewhere - find out why, make sure the events are displayed.

Offline WillLem

  • Moderator
  • Posts: 3384
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG] Infinite Skills hotkey
« Reply #8 on: March 18, 2024, 06:43:17 PM »
This feature is now complete!

With Infinite Skills mode active, the skillset is set to infinity across the board, and the icon is shown in blue to provide further visual feedback and differentiate it from a skillset (or individual skill) which may be set to infinite by the level designer:



With the mode active, the level can be played and completed, but no records are saved. So, if using the feature to see how many lemmings it would be possible to save given infinite skills (as an example use case), the save count will be displayed on the postview screen as usual, but any existing user record will not be updated.

When cancelling the mode (by subsequently pressing the hotkey again), gameplay skips back to when Infinite Skills mode was originally activated, resets the original skill count (minus any skills used prior to Infinite Skills mode being activated), but keeps all future replay actions intact until cancelled or overwritten by usual gameplay.

(Also managed to get Infinite Skills replay actions to show in the Replay Edit dialog list as well) :)

Looking forward to releasing this one! It should hopefully prove to be a very useful tool for solution experimentation, level creation, challenges, and much more besides :lemcat:

Implemented in Commits c060401d6 - 74e733404
« Last Edit: March 18, 2024, 06:54:30 PM by WillLem »