User:Hatninja

From SRB2 Wiki
Jump to navigation Jump to search

Hi, i'm Hatninja. I'm somebody who can script using lua.

Get Controls While in Stasis

Usual stasis methods prevent player.cmd.forwardmove and player.cmd.sidemove from receiving input, which may be a lot of trouble if you need both at the same time.

Heres how you can work around that!

addHook("ThinkFrame", function()
    for player in players.iterate do
        //Disable Movement
        player.thrustfactor = 0

        //Disable Weapon Shooting
        player.weapondelay = UINT16_MAX

        //You are now free to use player.cmd to the fullest!
    end
end)

addHook("JumpSpecial", function() return false end) //Jumping
addHook("SpinSpecial", function() return false end) //Spinning

Modify Object Gravity

There are no means to change gravity for an object directly, but you can still effectively change it!

addHook("ThinkFrame", function()
    for player in players.iterate do
         if player.mo then
             //Prevent momentum from being given when you're on the ground, theres nothing to counteract!
             if player.mo.z == player.mo.floorz then
                 //Gravity is FRACUNIT/2, so we counteract it with this for half the normal gravity!
                 player.mo.momz = $1 + FRACUNIT/4    
             end
         end
    end
end)

Client Side Code

The only client-sided code is used for the HUD. If you need to go further than the HUD, the hud function doesn't really allow you to make changes.

Heres how you can work around that!

local client = 0

addHook("ThinkFrame", function()
    for player in players.iterate do
        if client == player then
            P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + player.mo.height, MT_TAG)
            //"IT!" will now only show for your player!
        end
    end
end)

hud.add(function(g, player)
    client=player
end,"game")

As long as you don't change something that the game will try to sync (Like say, the player's position), you should be fine!