Page 1 of 2

GroundPound.lua - pound the ground! [v1.4]

Posted: Sat Sep 10, 2022 9:35 am
by Marioman2007
Another ground pound script.

Showcase:
Spoiler: show
Image

Credits
Spoiler: show
Marioman2007
Emral

LxXzit (Player frames)
CursedMario (Player frames)
OneTonShoe (SMW player frames)
Master of Disaster (Pound switch)

Changelog
Spoiler: show
1.1:
Fixed the pound killing generators and the score system.
1.2:
Lots of fixes, multiplayer support, pound filters and pound switch.
1.3:
Fixed various issues - error when not having a character registered, getting stuck on slopes, p-switch related issues etc, players can now automatically enter pipes (quickPipes.lua required) and clearpipes, functions to render the player or to override render data.
1.3.1:
Added npc whitelist and blacklist, fixed some overights in code.
1.3.2:
Added support for costumes and SMW styled sprites for mario and luigi, and peach's hover doesn't interfere with GP now.
1.4:
Updated the library with the new player fields, slightly refactored the code, fixed an issue with vines, (re)added the score combo

Download
https://drive.google.com/file/d/1nS5bub ... sp=sharing

Basic usage:

Code: Select all

local GP = require("GroundPound")
GP.applyDefaultSettings()
Frequently asked code snippets:
Spoiler: show
These are some code snippets which have been asked before. To use these, put them in your luna.lua file after loading GP.

Ability to destroy chain chomp posts:

Code: Select all

-- chain chomps
-- allows the player to destroy the chain chomp post
GP.registerCustomNPCFunc(650, function(v, p, combo)
    v:kill()

    local n = v.data.attachedNPC

    if n and n.isValid then
        n:mem(0x12E, FIELD_WORD, 30)
        n:mem(0x130, FIELD_WORD, p.idx)
    end

    local e = Effect.spawn(76, v.x + v.width/2, v.y + v.height/2)
    e.x = e.x - e.width/2
    e.y = e.y - e.height/2
end)

Bounce higher upon pounding a spring:

Code: Select all

local function setSpringFunc(id, checkDirection, speed)
    GP.registerCustomNPCFunc(id, function(v, p, combo)
        if checkDirection and v.direction ~= -1 then
            return
        end

        local launchSpeed

        if speed ~= nil then[spoiler][/spoiler]
            launchSpeed = math.abs(speed)
        else
            local config = NPC.config[id]
            launchSpeed = math.abs(config.force) + 2
        end

        p.speedY = -launchSpeed
        
        -- these are taken from scripts/npcs/ai/springs.lua
        p:mem(0x00, FIELD_BOOL, p.character == CHARACTER_TOAD and (p.powerup == 5 or p.powerup == 6))
        p:mem(0x0E, FIELD_BOOL, false)
        p:mem(0x18, FIELD_BOOL, p.character == CHARACTER_PEACH)
    end)
end

-- these allow the player to jump higher when pounding on a spring
setSpringFunc(26, false, 20) -- SMW green spring
setSpringFunc(457)           -- SMW red spring
setSpringFunc(455, true)     -- SMB1 red spring
Snippets in action:
Spoiler: show
Image

Settings are at the top of the file.
Give credits if used!

Re: GroundPound.lua - pound the ground! [v1]

Posted: Sat Sep 10, 2022 3:40 pm
by Registered sand eater
I decided to make a smw version cause why not.
Spoiler: show
Image

Download link:
Spoiler: show

Re: GroundPound.lua - pound the ground! [v1]

Posted: Thu Sep 15, 2022 6:53 am
by Mushroom King
Would it be possible to make the ground pound use the down button while in midair (crouching) and not the spin jump button?

Re: GroundPound.lua - pound the ground! [v1]

Posted: Thu Sep 15, 2022 10:19 am
by Marioman2007
Mushroom King wrote:
Thu Sep 15, 2022 6:53 am
Would it be possible to make the ground pound use the down button while in midair (crouching) and not the spin jump button?
Yeah its possible, but for a game where you can crouch in mid air it will be dangerous (for example, purple yoshi)

