TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ UpdateLifeRegen()

void Terraria.Player.UpdateLifeRegen ( )
inline

Definition at line 17302 of file Player.cs.

17303 {
17304 //IL_0a81: Unknown result type (might be due to invalid IL or missing references)
17305 //IL_0a86: Unknown result type (might be due to invalid IL or missing references)
17306 //IL_07a7: Unknown result type (might be due to invalid IL or missing references)
17307 //IL_07cb: Unknown result type (might be due to invalid IL or missing references)
17308 //IL_07d1: Unknown result type (might be due to invalid IL or missing references)
17309 //IL_07f6: Unknown result type (might be due to invalid IL or missing references)
17310 //IL_0800: Unknown result type (might be due to invalid IL or missing references)
17311 //IL_0805: Unknown result type (might be due to invalid IL or missing references)
17312 //IL_0848: Unknown result type (might be due to invalid IL or missing references)
17313 //IL_085f: Unknown result type (might be due to invalid IL or missing references)
17314 //IL_0864: Unknown result type (might be due to invalid IL or missing references)
17315 //IL_086e: Unknown result type (might be due to invalid IL or missing references)
17316 //IL_0870: Unknown result type (might be due to invalid IL or missing references)
17317 //IL_087c: Unknown result type (might be due to invalid IL or missing references)
17318 //IL_0883: Unknown result type (might be due to invalid IL or missing references)
17319 //IL_0888: Unknown result type (might be due to invalid IL or missing references)
17320 //IL_0893: Unknown result type (might be due to invalid IL or missing references)
17321 //IL_0898: Unknown result type (might be due to invalid IL or missing references)
17322 //IL_089a: Unknown result type (might be due to invalid IL or missing references)
17323 //IL_089f: Unknown result type (might be due to invalid IL or missing references)
17324 //IL_08eb: Unknown result type (might be due to invalid IL or missing references)
17325 //IL_090e: Unknown result type (might be due to invalid IL or missing references)
17326 //IL_0914: Unknown result type (might be due to invalid IL or missing references)
17327 //IL_0939: Unknown result type (might be due to invalid IL or missing references)
17328 //IL_0943: Unknown result type (might be due to invalid IL or missing references)
17329 //IL_0948: Unknown result type (might be due to invalid IL or missing references)
17330 //IL_0c41: Unknown result type (might be due to invalid IL or missing references)
17331 //IL_0c46: Unknown result type (might be due to invalid IL or missing references)
17332 //IL_0caa: Unknown result type (might be due to invalid IL or missing references)
17333 //IL_0caf: Unknown result type (might be due to invalid IL or missing references)
17334 //IL_0d69: Unknown result type (might be due to invalid IL or missing references)
17335 //IL_0d6e: Unknown result type (might be due to invalid IL or missing references)
17336 //IL_0d13: Unknown result type (might be due to invalid IL or missing references)
17337 //IL_0d18: Unknown result type (might be due to invalid IL or missing references)
17338 //IL_0b9e: Unknown result type (might be due to invalid IL or missing references)
17339 //IL_0ba3: Unknown result type (might be due to invalid IL or missing references)
17340 bool flag = false;
17342 {
17343 flag = true;
17344 }
17345 if (poisoned)
17346 {
17347 if (lifeRegen > 0)
17348 {
17349 lifeRegen = 0;
17350 }
17351 lifeRegenTime = 0f;
17352 lifeRegen -= 4;
17353 }
17354 if (venom)
17355 {
17356 if (lifeRegen > 0)
17357 {
17358 lifeRegen = 0;
17359 }
17360 lifeRegenTime = 0f;
17361 lifeRegen -= 30;
17362 }
17363 if (onFire)
17364 {
17365 if (lifeRegen > 0)
17366 {
17367 lifeRegen = 0;
17368 }
17369 lifeRegenTime = 0f;
17370 lifeRegen -= 8;
17371 }
17372 if (onFire3)
17373 {
17374 if (lifeRegen > 0)
17375 {
17376 lifeRegen = 0;
17377 }
17378 lifeRegenTime = 0f;
17379 lifeRegen -= 8;
17380 }
17381 if (onFrostBurn)
17382 {
17383 if (lifeRegen > 0)
17384 {
17385 lifeRegen = 0;
17386 }
17387 lifeRegenTime = 0f;
17388 lifeRegen -= 16;
17389 }
17390 if (onFrostBurn2)
17391 {
17392 if (lifeRegen > 0)
17393 {
17394 lifeRegen = 0;
17395 }
17396 lifeRegenTime = 0f;
17397 lifeRegen -= 16;
17398 }
17399 if (onFire2)
17400 {
17401 if (lifeRegen > 0)
17402 {
17403 lifeRegen = 0;
17404 }
17405 lifeRegenTime = 0f;
17406 lifeRegen -= 24;
17407 }
17408 if (burned)
17409 {
17410 if (lifeRegen > 0)
17411 {
17412 lifeRegen = 0;
17413 }
17414 lifeRegenTime = 0f;
17415 lifeRegen -= 60;
17416 moveSpeed *= 0.5f;
17417 }
17418 if (suffocating)
17419 {
17420 if (lifeRegen > 0)
17421 {
17422 lifeRegen = 0;
17423 }
17424 lifeRegenTime = 0f;
17425 lifeRegen -= 40;
17426 }
17427 if (electrified)
17428 {
17429 if (lifeRegen > 0)
17430 {
17431 lifeRegen = 0;
17432 }
17433 lifeRegenTime = 0f;
17434 lifeRegen -= 8;
17436 {
17437 lifeRegen -= 32;
17438 }
17439 }
17440 if (tongued && Main.expertMode)
17441 {
17442 if (lifeRegen > 0)
17443 {
17444 lifeRegen = 0;
17445 }
17446 lifeRegenTime = 0f;
17447 lifeRegen -= 100;
17448 }
17450 if (honey && lifeRegen < 0)
17451 {
17452 lifeRegen += 4;
17453 if (lifeRegen > 0)
17454 {
17455 lifeRegen = 0;
17456 }
17457 }
17459 {
17460 lifeRegen = 0;
17461 }
17462 if (flag && lifeRegen < 0)
17463 {
17464 lifeRegen /= 2;
17465 }
17466 lifeRegenTime += 1f;
17467 if (usedAegisCrystal)
17468 {
17469 lifeRegenTime += 0.2f;
17470 }
17471 if (crimsonRegen)
17472 {
17473 lifeRegenTime += 1f;
17474 }
17475 if (soulDrain > 0)
17476 {
17477 lifeRegenTime += 2f;
17478 }
17479 if (flag)
17480 {
17481 if (lifeRegenTime > 90f && lifeRegenTime < 1800f)
17482 {
17483 lifeRegenTime = 1800f;
17484 }
17485 lifeRegenTime += 4f;
17486 lifeRegen += 4;
17487 }
17488 if (honey)
17489 {
17490 lifeRegenTime += 2f;
17491 lifeRegen += 2;
17492 }
17493 if (starving)
17494 {
17495 if (lifeRegen > 0)
17496 {
17497 lifeRegen = 0;
17498 }
17499 if (lifeRegenCount > 0)
17500 {
17501 lifeRegenCount = 0;
17502 }
17503 if (lifeRegenTime > 0f)
17504 {
17505 lifeRegenTime = 0f;
17506 }
17507 int num = 3000;
17508 int num7 = 120 * statLifeMax2 / num;
17509 if (num7 < 4)
17510 {
17511 num7 = 4;
17512 }
17513 lifeRegen = -num7;
17514 }
17515 if (soulDrain > 0)
17516 {
17517 int num8 = (5 + soulDrain) / 2;
17519 lifeRegen += num8;
17520 }
17521 if (heartyMeal)
17522 {
17523 int num9 = 6;
17524 lifeRegen += num9;
17525 }
17526 if (whoAmI == Main.myPlayer && Main.SceneMetrics.HasCampfire)
17527 {
17528 lifeRegen++;
17529 }
17530 if (whoAmI == Main.myPlayer && Main.SceneMetrics.HasHeartLantern)
17531 {
17532 lifeRegen += 2;
17533 }
17535 if (bleed)
17536 {
17537 lifeRegenTime = 0f;
17538 }
17539 float num10 = 0f;
17540 if (lifeRegenTime >= 300f)
17541 {
17542 num10 += 1f;
17543 }
17544 if (lifeRegenTime >= 600f)
17545 {
17546 num10 += 1f;
17547 }
17548 if (lifeRegenTime >= 900f)
17549 {
17550 num10 += 1f;
17551 }
17552 if (lifeRegenTime >= 1200f)
17553 {
17554 num10 += 1f;
17555 }
17556 if (lifeRegenTime >= 1500f)
17557 {
17558 num10 += 1f;
17559 }
17560 if (lifeRegenTime >= 1800f)
17561 {
17562 num10 += 1f;
17563 }
17564 if (lifeRegenTime >= 2400f)
17565 {
17566 num10 += 1f;
17567 }
17568 if (lifeRegenTime >= 3000f)
17569 {
17570 num10 += 1f;
17571 }
17572 if (flag)
17573 {
17574 float num11 = lifeRegenTime - 3000f;
17575 num11 /= 300f;
17576 if (num11 > 0f)
17577 {
17578 if (num11 > 30f)
17579 {
17580 num11 = 30f;
17581 }
17582 num10 += num11;
17583 }
17584 }
17585 else if (lifeRegenTime >= 3600f)
17586 {
17587 num10 += 1f;
17588 lifeRegenTime = 3600f;
17589 }
17591 {
17592 lifeRegenTime += 3f;
17593 num10 *= 1.3f;
17594 }
17596 {
17597 TryToPoop();
17598 }
17599 num10 = ((velocity.X != 0f && grappling[0] <= 0) ? (num10 * 0.5f) : (num10 * 1.25f));
17600 if (crimsonRegen)
17601 {
17602 num10 *= 1.5f;
17603 }
17604 if (shinyStone)
17605 {
17606 num10 *= 1.1f;
17607 }
17608 if (whoAmI == Main.myPlayer && Main.SceneMetrics.HasCampfire)
17609 {
17610 num10 *= 1.1f;
17611 }
17612 if (Main.expertMode && !wellFed)
17613 {
17614 num10 = ((!shinyStone) ? (num10 / 2f) : (num10 * 0.75f));
17615 }
17616 if (rabid)
17617 {
17618 num10 = ((!shinyStone) ? (num10 / 2f) : (num10 * 0.75f));
17619 }
17621 float num12 = (float)statLifeMax2 / 400f * 0.85f + 0.15f;
17622 num10 *= num12;
17623 lifeRegen += (int)Math.Round(num10);
17625 if (palladiumRegen)
17626 {
17627 lifeRegenCount += 4;
17628 }
17629 if (flag && lifeRegen > 0 && statLife < statLifeMax2)
17630 {
17632 if (flag && ((float)Main.rand.Next(30000) < lifeRegenTime || Main.rand.Next(30) == 0))
17633 {
17634 int num13 = Dust.NewDust(position, width, height, 55, 0f, 0f, 200, default(Color), 0.5f);
17635 Main.dust[num13].noGravity = true;
17636 Dust obj = Main.dust[num13];
17637 obj.velocity *= 0.75f;
17638 Main.dust[num13].fadeIn = 1.3f;
17639 Vector2 vector = default(Vector2);
17640 ((Vector2)(ref vector))._002Ector((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
17641 ((Vector2)(ref vector)).Normalize();
17642 vector *= (float)Main.rand.Next(50, 100) * 0.04f;
17643 Main.dust[num13].velocity = vector;
17644 ((Vector2)(ref vector)).Normalize();
17645 vector *= 34f;
17646 Main.dust[num13].position = base.Center - vector;
17647 }
17648 }
17649 while (lifeRegenCount >= 120)
17650 {
17651 lifeRegenCount -= 120;
17652 if (statLife < statLifeMax2)
17653 {
17654 statLife++;
17655 if (crimsonRegen)
17656 {
17657 for (int i = 0; i < 10; i++)
17658 {
17659 int num14 = Dust.NewDust(position, width, height, 5, 0f, 0f, 175, default(Color), 1.75f);
17660 Main.dust[num14].noGravity = true;
17661 Dust obj2 = Main.dust[num14];
17662 obj2.velocity *= 0.75f;
17663 int num2 = Main.rand.Next(-40, 41);
17664 int num3 = Main.rand.Next(-40, 41);
17665 Main.dust[num14].position.X += num2;
17666 Main.dust[num14].position.Y += num3;
17667 Main.dust[num14].velocity.X = (float)(-num2) * 0.075f;
17668 Main.dust[num14].velocity.Y = (float)(-num3) * 0.075f;
17669 }
17670 }
17671 }
17672 if (statLife > statLifeMax2)
17673 {
17675 }
17676 }
17677 if (burned || suffocating || (tongued && Main.expertMode))
17678 {
17679 while (lifeRegenCount <= -600)
17680 {
17681 lifeRegenCount += 600;
17682 statLife -= 5;
17683 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, 5, dramatic: false, dot: true);
17684 if (statLife <= 0 && whoAmI == Main.myPlayer)
17685 {
17686 if (suffocating)
17687 {
17688 KillMe(PlayerDeathReason.ByOther(7), 10.0, 0);
17689 }
17690 else if (tongued)
17691 {
17692 KillMe(PlayerDeathReason.ByOther(12), 10.0, 0);
17693 }
17694 else
17695 {
17696 KillMe(PlayerDeathReason.ByOther(8), 10.0, 0);
17697 }
17698 }
17699 }
17700 return;
17701 }
17702 if (starving)
17703 {
17704 int num4 = statLifeMax2 / 50;
17705 if (num4 < 2)
17706 {
17707 num4 = 2;
17708 }
17709 int num5 = ((ZoneDesert || ZoneSnow) ? (num4 * 2) : num4);
17710 int num6 = 120 * num4;
17711 while (lifeRegenCount <= -num6)
17712 {
17714 statLife -= num5;
17715 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, num5, dramatic: false, dot: true);
17716 if (statLife <= 0 && whoAmI == Main.myPlayer)
17717 {
17718 KillMe(PlayerDeathReason.ByOther(18), 10.0, 0);
17719 }
17720 }
17721 return;
17722 }
17723 while (lifeRegenCount <= -120)
17724 {
17725 if (lifeRegenCount <= -480)
17726 {
17727 lifeRegenCount += 480;
17728 statLife -= 4;
17729 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, 4, dramatic: false, dot: true);
17730 }
17731 else if (lifeRegenCount <= -360)
17732 {
17733 lifeRegenCount += 360;
17734 statLife -= 3;
17735 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, 3, dramatic: false, dot: true);
17736 }
17737 else if (lifeRegenCount <= -240)
17738 {
17739 lifeRegenCount += 240;
17740 statLife -= 2;
17741 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, 2, dramatic: false, dot: true);
17742 }
17743 else
17744 {
17745 lifeRegenCount += 120;
17746 statLife--;
17747 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), CombatText.LifeRegen, 1, dramatic: false, dot: true);
17748 }
17749 if (statLife <= 0 && whoAmI == Main.myPlayer)
17750 {
17751 if (poisoned || venom)
17752 {
17753 KillMe(PlayerDeathReason.ByOther(9), 10.0, 0);
17754 }
17755 else if (electrified)
17756 {
17757 KillMe(PlayerDeathReason.ByOther(10), 10.0, 0);
17758 }
17759 else
17760 {
17761 KillMe(PlayerDeathReason.ByOther(8), 10.0, 0);
17762 }
17763 }
17764 }
17765 }
static PlayerDeathReason ByOther(int type, int playerIndex=-1)
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static void NaturalLifeRegen(Player player, ref float regen)
static void UpdateBadLifeRegen(Player player)
static void UpdateLifeRegen(Player player)
This is where all ModPlayer hooks are gathered and called.
float moveSpeed
The multiplier on this player's F:Terraria.Player.maxRunSpeed and F:Terraria.Player....
Definition Player.cs:2614
bool controlRight
Definition Player.cs:1896
int statLifeMax2
The maximum health this player can have, adjusted by buffs and equipment.
Definition Player.cs:2092
float lifeRegenTime
How effective this player's natural life regeneration should be. Resets whenever the player is hurt,...
Definition Player.cs:2146
bool IsStandingStillForSpecialEffects
Definition Player.cs:3677
PlayerSleepingHelper sleeping
Definition Player.cs:3011
bool palladiumRegen
Definition Player.cs:1390
bool crimsonRegen
Definition Player.cs:1329
bool onFrostBurn2
Definition Player.cs:2485
PlayerSittingHelper sitting
Definition Player.cs:3009
int statLife
The current health of this player. Capped at F:Terraria.Player.statLifeMax2. If you increase this v...
Definition Player.cs:2102
void TryToPoop()
Definition Player.cs:17248
void KillMe(PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp=false)
Definition Player.cs:37626
int[] grappling
Definition Player.cs:2840
int lifeRegenCount
This player's accumulated life regeneration. If this value reaches or exceeds 120,...
Definition Player.cs:2137
int lifeRegen
The rate of this player's life regeneration in health/ticks, divided by 120. For example,...
Definition Player.cs:2130
bool usedAegisCrystal
Definition Player.cs:1057
bool IsAToilet
If true, player will generate F:Terraria.ID.ItemID.PoopBlock after a short period of time while any t...

