Commit graph

129 commits

Author SHA1 Message Date
AJ Martinez
6173ca47aa SPB Attack: emblems/medals preliminary 2023-03-03 12:15:00 -08:00
toaster
182768aa32 Unlockable sounds updated
- Use sfx_achiev when any Challenge is completed
- If picking up MT_EMBLEM *doesn't* immediately complete a challenge, use sfx_ncitem as before
    - Bugfix: this sound is played even when online, which it wasn't previously doing (because the object couldn't be destroyed and play its sound)
2023-02-25 00:33:56 +00:00
toaster
339617a54e extras-challenges.c, M_UpdateChallengeGridExtraData: Be less lazy about reallocation
- Z_Calloc once, on menu load, instead of every time data changes
- Free once, on menu exit, instead of every time data changes
2023-02-24 19:10:44 +00:00
toaster
4380876959 Challenges Grid: create dedicated struct for menu extradata
- challengegridextradata_t
- Existing UINT8 data per entry has been converted to "flags" property
- This is a tool that will help us later.
2023-02-24 17:38:08 +00:00
toaster
f9f4d56850 m_cond.c/h: Copyright notice update
Intended to do this in my previous `unlockables-undefeatable` branch but forgot
2023-02-23 15:56:37 +00:00
James R
f05f040cea Fix faulty assertions 2023-02-14 00:46:54 -08:00
toaster
42969d8d15 M_CheckLevelEmblems: Support tagging ET_TIME emblems
An ET_TIME emblem with a nonzero tag is directly bound to a staff ghost's finish time. This will make late development medal implementation signifcantly easier.
2023-02-04 22:17:47 +00:00
toaster
f1e925553d M_CompletionEmblems: Fix check for ET_MAP 2023-02-04 20:33:19 +00:00
toaster
20b6a8389b Challenge grid population improvement
* Correctly identify that two columns with only one major unlock will have 6 empty tile slots, not two. This will result in less underutilised Challenges grid space.
2023-01-04 17:28:45 +00:00
toaster
2db7562c24 LF2_FINISHNEEDED
- Replacement for LF2_VISITNEEDED, which was itself a Kart-specific inversion of LF2_NOVISITNEEDED
- Prevents selection in time attack before you've beaten the level in another context (GP, or MP if applicable)
- Should be used for Sealed Stars (and Adventure Example) exclusively IMO, but usable for others too
Related adjustments:
- Allow a map to have a `TypeOfLevel` of 0 without error
- Change the Condition String for UC_MAPVISITED to "Finish a round on X" (previously "Beat X")
2022-12-31 16:22:46 +00:00
toaster
42f4f28e06 Statistics menu
Relatively quick port from v1., but with under-the-hood changes to match the Emblem/Medal and Extra Medal reworks. We can make it prettier (and contain more data) later.
2022-12-14 17:53:35 +00:00
toaster
2fbbe52ded Cache level ID for Emblems, too 2022-12-14 17:50:00 +00:00
toaster
c693be47f8 Fix possible out of bounds memory access for M_MapLocked 2022-12-14 17:30:39 +00:00
toaster
6545b693d4 Make level titles capitalised on Challenges menu 2022-12-14 17:29:22 +00:00
toaster
5bb149c47a Permit M_CheckNetUnlockByID if conditionset is zeroed 2022-12-13 22:20:06 +00:00
toaster
7081ffd509 Fixes and changes for Emblem system
- New `flags` field
    - Permits coexistence of var and flags
- `notMedal` boolean is now `GE_NOTMEDAL`
- New `GE_TIMED` flag
    - Disappears `var` tics after `starttime`
