Fixed [2.1.15] v.drawFill makes drawed bars look glitched in OpenGL

Status
Not open for further replies.

Lactozilla

Developer
Sonic Team Junior
srb20196.gif
srb22501.png

and I'm pretty sure it's not a problem with the script itself

(and sorry for the big image, blame aPNG)

 
Last edited by a moderator:
Please post the script (or a cut-down version of it specifically demonstrating the bug), along with instructions on how to replicate.
 
Please post the script (or a cut-down version of it specifically demonstrating the bug), along with instructions on how to replicate.

Code:
local malevolencehp
local tim1
local spawnhealth

hud.add(function(v, player)    
    if not player or not player.mo then return end
    if (player.pflags & PF_NIGHTSMODE) then return end
    if player.mo.skin == "sonic"
        local HUD_X = 130
        local HUD_Y = 174
        local HUD_HEIGHT = 5 + player.mo.spawnhealth/10
        local HUD_AMOUNT = player.mo.malevolencehp * 100/player.mo.spawnhealth
        local HUD_OVER = player.mo.malevolencehp * 200/player.mo.spawnhealth - 200
        local HUD_COLOR = 184
        if HUD_OVER > 0 then
            HUD_AMOUNT = 10
            HUD_OVER = min($1, 10)
        end
        if player.mo.malevolencehp < 4
            HUD_COLOR = 128
        else
            HUD_COLOR = 184
        end
        v.drawFill(HUD_X - 1, HUD_Y - HUD_HEIGHT/2 + 3, 102, HUD_HEIGHT + 2, 31)
        v.drawFill(HUD_X, HUD_Y - HUD_HEIGHT/2 + 4, HUD_AMOUNT, HUD_HEIGHT, HUD_COLOR)
        v.drawFill(HUD_X, HUD_Y - HUD_HEIGHT/2 + 4, HUD_OVER, HUD_TALL, 232)
        v.drawString(HUD_X-4, HUD_Y, "HP", V_MONOSPACE, "right")
        v.drawString(HUD_X+126, HUD_Y, player.mo.malevolencehp, V_MONOSPACE, "right")
        v.drawString(HUD_X+125, HUD_Y, "/"..player.mo.spawnhealth, V_MONOSPACE, "left")        
    end    
end)

addHook("ThinkFrame", do
    for player in players.iterate
        if not player.malevolencehp
            player.malevolencehp = 0
        end
        if not player.tim1
            player.tim1 = 0
        end
        if not player.spawnhealth
            player.spawnhealth = 10
        end
    end
end)

addHook("MobjSpawn", function(mo) mo.malevolencehp = 10 end, MT_PLAYER)

addHook("MobjSpawn", function(p) p.tim1 = TICRATE end, MT_PLAYER)

addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo
            if not player.tim1
                player.tim1 = 0
            end
        end
    end
end)

addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo
            if player.tim1 >= TICRATE
                player.tim1 = 0
            end
            player.tim1 = $1 + 1
        end
    end
end)

addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo and player.mo.skin == "sonic" then

            local malevolencehp
            local tim1
            
            if not (player.mo.malevolencehp == nil)
            and ((player.mo.malevolencehp < 1) or (player.mo.malevolencehp == 0)) and (player.health)
                player.health = 0
                P_KillMobj(player.mo)
                player.powers[pw_shield] = 0
                player.powers[pw_super] = 0                
            end
            if (player.exdelay == nil)
                player.exdelay = 0
            end
            if not (player.health) and not (player.exdelay == 0)
                player.exdelay = $1 - 1
            end
            if player.health == 0
                player.mo.malevolencehp = 0
            end
            if player.mo.malevolencehp > 10
                player.mo.malevolencehp = 10
            end
            if not (player.health) and (player.exdelay == 0)
                player.exdelay = 5
            end
        end
    end
end)

addHook("MobjDamage", function(target, inflictor, source, damage)
    if (target.player.pflags & PF_NIGHTSMODE) then return end
    if (target and target.skin == "sonic") and not (target.player.powers[pw_super])
        //S_StartSound(target, sfx_ded)
        target.player.powers[pw_flashing] = TICRATE*3
        target.player.mo.state = S_PLAY_PAIN
        P_SetObjectMomZ(target, FRACUNIT*6, false)
        P_InstaThrust(target, target.angle, -10*FRACUNIT)
        if not target.player.powers[pw_shield]
            P_PlayerWeaponPanelBurst(target.player)
            P_PlayerWeaponAmmoBurst(target.player)
            P_PlayerEmeraldBurst(target.player, false)
            P_PlayerFlagBurst(target.player)
            target.player.mo.malevolencehp = $1 - 1
        end
        if (target.player.powers[pw_shield] == SH_ELEMENTAL) and (target.player.mo.eflags & MFE_UNDERWATER)
            target.player.powers[pw_underwater] = 1050
        end
        P_RemoveShield(target.player)
        return true
    else
        return nil
        end
end, MT_PLAYER)


addHook("MobjSpawn", function(mo) mo.spawnhealth = 10 end, MT_PLAYER)
to replicate it, just get hit when using the OpenGL renderer
 
I get the feeling it's because HUD_OVER is negative. Software mode tells you to get lost for trying to draw with a width less than zero, and OpenGL happily does it and winds up with a wacky result.
 
犬夜叉;774074 said:
I get the feeling it's because HUD_OVER is negative. Software mode tells you to get lost for trying to draw with a width less than zero, and OpenGL happily does it and winds up with a wacky result.
srb22559.png

well, I replaced HUD_OVER with a non-negative value and it seems to work now
but still, any bar that has a negative value will do the glitch mentioned
 
Last edited:
Status
Not open for further replies.

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

Back
Top