What happens if you drink a Lifeforce Potion with negative HP in Terraria?

Terraria: Lifeforce Potion + Negative HP = ???
terra’s brainrot continues
Join my discord! We do stuff sometimes: https://discord.gg/yJrCt9YFz5

Credits:
Thank you to fili_pk on Discord for suggesting the idea that formed this idea.

Resources:
Terrasavr – https://yal.cc/r/terrasavr/
TerraPlrEdit – https://terra-plr-edit-page-92fe42.gitlab.io/

Chapters:
0:00 Introduction
0:47 What does the Lifeforce Potion… do?
1:35 What is an “integer underflow”?
2:09 Underflowing the HP value with Lifeforce!
3:37 YOU CANNOT GET 601 HP.
4:17 The weirdest freeze I’ve seen yet.
5:50 Conclusion & Outro

Music:
OMORI – A Place by the Lake
OMORI – H20:HCL
OMORI – Poems In The Fog

Mods and Packs:
Foundry & Alchemy (Pack) – https://steamcommunity.com/sharedfiles/filedetails/?id=2440505684
Fancy Lighting [Ultra Preset] (Mod) – https://steamcommunity.com/sharedfiles/filedetails/?id=2822950837
Stanberry Font (Pack) –
https://steamcommunity.com/sharedfiles/filedetails/?id=2559652586
Stormdark UI (Pack) –
https://steamcommunity.com/sharedfiles/filedetails/?id=2448259079
DragonLens (Cheat Mod) –
https://steamcommunity.com/sharedfiles/filedetails/?id=2939737748
Better Zoom (QoL) –
https://steamcommunity.com/sharedfiles/filedetails/?id=2562953970
Character Stats (QoL) –
https://steamcommunity.com/sharedfiles/filedetails/?id=3033200611

Terraria: Lifeforce Potion + Negative HP = ???

43 Comments

  1. So for the freeze, thanks to the blessing of modding tools, it appears that UI/FancyClassicPlayerResourcesDisplaySet uses the Clamp function to limit the display to 20 hearts, while neither UI/HorizontalBarsPlayerReosurcesDisplaySet nor UI/ClassicPlayerResourcesDisplaySet do, so they end up drawing about 84 million bar segments / hearts. The reason you need to be above MIN_INT + 400 is that in UI/PlayerStatsSnapshot, the game uses your "unboosted life" and "unboosted life – 400" to determine your life fruit situation; If you're below that threshold, the math sees you as having 400 million life fruit, which will require a lot of max health to draw even a single segment / heart. (Though I suspect this code path breaks in another way too)

  2. I don’t understand how YouTubers answer one question but makes it 6 minutes long, just give it to me straight.

    1+1 =?
    1+1 is a very interesting question, but first we need to understand what one is. One is a number. This is because it is! So what is 1+1 ? Before we answer this, I want you to remember, what does the plus sign mean? I mean we’ve all seen it before but what does it do and where can we find it? If we go to a shop, we can find a calculator but that’s not all, we have to find the sign. This is tricky, you can find the coordinates by asking a friend or using your eyes. Oh, what’s that? I don’t have friends. For some reason my eyes found two. One was tilted on its side. So we can conclude 1+1 doesn’t = ? It’s the meaning of life. Or window. I’ll never answer this question because I need my pay check.

    JUST SAY 2, THE FREAKING ANSWER AAAAAAA

  3. Imagine someone sends both of video's to at least one of terraria devs and they… idk, experement/fix? Contact ya after finding out what happened with the half fps thing?? Mayhaps.

  4. if you set your hp to 496 – 499 and use a life fruit and a life force potion you can get 601 – 604 max health but it will reset back to 500/600 once you leave the world

  5. Although terraria rejects characters with > 600 hp, I feel like it is possible to get more than 600 via stat editor mods. I have seen terraria servers where you can get over 600 hp and the game is completely fine with it.

  6. I would have expected life regeneration when underflowing with lifeforce to kill you, right?
    In the previous video, once natural regeneration kicks in it would instantly kill you, because that change in HP triggers the check for death, and so having less than 0, you die, right?
    So why does regenerating with negative HP on a positive max HP not kill you? Maybe it only calls on reductions to HP, so positive regeneration doesn't trigger it. In that case I imagine you'll still die on one hit from anything until your HP is positive.

  7. I'm curious to see what Starbound thinks when you set any of the stats to negative or a super high positive number.

    There are many ways to achieve this, Starbound is easy to mod so I could have it be an armor piece or something

    I'll try this sometime today

  8. Edit: Immediately after posting this I saw that someone else had already posted it earlier. Oh well

    Looking into the code, I’m pretty sure the slowdown happens from the draw code (all of which is in the namespace Terraria.GameContent.UI.ResourceSets). For classic style, line 73 of ClassicPlayResourcesDisplaySet.cs is a for loop that iterates based on the player’s statLifeMax2 (adjusted max health) stat and the life per heart, and in it draws the hearts for each iteration. For bars style (HorizontalBarsPlayerResourcesDisplaySet.cs), ResourceDrawSettings are used (a struct in the same namespace), which has another for loop (line 36) based on elementCount, which is set based on ElementCount (they’re two different things, but that might just be weirdness from the decompiler idk), which is set to _hpSegmentsCount + 2 for the background and to _hpSegmentsCount for the filling in horizontal bars (lines 111 and 121), so basically the same issue. For fancy style (FancyClassicPlayreResourcesDisplaySet.cs), ResourceDrawSettings are used again, this time twice, once for the top row and the bottom row. This time they’re set based on _heartCountRow1 and _heartCountRow2. These are set in lines 309 and 310 of the file, using Utils.Clamp() with a minimum of 0 and maximum of 10. In this case, it will only draw a number of times between 0 and 10 inclusive for each of the two rows, which is why that ui style specifically does not lag the game. As an added fun fact, based on the code I think the same thing would happen with mana, except in this case it would cause lag in the fancy style too since Utils.Clamp() isn’t used.

Leave A Reply