- Improved M_GetConditionString handling for specific Emblem grabs
- More explicit error handling for invalid Emblem
2022-12-13 22:19:37 +00:00
toaster
0e8c739efc Fix M_GetLevelEmblems to work with gamemap index (as it was used for) instead of mapheaderinfo index 2022-12-13 22:11:07 +00:00
toaster
dbb96dabd6 Fix M_UnlockableFollowerNum to work with followers whose names have spaces in 2022-12-13 22:10:35 +00:00
toaster
ff1574f80f Allow for marking Emblems as "not a Medal" via SOC definition
Also remove long-unused `hint` string
2022-12-13 17:48:35 +00:00
toaster
d5ab51fe38 Fixed unsignedness of M_UnlockableMapNum return type 2022-12-13 16:18:56 +00:00
toaster
0ef95875fa Fix copypaste typo for M_MapLocked 2022-12-13 16:15:48 +00:00
toaster
fc6eff65c2 Cache the result of M_UnlockableSkinNum/FollowerNum/MapNum/Cup
Improves performance on mapheader iteration for M_Map/CupLocked significantly.
2022-12-13 16:15:31 +00:00
toaster
2871ccb4f1 Rewrite level restrictions
Now uses `SECRET_CUP` and `SECRET_MAP` with a stringVar saying the map lump/cup name, instead of `SECRET_NONE` and a levelheader `unlockrequired` property.
2022-12-13 13:45:17 +00:00
toaster
76e290678f Groundwork for later commits
- Make the `SECRET_` constants an easily reshuffable `enum` instead of a series of byzantine `#define`s
    - Includes SECRET_CUP and SECRET_MAP in preperation
- Begin the conceptual seperation between Emblems (special in-level objects) and Medals (specific type of emblem that adds to the counter)
    - Rename UC_TOTALMEDALS and M_GotEnoughMedals, since the count is a Medals only thing
    - M_CountMedals, in addition to being renamed, now has an `all` boolean parameter since getting the total is no longer as easy as `emblems + extraemblems`
2022-12-13 13:07:46 +00:00
toaster
cc4518f80a M_DrawChallengePreview
Draws a preview of an unlock in the bottom left corner.
- Currently only supports unlocked ones (needs a roughly character-sized question mark graphic created)
- Currently only supports SECRET_SKIN and SECRET_FOLLOWER
Also, makes the area available to M_BuildConditionSetString smaller to avoid crossing into that region
2022-12-12 20:39:53 +00:00
toaster
cc9a65c8f8 Add unlock condition text to Challenges menu
Has ifdef'd out code for conditions to change between white and yellow when achieved to match V1 behaviour... wasn't able to figure out why it wasn't working, so dummied out for now.
2022-12-12 16:55:56 +00:00
toaster
81c9a7b928 Clean up the calculation of challengegridwidth to be more explicitly correct.
Also elegantly prevent the case where a non-looping grid stuffed to the brim with large tiles has them offset, preventing one tile from being placed.
2022-12-12 13:01:35 +00:00
toaster
f179a3523f Clean up M_UpdateUnlockablesAndExtraEmblems and related
* `gamedata->unlockpending[MAXUNLOCKABLES]` stores info to prevent the same unlock causing multiple sounds, and simplify `M_GetNextAchievedUnlock`
* Remove the DEVELOP cechotext
* Each unlock on the challenges menu updates all the unlockables, rather than just `M_CheckUnlockConditions`
* The unlock update function handles the incoming unlock sound itself if `loud` is true. This will allow us to quickly replace every sound at once when we've made a decision what to use