References Terraria.Player.bleed, Terraria.Player.burned, Terraria.DataStructures.PlayerDeathReason.ByOther(), Terraria.Player.controlLeft, Terraria.Player.controlRight, Terraria.Player.crimsonRegen, Terraria.GameContent.PlayerSittingHelper.details, Terraria.Main.dust, Terraria.Player.electrified, Terraria.Main.expertMode, Terraria.Player.grappling, Terraria.Player.heartyMeal, Terraria.Entity.height, Terraria.Player.honey, Terraria.GameContent.ExtraSeatInfo.IsAToilet, Terraria.GameContent.PlayerSittingHelper.isSitting, Terraria.GameContent.PlayerSleepingHelper.isSleeping, Terraria.Player.IsStandingStillForSpecialEffects, Terraria.Player.itemAnimation, Terraria.Player.KillMe(), Terraria.CombatText.LifeRegen, Terraria.Player.lifeRegen, Terraria.Player.lifeRegenCount, Terraria.Player.lifeRegenTime, Terraria.Player.moveSpeed, Terraria.Main.myPlayer, Terraria.ModLoader.PlayerLoader.NaturalLifeRegen(), Terraria.Dust.NewDust(), Terraria.CombatText.NewText(), Terraria.Player.onFire, Terraria.Player.onFire2, Terraria.Player.onFire3, Terraria.Player.onFrostBurn, Terraria.Player.onFrostBurn2, Terraria.Player.palladiumRegen, Terraria.Player.poisoned, Terraria.Entity.position, Terraria.Player.rabid, Terraria.Main.rand, Terraria.Main.SceneMetrics, Terraria.Player.shinyStone, Terraria.Player.sitting, Terraria.Player.sleeping, Terraria.Player.soulDrain, Terraria.Player.starving, Terraria.Player.statLife, Terraria.Player.statLifeMax2, Terraria.Player.suffocating, Terraria.Player.tongued, Terraria.Player.TryToPoop(), Terraria.ModLoader.PlayerLoader.UpdateBadLifeRegen(), Terraria.ModLoader.PlayerLoader.UpdateLifeRegen(), Terraria.Player.usedAegisCrystal, Terraria.Player.venom, Terraria.Player.wellFed, Terraria.Entity.whoAmI, Terraria.Entity.width, Terraria.Player.ZoneDesert, and Terraria.Player.ZoneSnow.

Referenced by Terraria.Player.Update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: