Lua Problem: No-Spin-Jump

Status
Not open for further replies.

Sapheros

Member
Okay, so I'm trying to use no-spin-jump on a silver wad that's lying around my files. I changed what I needed to change to use for the script, but it wouldn't seem to work....
I suck at uploading gifs online so I'll be using Gfycat to show gifs

http://gfycat.com/SameFamiliarJavalina
This Gif shows that the first jump kills enemies

http://gfycat.com/GargantuanDirtyBergerpicard
This Gif shows that while holding the jump button, silver will do a consecutive jump that actually IS the no-spin-jump lua working.

Here's the script, ignore the first section:
Code:
addHook("ThinkFrame", do
    for player in players.iterate
        if (player.mo and player.mo.skin == "silver")
            if (player.cmd.buttons & BT_USE)
                if not (((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL)) and (player.pflags & PF_ATTACKDOWN)) //noope, no firing rings at the same time :E
                and not (player.weapondelay) //no shooting when weapondelay hasn't gone back to 0 yet
                and not (player.pflags & PF_NIGHTSMODE) //no shooting when NiGHTS Super Sonic!
                and not (player.pflags & PF_ROPEHANG) //rope hangs use spin for letting go
                and not (player.pflags & PF_MACESPIN) //control chains use spin for shifting angle I think?
                and not (player.pflags & PF_TAGGED) //no shooting when tagged
                and not (player.pflags & PF_STASIS) //no shooting when in stasis in tag mode either
                and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT) //no shooting when following a zoomtube
                and not (player.pflags & PF_SPINNING) //no shooting when ...spinning?
                    // fire away!
                    local th = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + player.mo.height/2, MT_THOK)
                    // missiles can't hurt their targets, note
                    th.target = player.mo

                    
                end
            end
        end
    end
end)


addHook("MobjSpawn", function(mo) mo.jumping = 0 end, MT_PLAYER)

addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo and player.mo.skin == "silver" then
                        if not (player.pflags & PF_NIGHTSMODE)
                        and (player.cmd.buttons & BT_JUMP)
            and not (player.mo.state == S_PLAY_PAIN)
            and not (player.pflags & PF_MACESPIN)
            and not (player.pflags & PF_STASIS)
            and (player.mo.jumping == 0)
            and (P_IsObjectOnGround(player.mo))
                player.mo.state = S_PLAY_SPRING
                P_SetObjectMomZ(player.mo, FRACUNIT*10, false)
                S_StartSound(player.mo, sfx_jump)
            player.mo.jumping = 1
                        end
            if player.mo.jumping == 1
            and not (player.cmd.buttons & BT_JUMP)
            player.mo.jumping = 0
            end
        end
    end
end)
So yeah, i have no idea what is happening, considering I suck at lua, like almost every 2.1 newbie.
And if i could also get some way to figure out how to map a CA_ABILITY1 to the spin button, i would kindly appreciate it.
SameFamiliarJavalina
 
This should work for the no spin jump:

Code:
addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo.skin=="sonic"
            if (player.pflags & PF_JUMPED)
            and (player.mo.momz>=0) // Player vertical momentum is greater than or equal to 0
            and not P_IsObjectOnGround(player.mo)
                player.mo.state=S_PLAY_SPRING
                player.pflags=$1 & ~PF_SPINNING // Remove spinning flags if player has any at this point, otherwise it will act weird
            end
            if (player.pflags & PF_JUMPED)
            and (player.mo.momz<=-1) // Player vertical momentum is less than or equal to -1 (falling)
            and not P_IsObjectOnGround(player.mo)
                player.mo.state=S_PLAY_FALL1
                player.pflags=$1 & ~PF_JUMPED // Remove jump flags, allowing the player to get hurt
                player.pflags=$1 & ~PF_SPINNING
            end
        end
    end
end)
As for mapping an ability to a button, this should do (unless if you're asking for mapping an actual ability function to the key, in that case, I have no clue myself):

Code:
addHook("ThinkFrame", do
    for player in players.iterate
        if (player.cmd.buttons & BT_CUSTOM1)
            player.charability=CA_SWIM
        end
    end
end)
 
Thanks for the help, Silver can now get hurt to enemies! But I'm still gonna have to figure out about mapping a CA1_ABILITY to the spin button... Meh, Maybe later...
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top