Also:
* Fixes the size of the savebuffer allocation in `G_SaveGame` to account for the challengegrid array.
2022-12-11 16:59:11 +00:00
toaster
0211bed1eb Fix the condition for non-net unlock check with M_SecretUnlocked to not trip if the host has it unlocked 2022-12-11 16:14:12 +00:00
toaster
d554856d04 No longer necessary to call M_CheckUnlockConditions twice in M_UpdateUnlockablesAndExtraEmblems 2022-12-09 17:29:16 +00:00
toaster
e7c79ab461 M_CheckNetUnlockByID
System for netsyncing unlocks, inspired by but with nowhere near as many moving parts as (STJr/SRB2!1756).
* `gamedata->unlocked[MAXUNLOCKABLES]` is duplicated to `netUnlocked[MAXUNLOCKABLES]` (or all `true` in `dedicated`
* New `local` boolean for M_SecretUnlocked
* Removed last vestiges of SRB2 special stage token code because it occupied the spot in the netsave we wanted to use.
* Correct typing of multiple `m_cond` functions that returned `boolean` constants as `UINT8`s.
2022-12-09 17:26:52 +00:00
toaster
be38ba1511 A heaping of polish
* Challengegrid now loops and scrolls horizontally.
    - Scroll position currently tied directly to selected row/column, but can (and will) be seperated relatively easily later.
    - In `DEVELOP` builds always scrolls - but in release builds, if someone makes a custom gamedata with less than 20 challengegrid columns (BASEVIDWIDTH/16), it'll remain static.
* Challenge ticker now automatically unlocks all pending at a rate of ~one per second.
    - Based on VC discussion and Kirby Air Ride.
    - Since no user input necessary, screen is now part-faded when unlocks are pending.
* Drawing a specific grid tile is now its own `k_menudraw.c` function.
* There is now a light grey grid around unselected tiles.
* Unlock explosions now use the tile's colour or, if not provided, the current profile's color.
2022-12-04 15:30:38 +00:00
toaster
fefaee1982 SECRET_FOLLOWER
Completely clientside, unlike SECRET_SKIN. Followers have no gameplay function, and it saves us having to write even more to our demos/netsaves. Replaces SECRET_WARP.
Also:
- Now don't apply skins or followers from profiles if the skin is locked - instead, get the closest skin in stats. (Same function as from demos!)
- If you're looking at a profile and the skin or follower are locked, make them solid colour (TC_BLINK).
- Don't show the ring cursor before you've selected a profile.
2022-12-04 01:09:08 +00:00
toaster
a33d6d9235 Fix level/cup unlocks
- M_MapLocked
    - If a level has a cup, will return true if that cup is locked
    - will return always false in marathon mode (not yet accessible, that'll be another branch's work, but thinking ahead)
- Getting rid of a bunch of index fudging caused by SINT8 rather than UINT8 - we can use MAXUNLOCKABLES as the special invalid value
2022-12-03 17:29:14 +00:00
toaster
d061dd09fd Removing extraemblem_t
- You can now create an unlockable that gives you an emblem only with SECRET_EXTRAEMBLEM.
    - One step above the completely rewardless squares from Kirby Air Ride.
- Added color to `unlockable_t`.
    - Can be used both with user-specified icons (remappable green->color) and with non-SECRET_SKIN default graphics (invincibility full-range remap)
- Replaced condition type UC_EXTRAEMBLEM with the more general UC_UNLOCKABLE.
- MAXUNLOCKABLES is now == MAXCONDITIONSETS
2022-12-03 14:52:58 +00:00
toaster
6671e181b0 Increase unlockable/conditionset limits
- MAXCONDITIONSETS is UINT8_MAX
- MAXUNLOCKABLES is (MAXCONDITIONSETS-MAXEXTRAEMBLEMS)
Haven't come to a decision yet on whether Extra Emblems should just be made with the Unlockable struct or maintain their distinct status, this commit kicks that can down the road
2022-12-03 11:40:58 +00:00
toaster
9df1f1d34c Unlock explosions are now slightly delayed
Done so it doesn't begin during a transition, and you get to properly appreciate the first one

Comes with the following changes and refactors:
* Uses the default UN_RR00c icons for entries without icons (currently all except SECRET_SKIN)
* `challengesmenu->extradata` updated in less places
* `M_GetNextAchievedUnlock` no longer handles setting `unlocked` so we can do that during the above timer
* Test button explosion repetition no longer duplicates M_ChallengesTick code
* Instead of giving `challengesmenu->currentunlock == MAXUNLOCKABLES` special behaviour, add a `challengesmenu->requestnew`
* The crash prevention for nonexistent extradata in the input handler is now actually functional.
2022-12-02 22:39:45 +00:00
toaster
3c915d8f68 Fix Challenge Grid population where multiple large tiles should be packed closely together 2022-12-02 21:18:47 +00:00
toaster
ac15d4caa3 Icon selection + Extras menu access
* Icon selection
    * You can use up, down, left, right, etc to select icons on the Challenges menu
    * The text at the top changes based on the highlighted icon
        * This text is now ??? if not yet unlocked
    * Uses the border for character rank icons
* Challenges are now accessible on the Extras menu alongside Addons and Replay Hut.
    * Previously there was a "Extras Checklist" dummy which did nothing when selected
    * Now I won't have to clear my gamedata every time I want to check this menu!
* M_ChallengeGridExtraData's array is modified to now contain specific info on whether a given tile is connected to above or left (or both).
2022-12-02 20:13:52 +00:00
toaster
85160b1dc1 M_ChallengeGridExtraData
Precalculates adjacency rules for challengegrid instead of doing it in the drawer
- Simplifies `M_DrawChallenges` a lot, at the expense of a pretty complicated function living in `m_cond.c`
- Handles registering entries both not to be drawn (for non-primary components of `majorunlock` unlockables) and for hint highlights (new for this commit)
    - Hint highlights are a sky blue
2022-12-01 21:55:05 +00:00
toaster
8dc2b6bf81 I_Error on failed challengegrid malloc 2022-12-01 16:57:30 +00:00
toaster
1391cbe01e M_PopulateChallengeGrid
Basic challenge grid data is now generated the first time you head to the challenges menu.
- Large tiles are placed first.
    - `UINT8 majorunlock` in `unlockable_t`.
    - Builds a list of all possible positions the first large tile could be plonked at.
    - Randomly selects from that list, then removes every position that overlaps the given spot before the next large tile is handled.
- Smaller tiles are filled into all the remaining gaps.
    - Currently bubbles gaps through the random list if empty spots after large tile placement > number of small tiles to place, but all the gaps could be forced to the end.
- Has a REALLY prelim drawer, literally just enough to confirm the tilegrid data is correct visually.
- DEVELOP: Can be regenerated by pressing (C) while the challenges are up.
Also, general maintenance.
- Remove `showconditionset`, `nocecho`, and `nochecklist` from `unlockable_t` for not fitting with our new intent for challenges
- Remove M_AnySecretUnlocked - Not currently used, but its eventual use - stopping a player from seeing a completely blank challenges grid - isn't in the spirit.
- M_MapLocked no longer permits all map transitions in DEVELOP, so unlocks can actually be tested.
2022-12-01 16:04:12 +00:00
toaster
5ba1d4c197 Unlocks now only get marked unlocked when heading to the main menu
EXTREMELY early, but...
- M_InterruptMenuWithChallenges hijacks certain transitions
    - Currently only initial profile selection and title screen, but the intercept is low-profile enough to add wherever necessary
- M_GetNextAchievedUnlock gets the first unlock in the listing that has all its conditions achieved but isn't unlocked
- Preliminary Challenges menu
    - Currently only ticks between Achieved but not Unlocked unlocks with the above function, no tilegrid yet
2022-11-30 17:26:33 +00:00
toaster
845fe12b52 Conversion to using gamedata_t
A small piece of (STJr/SRB2!1756).
Due to how RR currently handles time attack records and how it WILL handle unlocks, it's not currently feasible to split everything such that you can have two independent gamedata_t... but what's done so far is certainly more sane and less dependent on global variables
Other minor refactors:
- M_UpdateUnlockablesAndExtraEmblems and M_SilentUpdateUnlockablesAndEmblems are now one function with a boolean for loudness
- Unlock prints are currently living in the console, since the cecho stuff was a little broken
2022-11-30 13:19:21 +00:00
toaster
6d0637d39d Unlockable skins (in a way friendly to #define MAXSKINS 255)
Mammoth commit, sorry. I only realised halfway through writing it that SECRET_SKIN was only partially merged.

Ports from 2.2:
- Merge SECRET_SKIN (STJr/SRB2!1474)
    - Default skin is now handled by checking all skins for unlock status, and I_Erroring if none are available
    - Don't show skin names on game startup, to keep our secrets hidden
    - Unlockables now have string variables zallocated.
         - For skin names rather than numbers.
    - Correctly clean up memory when freeing unlockables and emblems.

Bespoke code:
- For temporary testing. `unlocks.pk3`
    - Using this for rapid testing gameboot SOC instead of patch.pk3 because of the intent to turn that into scripts.pk3
- Don't not save gamedata in DEVELOP builds, even if you've used cheats!
- `player->availabilities` is now an array of UINT8
    - (MAXSKINS + 7)/8 entries, or 32 bytes.
    - Included with XD_ADDPLAYER instead of XD_NAMEANDCOLOR.
         - Simplifies a lot of logic with respect to demos, skin changes mid-game, etc.
             - Seriously, there's a lot of random places in the code that just iterate over MAXSPLITSCREENPLAYERS and g_localplayers to update availabilities in real time in a way that's not particularly netsafe...
         - Lines up with the plan for handling unlocks when returning to menus.
         - Was included with XD_ADDBOT, but that actually overruns the netxcmd buffer at first mapload with 7 bots. We might need to consider expanding the size of the netxcmd buffer...
    - In demos, can be interpreted as both relative to the original replay and the current skin list depending on boolean context provided to R_SkinUsable.
    - Used for SF_IRONMAN (and will crash if all other skins are inaccessible).
- Grand Prix bot randomisation uses the host's unlocks.
- Don't show locked characters on the fancy new character select.
-  DXD_JOINDATA for demos
    - Replaces the dual-purpose behaviour of DXD_PLAYSTATE
    - Contains availabilities
    - Handles bot material in a different way
- Forceskin restrictions
    - Won't run in demos, because it's assumed recorded DXD_SKIN will handle all the conversions the original match had
    - Won't run if K_CanChangeRules says no
- Correctly set `mapvisited` on level visit, even in [fake gasp] MULTIPLAYER/NETGAMES!! 🥹
- Added updating unlockables and extra emblems on `mapvisited` update.
    - Currently fails to produce the cecho, but that'll be stripped out entirely in a future commit so I'm not bothered.
2022-11-27 22:53:29 +00:00
VelocitOni
1d2e1420f6 Merge branch 'master' into cheats-streamline 2022-09-25 14:27:17 -04:00
toaster
f5998c7624 Skip over locked maps/cups when getting nextmap
(carve out an exception for marathon mode, although we will probably want to lock that behind all cups available)
2022-09-23 20:52:51 +01:00
Sally Coolatta
117d791424 Merge branch 'master' into cheats-streamline 2022-09-23 14:38:54 -04:00
toaster
60355d9efd Move two of the three remaining NUMMAPS arrays part of the mapheader_t struct
- mapvisited and recorddata_t (previously mainrecords)
- Changed how gamedata is saved and loaded
- Change the versioncheck (funny hex provided by chengi) AND call it `developringdata.dat` in develop builds
- Fix a bunch of off-by-ones in condition and emblem data
ALSO, for Time Attack:
- Fix menu not showing off your times
- Now save times even when gamedata modified, since the menu didn't care (come back to it?)
- Don't save times or do intermission screen if the Capsule Attack ended because you lost all your bumpers
- Fix a crash adding ghosts in Capsule Attack
2022-09-21 22:12:36 +01:00
toaster
b68710faf2 Rework special nextmap events.
- G_MapNumber now handles special NEXTMAP_ nextmapspecial_t constants that exist at the end of the available type.
- Cleanup of G_DoCompleted
- Add bounds checking to the various SOC maincfg map starts (spstage_start, etc)
- Add lump checking to titlemap behaviour
2022-09-17 19:10:04 +01:00