Page 1 of 2

anotherpowerup.lua - and another one

Posted: Wed Apr 01, 2020 3:51 pm
by Emral
I woke up today with motivation to do this so here you go:
https://drive.google.com/file/d/1FeFLta ... sp=sharing
Gif: show
Image
How does it work?
This essentially replaces the fire and ice flower with whatever you want. It comes preinstalled with fire and ice flower replacements, and I included a little demo level with a Gold Flower to show how a custom powerup might be implemented.

Features:
- Technically infinite powerups. The biggest bottleneck is your motivation to make player hitboxes and spritesheets and code.
- As mentioned above, every powerup state can have its own hitboxes and spritesheets. Hitboxes must be named like "mario-powerupname.ini", so in the example for the gold flower that'd be "mario-ap_goldflower.ini".
- Every powerup gets onTick, onDraw, onTickEnd which run only when the powerup is active, as well as onEnable and onDisable for when the player switches to and fro.
- As a little additional feature, you can define powerup tiers, or just whether you would like to have the powerup turn into a mushroom when the player is small.
- Powerups save across levels.

Limitations:
- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks).
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.

Stuff:
-- registerPowerup registers a new powerup to the system
--- libraryName: string - The name of the library containing powerup information. One library per powerup. Think of it as a require(libraryName) call

-- Returns the library table for the powerup
ap.registerPowerup(libraryName)

-- Returns the player's current powerup, accounting for anotherpowerup powerups. Use this instead of player.powerup.
function ap.getPowerup()

-- Use this instead of setting powerup. Silent avoids the powerup animation and sound.
function ap.setPlayerPowerup(appower, silent)

-- registerItemTier registers a new tier chain for items.
-- spawnedItem: number - The item that spawns from a block.
-- chain: table - The list of states ordered by significance. Numbers correspond to vanilla states, strings correspond to the names of anotherpowerup powerups. See demo for more info.
-- if you provide chain as "true", it will accept everything except for small mario
function ap.registerItemTier(spawnedItem, chain)

Score is doubled up for vanilla powerup npcs but literally who cares.
If you make powerups for this make sure that they're clearly marked as anotherpowerup mods so people can find them.

Enjoy.

Re: anotherpowerup.lua - and another one

Posted: Wed Apr 01, 2020 5:28 pm
by Taycamgame
I thought it was currently impossible to add new powerups due to the Id system?

Re: anotherpowerup.lua - and another one

Posted: Wed Apr 01, 2020 5:43 pm
by ElectriKong
Taycamgame wrote:
Wed Apr 01, 2020 5:28 pm
I thought it was currently impossible to add new powerups due to the Id system?
Still is. This system just replaces fire and ice flowers.

Re: anotherpowerup.lua - and another one

Posted: Sat May 02, 2020 12:36 am
by FanofSMBX
"- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks)."

Can't one theoretically
1. Combine fire and ice mario into slot 3
2. Make slot 7 have a small hitbox
3. Code custom blocks (brick and turn block replicas) that do NOT smash if one is in form 7?

It's complex, sure, but if one is already making Mini Mario's floaty physics and water stuff then this should be possible.

Re: anotherpowerup.lua - and another one

Posted: Sat May 02, 2020 1:30 am
by Emral
FanofSMBX wrote:
Sat May 02, 2020 12:36 am
"- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks)."

Can't one theoretically
1. Combine fire and ice mario into slot 3
2. Make slot 7 have a small hitbox
3. Code custom blocks (brick and turn block replicas) that do NOT smash if one is in form 7?

It's complex, sure, but if one is already making Mini Mario's floaty physics and water stuff then this should be possible.
Points 1 and 2 dont even contribute to changing those properties, especially since anotherpowerup gives each powerup a string-index, and each powerup already can have its own hitbox (by means of loading/unloading them for player.powerup in onEnable and onDisable). If you REALLY wanna reprogram the powerup hierarchy and all brick blocks and enemy bounce physics... and prevent the player from riding a mount then ... maybe... you can get close to something that resembles mini mushroom, though the amount of effort to make it non-janky is not trivial.

Re: anotherpowerup.lua - and another one

Posted: Fri May 08, 2020 11:29 am
by Bulby_VR
um i think that it's bad that it causes an error when you try to pick up a power up with a incompatible character? Is it the power up itself or the inner script?

Re: anotherpowerup.lua - and another one