Re: GroundPound.lua - pound the ground! [v1]

Posted: Sun Oct 02, 2022 10:20 pm
by Mal8rk
I wish you could change which blocks you could destroy and which ones you couldn't, cause' I've seen that you can break on & off blocks and things like that

Re: GroundPound.lua - pound the ground! [v1]

Posted: Sun Oct 02, 2022 10:53 pm
by Marioman2007
Mal8rk wrote:
Sun Oct 02, 2022 10:20 pm
I wish you could change which blocks you could destroy and which ones you couldn't, cause' I've seen that you can break on & off blocks and things like that

You can't change the blocks. However, you can prevent blocks from being destroyed:

Code: Select all

local avoidedBlocks = table.map{id1, id2} -- you can always add/remove IDs here

function onBlockPound(event, v)
    if avoidedBlocks[v.id] then
        event.cancelled = true
    end
end

Re: GroundPound.lua - pound the ground! [v1]

Posted: Tue Oct 25, 2022 10:12 pm
by Ness-Wednesday
Great work! I spent a lot of time toying with this for the last two days, and it feels much smoother than the old ground pound. In no way was the old ground pound bad, but there were a few perks I had with it. Namely with how it interacted with destroyed blocks and sizeables, both of which are fixed here. The pound jump is a pleasant surprise! Really gives me nostalgia for when I first discovered it while playing SM3DW. The only small flaw I can point out is when the player ground pounds on a generating NPC:
Spoiler: show
Image
Generators are set to generate an enemy every 2 seconds.
Just a small bug. Besides this, I really love how this turned out. Keep up the good work! :D

Re: GroundPound.lua - pound the ground! [v1.1]

Posted: Wed Oct 26, 2022 2:17 am
by Marioman2007
Thanks and glad you liked it!
I've updated the script, download and changelog in the original post!
Enjoy!

Re: GroundPound.lua - pound the ground! [v1]

Posted: Mon Nov 07, 2022 10:09 pm
by Shodax
Marioman2007 wrote:
Thu Sep 15, 2022 10:19 am
Mushroom King wrote:
Thu Sep 15, 2022 6:53 am
Would it be possible to make the ground pound use the down button while in midair (crouching) and not the spin jump button?
Yeah its possible, but for a game where you can crouch in mid air it will be dangerous (for example, purple yoshi)
I do not know much of lua but I have managed to make that with pressing down make the movement, in case someone serves

https://www.mediafire.com/file/rosns6de ... n.zip/file

Re: GroundPound.lua - pound the ground! [v1.1]

Posted: Fri Dec 09, 2022 2:56 pm
by Cognition
Is there a way to add custom power ups to this? For example, when using the cape feather by MDA.

Re: GroundPound.lua - pound the ground! [v1.1]

Posted: Sat Dec 10, 2022 2:35 pm
by Shodax
Cognition wrote:
Fri Dec 09, 2022 2:56 pm
Is there a way to add custom power ups to this? For example, when using the cape feather by MDA.
if compatible
Image

Re: GroundPound.lua - pound the ground! [v1.1]

Posted: Mon Feb 13, 2023 6:39 pm
by Torterra18
Nice script, however, is there a way to disable it for other characters?

Re: GroundPound.lua - pound the ground! [v1.2]

Posted: Wed Mar 15, 2023 4:32 am
by Marioman2007
Version 1.2 is here!

This version fixes a lot of bugs and adds multiplayer support + some custom blocks and npcs.
Download and changelog in the main post.

Enjoy!


Mushroom King wrote:
Thu Sep 15, 2022 6:53 am
Would it be possible to make the ground pound use the down button while in midair (crouching) and not the spin jump button?
Put this code after loading GP.

Code: Select all

GP.inputStyle = GP.INPUT_DOWN

Mal8rk wrote:
Sun Oct 02, 2022 10:20 pm
I wish you could change which blocks you could destroy and which ones you couldn't, cause' I've seen that you can break on & off blocks and things like that
This issue has been fixed in this version.


