From 1b105d730df9e99519a0a3f6f86dcc4181c780e1 Mon Sep 17 00:00:00 2001 From: JavidPack Date: Tue, 16 Jan 2024 15:17:35 -0700 Subject: [PATCH] Update various life regen and related hook docs. --- .../Terraria/ModLoader/GlobalNPC.cs | 5 ++++- .../tModLoader/Terraria/ModLoader/ModNPC.cs | 5 ++++- patches/tModLoader/Terraria/NPC.cs.patch | 20 +++++++++++++++++++ patches/tModLoader/Terraria/Player.cs.patch | 5 +++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/patches/tModLoader/Terraria/ModLoader/GlobalNPC.cs b/patches/tModLoader/Terraria/ModLoader/GlobalNPC.cs index 59e43094ce0..d09bbd0c183 100644 --- a/patches/tModLoader/Terraria/ModLoader/GlobalNPC.cs +++ b/patches/tModLoader/Terraria/ModLoader/GlobalNPC.cs @@ -188,7 +188,10 @@ public virtual void HitEffect(NPC npc, NPC.HitInfo hit) } /// - /// Allows you to make the NPC either regenerate health or take damage over time by setting npc.lifeRegen. Regeneration or damage will occur at a rate of half of npc.lifeRegen per second. The damage parameter is the number that appears above the NPC's head if it takes damage over time. + /// Allows you to make the NPC either regenerate health or take damage over time by setting . This is useful for implementing damage over time debuffs such as or . Regeneration or damage will occur at a rate of half of per second. + /// Essentially, modders implementing damage over time debuffs should subtract from a number that is twice as large as the intended damage per second. See DamageOverTimeGlobalNPC.cs for an example of this. + /// The damage parameter is the number that appears above the NPC's head if it takes damage over time. + /// Multiple debuffs work together by following some conventions: should not be assigned a number, rather it should be subtracted from. should only be assigned if the intended popup text is larger then its current value. /// /// /// diff --git a/patches/tModLoader/Terraria/ModLoader/ModNPC.cs b/patches/tModLoader/Terraria/ModLoader/ModNPC.cs index b9a3fa2790d..f8f65a1f4c5 100644 --- a/patches/tModLoader/Terraria/ModLoader/ModNPC.cs +++ b/patches/tModLoader/Terraria/ModLoader/ModNPC.cs @@ -278,7 +278,10 @@ public virtual void HitEffect(NPC.HitInfo hit) } /// - /// Allows you to make the NPC either regenerate health or take damage over time by setting NPC.lifeRegen. Regeneration or damage will occur at a rate of half of NPC.lifeRegen per second. The damage parameter is the number that appears above the NPC's head if it takes damage over time. + /// Allows you to make the NPC either regenerate health or take damage over time by setting . This is useful for implementing damage over time debuffs such as or . Regeneration or damage will occur at a rate of half of per second. + /// Essentially, modders implementing damage over time debuffs should subtract from a number that is twice as large as the intended damage per second. See DamageOverTimeGlobalNPC.cs for an example of this. + /// The damage parameter is the number that appears above the NPC's head if it takes damage over time. + /// Multiple debuffs work together by following some conventions: should not be assigned a number, rather it should be subtracted from. should only be assigned if the intended popup text is larger then its current value. /// /// public virtual void UpdateLifeRegen(ref int damage) diff --git a/patches/tModLoader/Terraria/NPC.cs.patch b/patches/tModLoader/Terraria/NPC.cs.patch index c932459c9bf..2f294b38b59 100644 --- a/patches/tModLoader/Terraria/NPC.cs.patch +++ b/patches/tModLoader/Terraria/NPC.cs.patch @@ -120,6 +120,26 @@ public bool canDisplayBuffs = true; public bool midas; public bool ichor; +@@ -136,7 +_,19 @@ + public bool shadowFlame; + public bool soulDrain; + public bool shimmering; ++ /// ++ /// The rate of this player's life regeneration or loss in health per tick, divided by 120. To put it another way, it is health regeneration every 2 seconds. Used to implement the damage over time of debuffs. ++ ///
For example, subtracting 12 from this value loses 12 / 120 = 1/10 health per tick, or 6 health per second. ++ ///
Life regeneration is accumulated every tick in . ++ ///
This value should be subtracted from in or . See DamageOverTimeGlobalNPC.cs for an example. The game does not actually use positive life regen for NPC, so positive values might not work as expected. ++ ///
+ public int lifeRegen; ++ /// ++ /// This NPC's accumulated life regeneration. ++ ///
If this value reaches or exceeds 120, the NPC gains / 120 health and this value decreases until it no longer exceeds 120. ++ ///
If this value reaches or exceeds -120, the NPC loses health in the same way. ++ ///
In either case, text will appear above the NPC indicating the life regeneration or life loss. ++ ///
+ public int lifeRegenCount; + public int lifeRegenExpectedLossPerSecond = -1; + public bool confused; @@ -182,35 +_,149 @@ public static bool unlockedArmsDealerSpawn = false; public static bool unlockedNurseSpawn = false; diff --git a/patches/tModLoader/Terraria/Player.cs.patch b/patches/tModLoader/Terraria/Player.cs.patch index 5d3a33492d8..90afdc57da0 100644 --- a/patches/tModLoader/Terraria/Player.cs.patch +++ b/patches/tModLoader/Terraria/Player.cs.patch @@ -397,7 +397,7 @@ public float manaCost = 1f; public bool fireWalk; public bool channel; -@@ -961,23 +_,96 @@ +@@ -961,23 +_,97 @@ public int golferScoreAccumulated; public int bartenderQuestLog; public bool downedDD2EventAnyDifficulty; @@ -464,7 +464,7 @@ public int statManaMax2; + + /// -+ /// The rate of this player's life regeneration in health/ticks, divided by 120. ++ /// The rate of this player's life regeneration in health per tick, divided by 120. To put it another way, it is health regeneration every 2 seconds. Used to implement the damage over time of debuffs and life regeneration accessories such as . + ///
For example, adding 10 to this value regenerates 10 / 120 = 1/6 health per tick, or 5 health per second. + ///
Life regeneration is accumulated every tick in . + ///
This value should be subtracted from in and added to in . @@ -475,6 +475,7 @@ + /// This player's accumulated life regeneration. + ///
If this value reaches or exceeds 120, the player gains / 120 health and this value decreases until it no longer exceeds 120. + ///
If this value reaches or exceeds -120, the player loses health in the same way. ++ ///
In either case, text will appear above the player indicating the life regeneration or life loss. + ///
public int lifeRegenCount; +