Posted: Fri May 08, 2020 12:35 pm
by Emral
Bulby_VR wrote:
Fri May 08, 2020 11:29 am
um i think that it's bad that it causes an error when you try to pick up a power up with a incompatible character? Is it the power up itself or the inner script?
Well, they're incompatible. I didn't optimize for those, because I figured an episode using this would hardly employ characters that don't work with it.

Re: anotherpowerup.lua - and another one

Posted: Sat May 09, 2020 12:51 pm
by Bulby_VR
ah, ok

Re: anotherpowerup.lua - and another one

Posted: Mon Jun 29, 2020 7:01 am
by ArtAddictedArchitect
So, apart from no mini Mario— what needs to get this useable? By making hit boxes do you mean importing the custom tiles for the new powerup you make or something else?

Re: anotherpowerup.lua - and another one

Posted: Mon Jun 29, 2020 7:49 am
by Emral
ArtAddictedArchitect wrote:
Mon Jun 29, 2020 7:01 am
So, apart from no mini Mario— what needs to get this useable? By making hit boxes do you mean importing the custom tiles for the new powerup you make or something else?
You need to use the player calibration tool in the data/pge folder to calibrate the hitboxes. Getting a powerup set up is inferrable from the included gold mario example.

Re: anotherpowerup.lua - and another one

Posted: Mon Jun 29, 2020 11:24 am
by MrDoubleA
I've been wondering... why exactly is the mini mushroom not possible? Couldn't the issues be avoided with onNPCHarm and onBlockHit, and onPlayerHarm?

Re: anotherpowerup.lua - and another one

Posted: Mon Jun 29, 2020 11:38 am
by Emral
MrDoubleA wrote:
Mon Jun 29, 2020 11:24 am
I've been wondering... why exactly is the mini mushroom not possible? Couldn't the issues be avoided with onNPCHarm and onBlockHit, and onPlayerHarm?
Potentially.

Re: anotherpowerup.lua - and another one

Posted: Mon Jul 13, 2020 1:21 pm
by MrDoubleA
I've been using this library for a bit, and I have a couple bugs/annoyances to share.

