Skip to content

Commit

Permalink
Fix up healthbars
Browse files Browse the repository at this point in the history
  • Loading branch information
chairclr committed Aug 21, 2023
1 parent 94d2282 commit 75d81f2
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
1 change: 0 additions & 1 deletion TerraAngel.Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class SetupSettings

private static void Main(string[] args)
{
Console.ReadLine();
if (args.Length == 0)
{
List<string> sdks = SDKUtility.GetDotnetSDKList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@@ -1,42 +1,57 @@
+using System;%0d%0a
using Microsoft.Xna.Framework;%0d%0ausing Micr
@@ -322,84 +322,140 @@
atch spriteBatch, float lifePercent)%0d%0a%09%7b%0d%0a
+ lifePercent = Math.Clamp(lifePercent, 0f, 1f);%0d%0a
%09%09Rectangle rectangle = Utils.CenteredRect
@@ -1522,104 +1522,124 @@
olor = Color.White * 0.2f;%0d%0a%09%09float num =
+Math.Clamp(
lifeAmount / lifeMax
+, 0f, 1f)
;%0d%0a%09%09int num2 = (int)((float)p.X * num);%0d%0a
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@@ -1,42 +1,57 @@
+using System;%0d%0a
using Microsoft.Xna.Framework;%0d%0ausing Micr
@@ -769,141 +769,85 @@
C.GetMatchingSpawnParams());%0d%0a%09%09int num =
-_creeperForReference.lifeMax * brainOfCthuluCreepersCount
+0
;%0d%0a%09%09float num2 = 0f;%0d%0a%09%09for (int i = 0; i
@@ -959,162 +959,241 @@
pe)%0d%0a%09%09%09%7b%0d%0a%09%09%09%09num2 += (float)nPC2.life;%0d%0a
-%09%09%09
+ num += nPC2.MaxHealthForProgressBar;%0d%0a
%7d%0d%0a%09%09%7d%0d%0a%09%09float current = (float)nPC.life + num2;%0d%0a%09%09int num3 = nPC.
-lifeMax
+MaxHealthForProgressBar
+ num;%0d%0a%09%09_cache.SetLife(current, num3);%0d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@@ -805,119 +805,85 @@
Params());%0d%0a%09%09int num3 = 0;%0d%0a%09%09int num4 =
-_segmentForReference.lifeMax * num2
+0
;%0d%0a%09%09for (int i = 0; i %3c 200; i++)%0d%0a%09%09%7b%0d%0a%09
@@ -964,87 +964,151 @@
ype %3c= 15)%0d%0a%09%09%09%7b%0d%0a%09%09%09%09num3 += nPC2.life;%0d%0a
-%09%09%09
+ num4 += nPC2.MaxHealthForProgressBar;%0d%0a
%7d%0d%0a%09%09%7d%0d%0a%09%09int num5 = num3;%0d%0a%09%09int num6 = n
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@@ -735,306 +735,102 @@
%0a%09%09%09return false;%0d%0a%09%09%7d%0d%0a%09%09int num = 0;%0d%0a%09%09
-_referenceDummy.SetDefaults(245, nPC.GetMatchingSpawnParams());%0d%0a%09%09num += _referenceDummy.lifeMax;%0d%0a%09%09_referenceDummy.SetDefaults(246, nPC.GetMatchingSpawnParams());%0d%0a%09%09num += _referenceDummy.lifeMax;%0d%0a%09%09
float num2 = 0f;%0d%0a
+
%09%09for (int i = 0; i %3c 200; i++)%0d%0a%09%09%7b%0d%0a%09%09%09N
@@ -878,115 +878,169 @@
e && ValidIds.Contains(nPC2.type))%0d%0a%09%09%09%7b%0d%0a
-
%09%09%09%09num2 += (float)nPC2.life;%0d%0a
+ num += nPC2.MaxHealthForProgressBar;%0d%0a
%09%09%09%7d%0d%0a%09%09%7d%0d%0a%09%09_cache.SetLife(num2, num);%0d%0a%09
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@@ -536,91 +536,107 @@
e == 126) ? 125 : 126);%0d%0a%09%09int num2 = nPC.
-lifeMax
+MaxHealthForProgressBar
;%0d%0a%09%09int num3 = nPC.life;%0d%0a%09%09for (int i =
@@ -716,91 +716,107 @@
nPC2.type == num)%0d%0a%09%09%09%7b%0d%0a%09%09%09%09num2 += nPC2.
-lifeMax
+MaxHealthForProgressBar
;%0d%0a%09%09%09%09num3 += nPC2.life;%0d%0a%09%09%09%09break;%0d%0a%09%09%09
10 changes: 10 additions & 0 deletions TerraAngel.Patches/Terraria/Terraria/NPC.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@
-2
+Extensions
.CatmullRom(vector304 + vector307, vector3
@@ -2283031,174 +2283031,335 @@
%09Main.npc%5bi%5d.netOffset *= 0f;%0d%0a%09%09%7d%0d%0a%09%7d%0d%0a%0d%0a
+ public int MaxHealthForProgressBar = 0;%0d%0a%0d%0a
%09public void UpdateNPC(int i)%0d%0a%09%7b%0d%0a%09%09whoAmI = i;%0d%0a%09%09if (!active)%0d%0a%09%09%7b%0d%0a
-%09%09%09
+
return;%0d%0a%09%09%7d%0d%0a
-%09%09
+%0d%0a MaxHealthForProgressBar = Math.Max(Math.Max(life, lifeMax), MaxHealthForProgressBar);%0d%0a%0d%0a
if (offSetDelayTime %3e 0)%0d%0a%09%09%7b%0d%0a%09%09%09netOffse

0 comments on commit 75d81f2

Please sign in to comment.