as you'd guess from the title, this aims to make the reserve box function like it does in SM3DL/SM3DW, with some added SMBX mannerisms.
such as:
- items default to being held (barring some already defined exceptions)
- auto held when first spawned (configurable)
- if riding yoshi, any holdable items are placed in yoshis mouth. (given yoshi can eat them in the first place)
- if in a clowncar, it spawns the npc on the players car on the side the player is facing.
- can spawn a holdable item while warping, only if the warp allows items.
- near every aspect is configurable. (see documentation for more)
scenarios: show
- in in the overworld.
- if in a launch barrel.
- all forced animation states. (aside from warping/using a clearpipe) all states can be found here.
- if a warp doesn't allow items or modernReserveItems.allowHeldItemsInWarps is false.
- is climbing on a vine. (held only)
- yoshi can't usually eat the item (held only)
- if yoshi's mouth is full. (held only)
- if mounted in a boot. (held only)
- if the player's hands are full. (held only)
- if using the tanooki statue. (held only)
- if currently dead.
- if the level is considered won.
- if any of the "modernReserveItems.allowX" options are false (per-case basis)
this mainly came about as a accessibility option for DA:E, but upon thinking about the best implementation, i figured others may also like said feature.
here's a showcase video for all the action:https://streamable.com/whte3v
how to use & documentation: show
this section assumes you have some knowledge of lunalua/lua. if not, then the only thing you need is the next two lines.
to start, use this to load it after which you can be on your way if your content with the default settings.
but if you'd rather do some tinkering, here's a breakdown of how to do so for individual npcs:
this will make smb3 goombas thrown rather then held when dropped. there is a function for seting multiple at once as well:
(not every value needs to be set here)
let's go over all that:
to start, use this to load it
Code: Select all
local modernReserveItems = require("modernReserveItems")
but if you'd rather do some tinkering, here's a breakdown of how to do so for individual npcs:
Code: Select all
modernReserveItems.config[1].isHeld = false
modernReserveItems.config[1].isThrowm = true
Code: Select all
modernReserveItems.setConfigs(npcID, {speedX=number, speedY=number, isHeld=bool, forcedState=number, isThrown=bool, doesntMove=bool, sfx=number or string of sound file, yoshiSFX=number or string of sound file, idOverwrite=number, ai1-ai6=number, data={variable=value}})
let's go over all that:
- npcID - fill this with the npc ID you want to change the settings for.
- speedX/speedY - sets the speedX/Y upon it's spawn.
- isHeld - is used to determine if the item should be held upon spawning it. set to false if you intend to use one of the two other flags to determine behavior.
- forcedState - (currently only used by the reserve stopwatch) is used to determine misc behavior upon spawning it. see this page for more details on NPC forcedStates.
- isThrown - is used to determine if the item should be thrown upon spawning it. set to false if you intend to use one of the two other flags to determine behavior.
- doesntMove - (only applies to isThrown items.) if the item should not move upon spawning. sets the projectile flag for this to work properly, may lead to accidental npc kills. you have been warned.
- sfx - the sound played upon the npc's spawn. does not play if modernReserveItems.playSounds is false, also doesn't play a sound for isContained items.
- yoshiSFX - the sound played upon a held npc's spawn while riding yoshi. does not play if modernReserveItems.playSounds is false.
- idOverwrite - changes the id of the spawned npc. good for container npcs. (currently only used for proper yoshi spawning. lest we forget...)
- ai1-ai6 - the ai values to be set upon spawning. see this page for more information.
- data - variables to set in the npc's data fields upon spawn. (not used by anything predefined, mainly added for the neatness of the feature)
- modernReserveItems.enabled - bool;whether or not the library is allowed to run. good for making it an optional setting. true by default.
- modernReserveItems.autoHold - bool;if the library is allowed to auto hold the run button for a short time after spawning isHeld npcs. true by default.
- modernReserveItems.timeAutoHeld- number;how long AutoHold will hold npcs in enabled. 32 by default.
- modernReserveItems.playSounds - bool;if the library should play sounds upon spawning npcs. true by default.
- modernReserveItems.playerXMomentum/modernReserveItems.playerYMomentum - number;how much to times the player's speedX/speedY by before adding it to the spawned npc's speedX/speedY. i recommend decimal numbers, such as 0.5 or so. 0 by default.
- modernReserveItems.allowThrownItems - bool;a flag to disable thrown items from being spawned. good for user edge cases. true by default.
- modernReserveItems.allowHeldItems - bool;a flag to disable held items from being spawned. good for user edge cases. true by default.
- modernReserveItems.allowHeldItemsInWarps- bool;a flag to disable held items from being spawned in warps/clearpipes. good for user edge cases. true by default.
- modernReserveItems.allowForcedStateItems - bool;a flag to disable forcedStateitems from being spawned. good for user edge cases. true by default.
- modernReserveItems.allowAnyItems - bool;a flag to disable all items from being spawned. good for user edge cases. true by default.
- modernReserveItems.spawnLayer - string;determines what layer the npc is given on spawn. "Spawned NPCs" by default.
- modernReserveItems.useBuiltInDrop - bool;a third flag that gets checked alongside modernReserveItems.enabled and isOverworld. good for systems where you need to use modernReserveItems.drop without changing modernReserveItems.enabled. true by default.
- modernReserveItems.offScreenDespawn - number;determines how many ticks the npc can be offscreen before being despawned. 3600 (or 60 seconds) by default.
- modernReserveItems.drop(npcID, p) - function;used to spawn a reserve item. can be used to integrate modernReserveItems's system into external ones. returns the spawned NPC reference or nil if failed. will require modernReserveItems to be loaded in the same file to use.
- npcID - npc ID (intended for player.reservePowerup)
- p - player object. - modernReserveItems.validityCheck(npcID, p) - function;used to resolve conditions which .drop() can be used. can also allow external libraries to check the conditions without needing to recreate them. returns false upon meeting any criteria in it, otherwise returns true. see scenarios spoiler for details. will require modernReserveItems to be loaded in the same file to use.
- npcID - npc ID (intended for player.reservePowerup)
- p - player object. - modernReserveItems.onReserveUse(eventObj, npcID, p) - function; used to run code upon modernReserveItems.drop being called. will require modernReserveItems to be loaded in the same file to use.
- eventObj - used as any other lua event object. doing eventObj.cancelled = true will cause modernReserveItems.drop to abort and return nil.
- npcID - the current ID being used by modernReserveItems.drop
- p - the current player object being used by modernReserveItems.drop
Example code is included in the download as testLib.lua. - modernReserveItems.onPostReserveUse(npc, p) - function;runs after modernReserveItems.drop successfully executes. npc being the npc resulting from modernReserveItems.drop and p the player object it was using. will require modernReserveItems to be loaded in the same file to use.
- npc - npc object resulting from a successful drop
- p - player object.
known bugs: show
N/A
changelog: show
-- v1.2 (2/18/2023) --
- fixed a mass typo of "pattren".
- made it use onInputUpdate instead of onTick. preeettty sure that won't change anything...
- adjusted items being spawned whilst riding yoshi. fixing yoshi ducking/opening their mouth for a frame.
- renamed the npc variable for modernReserveItems.drop from "spawned" to "MRINPC". was having issues with other npc variables of the same name somehow referencing it.
- added modernReserveItems.spawnLayer (string). see the documentation for more info.
- moved all validity checking to modernReserveItems.validityCheck(ID, p). see the documentation for more info.
- now checks if the player's dead or if the game is in a winning state as well. - modernReserveItems.drop(ID, p) now returns nil on an event cancel from modernReserveItems.onReserveUse (see documentation) or the npc object it spawns.
- added modernReserveItems.onReserveUse(eventObj, ID, p, throwSettings). see the documentation for more info.
- added modernReserveItems.onPostReserveUse(npc, p). npc being the npc resulting from modernReserveItems.drop and p the player object. see the documentation for more info.
- modernReserveItems.resolveThrowSettings(npcID, field) is now usable by external sources. see the documentation for more info.
- added modernReserveItems.useBuiltInDrop (bool). see the documentation for more info.
- added modernReserveItems.offScreenDespawn (number). see the documentation for more info.
- adjusted item coordinates calulations, fixing a few oddities with using reserve items on mounts.
- this causes isMega to become unused. it is now left in for users instead. - added an entire system to handle projectile npcs killing other npcs, fixing powerups dying to what ever is in their way. (lightly tested;may have missed edge case.)
- fixed up original post and added more documentation.
- rebuilt/took config system from npcconfig_core.lua. this reduces alot of repeat code.
- patterns have been completely removed as a result of the config system overhaul.
- resolveThrowSettings has been removed due to config overhaul as well.
- removed an unnecessary loop for warp checking.
- more code comments (for personal rememberance).
- any mem addresses that have field equivalents in B5 have been updated.
- isMega has been completely removed.
- isContained & containedID have been combined into one config, forcedState.
- allowContainedItems has been renamed allowForcedStateItems as following the config renamed
- isEgg has been replaced by idOverwrite. useful for container npcs.
- SFX has been renamed to sfx.
- the ai config table has been separated into indivdual ai# fields (1-6).
- onReserveUse has lost the throwSettings argument following config overhaul.
- fixed onPostReserveUse not returning the resulting npc from .drop
- onReserveUse and onPostReserveUse have been made to work across mulitle lua files (see included example materials for how)
included in the download is example material and offline docs & changelog (just some txt files).
feel free to suggest things, bug report, or what have you. have a nice day.