Torterra18 wrote:
Mon Feb 13, 2023 6:39 pm
Nice script, however, is there a way to disable it for other characters?
Put the following code after loading GP.

Code: Select all

GP.disableCharacter(CHARACTER_#)
CHARACTER_# should be a character constant from the following list.
https://docs.codehaus.moe/#/constants/characters

Re: GroundPound.lua - pound the ground! [v1.2]

Posted: Tue Mar 21, 2023 12:08 am
by GalaxyComet
Question, is ground pounding only available for Mario & Luigi?

Re: GroundPound.lua - pound the ground! [v1.2]

Posted: Tue Mar 21, 2023 6:10 am
by Marioman2007
GalaxyComet wrote:
Tue Mar 21, 2023 12:08 am
Question, is ground pounding only available for Mario & Luigi?
Every registered character can use GP, however, compatibility is only guaranteed for the base 5.
The GP.applyDefaultSettings function only registers the base 5 characters, so you'd have to register any other character by yourself.

Re: GroundPound.lua - pound the ground! [v1]

Posted: Sat May 06, 2023 2:08 pm
by Alfur
Marioman2007 wrote:
Sun Oct 02, 2022 10:53 pm
Mal8rk wrote:
Sun Oct 02, 2022 10:20 pm
I wish you could change which blocks you could destroy and which ones you couldn't, cause' I've seen that you can break on & off blocks and things like that

You can't change the blocks. However, you can prevent blocks from being destroyed:

Code: Select all

local avoidedBlocks = table.map{id1, id2} -- you can always add/remove IDs here

function onBlockPound(event, v)
    if avoidedBlocks[v.id] then
        event.cancelled = true
    end
end
How is the meant to work? I put this in the luna.lua file but the block is still breakable. How are we meant to blacklist blocks from being groundpounded?

Re: GroundPound.lua - pound the ground! [v1.2]

Posted: Sat May 06, 2023 11:40 pm
by Marioman2007
Alfur wrote:
Sat May 06, 2023 2:08 pm
How is the meant to work? I put this in the luna.lua file but the block is still breakable. How are we meant to blacklist blocks from being groundpounded?

That was the old method, now you can just do this:

Code: Select all

GP.blacklistBlock(id)
This'll go after loading GP.

Re: GroundPound.lua - pound the ground! [v1.3]

Posted: Mon Feb 05, 2024 9:58 am
by Marioman2007
Version 1.3 is released!
Fixes some bugs, adds some new features and optimizes the code a bit.
Changelog in the main post.

Re: GroundPound.lua - pound the ground! [v1.3]

Posted: Tue Feb 06, 2024 8:00 am
by Mushroom King
Thanks for the update. Do you think it would be possible to add some feature like the higher bouncing from springboard/trampoline when ground pounding, like in the 3d games, and the increasing score when you hit multiple npcs like in a goomba tower?

Re: GroundPound.lua - pound the ground! [v1.3.1]

Posted: Tue Feb 06, 2024 8:36 am
by Marioman2007
Version 1.3.1 released
Fixed some code oversights and added npc whitelist and blacklist.

Mushroom King wrote:
Tue Feb 06, 2024 8:00 am
Thanks for the update. Do you think it would be possible to add some feature like the higher bouncing from springboard/trampoline when ground pounding, like in the 3d games, and the increasing score when you hit multiple npcs like in a goomba tower?

I tried to do the latter once but my way was pretty janky, so I'm not adding that.
As for the former, you can use this code to do that:

Code: Select all

GP.registerCustomNPCFunc(26, function(v, p)
    p.speedY = -20
    
    -- these are taken from scripts/npcs/ai/springs.lua
    p:mem(0x00, FIELD_BOOL, p.character == CHARACTER_TOAD and (p.powerup == 5 or p.powerup == 6))
    p:mem(0x0E, FIELD_BOOL, false)
    p:mem(0x18, FIELD_BOOL, p.character == CHARACTER_PEACH)
end)