- If you pick up a custom powerup but you already have that powerup, it'll still play the animation.
- When picking up a custom powerup, often times the wrong powerup will appear in the item box. This could maybe be fixed by setting 0x46 to the NPC ID of the powerup (though it'd need to happen after the animation happens, and therefore outside of the setPlayerPowerup function).
- Not a bug, but it'd be really nice to let the sound effect played when grabbing it be customisable.
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.
- Link's projectiles have a dedicated timer, so you can just do this every tick:

Code: Select all

player:mem(0x162,FIELD_WORD,29)
As for the x2 characters... I don't really think anybody cares about those lol


Good job on this, though! It's really nice to have a functional custom powerup library.


Edit: There's also some bugs with the fire/ice flower recreations:
- Both don't spawn fireballs when spin jumping.
- Fire flowers (but not ice flowers) give this error:
Error: show
Image

Re: anotherpowerup.lua - and another one

Posted: Mon Jul 13, 2020 1:51 pm
by Emral
Thanks for pointing these out! I'll get to fixing them when I have time. I'll reply here when that's happened.

The spinjump thing is actually intentional. Mostly because platforming with a fire flower or ice flower is pretty miserable otherwise. Part of it is also though that I'm not sure how to best do it... Maybe I could make it toggleable if I find that out.

Added in 3 hours 16 minutes 14 seconds:
... alright... Updated the file with a few fixes and experiments.
- Link support? I guess? I'm not sure? The existing powerups don't work with them the way they're written, but the script at least won't outright reject link now. I don't really feel like dealing with link code in the example powerups tbh, but maybe he'll work for further custom ones.
- Fixed the fireflower crash
- You can now have .apSounds table in your powerup file for the upgrade and reserve storage sound effect. Check gold flower for an example. If you wanna change it per character, adjust it upon character change on your end.
- Redesigned the powerup distribution mechanism. Instead of spawning an item on the player it now manually sets the relevant offsets.
- Hopefully fixed reserve powerup distribution as well?

Known issues:
- No change to the way fireball spinjumping works. You can still manually shoot fireballs throughout a spinjump, however.
- Because fire and ice flower in the basic example only use the basegame powerup, there are some duplicate effects, and sometimes the wrong sound effect for the animation plays. The solution here is to introduce new powerup items for those states.
- Still no multiplayer. I toyed around with the idea a little bit, but it's getting late and I don't consider it a priority.

Re: anotherpowerup.lua - and another one

Posted: Wed Jul 15, 2020 6:10 pm
by MrDoubleA
Thanks for the update! There's just 3 new bugs I've found recently. (Sorry for all the hassle...)

- The reserve powerup is much more functional now, though it still doesn't seem to work 100% properly.
you're a mouse? - If you collect a custom powerup with nothing in 0x46, you'll get the custom powerup in the item box for whatever reason
you're a mouse? - If you collect a normal powerup while having a custom powerup, a fire/ice flower will appear in the item box
(you should just be able to set 0x46 and reservePowerup appropriately when getting a custom powerup, since 0x46 isn't cleared on level load, though I don't know what's going on with that latter bug)

- The player's frame doesn't get reset to 1 like it normally does when picking up a custom powerup, resulting in the animation almost always looking odd when transforming from small mario)
- Costumes do not work with the fire/ice flower recreations

Edit: it also seems that hitting a block containing a non-custom powerup gives this error:
Error: show
Image

Re: anotherpowerup.lua - and another one

Posted: Tue Sep 29, 2020 5:03 am
by Marioman2007
Wow, I was just looking for a Gold Flower, Thanks. But I replaced the golden mario and Gold ball sprites with the one that lx xzit made. I want to ask you one question is it possible to add an sparkling effect and golden trail like the fire flower (effect-77) ?

Re: anotherpowerup.lua - and another one

Posted: Tue Mar 23, 2021 12:32 pm
by timocomsmbx2345
For some reason I still get an error when I hit a block with a fire flower in it, even within the demo.

Re: anotherpowerup.lua - and another one

Posted: Fri Jun 18, 2021 4:21 pm
by Emral
Thanks to MrDoubleA, the reserve item bug is now fixed! Big thanks to them.

Re: anotherpowerup.lua - and another one

Posted: Sat Sep 04, 2021 8:18 am
by Zaturno Dominicano
Enjl wrote:
Wed Apr 01, 2020 3:51 pm
I woke up today with motivation to do this so here you go:
https://drive.google.com/file/d/1FeFLta ... sp=sharing
Gif: show
Image
How does it work?
This essentially replaces the fire and ice flower with whatever you want. It comes preinstalled with fire and ice flower replacements, and I included a little demo level with a Gold Flower to show how a custom powerup might be implemented.

Features:
- Technically infinite powerups. The biggest bottleneck is your motivation to make player hitboxes and spritesheets and code.
- As mentioned above, every powerup state can have its own hitboxes and spritesheets. Hitboxes must be named like "mario-powerupname.ini", so in the example for the gold flower that'd be "mario-ap_goldflower.ini".
- Every powerup gets onTick, onDraw, onTickEnd which run only when the powerup is active, as well as onEnable and onDisable for when the player switches to and fro.
- As a little additional feature, you can define powerup tiers, or just whether you would like to have the powerup turn into a mushroom when the player is small.
- Powerups save across levels.

Limitations:
- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks).
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.

Stuff:
-- registerPowerup registers a new powerup to the system
--- libraryName: string - The name of the library containing powerup information. One library per powerup. Think of it as a require(libraryName) call

-- Returns the library table for the powerup
ap.registerPowerup(libraryName)

-- Returns the player's current powerup, accounting for anotherpowerup powerups. Use this instead of player.powerup.
function ap.getPowerup()

-- Use this instead of setting powerup. Silent avoids the powerup animation and sound.
function ap.setPlayerPowerup(appower, silent)

-- registerItemTier registers a new tier chain for items.
-- spawnedItem: number - The item that spawns from a block.
-- chain: table - The list of states ordered by significance. Numbers correspond to vanilla states, strings correspond to the names of anotherpowerup powerups. See demo for more info.
-- if you provide chain as "true", it will accept everything except for small mario
function ap.registerItemTier(spawnedItem, chain)

Score is doubled up for vanilla powerup npcs but literally who cares.
If you make powerups for this make sure that they're clearly marked as anotherpowerup mods so people can find them.

Enjoy.
Hey could you upload the files of the golden flower? it looks very cool

Re: anotherpowerup.lua - and another one

Posted: Sat Sep 04, 2021 10:05 am
by Marioman2007
Zaturno Dominicano wrote:
Sat Sep 04, 2021 8:18 am
Hey could you upload the files of the golden flower? it looks very cool
It is contained with the download