Issues making a working charging system

Icalasari

Member
Gotten lots of help, and also came up with some work arounds myself, but I have hit a wall

The code not only doesn't reset the charge timer on button release (which is a problem as I want it so if you hold it too long, it self destructs you, causing rings to fly out and your custom ability to be disabled - Right now I don't have damage code so I can debug it), it also just keeps launching the orb automatically when enemies are in range when I want it to release on button release

Nothing is working to make it wait til button release

If the indenting is bad, sorry - It likes to mess it up sometimes when I copy paste it which, combined with me having had for a while no idea how I'm supposed to properly indent, made it a bit of a nightmare

Code:
--Gunslinger Coding
addHook("ThinkFrame", function()
    local dollcharge = 0
    for player in players.iterate do
        if player.mo.skin == "icatailsdoll" then
            if not (player.cmd.buttons & BT_SPIN) then
                player.holdingspin = false
                player.spintapready = true
                player.spintapping = false
            elseif player.spintapready then
                player.spintapping = true
                player.spintapready = false
            else
                player.spintapping = false
            end

            if player.spintapping then
                S_StartSound(player.mo, sfx_s3k53)
            end
            if player.cmd.buttons & BT_SPIN and not player.holdingspin then
                dollcharge = 1
                player.mo.momy = 0
                player.mo.momx = 0
                player.mo.momz = 0
                player.chargetimer = $ or 0
                player.chargetimer = $ + 1
                if player.chargetimer >= 71 then
                    P_NukeEnemies(player.mo, player.mo, 700*FRACUNIT)
                    dollcharge = 0
                    player.chargetimer = 0
                    player.holdingspin = true
                elseif player.chargetimer <= 70
                    local enemy = P_LookForEnemies(player, true, true)
                     if enemy and enemy.valid and not player.holdingspin ==  true and player.chargetimer >= 1 and dollcharge >= 1 then
                        P_SpawnMissile(player.mo, enemy, MT_NANB)
                        dollcharge = 0
                        player.chargetimer = 0
                        player.holdingspin = true
                    end
                end
            end
        end
    end
end)
 
Last edited:

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

Back
Top