Standardized all player healing effects into a Player.HealPlayer extension method (#68)
This commit is contained in:
1 parent
afa5291cb2
commit
c4386f6272
15 files changed
+66
-83
No files matched your search
@@ -12,6 +12,7 @@ using CalamityMod.CalPlayer.Dashes;
|
||||
using CalamityMod.Cooldowns;
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.FluidSimulation;
|
||||
using CalamityMod.Items;
|
||||
@@ -2894,10 +2895,7 @@ namespace CalamityMod.CalPlayer
|
||||
int damage = Player.ApplyArmorAccDamageBonusesTo(proj.damage / 10);
|
||||
|
||||
Projectile.NewProjectile(source, new Vector2((int)(Player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(Player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ProjectileType<AngelicAllianceArchangel>(), damage, proj.knockBack / 10f, Player.whoAmI, Main.rand.Next(180), projIndex * start);
|
||||
Player.statLife += 2;
|
||||
Player.HealEffect(2);
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(2);
|
||||
}
|
||||
}
|
||||
if (CalamityKeybinds.SandCloakHotkey.JustPressed && sandCloak && Main.myPlayer == Player.whoAmI && !Player.HasCooldown(Cooldowns.SandCloak.ID))
|
||||
|
||||
@@ -278,12 +278,7 @@ namespace CalamityMod.CalPlayer
|
||||
chaliceBleedoutBuffer = 0D;
|
||||
chaliceDamagePointPartialProgress = 0D;
|
||||
}
|
||||
|
||||
Player.statLife += 100;
|
||||
Player.HealEffect(100);
|
||||
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(100);
|
||||
|
||||
Player.AddCooldown(Cooldowns.NebulousCore.ID, CalamityUtils.SecondsToFrames(90));
|
||||
return false;
|
||||
@@ -307,11 +302,7 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
if (silvaWings)
|
||||
{
|
||||
Player.statLife += Player.statLifeMax2 / 3;
|
||||
Player.HealEffect(Player.statLifeMax2 / 3);
|
||||
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(Player.statLifeMax2 / 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using CalamityMod.Buffs.Alcohol;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Buffs.Placeables;
|
||||
using CalamityMod.Cooldowns;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Items.Accessories;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
@@ -740,9 +741,7 @@ namespace CalamityMod.CalPlayer
|
||||
if (pinkCandleHealFraction >= 1D)
|
||||
{
|
||||
pinkCandleHealFraction = 0D;
|
||||
|
||||
if (Player.statLife < Player.statLifeMax2)
|
||||
Player.statLife++;
|
||||
Player.HealPlayer(1, HealTextType.None);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -12,6 +12,7 @@ using CalamityMod.Cooldowns;
|
||||
using CalamityMod.CustomRecipes;
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.ExtraTextures;
|
||||
using CalamityMod.Items;
|
||||
@@ -541,9 +542,7 @@ namespace CalamityMod.CalPlayer
|
||||
// 26AUG2024: Ozzatron: Cut Draedon's Heart healing in half by making it heal every other frame.
|
||||
if (draedonsHeart && Player.miscCounter % 2 == 1)
|
||||
{
|
||||
Player.statLife += DraedonsHeart.NanomachinesHealPerFrame;
|
||||
if (Player.statLife >= Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(DraedonsHeart.NanomachinesHealPerFrame, HealTextType.None);
|
||||
|
||||
// Old Draedon's Heart dust effect from its standing still regen. Works just fine.
|
||||
int dustID = DustID.TerraBlade;
|
||||
@@ -1280,10 +1279,7 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
if (Player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
Player.statLife += 15;
|
||||
Player.HealEffect(15);
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(15);
|
||||
|
||||
if (profanedCrystal)
|
||||
{
|
||||
@@ -1622,10 +1618,7 @@ namespace CalamityMod.CalPlayer
|
||||
--silverMedkitTimer;
|
||||
if (silverMedkitTimer == 0)
|
||||
{
|
||||
Player.HealEffect(SilverArmorSetChange.SetBonusHealAmount, true);
|
||||
Player.statLife += SilverArmorSetChange.SetBonusHealAmount;
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(SilverArmorSetChange.SetBonusHealAmount);
|
||||
|
||||
SilverArmorSetChange.OnHealEffects(Player);
|
||||
}
|
||||
@@ -2847,10 +2840,7 @@ namespace CalamityMod.CalPlayer
|
||||
// Bloodflare Core's heal over time
|
||||
if (bloodflareCore && bloodflareCoreRemainingHealOverTime > 0 && Player.miscCounter % BloodflareCore.HealFrameCooldown == 0)
|
||||
{
|
||||
Player.statLife += 1;
|
||||
Player.HealEffect(1, false);
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(1, HealTextType.Local);
|
||||
|
||||
// Produce an implosion of blood themed dust so it's obvious an effect is occurring
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
||||
@@ -7,6 +7,8 @@ using CalamityMod.Buffs.StatBuffs;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Cooldowns;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.EntitySources;
|
||||
using CalamityMod.Items.Accessories;
|
||||
using CalamityMod.Items.Armor.Reaver;
|
||||
using CalamityMod.Items.Potions.Alcohol;
|
||||
@@ -118,10 +120,7 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
int heal = 2;
|
||||
Player.lifeSteal -= heal;
|
||||
Player.statLife += heal;
|
||||
Player.HealEffect(heal);
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(heal);
|
||||
|
||||
break;
|
||||
|
||||
@@ -259,10 +258,7 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
int heal = 2;
|
||||
Main.player[Main.myPlayer].lifeSteal -= heal;
|
||||
Player.statLife += heal;
|
||||
Player.HealEffect(heal);
|
||||
if (Player.statLife > Player.statLifeMax2)
|
||||
Player.statLife = Player.statLifeMax2;
|
||||
Player.HealPlayer(heal);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace CalamityMod.Enums
|
||||
{
|
||||
public enum HealTextType
|
||||
{
|
||||
None,
|
||||
Local,
|
||||
Broadcast
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
using CalamityMod.Rarities;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -44,10 +45,7 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
|
||||
int heal = 5;
|
||||
player.lifeSteal -= heal;
|
||||
player.statLife += heal;
|
||||
player.HealEffect(heal);
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
player.HealPlayer(heal);
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo)
|
||||
@@ -57,10 +55,7 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
|
||||
int heal = 5;
|
||||
player.lifeSteal -= heal;
|
||||
player.statLife += heal;
|
||||
player.HealEffect(heal);
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
player.HealPlayer(heal);
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -272,14 +272,20 @@ namespace CalamityMod.Projectiles.Boss
|
||||
if (cannotBeHurt)
|
||||
return true;
|
||||
|
||||
// Applies Vulnerability Hex and/or the effects of Supreme Cirrus' HAGE faces.
|
||||
OnHitPlayer_Internal(player);
|
||||
|
||||
// Compute distance for direct health reduction from overlap.
|
||||
float distSQ = Projectile.DistanceSQ(player.Center);
|
||||
float radiusSQ = CircularHitboxRadius * CircularHitboxRadius * Projectile.scale * Projectile.scale;
|
||||
float radiusRatio = distSQ / radiusSQ;
|
||||
|
||||
// If this code happens to run when the player is not colliding, don't apply any effects.
|
||||
// The performance impact of verifying this is marginal, especially since there's only ever one of this projectile.
|
||||
// == false is necessary since the method is a nullable.
|
||||
if (Colliding(Projectile.Hitbox, player.Hitbox) == false)
|
||||
return false;
|
||||
|
||||
// Applies Vulnerability Hex and/or the effects of Supreme Cirrus' HAGE faces.
|
||||
OnHitPlayer_Internal(player);
|
||||
|
||||
// Check the player's speed. If they are moving fast enough, damage them more severely; this prevents trying to rush straight through the vortex.
|
||||
float playerSpeed = player.velocity.LengthSquared();
|
||||
float speedRatio = playerSpeed / (SpeedToForceMaxDamage * SpeedToForceMaxDamage);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.NPCs.Providence;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -63,12 +64,7 @@ namespace CalamityMod.Projectiles.Boss
|
||||
if (!player.immune && playerDist < 50f && !player.dead && Projectile.position.X < player.position.X + player.width && Projectile.position.X + Projectile.width > player.position.X && Projectile.position.Y < player.position.Y + player.height && Projectile.position.Y + Projectile.height > player.position.Y)
|
||||
{
|
||||
int healAmt = (int)Projectile.ai[1];
|
||||
player.HealEffect(healAmt, false);
|
||||
player.statLife += healAmt;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
{
|
||||
player.statLife = player.statLifeMax2;
|
||||
}
|
||||
player.HealPlayer(healAmt, HealTextType.Local);
|
||||
NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, index, healAmt);
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using CalamityMod.Balancing;
|
||||
using CalamityMod.Enums;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -76,10 +77,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
if (playerDist < 50f && Projectile.position.X < player.position.X + player.width && Projectile.position.X + Projectile.width > player.position.X && Projectile.position.Y < player.position.Y + player.height && Projectile.position.Y + Projectile.height > player.position.Y)
|
||||
{
|
||||
int heal = 10;
|
||||
player.HealEffect(heal, false);
|
||||
player.statLife += heal;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
player.HealPlayer(heal, HealTextType.Local);
|
||||
|
||||
SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/OrbHeal", 5) { Volume = 0.15f }, Projectile.Center);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -116,10 +117,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
int heal = Main.rand.NextBool(4) ? 2 : 1;
|
||||
player.lifeSteal -= heal;
|
||||
player.statLife += heal;
|
||||
player.HealEffect(heal);
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
player.HealPlayer(heal);
|
||||
}
|
||||
|
||||
public void PlayChainsawSounds()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using CalamityMod.Enums;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -46,10 +47,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
if (!player.immune && playerDist < 50f && !player.dead && Projectile.position.X < player.position.X + player.width && Projectile.position.X + Projectile.width > player.position.X && Projectile.position.Y < player.position.Y + player.height && Projectile.position.Y + Projectile.height > player.position.Y)
|
||||
{
|
||||
int healAmt = Utils.Clamp((200 - Projectile.timeLeft) / 10, 1, 10); //min heal is 5, max heal is 10, achievable after 2 seconds
|
||||
player.HealEffect(healAmt, false);
|
||||
player.statLife += healAmt;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
player.HealPlayer(healAmt, HealTextType.Local);
|
||||
|
||||
NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, index, healAmt);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Items;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -70,12 +71,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
dust.fadeIn = Main.rand.NextFloat(3f, 4f);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
player.HealEffect(70, false);
|
||||
player.statLife += 70;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
{
|
||||
player.statLife = player.statLifeMax2;
|
||||
}
|
||||
player.HealPlayer(70, HealTextType.Local);
|
||||
SoundEngine.PlaySound(SoundID.DD2_DarkMageHealImpact, Projectile.Center);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
@@ -363,12 +364,7 @@ namespace CalamityMod
|
||||
if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech)
|
||||
{
|
||||
int healAmt = healing;
|
||||
player.HealEffect(healAmt, false);
|
||||
player.statLife += healAmt;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
{
|
||||
player.statLife = player.statLifeMax2;
|
||||
}
|
||||
player.HealPlayer(healAmt, HealTextType.Local);
|
||||
NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0);
|
||||
}
|
||||
projectile.Kill();
|
||||
|
||||
@@ -13,6 +13,7 @@ using Terraria;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Enums;
|
||||
using static Terraria.Player;
|
||||
|
||||
namespace CalamityMod
|
||||
@@ -930,6 +931,22 @@ namespace CalamityMod
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A short method that heals the player.
|
||||
/// All direct heals in Calamity should use this.
|
||||
/// </summary>
|
||||
/// <param name="player">The player being healed.</param>
|
||||
/// <param name="amount">The amount of life being healed.</param>
|
||||
/// <param name="healTextType">Whether the heal CombatText should be displayed, and whether it should be synced. Displays and syncs by default.</param>
|
||||
public static void HealPlayer(this Player player, int amount, HealTextType healTextType = HealTextType.Broadcast)
|
||||
{
|
||||
player.statLife += amount;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
player.statLife = player.statLifeMax2;
|
||||
if (healTextType != HealTextType.None)
|
||||
player.HealEffect(amount, healTextType == HealTextType.Broadcast);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the given player send the given packet to all appropriate receivers.<br />
|
||||
/// If server is false, the packet is sent only to the multiplayer host.<br />
|
||||
|
||||
Reference in new issue
Block a user