Bonuspunkt

TrueStack

4 posts in this topic

NOTE: i did not stop fiddling with the code, and extracted functions to own modules so you need more than one file, and specific file locations etc etc etc.

if you want an up-to-date copy you can download the bundle here but this code should work anyway

 

Displays how much damage it takes to kill you

require "base/internal/ui/reflexcore"

TrueStack =
{
    draw = function()

        -- Early out if HUD shouldn´t be shown.
        if not shouldShowHUD() then return end;

        -- Find player
        local player = getPlayer();

        local textColor = Color(255,255,255,255);

        nvgFontSize(52);
        nvgFontFace("TitilliumWeb-Bold");
        nvgTextAlign(NVG_ALIGN_CENTER, NVG_ALIGN_TOP);
        nvgFontBlur(0);
        nvgFillColor(textColor);

        local armorProtection = player.armorProtection + 1;

        local maxDamage =
            math.min(player.armor, player.health * armorProtection) +
            player.health;

        nvgText(0, 0, maxDamage);
    end
};
registerWidget("TrueStack");
Stalast, Spannzer, MnstH and 1 other like this

Share this post


Link to post
Share on other sites
        local armorProtection = player.armorProtection + 1;

        local maxDamage =
            math.min(player.armor, player.health * armorProtection) +
            player.health;

Strange formula... I'd be interested in knowing what exactly what the armorProtection variable is... is it a bool 0/1, i.e. you either have protection or your don't or some scalar?

Share this post


Link to post
Share on other sites

LuaVariables.txt

number armorProtection          0 = green, 1 = yellow, 2 = red

it isn't strange, it just took me a while to wrap my head around because you usually calculate in the other direction.

 

as mentioned on the wiki - Green provides a 1:1 protection, Yellow 2:1 and Red 3:1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now