Sonic Time Twisted Styled Whirlwind Shield

[Open Assets] Sonic Time Twisted Styled Whirlwind Shield V.1.7/Redberries

This content may be freely modified and/or maintained by anyone.

Rodriv64

Member
Rodriv64 submitted a new resource:

Sonic Time Twisted Styled Whirlwind Shield - Fly up to the sky, babe!

This is my first lua script and my first addon, so please, enjoy.

Are you tired of the vanilla whirlwind shield, and its lame double jump? Well, say no more!

This lua script changes the behaviour of the whirlwind shield and makes it behave like the Wind shield from the fangame Sonic Time Twisted.
To activate the ability, press spin while in a high place to start floating. Once done, you can press spin or jump to fly down or up. This ability will last 10 seconds...

Read more about this resource...
 
Cool! The windy shield just got tunned. Now it's more like Airplane shield lmao.
(Hey! Look! That's me on the credits!)
 
Cool! The windy shield just got tunned. Now it's more like Airplane shield lmao.
(Hey! Look! That's me on the credits!)
Hey, Dark94, can you help me with the script? I'm trying to add support for MCSonic's shield button map, but for some reason, when it use the whirlwind shield with him, it makes hi float up to the sky. Here's the code i added:
if player.mo.skin == "xsonic"
and player.cmd.buttons & BT_CUSTOM3
player.float = true
elseif player.mo.skin == "mcsonic"
and (player.cmd.buttons & BT_JUMP
and player.cmd.buttons & BT_USE)
player.mcfloat = true
if player.mcfloat
player.float = true
player.airrolled = false
end
end
Post automatically merged:

Nvm, i got it fixed, but there's now another problem. I thought of adding a exclude config, like in Air Options, so i borrowed a bit of the code from it and modified the code. But now the ability of the shield won't work. Btw here's the code i borrowed:
Exclude skin from shield ability:
local EXCLUSION = "client/sttwind/floatexclusion.dat"

local function ReadExclusionsFromFile(file)
    local result = {}
    local file = io.openlocal(EXCLUSION, "r")

    if file
        local fileContent = file:read("*all")
        for skinName in string.gmatch(fileContent, "[^\n]+")
            result[skinName] = true
        end
        file:close()
    end

    return result
end

local exclusions = ReadExclusionsFromFile(file)

local function WriteExclusionsToFile(file)
    local file = io.openlocal(EXCLUSION, "w")

    local isFirst = true
    for key, _ in pairs(exclusions)
        if isFirst
            isFirst = false
        else
            file:write("\n")
        end
        file:write(key)
    end
    
    file:close()
end

local function RemoveCharacters(player, ...)
    local args = {...}
    local noArgs = true

    CONS_Printf(player, "Excluded characters: ")
    for i, skinName in ipairs(args)
        exclusions[skinName] = true
        CONS_Printf(player, "- " .. skinName)
        noArgs = false
    end

    if noArgs
        CONS_Printf(player, "(no arguments given)")
    else
        WriteExclusionsToFile()
    end
end

local function AddCharacters(player, ...)
    local args = {...}
    local noArgs = true

    CONS_Printf(player, "Included characters: ")
    for _, skinName in ipairs(args)
        exclusions[skinName] = nil
        CONS_Printf(player, "- " .. skinName)
        noArgs = false
    end

    if noArgs
        CONS_Printf(player, "(no arguments given)")
    else
        WriteExclusionsToFile()
    end
end

local function ViewExclusions(player, ...)
    CONS_Printf(player, "Characters excluded from Float ability: ")
    for key, _ in pairs(exclusions)
        CONS_Printf(player, "- " .. key)
    end
end

COM_AddCommand("floatremove", RemoveCharacters)
COM_AddCommand("floatadd", AddCharacters)
COM_AddCommand("floatexclusions", ViewExclusions)
The error might be because of the local exclusions function.
 
Last edited:
Sonic Time Twisted mentioned!! love that game
Also merry Christmas or something
 
I don't see you need to type the command "floattoggle" for this mod to work at all: considering you can hold jump and press spin to still active the whirlwind jump regardless even when "floattoggle" is on

regardless, its a pretty good mod: a bit overpowered though
 
I don't see you need to type the command "floattoggle" for this mod to work at all: considering you can hold jump and press spin to still active the whirlwind jump regardless even when "floattoggle" is on

regardless, its a pretty good mod: a bit overpowered though
Yeah, but it was in case some characters used the spin+jump combo to use shields, like MCSonic. Anyway, I should reduce the float time to balance it.
 
Rodriv64 updated Sonic Time Twisted Styled Whirlwind Shield with a new update entry:

Takis Oof & Time Reduce

This update adds only two changes to the script:
  • Removed support for Takis, since idk how to make him float down without activating his hammer blast.
  • Float time has been reduced to match with original sonic time twisted float time.
In another update, if possible, i'll actually make support for Takis, and i'll add a timer to check the float time.

Read the rest of this update entry...
 
Rodriv64 updated Sonic Time Twisted Styled Whirlwind Shield with a new update entry:

2.2.14 Changes

Hey everyone! This time the update is literal due to some changes made by 2.2.14. So here are the changes:
  • Added a timer that will tell you the time left before you fall.
  • MCSonic now doesn't require to press jump+spin to activate the ability, since you can map the shield button to any button.
That's all. If i can, i'll add support for Takis. Enjoy!

Read the rest of this update entry...
 
I was going to reply the message, but seems like you fixed it so congrats for that.
Btw Happy Holiday/Christmas/Whatever You Call It!
Hey Dark94, i need some help, i'm trying to make an exclusion system similar to Air Options, but when i tried the mod with the new code, it says that exclusions is a nil value, could you help me? Also, i have to update the mod to fix the outdated shield button feature. Here's the code btw:
Script with the air options exclusion system code:
local float_timelimit = 10

addHook("PlayerThink", function(player)
    if exclusions[player.mo.skin] or player.canfloat == false
        return
    end
    if player.mo
    and player.mo.valid
        if player.powers[pw_shield] == SH_WHIRLWIND
        and player.pflags & PF_SHIELDABILITY
        and player.canfloat == true
            player.float = true
        end
    end
    if player.float
        player.mo.flags = $|MF_NOGRAVITY
        player.float_time = $-1
        if player.cmd.buttons & BT_JUMP
            player.mo.state = S_PLAY_ROLL
            player.mo.momz = 10*player.mo.scale*P_MobjFlip(player.mo)
            player.pflags = $|PF_JUMPED
        elseif player.cmd.buttons & BT_USE
            player.mo.state = S_PLAY_ROLL
            player.mo.momz = -(10*player.mo.scale*P_MobjFlip(player.mo))
            player.pflags = $|PF_JUMPED
        else
            player.mo.state = S_PLAY_ROLL
            player.mo.momz = $*5/6
            player.pflags = $|PF_JUMPED
        end
        if P_PlayerInPain(player)
        or player.playerstate != PST_LIVE
        or not (player.pflags & PF_SHIELDABILITY)
        or player.powers[pw_shield] != SH_WHIRLWIND
        or P_IsObjectOnGround(player.mo)
        or player.exiting
        or (player.cmd.buttons & BT_JUMP
        and player.cmd.buttons & BT_USE)
        or not player.float_time
            player.mo.state = S_PLAY_FALL
            player.mo.flags = $ & ~MF_NOGRAVITY
            player.pflags = $|PF_THOKKED & ~PF_SHIELDABILITY & ~PF_JUMPED
            player.float = false
        end
        if player.mo.skin == "xsonic"
        and player.cmd.buttons & BT_CUSTOM3
            player.float = true
        end
        if player.mo.skin == "mcsonic"
        and (player.cmd.buttons & BT_JUMP
        and player.cmd.buttons & BT_USE)
            player.mcfloat = true
            player.pflags = $| PF_SHIELDABILITY
            if player.mcfloat
                player.float = true
                player.mo.state = S_PLAY_ROLL
            end
        end
        if player.mo.state == S_PLAY_SPRING
        and player.canfloat
            player.springfrontflip = false
        end
    else
        player.float_time = float_timelimit*30
    end
end)

--These are the functions for the command

//The Command
local function Floattoggle(player, arg)
    if player.mo and player.mo.valid
        if player.powers[pw_shield] == SH_WHIRLWIND
            if arg == "on"
                player.canfloat = true
                CONS_Printf(player, "Float Enabled")
            elseif arg == "off"
                player.canfloat = false
                CONS_Printf(player, "Float Disabled")
            else
                CONS_Printf(player, "Invalid Argument")
            end
        else
            CONS_Printf(player, "This is not a level")
        end
    end
end

COM_AddCommand("floattoggle", Floattoggle)

local function floattime(v, player)
    if not player.mo and player.mo.valid return end
    if (player.powers[pw_carry] == CR_NIGHTSMODE) return end
    if not player.powers[pw_shield] == SH_WHIRLWIND return end
    if player.float == false return end
    
    if player.mo and player.mo.valid and player.powers[pw_shield] == SH_WHIRLWIND and player.float == true
        v.drawString(-10, 160, ("Float Time:"),V_SNAPTOBOTTOM|V_ALLOWLOWERCASE|V_YELLOWMAP, "left")
    end
end

hud.add(floattime, "game")

local function floattime2(v, player)
    if not player.mo and player.mo.valid return end
    if (player.powers[pw_carry] == CR_NIGHTSMODE) return end
    if not player.powers[pw_shield] == SH_WHIRLWIND return end
    if player.float == false return end
    
    if player.mo and player.mo.valid and player.powers[pw_shield] == SH_WHIRLWIND and player.float == true
        v.drawString(85, 160, (player.float_time/30),V_SNAPTOBOTTOM|V_ALLOWLOWERCASE, "left")
    end
end

hud.add(floattime2, "game")

-- EXCLUSION SYSTEM

local EXCLUSIONS_FILENAME = "client/sttwind/exclusions.dat"

local function ReadExclusionsFromFile()
    local result = {}
    local file = io.openlocal(EXCLUSIONS_FILENAME, "r")

    if file
        local fileContent = file:read("*all")
        for skinName in string.gmatch(fileContent, "[^\n]+")
            result[skinName] = true
        end
        file:close()
    end

    return result
end

local exclusions = ReadExclusionsFromFile()

local function WriteExclusionsToFile()
    local file = io.openlocal(EXCLUSIONS_FILENAME, "w")

    local isFirst = true
    for key, _ in pairs(exclusions)
        if isFirst
            isFirst = false
        else
            file:write("\n")
        end
        file:write(key)
    end
    
    file:close()
end

local function ExcludeCharacters(player, ...)
    local args = {...}
    local noArgs = true

    CONS_Printf(player, "Excluded characters: ")
    for i, skinName in ipairs(args)
        exclusions[skinName] = true
        CONS_Printf(player, "- " .. skinName)
        noArgs = false
    end

    if noArgs
        CONS_Printf(player, "(no arguments given)")
    else
        WriteExclusionsToFile()
    end
end

local function IncludeCharacters(player, ...)
    local args = {...}
    local noArgs = true

    CONS_Printf(player, "Included characters: ")
    for _, skinName in ipairs(args)
        exclusions[skinName] = nil
        CONS_Printf(player, "- " .. skinName)
        noArgs = false
    end

    if noArgs
        CONS_Printf(player, "(no arguments given)")
    else
        WriteExclusionsToFile()
    end
end

local function ViewExclusions(player, ...)
    CONS_Printf(player, "Characters excluded from Float Ability: ")
    for key, _ in pairs(exclusions)
        CONS_Printf(player, "- " .. key)
    end
end

COM_AddCommand("faexclude", ExcludeCharacters)
COM_AddCommand("fainclude", IncludeCharacters)
COM_AddCommand("faviewexclusions", ViewExclusions)
 
Hey Dark94, i need some help, i'm trying to make an exclusion system similar to Air Options, but when i tried the mod with the new code, it says that exclusions is a nil value, could you help me? Also, i have to update the mod to fix the outdated shield button feature. Here's the code btw:

[LONG CODE GOES HERE]
It's a little difficult for me to find an error like this without the game's log, but given your description, you can move the PlayerThink hook to the end of the script...

OR you could check if the exclusions table exists:
'[exclusions] is nil' fix (Not sure if this works):
local float_timelimit = 10

addHook("PlayerThink", function(player)
    if not (player.mo
    and player.mo.valid
    and (not exclusions
    or (exclusions
    and not exclusions[player.mo.skin]))
    and player.float)
        return
    end
    ...
 
It's a little difficult for me to find an error like this without the game's log, but given your description, you can move the PlayerThink hook to the end of the script...

OR you could check if the exclusions table exists:
'[exclusions] is nil' fix (Not sure if this works)'[exclusions] is nil' fix (Not sure if this works):
local float_timelimit = 10

addHook("PlayerThink", function(player)
    if not (player.mo
    and player.mo.valid
    and (not exclusions
    or (exclusions
    and not exclusions[player.mo.skin]))
    and player.float)
        return
    end
    ...
Ok, i managed to fix the issue, and now it works, thanks for help. I will now release the update to fix the shield button issue.
 
Rodriv64 updated Sonic Time Twisted Styled Whirlwind Shield with a new update entry:

Redberries float / 2.2.15 fixes

Hey, it's been a lot, but now the mod is updated, mainly for two changes:
  • Removed the float toggle command, and replaced it with an exclusion system similar to Air Options.
  • Fixed MCSonic's shield button issue.
As a bonus, i've included a file with support for the custom build Redberries from Pastel (it also works for Reveries).
Enjoy!

Read the rest of this update entry...
 
I might could fix that New Thok thing, but my laptop is out of commission right now. The trouble here (probably) is that rising causes your abilities to refresh, not actually monitor / badnik bouncing.

If that’s not the only issue then rip
 

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

Back
Top