Merge The Hogs
No files matched your search
@@ -182,15 +182,17 @@ namespace CalamityMod.Backgrounds
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, distortionShader.Shader, CalamityUtils.BackgroundMatrix);
|
||||
|
||||
const float distortionXSpeed = -0.012f;
|
||||
const float distortionYSpeed = 0.02f;
|
||||
const float noiseScale = 0.075f;
|
||||
const float noiseStrength = 0.035f;
|
||||
Vector2 timeOffset = new Vector2(distortionXSpeed, distortionYSpeed) * Main.GlobalTimeWrappedHourly * noiseScale;
|
||||
Vector2 noiseScaleStrength = new Vector2(noiseScale, noiseStrength);
|
||||
distortionShader.Shader.Parameters["timeOffset"].SetValue(timeOffset);
|
||||
distortionShader.Shader.Parameters["noiseScaleStrength"].SetValue(noiseScaleStrength);
|
||||
distortionShader.SetShaderTexture(distortionTexture);
|
||||
float distortionXSpeed = -0.012f;
|
||||
float distortionYSpeed = 0.02f;
|
||||
float noiseScale = 0.075f;
|
||||
float noiseStrength = 0.035f;
|
||||
|
||||
distortionShader.Shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
|
||||
distortionShader.Shader.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
distortionShader.Shader.Parameters["distortionStrength"].SetValue(noiseStrength);
|
||||
distortionShader.Shader.Parameters["timeOffset"].SetValue(new Vector2(distortionXSpeed, distortionYSpeed));
|
||||
Main.graphics.GraphicsDevice.Textures[1] = distortionTexture.Value;
|
||||
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
|
||||
|
||||
Main.spriteBatch.Draw(WaterDistortionTarget.Target, new Rectangle(16, 16, Main.screenWidth, Main.screenHeight), Color.White);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.NPCs.AstrumAureus;
|
||||
using CalamityMod.NPCs.CeaselessVoid;
|
||||
using CalamityMod.NPCs.Crabulon;
|
||||
using CalamityMod.NPCs.NormalNPCs.HorribleHog;
|
||||
using CalamityMod.NPCs.OldDuke;
|
||||
using CalamityMod.NPCs.ProfanedGuardians;
|
||||
using CalamityMod.NPCs.Providence;
|
||||
@@ -54,6 +55,13 @@ namespace CalamityMod.Balancing
|
||||
|
||||
NPCSpecificBalancingChanges = new List<NPCBalancingChange>();
|
||||
|
||||
// ENEMIES
|
||||
#region Horrible Hog
|
||||
// Take 300% damage from Finch Staff.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<HorribleHog>(), Do(new ProjectileResistBalancingRule(3f, ProjectileID.BabyBird))));
|
||||
#endregion
|
||||
|
||||
// BOSSES
|
||||
#region Crabulon
|
||||
// 20% resist to true melee.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<Crabulon>(), ResistTrueMelee(0.8f)));
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using CalamityMod.Projectiles.Pets;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.Pets
|
||||
{
|
||||
public class BeldumBuff : ModBuff
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.buffNoTimeDisplay[Type] = true;
|
||||
Main.vanityPet[Type] = true;
|
||||
}
|
||||
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
player.buffTime[buffIndex] = 18000;
|
||||
player.Calamity().beldum = true;
|
||||
bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType<Beldum>()] <= 0;
|
||||
if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType<Beldum>(), 0, 0f, player.whoAmI, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 632 B |
@@ -36,6 +36,7 @@ using CalamityMod.Items.Armor.TitanHeart;
|
||||
using CalamityMod.Items.Armor.Victide;
|
||||
using CalamityMod.Items.Armor.Wulfrum;
|
||||
using CalamityMod.Items.Dyes;
|
||||
using CalamityMod.Items.Fishing;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Mounts;
|
||||
using CalamityMod.Items.Mounts.Minecarts;
|
||||
@@ -600,6 +601,7 @@ namespace CalamityMod.CalPlayer
|
||||
public bool lordePet = false;
|
||||
public bool frostyBat = false;
|
||||
public bool toastyBat = false;
|
||||
public bool beldum = false;
|
||||
public bool starSwallowerPetFroge = false;
|
||||
#endregion
|
||||
|
||||
@@ -2306,6 +2308,7 @@ namespace CalamityMod.CalPlayer
|
||||
lordePet = false;
|
||||
frostyBat = false;
|
||||
toastyBat = false;
|
||||
beldum = false;
|
||||
starSwallowerPetFroge = false;
|
||||
|
||||
onyxExcavator = false;
|
||||
@@ -6338,6 +6341,9 @@ namespace CalamityMod.CalPlayer
|
||||
if (it.type == ItemType<ElephantKiller>())
|
||||
playerUsingWeapon = false;
|
||||
|
||||
if (it.type == ItemType<Spadefish>())
|
||||
playerUsingWeapon = false;
|
||||
|
||||
// Animation check depends on whether the item is "clockwork", like Clockwork Assault Rifle.
|
||||
// "Clockwork" weapons can chain-fire multiple stealth strikes (really only 2 max) until you run out of stealth.
|
||||
bool animationCheck = it.useAnimation == it.useTime
|
||||
|
||||
@@ -323,6 +323,16 @@ namespace CalamityMod.CalPlayer
|
||||
itemDrop = ModContent.ItemType<Shadowfish>();
|
||||
}
|
||||
|
||||
// Lower chance of Spadefish in Hardmode
|
||||
if (underground) // Underground
|
||||
{
|
||||
int chance = Main.hardMode ? 10 : 4;
|
||||
if (attempt.veryrare && Main.rand.NextBool(chance))
|
||||
{
|
||||
itemDrop = ModContent.ItemType<Spadefish>();
|
||||
}
|
||||
}
|
||||
|
||||
if (ZoneAstral)
|
||||
{
|
||||
if (attempt.legendary)
|
||||
|
||||
@@ -212,6 +212,11 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.whoAmI != Main.myPlayer)
|
||||
return;
|
||||
|
||||
// Don't activate for non-friendly projectiles (obviously).
|
||||
// Override CanHitNPC if you want a hostile projectile that can also damage enemies.
|
||||
if (!proj.friendly)
|
||||
return;
|
||||
|
||||
//Undo raider crit after hit
|
||||
if (!proj.Calamity().stealthStrike && !proj.Calamity().stealthStrikeSubProjectile && raiderCritLifespan > 0f)
|
||||
{
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
sampler baseTexture : register(s0);
|
||||
sampler distortionTexture : register(s1);
|
||||
|
||||
float time;
|
||||
float noiseScale;
|
||||
float distortionStrength;
|
||||
float2 timeOffset;
|
||||
float2 noiseScaleStrength;
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR
|
||||
{
|
||||
float2 distortedCoords = coords * noiseScaleStrength.x + timeOffset;
|
||||
float distortion = tex2D(distortionTexture, distortedCoords).r * noiseScaleStrength.y;
|
||||
return tex2D(baseTexture, coords + distortion) * sampleColor.a;
|
||||
float2 distortedCoords = coords + float2(time * timeOffset.x, time * timeOffset.y);
|
||||
float distortion = tex2D(distortionTexture, distortedCoords * noiseScale).r;
|
||||
return tex2D(baseTexture, coords + distortion * distortionStrength);
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
|
||||
@@ -257,6 +257,15 @@ namespace CalamityMod.Effects
|
||||
|
||||
// The shader effect used for Voidragon's Abyssal Fire laser projectile.
|
||||
internal static Asset<Effect> AbyssalFireShader;
|
||||
|
||||
// A simple chromatic abberation effect shader with support for custom abberation colors.
|
||||
internal static Asset<Effect> ChromaticAbberationShader;
|
||||
|
||||
// Distorts a texture using a sine wave of specified amplitude and frequency either vertically or horizontally.
|
||||
internal static Asset<Effect> SineWaveDistortionShader;
|
||||
|
||||
// The swirling aura effect seen around Horrible Hog while its idling.
|
||||
internal static Asset<Effect> HorribleHogAuraShader;
|
||||
#endregion
|
||||
|
||||
#region Big E's Shaders
|
||||
@@ -519,6 +528,15 @@ namespace CalamityMod.Effects
|
||||
|
||||
AbyssalFireShader = LoadShader("AbyssalFireShader");
|
||||
RegisterMiscShader(AbyssalFireShader, "LaserPass", "AbyssalFire");
|
||||
|
||||
ChromaticAbberationShader = LoadShader("ChromaticAbberationShader");
|
||||
RegisterMiscShader(ChromaticAbberationShader, "ChormaAbberationPass", "ChromaticAbberation");
|
||||
|
||||
SineWaveDistortionShader = LoadShader("SineWaveDistortionShader");
|
||||
RegisterMiscShader(SineWaveDistortionShader, "SinePass", "SineWaveDistortion");
|
||||
|
||||
HorribleHogAuraShader = LoadShader("HorribleHogAuraShader");
|
||||
RegisterMiscShader(HorribleHogAuraShader, "ScaryAuraPass", "HorribleHogAura");
|
||||
#endregion
|
||||
|
||||
#region Loading Big E's Shaders
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
sampler baseTexture : register(s0);
|
||||
|
||||
bool useCustomColors;
|
||||
float abberationStrength;
|
||||
float2 impactPosition;
|
||||
float3 primaryAbberationColor;
|
||||
float3 secondaryAbberationColor;
|
||||
float3 tertiaryAbberationColor;
|
||||
|
||||
float3 ChromaticAbberation(sampler2D samplerTexture, float2 coords)
|
||||
{
|
||||
// Calculate the distortion level of each color.
|
||||
float separation = abberationStrength / distance(coords, impactPosition);
|
||||
float rColor = tex2D(samplerTexture, coords + float2(-1, -1) * separation).r;
|
||||
float gColor = tex2D(samplerTexture, coords + float2(1, -1) * separation).g;
|
||||
float bColor = tex2D(samplerTexture, coords + float2(0, 1) * separation).b;
|
||||
|
||||
// Return the three calculations as one singular color.
|
||||
float3 returnColor = float3(rColor, gColor, bColor);
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
float3 ChromaticAbberation_CustomColors(sampler2D samplerTexture, float2 coords)
|
||||
{
|
||||
// Calculate the distortion level of each color.
|
||||
float separation = abberationStrength / distance(coords, impactPosition);
|
||||
float4 pColor = tex2D(samplerTexture, coords + float2(-1, -1) * separation) * float4(primaryAbberationColor, 1);
|
||||
float4 sColor = tex2D(samplerTexture, coords + float2(1, -1) * separation) * float4(primaryAbberationColor, 1);
|
||||
float4 tColor = tex2D(samplerTexture, coords + float2(0, 1) * separation) * float4(primaryAbberationColor, 1);
|
||||
|
||||
// Return the three calculations as one singular color.
|
||||
float3 returnColor = saturate(pColor + sColor + tColor);
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float3 color = useCustomColors ? ChromaticAbberation_CustomColors(baseTexture, coords) : ChromaticAbberation(baseTexture, coords);
|
||||
return sampleColor * float4(color, 1.0);
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass ChormaAbberationPass
|
||||
{
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
sampler vortexNoiseTexture : register(s0);
|
||||
sampler vortexNoiseTexture2 : register(s1);
|
||||
sampler distortionTexture : register(s2);
|
||||
|
||||
float time;
|
||||
float colorPaletteLimit;
|
||||
float spiralArms;
|
||||
float spiralAdditionalAngle;
|
||||
float minPixelFadeDistance;
|
||||
float maxPixelFadeDistance;
|
||||
|
||||
float2 pixelatonFactor;
|
||||
float2 spiralTimeOffset;
|
||||
float2 pixelationFactor;
|
||||
float3 vortexDarkColor;
|
||||
float3 vortexBrightColor;
|
||||
|
||||
float inverseLerp(float from, float to, float x)
|
||||
{
|
||||
return saturate((x - from) / (to - from));
|
||||
}
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// Pixelate.
|
||||
coords = round(coords * pixelationFactor) / pixelationFactor;
|
||||
|
||||
float2 centeredCoords = coords - 0.5;
|
||||
float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283;
|
||||
float distanceToCenter = length(centeredCoords);
|
||||
float2 polarCoords = float2(polarAngle, distanceToCenter);
|
||||
|
||||
// Define coordinates for creating the vortex effect.
|
||||
float vortexRadius = pow(distanceToCenter, 0.6);
|
||||
float vortexAngle = spiralArms * atan2(centeredCoords.y, centeredCoords.x) / 3.141 + spiralAdditionalAngle * vortexRadius;
|
||||
float2 vortexPolarCoords = float2(vortexAngle, vortexRadius) * 0.5 + float2(time * spiralTimeOffset.x, time * spiralTimeOffset.y);
|
||||
|
||||
// Add some distortion over it.
|
||||
float distortion1 = tex2D(distortionTexture, coords * 0.46 + float2(time * -0.02, time * 0.022)).r;
|
||||
float distortion2 = tex2D(distortionTexture, coords * 0.32 + float2(time * 0.018, time * -0.03)).r;
|
||||
float totalDistortion = (distortion1 * 0.5) + (distortion2 * 0.5);
|
||||
|
||||
float4 vortexNoiseColor1 = tex2D(vortexNoiseTexture, vortexPolarCoords + totalDistortion);
|
||||
float4 vortexNoiseColor2 = tex2D(vortexNoiseTexture2, polarCoords + float2(time * -0.02, time * -0.092) + totalDistortion * 0.64);
|
||||
float4 vortexNoiseColor = lerp(vortexNoiseColor1, vortexNoiseColor2, inverseLerp(0, maxPixelFadeDistance - 0.075, distanceToCenter));
|
||||
|
||||
// Apply coloration based on pixel brightness.
|
||||
float brightness = (vortexNoiseColor.r + vortexNoiseColor.g + vortexNoiseColor.b) / 3.0;
|
||||
vortexNoiseColor.rgb *= lerp(vortexDarkColor, vortexBrightColor, brightness);
|
||||
|
||||
// Quantization.
|
||||
vortexNoiseColor = round(vortexNoiseColor * colorPaletteLimit) / colorPaletteLimit;
|
||||
|
||||
// Fade out at the edge of the texture.
|
||||
float edgeFade = inverseLerp(0, minPixelFadeDistance - 0.016, distanceToCenter) * inverseLerp(maxPixelFadeDistance, minPixelFadeDistance, distanceToCenter);
|
||||
// float edgeOffset = tex2D(edgeFadeTexture, vortexPolarCoords + float2(time * spiralTimeOffset.x, time * spiralTimeOffset.y)).r * 0.13;
|
||||
// float edgeFade = smoothstep(0.5, opacityCutoffValue, polarCoords.y + edgeOffset);
|
||||
|
||||
return (vortexNoiseColor * edgeFade) * sampleColor.a;
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass ScaryAuraPass
|
||||
{
|
||||
PixelShader = compile ps_3_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
float rotation; // The rotation of the sprite.
|
||||
float4 color;
|
||||
|
||||
|
||||
texture sampleTexture;
|
||||
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
|
||||
sampler baseTexture : register(s0);
|
||||
float rotation; // The rotation of the sprite.
|
||||
float2 spriteDimensions; // Dimensions of the sprite.
|
||||
float4 spriteRectangle; // For use with animated sprites.
|
||||
|
||||
float realCos(float value)
|
||||
{
|
||||
@@ -11,7 +9,7 @@ float realCos(float value)
|
||||
}
|
||||
|
||||
//This only works on square sprites.
|
||||
float4 main(float2 uv : TEXCOORD) : COLOR
|
||||
float4 main(float4 sampleColor : COLOR0, float2 uv : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float2x2 rotate = float2x2(realCos(rotation), -sin(rotation), sin(rotation), realCos(rotation));
|
||||
float spriteDiagonal = 1 / (sqrt(2) / 2);
|
||||
@@ -19,14 +17,14 @@ float4 main(float2 uv : TEXCOORD) : COLOR
|
||||
|
||||
uv += float2(-0.5, -0.5); //remap the uv to (-0.5, -0.5) - (0.5, 0.5) for trig to work.
|
||||
uv = mul(uv, rotate);
|
||||
uv = mul(uv, downscale);
|
||||
//uv = mul(uv, downscale);
|
||||
uv += float2(0.5, 0.5); //remap the uv properly
|
||||
|
||||
//Crop (Attempting to sample a texture with coordinates that arent between 0 to 1 wraps it around
|
||||
if (uv.x < 0 || uv.x >= 1 || uv.y < 0 || uv.y >= 1)
|
||||
return float4(0, 0, 0, 0);
|
||||
|
||||
return tex2D(Texture1Sampler, uv) * color;
|
||||
return tex2D(baseTexture, uv) * sampleColor;
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
sampler baseTexture : register(s0);
|
||||
|
||||
float time;
|
||||
float waveAmplitude;
|
||||
float waveFrequency;
|
||||
bool distortHorizontally;
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float2 horizontalDistortion = sin(coords.x * waveFrequency + time) * waveAmplitude;
|
||||
float2 verticalDistortion = sin(coords.y * waveFrequency + time) * waveAmplitude;
|
||||
|
||||
if (distortHorizontally)
|
||||
coords.y += horizontalDistortion;
|
||||
else
|
||||
coords.x += verticalDistortion;
|
||||
|
||||
return tex2D(baseTexture, coords) * sampleColor;
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass SinePass
|
||||
{
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 480 B |
|
After Width: | Height: | Size: 468 B |
@@ -12,19 +12,13 @@ namespace CalamityMod.Items.Accessories
|
||||
|
||||
public Color? TooltipExtensionColor => new(195, 223, 255);
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType<HeartofDarkness>();
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 26;
|
||||
Item.height = 26;
|
||||
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.value = CalamityGlobalItem.RarityGreenBuyPrice;
|
||||
Item.rare = ItemRarityID.Green;
|
||||
Item.accessory = true;
|
||||
Item.SetRevExclusive();
|
||||
}
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories
|
||||
|
||||
public class ScionsCurio : ModItem, ILocalizedModType
|
||||
{
|
||||
public static int postHitDamage = 45;
|
||||
public static int postHitDamage = 20;
|
||||
public new string LocalizationCategory => "Items.Accessories";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories
|
||||
public new string LocalizationCategory => "Items.Accessories";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType<Laudanum>();
|
||||
ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType<HeartofDarkness>();
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Critters
|
||||
{
|
||||
public class PiggyGoldItem : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Misc";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Item.ResearchUnlockCount = 5;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.DefaultToCapturedCritter(ModContent.NPCType<PiggyGold>());
|
||||
Item.value = Item.sellPrice(gold: 10);
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 606 B |
@@ -8,6 +8,7 @@ namespace CalamityMod.Items.Critters
|
||||
public class PiggyItem : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Misc";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Item.ResearchUnlockCount = 5;
|
||||
@@ -16,7 +17,7 @@ namespace CalamityMod.Items.Critters
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.DefaultToCapturedCritter(ModContent.NPCType<Piggy>());
|
||||
Item.value = Item.sellPrice(gold: 10);
|
||||
Item.value = Item.sellPrice(silver: 5);
|
||||
Item.rare = ItemRarityID.Blue;
|
||||
Item.Calamity().donorItem = true;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 606 B |
@@ -0,0 +1,409 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.GameContent.Achievements;
|
||||
using Terraria.Graphics.Renderers;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.IO;
|
||||
|
||||
namespace CalamityMod.Items.Fishing
|
||||
{
|
||||
public class Spadefish : RogueWeapon, ILocalizedModType
|
||||
{
|
||||
public static float SpinsToThrow => 3;
|
||||
|
||||
public static float SpinDamageMult => 0.33f;
|
||||
|
||||
public static float SpinAccel => 1.0175f;
|
||||
|
||||
public static float SpinThrowVelocityMult => 1.5f;
|
||||
|
||||
public override float StealthDamageMultiplier => 2f;
|
||||
|
||||
public static int PickPower => 50;
|
||||
public new string LocalizationCategory => "Items.Fishing";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 46;
|
||||
Item.height = 44;
|
||||
Item.damage = 30;
|
||||
Item.knockBack = 2f;
|
||||
Item.useTime = 40;
|
||||
Item.useAnimation = 40;
|
||||
Item.shootSpeed = 12;
|
||||
Item.DamageType = RogueDamageClass.Instance;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.value = CalamityGlobalItem.RarityGreenBuyPrice;
|
||||
Item.rare = ItemRarityID.Green;
|
||||
Item.UseSound = SoundID.Item1;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ModContent.ProjectileType<SpadefishThrown>();
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.pick = PickPower;
|
||||
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
if (player.Calamity().StealthStrikeAvailable())
|
||||
{
|
||||
type = ModContent.ProjectileType<SpadefishHoldout>();
|
||||
Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); //This proj sets StealthStrike on its own setdefaults
|
||||
|
||||
player.Calamity().ConsumeStealthByAttacking(); //Due to the holdout, we manually consume stealth here and on spam.
|
||||
return false;
|
||||
}
|
||||
player.Calamity().rogueStealth = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#region Toggleable Mining
|
||||
|
||||
public bool CanMine = false;
|
||||
public override void ModifyTooltips(List<TooltipLine> tooltips)
|
||||
{
|
||||
tooltips.FindAndReplace("[TOGGLE]", CanMine ? this.GetLocalizedValue("TextWhileEnabled") : this.GetLocalizedValue("TextWhileDisabled"));
|
||||
}
|
||||
public override bool CanRightClick() => Main.keyState.PressingShift();
|
||||
public override void RightClick(Player player)
|
||||
{
|
||||
CanMine = !CanMine;
|
||||
Item.NetStateChanged();
|
||||
}
|
||||
public override bool ConsumeItem(Player player) => false;
|
||||
public override void SaveData(TagCompound tag)
|
||||
{
|
||||
tag.Add("CanMine", CanMine);
|
||||
}
|
||||
|
||||
public override void LoadData(TagCompound tag)
|
||||
{
|
||||
CanMine = tag.GetBool("CanMine");
|
||||
}
|
||||
|
||||
public override void NetSend(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(CanMine);
|
||||
}
|
||||
|
||||
public override void NetReceive(BinaryReader reader)
|
||||
{
|
||||
CanMine = reader.ReadBoolean();
|
||||
}
|
||||
Asset<Texture2D> texture;
|
||||
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
||||
{
|
||||
if (CanMine)
|
||||
{
|
||||
var tex = CalamityUtils.GetTextureEfficient(ref texture, "Terraria/Images/Extra_48").Value;
|
||||
var dotFrame = tex.Frame(8, 39, 4, 23);
|
||||
spriteBatch.Draw(tex, position + new Vector2(16, 16) * Main.inventoryScale, dotFrame, Color.White, 0, dotFrame.Size() * 0.5f, Main.inventoryScale, SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SpadefishThrown : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override string Texture => "CalamityMod/Items/Fishing/Spadefish";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.penetrate = 3;
|
||||
Projectile.width = 16;
|
||||
Projectile.height = 16;
|
||||
Projectile.friendly = true;
|
||||
Projectile.stopsDealingDamageAfterPenetrateHits = true;
|
||||
Projectile.timeLeft = 480;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
bool frameOne = true;
|
||||
public override void AI()
|
||||
{
|
||||
if (frameOne)
|
||||
{
|
||||
Projectile.velocity /= Projectile.MaxUpdates;
|
||||
frameOne = false;
|
||||
}
|
||||
if (Projectile.ai[0] <= 1 && Projectile.timeLeft < 450)
|
||||
Projectile.velocity.Y += 0.08f;
|
||||
if (Projectile.ai[0] == 0)
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4;
|
||||
else if (Projectile.ai[0] == 1)
|
||||
Projectile.rotation += Projectile.velocity.X * 0.15f;
|
||||
|
||||
if (Projectile.timeLeft < 60)
|
||||
{
|
||||
Projectile.Opacity = Projectile.timeLeft / 60f;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
|
||||
if (Projectile.ai[0] == 1)
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4;
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
Projectile.Center += oldVelocity;
|
||||
Projectile.ai[0] = 2;
|
||||
SoundEngine.PlaySound(SoundID.Dig, Projectile.Center);
|
||||
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
|
||||
if (Main.myPlayer == Projectile.owner && Main.LocalPlayer.HeldItem.ModItem is Spadefish s && s.CanMine)
|
||||
for (var j = -1; j < 2; j++)
|
||||
for (var k = -1; k < 2; k++)
|
||||
Dig(Spadefish.PickPower, Projectile.Center.ToTileCoordinates() + new Point(j, k));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Dig(int pickPower, Point point)
|
||||
{
|
||||
var tile = Main.tile[point];
|
||||
var x = tile.X();
|
||||
var y = tile.Y();
|
||||
|
||||
if (!tile.HasTile || Main.tileAxe[tile.TileType] || Main.tileHammer[tile.TileType])
|
||||
return;
|
||||
|
||||
int hitIndex = Main.LocalPlayer.hitTile.HitObject(x, y, 1);
|
||||
|
||||
if (tile.TileType == TileID.MysticSnakeRope)
|
||||
return;
|
||||
|
||||
int pickDmg = Main.LocalPlayer.GetPickaxeDamage(x, y, pickPower, hitIndex, tile);
|
||||
|
||||
|
||||
if (!WorldGen.CanKillTile(x, y))
|
||||
pickDmg = 0;
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
pickDmg *= 2;
|
||||
|
||||
if (Main.LocalPlayer.DoesPickTargetTransformOnKill(Main.LocalPlayer.hitTile, pickDmg, x, y, pickPower, hitIndex, tile))
|
||||
pickDmg = 0;
|
||||
|
||||
if (Main.LocalPlayer.hitTile.AddDamage(hitIndex, pickDmg) >= 100)
|
||||
{
|
||||
AchievementsHelper.CurrentlyMining = true;
|
||||
Main.LocalPlayer.ClearMiningCacheAt(x, y, 1);
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient && Main.tileContainer[tile.TileType])
|
||||
{
|
||||
if (tile.TileType == TileID.DisplayDoll || tile.TileType == TileID.HatRack)
|
||||
NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 20, x, y);
|
||||
else
|
||||
{
|
||||
WorldGen.KillTile(x, y, fail: true);
|
||||
NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y, 1f);
|
||||
}
|
||||
if (tile.TileType == TileID.Containers)
|
||||
{
|
||||
NetMessage.SendData(MessageID.ChestUpdates, -1, -1, null, 1, x, y);
|
||||
}
|
||||
if (tile.TileType == TileID.Containers2)
|
||||
{
|
||||
NetMessage.SendData(MessageID.ChestUpdates, -1, -1, null, 5, x, y);
|
||||
}
|
||||
if (tile.TileType == TileID.Dressers)
|
||||
{
|
||||
NetMessage.SendData(MessageID.ChestUpdates, -1, -1, null, 3, x, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag = tile.HasTile;
|
||||
WorldGen.KillTile(x, y);
|
||||
if (!Main.dedServ && flag && !tile.HasTile)
|
||||
{
|
||||
AchievementsHelper.HandleMining();
|
||||
}
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y);
|
||||
}
|
||||
}
|
||||
AchievementsHelper.CurrentlyMining = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldGen.KillTile(x, y, fail: true);
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y, 1f);
|
||||
NetMessage.SendData(MessageID.SyncTilePicking, -1, -1, null, Main.myPlayer, x, y, pickDmg);
|
||||
}
|
||||
}
|
||||
if (pickDmg != 0)
|
||||
{
|
||||
Main.LocalPlayer.hitTile.Prune();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item178 with { Pitch = -0.5f + 0.25f * Projectile.numHits + (Projectile.Calamity().stealthStrike ? 1f : 0f) }, Projectile.Center);
|
||||
|
||||
Projectile.velocity.X = -Projectile.velocity.X.DirectionalSign();
|
||||
Projectile.velocity.Y = -2f;
|
||||
Projectile.ai[0] = 1;
|
||||
Projectile.damage /= 2;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
var tex = TextureAssets.Projectile[Type];
|
||||
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, lightColor * Projectile.Opacity, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class SpadefishHoldout : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override string Texture => "CalamityMod/Items/Fishing/Spadefish";
|
||||
|
||||
ref float spin => ref Projectile.ai[0];
|
||||
ref float startingDir => ref Projectile.ai[1];
|
||||
|
||||
float throwSpeed = 12; //changing this does nothing, as this is set in the code. This is just a fallback value if something breaks.
|
||||
|
||||
bool reset = false;
|
||||
|
||||
float oldSpin = 0;
|
||||
int digDir = 0;
|
||||
|
||||
float spinSin => MathF.Sin(spin);
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.width = 64;
|
||||
Projectile.height = 64;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Calamity().stealthStrike = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
On_LegacyPlayerRenderer.DrawPlayer += spinThePlayer;
|
||||
}
|
||||
|
||||
private void spinThePlayer(On_LegacyPlayerRenderer.orig_DrawPlayer orig, LegacyPlayerRenderer self, Terraria.Graphics.Camera camera, Player drawPlayer, Vector2 position, float rotation, Vector2 rotationOrigin, float shadow, float scale)
|
||||
{
|
||||
var t = ModContent.ProjectileType<SpadefishHoldout>();
|
||||
if (drawPlayer.ownedProjectileCounts[t] <= 0)
|
||||
{
|
||||
orig(self, camera, drawPlayer, position, rotation, rotationOrigin, shadow, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
var Spade = Main.projectile.FirstOrDefault(p => p.active && p.owner == drawPlayer.whoAmI && p.type == t)?.ModProjectile<SpadefishHoldout>();
|
||||
|
||||
if (Spade is null || Spade.startingDir == 0)
|
||||
{
|
||||
orig(self, camera, drawPlayer, position, rotation, rotationOrigin, shadow, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
using var lease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice);
|
||||
using (lease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
orig(self, camera, drawPlayer, position, rotation, rotationOrigin, shadow, scale);
|
||||
|
||||
bool flip = (Spade.spinSin * Spade.startingDir) < 0;
|
||||
var tex = TextureAssets.Projectile[Type];
|
||||
Main.EntitySpriteDraw(tex.Value, drawPlayer.Center + new Vector2(40, 0) - Main.screenPosition, null, Lighting.GetColor(Spade.Projectile.Center.ToTileCoordinates()), Spade.Projectile.rotation - (flip ? MathHelper.PiOver2 : 0), tex.Size() * 0.5f, new Vector2(Spade.Projectile.scale, Spade.Projectile.scale), flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
|
||||
}
|
||||
float width = Spade.spinSin * Spade.startingDir * drawPlayer.direction;
|
||||
|
||||
using (Main.spriteBatch.Scope())
|
||||
{
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.identity);
|
||||
Main.spriteBatch.Draw(lease.Target, position - Main.screenPosition, null, Color.White, 0, position - Main.screenPosition, new Vector2(MathF.Abs(width), 1), width < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
var player = Main.player[Projectile.owner];
|
||||
if (startingDir == 0)
|
||||
{
|
||||
startingDir = Projectile.velocity.X.DirectionalSign();
|
||||
throwSpeed = Projectile.velocity.Length();
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
}
|
||||
player.direction = 1;
|
||||
player.SetDummyItemTime((int)(player.HeldItem.useTime * player.GetWeaponAttackSpeed(player.HeldItem)));
|
||||
Projectile.Center = player.Center + new Vector2(48 * spinSin, 0 * MathF.Cos(spin)) * startingDir;
|
||||
Projectile.rotation = Projectile.DirectionFrom(player.Center).ToRotation() + MathHelper.PiOver4;
|
||||
if (spin == 0)
|
||||
{
|
||||
spin = MathHelper.TwoPi;
|
||||
}
|
||||
spin *= Spadefish.SpinAccel;
|
||||
|
||||
int res = reset ? -1 : 1;
|
||||
if (res != spinSin.DirectionalSign())
|
||||
{
|
||||
Projectile.ResetLocalNPCHitImmunity();
|
||||
reset = !reset;
|
||||
}
|
||||
|
||||
if (Projectile.timeLeft % 5 == 0 && Main.myPlayer == Projectile.owner && Main.LocalPlayer.HeldItem.ModItem is Spadefish s && s.CanMine)
|
||||
for (var j = -1; j < 2; j++)
|
||||
for (var k = -1; k < 2; k++)
|
||||
SpadefishThrown.Dig(Spadefish.PickPower, Projectile.Center.ToTileCoordinates() + new Point(j, k));
|
||||
|
||||
if (spin > MathHelper.TwoPi * (1 + Spadefish.SpinsToThrow))
|
||||
{
|
||||
player.direction = (int)startingDir;
|
||||
if (Main.myPlayer == Projectile.owner)
|
||||
{
|
||||
var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), player.Center, player.Calamity().mouseRotationFromPlayer.ToRotationVector2() * throwSpeed * Spadefish.SpinThrowVelocityMult, ModContent.ProjectileType<SpadefishThrown>(), Projectile.damage, Projectile.knockBack, player.whoAmI);
|
||||
p.Calamity().stealthStrike = true;
|
||||
}
|
||||
Projectile.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item178 with { pitch = (spin-MathHelper.TwoPi) / (MathHelper.TwoPi * Spadefish.SpinsToThrow) - 0.5f }, Projectile.Center);
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
modifiers.SourceDamage *= Spadefish.SpinDamageMult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 624 B |
@@ -0,0 +1,30 @@
|
||||
using CalamityMod.Buffs.Pets;
|
||||
using CalamityMod.Projectiles.Pets;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Pets
|
||||
{
|
||||
public class IronBall : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Pets";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.DefaultToVanitypet(ModContent.ProjectileType<Beldum>(), ModContent.BuffType<BeldumBuff>());
|
||||
Item.UseSound = SoundID.NPCHit4;
|
||||
Item.value = Item.sellPrice(gold: 2);
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.Calamity().donorItem = true;
|
||||
}
|
||||
|
||||
public override void UseStyle(Player player, Rectangle heldItemFrame)
|
||||
{
|
||||
if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
|
||||
{
|
||||
player.AddBuff(Item.buffType, 15, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 380 B |
@@ -0,0 +1,7 @@
|
||||
namespace CalamityMod.Items.Placeables.Banners
|
||||
{
|
||||
public class HorribleHogBanner : BaseBanner
|
||||
{
|
||||
public override int BannerTileID => 152;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 397 B |
|
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 302 B |
@@ -79,6 +79,7 @@ namespace CalamityMod.Items.Placeables.Furniture.Paintings
|
||||
"Fluffy",
|
||||
"fryzahh",
|
||||
"Gpscorpion",
|
||||
"Hugekraken",
|
||||
"jasper",
|
||||
"LordMetarex",
|
||||
"Moonburn",
|
||||
@@ -143,7 +144,6 @@ namespace CalamityMod.Items.Placeables.Furniture.Paintings
|
||||
"Grox the Great",
|
||||
"Heart Plus Up!",
|
||||
"Hectique",
|
||||
"Hugekraken",
|
||||
"Huggles",
|
||||
"Ian-1KV",
|
||||
"IbanPlay",
|
||||
|
||||
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 698 B |
@@ -1,4 +1,5 @@
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Placeables
|
||||
{
|
||||
@@ -11,5 +12,14 @@ namespace CalamityMod.Items.Placeables
|
||||
}
|
||||
|
||||
public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.VernalSoil>());
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe(25).
|
||||
AddIngredient(ItemID.MudBlock, 25).
|
||||
AddIngredient(ItemID.JungleSpores).
|
||||
AddTile(TileID.Anvils).
|
||||
Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ namespace CalamityMod.Items.Potions.Food
|
||||
public new string LocalizationCategory => "Items.Potions";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType<DisgustingMeat>();
|
||||
Item.ResearchUnlockCount = 5;
|
||||
Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3));
|
||||
ItemID.Sets.FoodParticleColors[Type] = new Color[2] {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Items.Tools;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Potions.Food
|
||||
{
|
||||
public class DivineMeat : ModItem, ILocalizedModType
|
||||
{
|
||||
private static Asset<Texture2D> FadedStarRing;
|
||||
private static Asset<Texture2D> BloomFlare;
|
||||
|
||||
public new string LocalizationCategory => "Items.Potions";
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
BloomFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BloomFlare");
|
||||
FadedStarRing = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/FadedStarRing");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Item.ResearchUnlockCount = 1;
|
||||
Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3));
|
||||
|
||||
ItemID.Sets.IsFood[Type] = true;
|
||||
ItemID.Sets.FoodParticleColors[Type] = new Color[4] {
|
||||
new Color(27, 103, 155),
|
||||
new Color(164, 255, 253),
|
||||
new Color(250, 219, 127),
|
||||
new Color(248, 211, 179),
|
||||
};
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 30;
|
||||
Item.height = 40;
|
||||
Item.useAnimation = Item.useTime = 17;
|
||||
Item.rare = ItemRarityID.Blue;
|
||||
Item.value = Item.buyPrice(silver: 50);
|
||||
Item.maxStack = 1;
|
||||
Item.UseSound = SoundID.Item2;
|
||||
Item.useStyle = ItemUseStyleID.EatFood;
|
||||
Item.buffType = BuffID.WellFed2;
|
||||
Item.buffTime = CalamityUtils.MinutesToFrames(30);
|
||||
Item.useTurn = true;
|
||||
Item.consumable = false;
|
||||
}
|
||||
|
||||
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
|
||||
{
|
||||
// Spawn some cute sparkles for added effect when dropped in the world.
|
||||
if (Main.rand.NextBool(45))
|
||||
{
|
||||
int sparkleAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < sparkleAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Item.Center + Main.rand.NextVector2Circular(Item.width, Item.height);
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
|
||||
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, Main.rand.NextFloat(0.2f, 0.3f), Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.QueueParticleForNextFrame(sparkle, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Additional glowy effects similar to Divine Swine itself.
|
||||
Main.GetItemDrawFrame(Item.type, out _, out Rectangle itemFrame);
|
||||
Vector2 origin = itemFrame.Size() * 0.5f;
|
||||
Vector2 drawPosition = Item.Bottom - Main.screenPosition - new Vector2(0f, origin.Y);
|
||||
float sineWave = MathF.Sin((float)Main.timeForVisualEffects / 180f) * 0.5f + 0.5f;
|
||||
Color drawColor = Color.White * MathHelper.Lerp(0.7f, 0f, sineWave);
|
||||
|
||||
spriteBatch.End(out var snapshot);
|
||||
|
||||
using var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
|
||||
using (pixelationLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Effect chromaAbberShader = CalamityShaders.ChromaticAbberationShader.Value;
|
||||
chromaAbberShader.Parameters["abberationStrength"].SetValue(10f);
|
||||
chromaAbberShader.Parameters["impactPosition"].SetValue(drawPosition);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, chromaAbberShader, PixelationManager.PixelationMatrix);
|
||||
|
||||
float starCircleScale = MathHelper.Lerp(0.3f, 0.15f, sineWave);
|
||||
float starCircleRotation = (float)(Main.timeForVisualEffects / 720f) + whoAmI;
|
||||
spriteBatch.Draw(FadedStarRing.Value, drawPosition, null, drawColor with { A = 0 }, starCircleRotation, FadedStarRing.Size() * 0.5f, starCircleScale, 0, 0f);
|
||||
|
||||
float bloomFlareScale = MathHelper.Lerp(0.15f, 0.05f, sineWave);
|
||||
float bloomFlareRotation = (float)(Main.timeForVisualEffects / 540f) + whoAmI;
|
||||
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, drawColor with { A = 0 }, -bloomFlareRotation, BloomFlare.Size() * 0.5f, bloomFlareScale, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
spriteBatch.Begin(snapshot);
|
||||
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 748 B |
@@ -38,7 +38,7 @@ namespace CalamityMod.Items.SummonItems
|
||||
{
|
||||
var Prov = CalamityGlobalNPC.holyBoss;
|
||||
bool canPissOffProvi = Prov != -1 && Main.npc[Prov].life >= (Main.npc[Prov].lifeMax * 0.95f) && Main.npc[Prov].Calamity().newAI[3] >= 180f && !Main.npc[Prov].Calamity().CurrentlyEnraged;
|
||||
return (!NPC.AnyNPCs(ModContent.NPCType<Providence>()) || canPissOffProvi) && (player.ZoneHallow || player.ZoneUnderworldHeight) && !BossRushEvent.BossRushActive;
|
||||
return ((!NPC.AnyNPCs(ModContent.NPCType<Providence>()) && (player.ZoneHallow || player.ZoneUnderworldHeight)) || canPissOffProvi) && !BossRushEvent.BossRushActive;
|
||||
}
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
using CalamityMod.Items.PermanentBoosters;
|
||||
using System;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Items.PermanentBoosters;
|
||||
using CalamityMod.Items.Potions.Food;
|
||||
using CalamityMod.Packets;
|
||||
using CalamityMod.Packets.Worlds;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -8,90 +21,344 @@ namespace CalamityMod.Items.Tools
|
||||
{
|
||||
public class DisgustingMeat : ModItem, ILocalizedModType
|
||||
{
|
||||
private static Asset<Texture2D> SmallGreyscaleCircle;
|
||||
|
||||
public new string LocalizationCategory => "Items.Tools";
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
SmallGreyscaleCircle = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/SmallGreyscaleCircle");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType<DeliciousMeat>();
|
||||
ItemID.Sets.FoodParticleColors[Type] = new Color[6] {
|
||||
new Color(61, 69, 41),
|
||||
new Color(91, 100, 48),
|
||||
new Color(122, 123, 67),
|
||||
new Color(128, 69, 46),
|
||||
new Color(183, 116, 80),
|
||||
new Color(95, 59, 46),
|
||||
};
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.DefaultToFood(26, 36, 0, 0);
|
||||
Item.value = 0;
|
||||
Item.UseSound = SoundID.NPCDeath13;
|
||||
Item.maxStack = 1;
|
||||
Item.consumable = false;
|
||||
Item.UseSound = SoundID.NPCHit20;
|
||||
}
|
||||
|
||||
public override bool AltFunctionUse(Player player) => true;
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
DisgustingMeatPlayer modPlayer = player.GetModPlayer<DisgustingMeatPlayer>();
|
||||
return !modPlayer.DoingVomitAnimation;
|
||||
}
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
if (player.ItemTimeIsZero)
|
||||
{
|
||||
var calPlayer = player.Calamity();
|
||||
DisgustingMeatPlayer modPlayer = player.GetModPlayer<DisgustingMeatPlayer>();
|
||||
if (player.altFunctionUse == 2)
|
||||
{
|
||||
TryDropBoosterItem(player, ref calPlayer.rageBoostOne, ModContent.ItemType<MushroomPlasmaRoot>());
|
||||
TryDropBoosterItem(player, ref calPlayer.rageBoostTwo, ModContent.ItemType<InfernalBlood>());
|
||||
TryDropBoosterItem(player, ref calPlayer.rageBoostThree, ModContent.ItemType<RedLightningContainer>());
|
||||
TryDropBoosterItem(player, ref calPlayer.adrenalineBoostOne, ModContent.ItemType<ElectrolyteGelPack>());
|
||||
TryDropBoosterItem(player, ref calPlayer.adrenalineBoostTwo, ModContent.ItemType<StarlightFuelCell>());
|
||||
TryDropBoosterItem(player, ref calPlayer.adrenalineBoostThree, ModContent.ItemType<Ectoheart>());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (calPlayer.sTangerine || calPlayer.mFruit || calPlayer.tCloudberry || calPlayer.sStrawberry)
|
||||
{
|
||||
TryDropBoosterItem(player, ref calPlayer.sTangerine, ModContent.ItemType<SanguineTangerine>());
|
||||
TryDropBoosterItem(player, ref calPlayer.mFruit, ModContent.ItemType<MiracleFruit>());
|
||||
TryDropBoosterItem(player, ref calPlayer.tCloudberry, ModContent.ItemType<TaintedCloudberry>());
|
||||
TryDropBoosterItem(player, ref calPlayer.sStrawberry, ModContent.ItemType<SacredStrawberry>());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < player.ConsumedLifeFruit; i++)
|
||||
{
|
||||
int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeFruit);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
}
|
||||
player.ConsumedLifeFruit = 0;
|
||||
for (int j = 0; j < player.ConsumedLifeCrystals; j++)
|
||||
{
|
||||
int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeCrystal);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
}
|
||||
player.ConsumedLifeCrystals = 0;
|
||||
}
|
||||
modPlayer.EjectMiscUpgrades = true;
|
||||
modPlayer.DoingVomitAnimation = true;
|
||||
|
||||
if (calPlayer.cShard || calPlayer.eCore || calPlayer.pHeart)
|
||||
{
|
||||
TryDropBoosterItem(player, ref calPlayer.cShard, ModContent.ItemType<CometShard>());
|
||||
TryDropBoosterItem(player, ref calPlayer.eCore, ModContent.ItemType<EtherealCore>());
|
||||
TryDropBoosterItem(player, ref calPlayer.pHeart, ModContent.ItemType<PhantomHeart>());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int k = 0; k < player.ConsumedManaCrystals; k++)
|
||||
{
|
||||
int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.ManaCrystal);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
}
|
||||
player.ConsumedManaCrystals = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void TryDropBoosterItem(Player player, ref bool condition, int itemType)
|
||||
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
||||
{
|
||||
// Stink particles and flies coming off of the item while it's in the world (yuck!!) ((:sick:))
|
||||
if (Main.rand.NextBool(25))
|
||||
{
|
||||
int stinkFumesAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < stinkFumesAmt; i++)
|
||||
{
|
||||
Vector2 fumesSpawnPosition = Item.Center + Main.rand.NextVector2Circular(Item.width - 8, Item.height - 8);
|
||||
Color fumesInitialColor = Color.Lerp(Color.OliveDrab, Color.DarkGreen, Main.rand.NextFloat());
|
||||
Color fumesFadeColor = Color.Lerp(fumesInitialColor, Color.GhostWhite, Main.rand.NextFloat(0.3f, 0.5f));
|
||||
TimedSmokeParticle fumes = new(fumesSpawnPosition, Vector2.Zero, fumesInitialColor, fumesFadeColor, Main.rand.NextFloat(0.15f, 0.2f), Main.rand.NextFloat(0.4f, 0.6f), Main.rand.Next(45, 60), 0.002f * Main.rand.NextBool().ToDirectionInt(), true);
|
||||
GeneralParticleHandler.QueueParticleForNextFrame(fumes);
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(150))
|
||||
{
|
||||
Vector2 flyGroupSpawnPosition = Item.Top + new Vector2(Main.rand.NextFloat(-16f, 16f), Main.rand.NextFloat(-8f, 0f));
|
||||
int fliesAmt = Main.rand.Next(1, 4);
|
||||
for (int i = 0; i < fliesAmt; i++)
|
||||
{
|
||||
Vector2 flySpawnPosition = flyGroupSpawnPosition + Main.rand.NextVector2Circular(8f, 8f);
|
||||
float flyScale = Main.rand.NextFloat(0.8f, 1f);
|
||||
int flyLifetime = Main.rand.Next(360, 480);
|
||||
FlyParticle fly = new(flySpawnPosition, flyScale, flyLifetime, Item);
|
||||
GeneralParticleHandler.QueueParticleForNextFrame(fly);
|
||||
}
|
||||
}
|
||||
|
||||
// Stink lines.
|
||||
spriteBatch.End(out var snapshot);
|
||||
|
||||
using var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
|
||||
using (pixelationLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Effect sineWaveDistortion = CalamityShaders.SineWaveDistortionShader.Value;
|
||||
sineWaveDistortion.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 6f + whoAmI);
|
||||
sineWaveDistortion.Parameters["waveAmplitude"].SetValue(0.25f);
|
||||
sineWaveDistortion.Parameters["waveFrequency"].SetValue(20f);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, sineWaveDistortion, PixelationManager.PixelationMatrix);
|
||||
|
||||
Main.GetItemDrawFrame(Item.type, out _, out Rectangle itemFrame);
|
||||
Vector2 baseItemDrawOrigin = itemFrame.Size() * 0.5f;
|
||||
Vector2 stinkLineScale = new(0.125f, 0.6f);
|
||||
|
||||
int stinkLineAmt = 2;
|
||||
for (int i = 0; i < stinkLineAmt; i++)
|
||||
{
|
||||
float riseAndFall = MathHelper.Lerp(4f, -4f, MathF.Sin((float)Main.timeForVisualEffects / 120f + whoAmI + (i * 14)) * 0.5f + 0.5f);
|
||||
Vector2 stinkLineDrawPosition = Item.Bottom + new Vector2(Utils.Remap(i, 0, stinkLineAmt - 1, -8f, 8f, true) - 4f, -24f + riseAndFall);
|
||||
spriteBatch.Draw(SmallGreyscaleCircle.Value, stinkLineDrawPosition - Main.screenPosition - new Vector2(0f, baseItemDrawOrigin.Y), null, Color.DarkOliveGreen * 0.82f, 0f, SmallGreyscaleCircle.Size() * 0.5f, stinkLineScale * 0.7f * Item.scale, 0, 0f);
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
spriteBatch.Begin(snapshot);
|
||||
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
public class DisgustingMeatPlayer : ModPlayer
|
||||
{
|
||||
public static int VomitEjectTime => 75;
|
||||
|
||||
public static int VomitMaxTime => 130;
|
||||
|
||||
public bool DoingVomitAnimation = false;
|
||||
|
||||
public bool EjectMiscUpgrades = false;
|
||||
|
||||
public int VomitTime = 0;
|
||||
|
||||
public override void SyncPlayer(int toWho, int fromWho, bool newPlayer) => DisgustingMeatPlayerSyncPacket.Send(this, toWho, fromWho);
|
||||
|
||||
public override void CopyClientState(ModPlayer targetCopy)
|
||||
{
|
||||
DisgustingMeatPlayer clientClone = (DisgustingMeatPlayer)targetCopy;
|
||||
clientClone.DoingVomitAnimation = DoingVomitAnimation;
|
||||
clientClone.EjectMiscUpgrades = EjectMiscUpgrades;
|
||||
clientClone.VomitTime = VomitTime;
|
||||
clientClone.Player.eyeHelper.CurrentEyeFrame = Player.eyeHelper.CurrentEyeFrame;
|
||||
}
|
||||
|
||||
public override void SendClientChanges(ModPlayer clientPlayer)
|
||||
{
|
||||
DisgustingMeatPlayer clientClone = (DisgustingMeatPlayer)clientPlayer;
|
||||
if (clientClone.DoingVomitAnimation != DoingVomitAnimation)
|
||||
DisgustingMeatPlayerSyncPacket.Send(this);
|
||||
}
|
||||
|
||||
public override void UpdateDead()
|
||||
{
|
||||
DoingVomitAnimation = false;
|
||||
EjectMiscUpgrades = false;
|
||||
VomitTime = 0;
|
||||
}
|
||||
|
||||
public override void PostUpdateMiscEffects()
|
||||
{
|
||||
if (Player.whoAmI == Main.myPlayer && DoingVomitAnimation)
|
||||
{
|
||||
// Eject all necessary items at once.
|
||||
if (VomitTime == VomitEjectTime)
|
||||
{
|
||||
EjectPermanentUpgrades();
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath13, Player.Center);
|
||||
}
|
||||
|
||||
if (VomitTime >= VomitMaxTime)
|
||||
{
|
||||
VomitTime = 0;
|
||||
DoingVomitAnimation = false;
|
||||
EjectMiscUpgrades = false;
|
||||
}
|
||||
|
||||
VomitTime++;
|
||||
}
|
||||
|
||||
// Vomit particles bleeehhhhggghghghgh
|
||||
if (VomitTime >= VomitEjectTime && VomitTime <= VomitMaxTime)
|
||||
{
|
||||
if (Main.rand.NextBool(2))
|
||||
{
|
||||
int dustAmt = Main.rand.Next(2, 5);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
int dustType = Utils.SelectRandom(Main.rand, DustID.ToxicBubble, DustID.GreenBlood, DustID.Blood);
|
||||
Vector2 spawnPosition = Player.Center + new Vector2(9f * Player.direction, -8f);
|
||||
Vector2 velocity = Vector2.UnitX.RotatedByRandom(MathHelper.ToRadians(20f) + Player.headRotation) * Main.rand.NextFloat(6f, 8f) * Player.direction;
|
||||
Dust.NewDust(spawnPosition, 1, 1, dustType, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
Vector2 spawnPosition = Player.Center - new Vector2(9f * Player.direction, 8f);
|
||||
Vector2 velocity = Vector2.UnitX.RotatedByRandom(MathHelper.ToRadians(20f) + Player.headRotation) * Main.rand.NextFloat(6f, 8f) * Player.direction;
|
||||
Color color = Color.Lerp(Color.DarkOliveGreen, Color.Green, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle vomit = new(spawnPosition, velocity, color, color, Main.rand.NextFloat(0.3f, 0.5f), Main.rand.NextFloat(0.8f, 1f), Main.rand.Next(30, 45), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(vomit, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyDrawInfo(ref PlayerDrawSet drawInfo)
|
||||
{
|
||||
if (DoingVomitAnimation)
|
||||
{
|
||||
// Rapidly shift between random angles while vomiting.
|
||||
float interpolant = Utils.GetLerpValue(0f, VomitEjectTime, VomitTime, true) * Utils.GetLerpValue(VomitMaxTime, VomitMaxTime - 15, VomitTime, true);
|
||||
float idealRotationDegrees = MathHelper.Lerp(0f, 15f, interpolant);
|
||||
Player.headRotation = MathHelper.ToRadians(Main.rand.NextFloat(-idealRotationDegrees, idealRotationDegrees));
|
||||
|
||||
// Close the eyes as well.
|
||||
Player.eyeHelper.CurrentEyeFrame = Terraria.GameContent.PlayerEyeHelper.EyeFrame.EyeHalfClosed;
|
||||
if (VomitTime >= VomitEjectTime)
|
||||
Player.eyeHelper.CurrentEyeFrame = Terraria.GameContent.PlayerEyeHelper.EyeFrame.EyeClosed;
|
||||
}
|
||||
}
|
||||
|
||||
private void EjectPermanentUpgrades()
|
||||
{
|
||||
var calPlayer = Player.Calamity();
|
||||
if (EjectMiscUpgrades)
|
||||
{
|
||||
// Rage and Adrenaline upgrades.
|
||||
TryDropBoosterItem(ref calPlayer.rageBoostOne, ModContent.ItemType<MushroomPlasmaRoot>());
|
||||
TryDropBoosterItem(ref calPlayer.rageBoostTwo, ModContent.ItemType<InfernalBlood>());
|
||||
TryDropBoosterItem(ref calPlayer.rageBoostThree, ModContent.ItemType<RedLightningContainer>());
|
||||
TryDropBoosterItem(ref calPlayer.adrenalineBoostOne, ModContent.ItemType<ElectrolyteGelPack>());
|
||||
TryDropBoosterItem(ref calPlayer.adrenalineBoostTwo, ModContent.ItemType<StarlightFuelCell>());
|
||||
TryDropBoosterItem(ref calPlayer.adrenalineBoostThree, ModContent.ItemType<Ectoheart>());
|
||||
|
||||
// Celestal Onion.
|
||||
TryDropBoosterItem(ref calPlayer.extraAccessoryML, ModContent.ItemType<CelestialOnion>());
|
||||
|
||||
// Demon Heart.
|
||||
TryDropBoosterItem(ref Player.extraAccessory, ItemID.DemonHeart);
|
||||
|
||||
// Shimmer upgrades.
|
||||
if (Player.usedAegisCrystal || Player.usedAegisFruit || Player.usedArcaneCrystal || Player.usedAmbrosia || Player.usedGalaxyPearl || Player.usedGummyWorm || NPC.peddlersSatchelWasUsed || NPC.combatBookWasUsed || NPC.combatBookVolumeTwoWasUsed)
|
||||
{
|
||||
TryDropBoosterItem(ref Player.usedAegisCrystal, ItemID.AegisCrystal);
|
||||
TryDropBoosterItem(ref Player.usedAegisFruit, ItemID.AegisFruit);
|
||||
TryDropBoosterItem(ref Player.usedArcaneCrystal, ItemID.ArcaneCrystal);
|
||||
TryDropBoosterItem(ref Player.usedAmbrosia, ItemID.Ambrosia);
|
||||
TryDropBoosterItem(ref Player.usedGalaxyPearl, ItemID.GalaxyPearl);
|
||||
TryDropBoosterItem(ref Player.usedGummyWorm, ItemID.GummyWorm);
|
||||
|
||||
// Sync the world data immediately for these three specifically since they aren't fully player side.
|
||||
bool hadSatchel = NPC.peddlersSatchelWasUsed;
|
||||
TryDropBoosterItem(ref NPC.peddlersSatchelWasUsed, ItemID.PeddlersSatchel);
|
||||
if (hadSatchel && Main.netMode != NetmodeID.SinglePlayer)
|
||||
DisableNPCUpgradesSyncPacket.Send(0);
|
||||
|
||||
bool hadCombatBook = NPC.combatBookWasUsed;
|
||||
TryDropBoosterItem(ref NPC.combatBookWasUsed, ItemID.CombatBook);
|
||||
if (hadCombatBook && Main.netMode != NetmodeID.SinglePlayer)
|
||||
DisableNPCUpgradesSyncPacket.Send(1);
|
||||
|
||||
bool hadCombatBookTwo = NPC.combatBookVolumeTwoWasUsed;
|
||||
TryDropBoosterItem(ref NPC.combatBookVolumeTwoWasUsed, ItemID.CombatBookVolumeTwo);
|
||||
if (hadCombatBookTwo && Main.netMode != NetmodeID.SinglePlayer)
|
||||
DisableNPCUpgradesSyncPacket.Send(2);
|
||||
}
|
||||
|
||||
// Artisan Loaf.
|
||||
TryDropBoosterItem(ref Player.ateArtisanBread, ItemID.ArtisanLoaf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calamity health booster fruits.
|
||||
if (calPlayer.sTangerine || calPlayer.mFruit || calPlayer.tCloudberry || calPlayer.sStrawberry)
|
||||
{
|
||||
TryDropBoosterItem(ref calPlayer.sTangerine, ModContent.ItemType<SanguineTangerine>());
|
||||
TryDropBoosterItem(ref calPlayer.mFruit, ModContent.ItemType<MiracleFruit>());
|
||||
TryDropBoosterItem(ref calPlayer.tCloudberry, ModContent.ItemType<TaintedCloudberry>());
|
||||
TryDropBoosterItem(ref calPlayer.sStrawberry, ModContent.ItemType<SacredStrawberry>());
|
||||
}
|
||||
|
||||
// Life fruit.
|
||||
if (Player.ConsumedLifeFruit > 0)
|
||||
{
|
||||
for (int i = 0; i < Player.ConsumedLifeFruit; i++)
|
||||
{
|
||||
int drop = Player.QuickSpawnItem(Player.GetSource_DropAsItem(), ItemID.LifeFruit);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
Main.item[drop].velocity = new Vector2(Main.rand.NextFloat(3f, 9f) * Player.direction, Main.rand.NextFloat(-6f, -4f));
|
||||
}
|
||||
Player.ConsumedLifeFruit = 0;
|
||||
}
|
||||
|
||||
// Heart crystals.
|
||||
if (Player.ConsumedLifeCrystals > 0)
|
||||
{
|
||||
for (int j = 0; j < Player.ConsumedLifeCrystals; j++)
|
||||
{
|
||||
int drop = Player.QuickSpawnItem(Player.GetSource_DropAsItem(), ItemID.LifeCrystal);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
Main.item[drop].velocity = new Vector2(Main.rand.NextFloat(3f, 9f) * Player.direction, Main.rand.NextFloat(-6f, -4f));
|
||||
}
|
||||
Player.ConsumedLifeCrystals = 0;
|
||||
}
|
||||
|
||||
// Calamity mana upgrades.
|
||||
if (calPlayer.cShard || calPlayer.eCore || calPlayer.pHeart)
|
||||
{
|
||||
TryDropBoosterItem(ref calPlayer.cShard, ModContent.ItemType<CometShard>());
|
||||
TryDropBoosterItem(ref calPlayer.eCore, ModContent.ItemType<EtherealCore>());
|
||||
TryDropBoosterItem(ref calPlayer.pHeart, ModContent.ItemType<PhantomHeart>());
|
||||
}
|
||||
|
||||
// Mana Crystals.
|
||||
if (Player.ConsumedManaCrystals > 0)
|
||||
{
|
||||
for (int k = 0; k < Player.ConsumedManaCrystals; k++)
|
||||
{
|
||||
int drop = Player.QuickSpawnItem(Player.GetSource_DropAsItem(), ItemID.ManaCrystal);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
Main.item[drop].velocity = new Vector2(Main.rand.NextFloat(3f, 9f) * Player.direction, Main.rand.NextFloat(-6f, -4f));
|
||||
}
|
||||
Player.ConsumedManaCrystals = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NetMessage.SendData(MessageID.SyncPlayer, -1, -1, null, Player.whoAmI);
|
||||
DisgustingMeatPlayerSyncPacket.Send(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void TryDropBoosterItem(ref bool condition, int itemType)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
condition = false;
|
||||
int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, itemType);
|
||||
int drop = Player.QuickSpawnItem(Player.GetSource_DropAsItem(), itemType);
|
||||
Main.item[drop].noGrabDelay = 100;
|
||||
Main.item[drop].velocity = new Vector2(Main.rand.NextFloat(3f, 9f) * Player.direction, Main.rand.NextFloat(-6f, -4f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,11 @@ GemCrawler: Relatives to the Ilmeran Sea's prismbacks. The aquatic lizards ended
|
||||
BlightSlime: Slimes that have absorbed some of the blighted godly essence. Riddled with impurity, they are now more putrid flesh than gelatin and, having taken in such an amount that they seem ready to burst. Yet unlike most slimes which have relatively basic minds, these seem to be collecting mass with a purpose.
|
||||
Cryon: Archmage Permafrost went through great pains to not take part in combat himself, instead molding cryons to act as his personal guardians. Noticing the spread of godly essence just as many other creatures have, they have come out of stasis to combat any signs of it so that they may defend their master.
|
||||
CryoSlime: Slimes enchanted by the Archmage, as a host to crystallize the frozen power of the tundra into a magical metal. He cast a spell to hide away most of his creations and research soon after leaving the Godseeker's side, well aware that Yharim may attempt to exploit his previous work.
|
||||
DivineSwine: A pig ascended by divine blessing. It flies beautifully through the skies, having become a shining beacon to the sun's primordial light. Incredibly rare, legends say that they reward those who give them a bountiful offering of money.
|
||||
Eidolist: Once members of the dragon cult, they now beg the favor of a new master. They are able to live in the abyss indefinitely thanks to their wyrm-like form, allowing them to serve a new purpose.
|
||||
FearlessGoldfishWarrior: Though Goldfish thrive in their ponds and lakes, many take to land during storms to feed on the worms that have also surfaced. There are even accounts of aquatic warriors who carry daggers of shimmering gold, though most consider these tales far too fishy to be credible.
|
||||
Frogfish: Well-camouflaged and prepared to strike at any moment, Frogfish show that the ocean is rarely as serene as it seems. There are few places where one can find true peace here in the heart of what once was an empire unrivaled.
|
||||
HorribleHog: A hog corrupted by divine blight. It waddles maliciously beneath the scarlet light of the Blood Moon, leading the horde with its hideous bellow. Thankfully, it is not lost, and can be returned to its swine pristinity with the right tools.
|
||||
EarthElemental: After the Brimstone Elemental became dormant, the forgemasters of Azafure used clockwork and crystal to bind the powers of an elemental to a mechanical body. While formidable, it seems the dream of creating a true replacement for an elemental died unfulfilled with Azafure itself.
|
||||
IceClasper: Though their exact origins are an enigma, what is known is that these ethereal beings seek to stamp out any and all sources of warmth that exist in their home. Due to this fact, and taking into account the fossil record, many speculate that ice claspers may have played a vital role in the tundra's creation.
|
||||
ImpiousImmolator: An idol carved in the image of Her, it is lit ablaze with the crafter's lifeforce. After all, what weight does one's life hold when one wishes to see the world wreathed in Her holy flames?
|
||||
@@ -86,7 +88,7 @@ MantisShrimp: Though a variety of answers are given when one asks adventurers ab
|
||||
OverloadedSoldier: A body given life again, overflowing with the souls of warriors that perished during the Crusade who were unable to find peace. Their ravenous hunger for battle has been reignited due to sensing godly essences in the land once more.
|
||||
PerennialSlime: These slimes have seized a small amount of the Goddess of Life's essence. Despite her reimprisonment in the deepest depths of the Abyss, the tendrils of her influence now stretch far into the world beyond.
|
||||
PhantomSpirit: The spirits within the Dungeon only vaguely recall their lives, and yet there is one thing each and all clearly remember, that drives them to chaos: the man responsible for locking them in these cursed walls, and his overwhelming power– power that they have been reminded of, due to one ever growing in strength roaming their halls.
|
||||
Piggy: These little swines waddle their little legs across these lands with little purpose, but they are happy with just that. Yet, little is known about how their little stomach carries a not-so-little amount of fat and muscle.
|
||||
Piggy: Little swines that waddle their little legs across these lands with little purpose. They are strangely reactive to their surroundings, particularly to divine influence. Little is known about why, but that has never stopped all kinds of people from keeping them as cute little pets.
|
||||
ProfanedEnergyBody: Those most devout to Her travel the world, being planted into societies and acting as spies and assassins. Among their duties is constructing shrines in Her honor infused with Her divine power, that She might bless pagans blinded by darkness with visions of Her new age of light.
|
||||
Rimehound: These hounds were bred and trained to survive in the tundra's hostile conditions by Yharim's forces, so that they may act as scouts. Most were simply abandoned by their masters out of either necessity or choice, and were resigned to roam forever without purpose.
|
||||
Rotdog: Fast and furious, these hounds prowl the night, hunting prey with their razor sharp teeth. They are similar in nature to the demon eyes, both being spawned from the same vile mire, yet these creatures are tailored made to end those who have proven themselves a threat to it.
|
||||
|
||||
@@ -507,6 +507,11 @@ BearBuff: {
|
||||
Description: A guardian angel is following you
|
||||
}
|
||||
|
||||
BeldumBuff: {
|
||||
DisplayName: Iron Ball
|
||||
Description: Extra shiny!
|
||||
}
|
||||
|
||||
BloodBound: {
|
||||
DisplayName: Blood Bound
|
||||
Description: You must be desperate for company
|
||||
|
||||
@@ -261,6 +261,20 @@ HydrothermalCrate: {
|
||||
Tooltip: "{$CommonItemTooltip.RightClickToOpen}"
|
||||
}
|
||||
|
||||
Spadefish: {
|
||||
DisplayName: Spadefish
|
||||
Tooltip:
|
||||
'''
|
||||
Throws a spadefish at enemies
|
||||
Stealth Strikes cause you to spin the spade before throwing, damaging nearby enemies
|
||||
[c/aaaaaa:Shift-<right> this item in your inventory to [TOGGLE] breaking tiles]
|
||||
'How can a fish be used to dig through the ground?
|
||||
Some questions are best left unanswered...'
|
||||
'''
|
||||
TextWhileEnabled: disable
|
||||
TextWhileDisabled: enable
|
||||
}
|
||||
|
||||
StuffedFish: {
|
||||
DisplayName: Stuffed Fish
|
||||
Tooltip: Press <right> to extract [HERBS] herbs and [SEEDS] seeds
|
||||
|
||||
@@ -128,6 +128,11 @@ PiggyItem: {
|
||||
Tooltip: ""
|
||||
}
|
||||
|
||||
PiggyGoldItem: {
|
||||
DisplayName: "{$NPCs.PiggyGold.DisplayName}"
|
||||
Tooltip: ""
|
||||
}
|
||||
|
||||
PrismaticGuppyBlueItem: {
|
||||
DisplayName: Blue Prismatic Guppy
|
||||
Tooltip: ""
|
||||
|
||||
@@ -106,6 +106,16 @@ HermitsBoxofOneHundredMedicines: {
|
||||
'''
|
||||
}
|
||||
|
||||
IronBall: {
|
||||
DisplayName: Iron Ball
|
||||
Tooltip:
|
||||
'''
|
||||
Summons a living iron ball
|
||||
<left> the pet to pet it
|
||||
<right> the pet to have it sit on your shoulder
|
||||
'''
|
||||
}
|
||||
|
||||
JoyfulHeart: {
|
||||
DisplayName: Joyful Heart
|
||||
Tooltip: It's oddly warm. Attracts the forbidden one
|
||||
|
||||
@@ -4681,6 +4681,8 @@ GreedPot: {
|
||||
Tooltip: Offer your treasures to the Urn, and your avarice may at last be satiated
|
||||
}
|
||||
|
||||
HorribleHogBanner.DisplayName: Horrible Hog Banner
|
||||
|
||||
EutrophicSandWall: {
|
||||
DisplayName: Unsafe Eutrophic Sand Wall
|
||||
Tooltip: ""
|
||||
|
||||
@@ -561,6 +561,16 @@ Cometfruit: {
|
||||
'''
|
||||
}
|
||||
|
||||
DivineMeat: {
|
||||
DisplayName: Divine Meat
|
||||
Tooltip:
|
||||
'''
|
||||
{$CommonItemTooltip.MinorStats}
|
||||
Not consumabale
|
||||
'A blessed strip of pork that never seems to be entirely consumed...'
|
||||
'''
|
||||
}
|
||||
|
||||
Jackfruit: {
|
||||
DisplayName: Jackfruit
|
||||
Tooltip: "{$CommonItemTooltip.MinorStats}"
|
||||
|
||||
@@ -187,7 +187,7 @@ DisgustingMeat: {
|
||||
Tooltip:
|
||||
'''
|
||||
<left> will remove health and mana upgrades, use with no Calamity upgrades to remove vanilla upgrades
|
||||
<right> will remove rage and adrenaline upgrades, plus other miscellaneous boosters
|
||||
<right> will remove Rage and Adrenaline upgrades, plus other miscellaneous boosters such as Demon Heart
|
||||
Removed boosters will be vomited out of you as items
|
||||
'''
|
||||
}
|
||||
|
||||
@@ -172,6 +172,7 @@ CrawlerTopaz.DisplayName: Topaz Crawler
|
||||
CrimulanBlightSlime.DisplayName: Crimulan Blight Slime
|
||||
Cryon.DisplayName: Cryon
|
||||
CryoSlime.DisplayName: Cryo Slime
|
||||
DivineSwine.DisplayName: Divine Swine
|
||||
EbonianBlightSlime.DisplayName: Ebonian Blight Slime
|
||||
Eidolist.DisplayName: Eidolist
|
||||
FearlessGoldfishWarrior.DisplayName: Fearless Goldfish Warrior
|
||||
@@ -186,6 +187,7 @@ OverloadedSoldier.DisplayName: Overloaded Soldier
|
||||
PerennialSlime.DisplayName: Perennial Slime
|
||||
PhantomSpirit.DisplayName: Phantom Spirit
|
||||
Piggy.DisplayName: Piggy
|
||||
PiggyGold.DisplayName: Gold Piggy
|
||||
PlanterasFreeTentacle.DisplayName: Plantera's Tentacle
|
||||
ProfanedEnergyBody.DisplayName: Profaned Energy
|
||||
Rimehound.DisplayName: Rimehound
|
||||
@@ -576,3 +578,5 @@ TownPiggy: {
|
||||
2: Snort!
|
||||
}
|
||||
}
|
||||
|
||||
HorribleHog.DisplayName: Horrible Hog
|
||||
@@ -19,6 +19,14 @@ GammaAcid.DisplayName: Acid
|
||||
GammaBeam.DisplayName: Gamma Ray
|
||||
GammaRayBurst.DisplayName: G-FUEL BEAM
|
||||
GhostBellShock.DisplayName: Electrical Field
|
||||
HorribleHogChargeHitbox.DisplayName: Horrible Hog
|
||||
HorribleHogRubble.DisplayName: Rubble
|
||||
HorribleHogShockwave.DisplayName: Sinister Swine Shockwave
|
||||
HorribleHogShockwaveSpawner.DisplayName: Horrible Hog Shockwave Spawner
|
||||
HorribleHogVomitBomb.DisplayName: Barf Bomb
|
||||
HorribleHogVomitChunk.DisplayName: Horrible Hog's Leftovers
|
||||
HorribleHogVomitEye.DisplayName: Regurgitated Demon Eye
|
||||
HorribleHogZombieSpawner.DisplayName: Horrible Hog Zombie Spawner
|
||||
HorsPoisonBlast.DisplayName: Poisonous Spit
|
||||
HorsWaterBlast.DisplayName: Water
|
||||
IceClasperEnemyProjectile.DisplayName: Ice Shard
|
||||
|
||||
@@ -2,6 +2,7 @@ Akato.DisplayName: Akato
|
||||
Astrophage.DisplayName: Astrophage
|
||||
BabyGhostBell.DisplayName: Baby Ghost Bell
|
||||
Bear.DisplayName: Bear
|
||||
Beldum.DisplayName: Beldum
|
||||
BendyPet.DisplayName: Dreamfog Dragon
|
||||
BrimlingPet.DisplayName: Brimling
|
||||
ChibiiDoggo.DisplayName: Chibii Devourer
|
||||
|
||||
@@ -345,3 +345,5 @@ WulfrumKnifeProj.DisplayName: Wulfrum Knife
|
||||
NanoblackLightspeedCarveSlashVisual.DisplayName: Nanoblack Light-speed Carve Visuals
|
||||
LemonNadeHoldout.DisplayName: Lemon 'nade
|
||||
LemonNadeProjectile.DisplayName: Lemon 'nade
|
||||
SpadefishHoldout.DisplayName: Spinfish
|
||||
SpadefishThrown.DisplayName: Spadefish
|
||||
@@ -664,6 +664,7 @@ Abyss: Disposing of Silva's remains
|
||||
SulphurSea2: Irradiating one of the oceans
|
||||
Roxcalibur: I wanna rock
|
||||
AuricLandMines: Setting god killing traps
|
||||
IronBall: Adding a bit more iron
|
||||
// Hold Shift tooltip default
|
||||
HoldShiftTooltipExtensionIndicator: Hold Shift for more
|
||||
HoldShiftTooltipReplacementIndicator: Hold Shift for details
|
||||
|
||||
@@ -0,0 +1,988 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Graphics.Metaballs;
|
||||
using CalamityMod.Items.Ammo;
|
||||
using CalamityMod.Items.Critters;
|
||||
using CalamityMod.Items.Placeables.Banners;
|
||||
using CalamityMod.Items.Potions.Food;
|
||||
using CalamityMod.Packets;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace CalamityMod.NPCs.NormalNPCs
|
||||
{
|
||||
public class DivineSwine : ModNPC
|
||||
{
|
||||
public enum BehaviorState
|
||||
{
|
||||
PiggyTransformation = -1,
|
||||
IdleAndFly,
|
||||
OfferingAccepted,
|
||||
OfferingFailed
|
||||
}
|
||||
|
||||
private static Asset<Texture2D> BloomCircle;
|
||||
private static Asset<Texture2D> BloomFlare;
|
||||
private static Asset<Texture2D> ShineFlare;
|
||||
private static Asset<Texture2D> MagicStarCircle;
|
||||
private static Asset<Texture2D> FadedStarRing;
|
||||
private static Asset<Texture2D> DistortionTexture;
|
||||
private static Asset<Texture2D> DivineMeatTexture;
|
||||
|
||||
private static SoundStyle IdleSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineIdle", 4);
|
||||
private static SoundStyle CoinFailSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineCoinFail", 3);
|
||||
private static SoundStyle CoinPassSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineCoinPass", 2);
|
||||
private static SoundStyle SwineSpeakLoopingSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineNearbyLoop")
|
||||
{
|
||||
IsLooped = true,
|
||||
PauseBehavior = PauseBehavior.PauseWithGame,
|
||||
MaxInstances = 0,
|
||||
};
|
||||
|
||||
public int FrameY;
|
||||
|
||||
public bool ShouldTurnAway;
|
||||
|
||||
public Vector2 SquashVector;
|
||||
|
||||
public Vector2 IdleMovementVector;
|
||||
|
||||
public SlotId SwineSpeakSoundSlot;
|
||||
|
||||
public static float MaxSpeed => 0.38f;
|
||||
public static float MaxAcceleration => 0.06f;
|
||||
|
||||
public static Color DivineBlue => new(166, 238, 247);
|
||||
public static Color DivineYellow => new(247, 242, 166);
|
||||
|
||||
public ref float Timer => ref NPC.ai[0];
|
||||
|
||||
public ref float AIState => ref NPC.ai[1];
|
||||
|
||||
public ref float LocalAIState => ref NPC.ai[2];
|
||||
|
||||
public ref float IdleMovementTimer => ref NPC.ai[3];
|
||||
|
||||
public ref float AdditionalBrightness => ref NPC.localAI[0];
|
||||
|
||||
public ref float GlowingVisualScale => ref NPC.localAI[1];
|
||||
|
||||
public ref float DivineSwineTintStrength => ref NPC.localAI[2];
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
On_Main.HoverOverNPCs += DivineSwineRightClickInteraction;
|
||||
On_Main.DrawInfoAccs_AdjustInfoTextColorsForNPC += AdjustLifeformAnalyzerTextColor;
|
||||
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
BloomCircle = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
|
||||
BloomFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BloomFlare");
|
||||
ShineFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/ShineFlare");
|
||||
MagicStarCircle = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/MagicStarCircle");
|
||||
FadedStarRing = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/FadedStarRing");
|
||||
DistortionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Smudges");
|
||||
DivineMeatTexture = ModContent.Request<Texture2D>("CalamityMod/Items/Potions/Food/DivineMeat");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.npcFrameCount[Type] = 14;
|
||||
NPCID.Sets.CountsAsCritter[Type] = true;
|
||||
NPCID.Sets.CantTakeLunchMoney[Type] = true;
|
||||
NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 3, Type);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.damage = 0;
|
||||
NPC.width = 32;
|
||||
NPC.height = 34;
|
||||
NPC.lifeMax = 5;
|
||||
NPC.defense = 99999999;
|
||||
NPC.rarity = 5;
|
||||
NPC.aiStyle = -1;
|
||||
NPC.knockBackResist = 0.1f;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.immortal = true;
|
||||
NPC.noGravity = true;
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
SquashVector = Vector2.One;
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
{
|
||||
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
|
||||
{
|
||||
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Sky,
|
||||
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.DivineSwine")
|
||||
});
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(FrameY);
|
||||
writer.Write(ShouldTurnAway);
|
||||
writer.WriteVector2(SquashVector);
|
||||
writer.WriteVector2(IdleMovementVector);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
writer.Write(NPC.localAI[i]);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
FrameY = reader.ReadInt32();
|
||||
ShouldTurnAway = reader.ReadBoolean();
|
||||
SquashVector = reader.ReadVector2();
|
||||
IdleMovementVector = reader.ReadVector2();
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
NPC.localAI[i] = reader.ReadSingle();
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
switch ((BehaviorState)AIState)
|
||||
{
|
||||
case BehaviorState.PiggyTransformation:
|
||||
MainBehavior_PiggyTransformation();
|
||||
break;
|
||||
|
||||
case BehaviorState.IdleAndFly:
|
||||
MainBehavior_IdleAndFly();
|
||||
break;
|
||||
|
||||
case BehaviorState.OfferingAccepted:
|
||||
MainBehavior_OfferingAccepted();
|
||||
break;
|
||||
|
||||
case BehaviorState.OfferingFailed:
|
||||
MainBehavior_OfferingFailed();
|
||||
break;
|
||||
}
|
||||
|
||||
SoundEffects();
|
||||
AmbientParticles();
|
||||
AnimateSprite();
|
||||
|
||||
Lighting.AddLight(NPC.Center, DivineYellow.ToVector3() * NPC.scale * 0.825f);
|
||||
|
||||
if (AIState != (int)BehaviorState.PiggyTransformation && AIState != (int)BehaviorState.OfferingAccepted && AIState != (int)BehaviorState.OfferingFailed)
|
||||
{
|
||||
AdditionalBrightness = MathHelper.Lerp(AdditionalBrightness, 0f, 0.05f);
|
||||
GlowingVisualScale = MathHelper.Lerp(GlowingVisualScale, 1f, 0.05f);
|
||||
}
|
||||
|
||||
SquashVector = Vector2.Lerp(SquashVector, Vector2.One, 0.05f);
|
||||
ShouldTurnAway = NPC.ArcCollisionCheck(-0.3f, 0.3f, 0.05f, optionalCollisionCheckOverride: (arcBasePoint, arcPoint) =>
|
||||
{
|
||||
return !Collision.CanHitLine(arcBasePoint, 1, 1, arcPoint, 1, 1) || Collision.WetCollision(arcPoint, 1, 1);
|
||||
});
|
||||
|
||||
NPC.rotation = NPC.velocity.X * 0.12f;
|
||||
Timer++;
|
||||
}
|
||||
|
||||
public void MainBehavior_PiggyTransformation()
|
||||
{
|
||||
NPC.velocity *= 0f;
|
||||
NPC.ShowNameOnHover = false;
|
||||
NPC.dontTakeDamage = true;
|
||||
|
||||
// Shrink the sigil and start tinting white.
|
||||
float dissolveStrength = CalamityUtils.SineInOutEasing(Utils.GetLerpValue(0f, 240f, Timer, true), 1);
|
||||
DivineSwineTintStrength = dissolveStrength;
|
||||
GlowingVisualScale = 1f - dissolveStrength;
|
||||
AdditionalBrightness = MathHelper.Lerp(0f, 50f, dissolveStrength);
|
||||
|
||||
// Shake the screen slightly while the player is near Divine Swine.
|
||||
float distanceFromSwine = Main.LocalPlayer.Distance(NPC.Center);
|
||||
if (distanceFromSwine < 400f)
|
||||
{
|
||||
float shakeStrength = Utils.Remap(distanceFromSwine, 400f, 100f, 0f, 3f, true) * Utils.GetLerpValue(0f, 180f, Timer, true);
|
||||
Main.LocalPlayer.SetScreenshake(shakeStrength);
|
||||
}
|
||||
|
||||
// Typical glowy particle VFX.
|
||||
float particleStrengthInterpolant = Utils.GetLerpValue(0f, 180f, Timer, true);
|
||||
int lightSpawnRate = (int)MathHelper.Lerp(8, 1, particleStrengthInterpolant);
|
||||
if (Main.rand.NextBool(lightSpawnRate))
|
||||
{
|
||||
int lightAmt = (int)MathHelper.Lerp(1, 6, particleStrengthInterpolant);
|
||||
for (int i = 0; i < Main.rand.Next(1, lightAmt + 1); i++)
|
||||
{
|
||||
float lightSpeed = MathHelper.Lerp(6f, 12f, particleStrengthInterpolant);
|
||||
float lightScale = MathHelper.Lerp(0.5f, 0.8f, particleStrengthInterpolant) * Main.rand.NextFloat(0.5f, 1f);
|
||||
|
||||
SquishyLightParticle transformLight = new(NPC.Center, Main.rand.NextVector2Circular(lightSpeed, lightSpeed), lightScale, Color.White, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(transformLight, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(lightSpawnRate + 2))
|
||||
{
|
||||
int sparkleAmt = (int)MathHelper.Lerp(1, 5, particleStrengthInterpolant);
|
||||
for (int i = 0; i < Main.rand.Next(1, sparkleAmt + 1); i++)
|
||||
{
|
||||
float sparkleSpeed = MathHelper.Lerp(8f, 18f, particleStrengthInterpolant);
|
||||
float sparkleScale = MathHelper.Lerp(0.2f, 0.5f, particleStrengthInterpolant) * Main.rand.NextFloat(0.5f, 1f);
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
|
||||
QuickSparkleParticle transformSparkle = new(NPC.Center, Main.rand.NextVector2Circular(sparkleSpeed, sparkleSpeed), sparkleColor, sparkleScale, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(transformSparkle, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer >= 180f && Timer % 15f == 0f)
|
||||
{
|
||||
float glowRingScale = Utils.Remap(Timer, 180f, 240f, 1.6f, 2.2f, true);
|
||||
CustomPulse transformRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, glowRingScale, 45);
|
||||
GeneralParticleHandler.SpawnParticle(transformRing, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
|
||||
if (Timer >= 240f)
|
||||
{
|
||||
CustomPulse glowRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 3f, 75);
|
||||
GeneralParticleHandler.SpawnParticle(glowRing, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
BloomParticle bloom = new(NPC.Center, Vector2.Zero, Color.White, 0f, 2f, 125);
|
||||
for (int i = 0; i < 3; i++)
|
||||
GeneralParticleHandler.SpawnParticle(bloom, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
QuickSparkleParticle sparkle = new(NPC.Center, Main.rand.NextVector2Circular(20f, 20f), Color.White, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
|
||||
SquishyLightParticle light = new(NPC.Center, Main.rand.NextVector2Circular(10f, 10f), Main.rand.NextFloat(0.6f, 0.8f), Color.White, Main.rand.Next(45, 60));
|
||||
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? sparkle : light, true, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center);
|
||||
SoundEngine.PlaySound(IdleSound, NPC.Center);
|
||||
if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out var activeSound))
|
||||
activeSound.Stop();
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NPC.Transform(ModContent.NPCType<Piggy>());
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_IdleAndFly()
|
||||
{
|
||||
// Flying around.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer > 0f && Timer % 120f == 0f && Main.rand.NextBool(6))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 1f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
Point tileAhead = (NPC.Center + NPC.velocity * 16f).ToTileCoordinates();
|
||||
bool leavingWorldTop = tileAhead.Y <= 40;
|
||||
bool leavingWorldBottom = tileAhead.Y >= Main.maxTilesY - 40;
|
||||
bool leavingWorldLeft = tileAhead.X <= 40;
|
||||
bool leavingWorldRight = tileAhead.X >= Main.maxTilesX - 40;
|
||||
if (ShouldTurnAway || leavingWorldTop || leavingWorldBottom || leavingWorldLeft || leavingWorldRight)
|
||||
{
|
||||
AvoidTileCollision(MaxSpeed + 0.6f, ref leavingWorldTop, ref leavingWorldBottom, ref leavingWorldLeft, ref leavingWorldRight);
|
||||
IdleMovementTimer = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IdleMovementTimer == 0f)
|
||||
{
|
||||
IdleMovementVector = new Vector2(Main.rand.NextFloat(-100f, 101f));
|
||||
IdleMovementTimer = Main.rand.Next(240, 360);
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
float idealSpeed = MaxSpeed / IdleMovementVector.Length();
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, IdleMovementVector * idealSpeed, MaxAcceleration);
|
||||
IdleMovementTimer--;
|
||||
|
||||
if (NPC.velocity.Y < 2.2f)
|
||||
NPC.velocity.Y += 0.022f;
|
||||
}
|
||||
|
||||
NPC.spriteDirection = (NPC.velocity.X > 0).ToDirectionInt();
|
||||
}
|
||||
|
||||
// Stop and occasionally switch directions.
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
if (Timer > 0f && Timer % 120f == 0f && Main.rand.NextBool(6))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.velocity *= 0.9f;
|
||||
if (Timer > 0f && Timer % 75f == 0f && Main.rand.NextBool(4))
|
||||
NPC.spriteDirection *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_OfferingAccepted()
|
||||
{
|
||||
// Spawn particles and do a lil animation and whateva
|
||||
if (Timer <= 210f)
|
||||
{
|
||||
float lightSpawnDistance = MathHelper.Lerp(52f, 84f, Timer / 210f);
|
||||
float glowRingScale = MathHelper.Lerp(0.3f, 0.9f, Timer / 210f);
|
||||
|
||||
int lightAmt = Main.rand.Next(1, 2);
|
||||
for (int i = 0; i < lightAmt; i++)
|
||||
{
|
||||
Vector2 lightSpawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.7f, 1f);
|
||||
Vector2 lightVelocity = (NPC.Center - lightSpawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(3f, 4f);
|
||||
float lightScale = Utils.Remap(Timer, 0f, 180f, 0.3f, 0.9f, true);
|
||||
Color lightColor = Color.Lerp(DivineBlue, DivineYellow, Main.rand.NextFloat());
|
||||
|
||||
SquishyLightParticle meatLight = new(lightSpawnPosition, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(meatLight, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
|
||||
int sparkleSpawnRate = (int)Utils.Remap(Timer, 0f, 180f, 45, 5, true);
|
||||
if (Main.rand.NextBool(sparkleSpawnRate))
|
||||
{
|
||||
int sparkleAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < sparkleAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.8f, 1.2f);
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
float sparkleScale = Utils.Remap(Timer, 0f, 180f, 0.2f, 0.8f, true);
|
||||
|
||||
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, sparkleScale * Main.rand.NextFloat(0.5f, 1f), Main.rand.Next(20, 30));
|
||||
GeneralParticleHandler.SpawnParticle(sparkle, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer % 15f == 0f)
|
||||
{
|
||||
CustomPulse meatLightRing = new(NPC.Center, Vector2.Zero, DivineBlue, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, glowRingScale, 0f, 25);
|
||||
GeneralParticleHandler.SpawnParticle(meatLightRing, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
}
|
||||
|
||||
// Divine meat granted
|
||||
if (Timer == 210f)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int meat = Item.NewItem(NPC.GetSource_GiftOrReward(), NPC.Center, ModContent.ItemType<DivineMeat>());
|
||||
Main.item[meat].velocity = Vector2.UnitY * -3f;
|
||||
}
|
||||
|
||||
CustomPulse meatLightRing = new(NPC.Center, Vector2.Zero, DivineBlue, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 3f, 75);
|
||||
GeneralParticleHandler.SpawnParticle(meatLightRing, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
BloomParticle meatBloom = new(NPC.Center, Vector2.Zero, Color.White, 0f, 3f, 125);
|
||||
for (int i = 0; i < 3; i++)
|
||||
GeneralParticleHandler.SpawnParticle(meatBloom, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
QuickSparkleParticle meatSparkle = new(NPC.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(13f, 15f), sparkleColor, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
|
||||
|
||||
Color lightColor = Color.Lerp(DivineBlue, DivineYellow, Main.rand.NextFloat());
|
||||
SquishyLightParticle meatLight = new(NPC.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(3f, 5f), Main.rand.NextFloat(1.4f, 1.8f), lightColor, Main.rand.Next(45, 60));
|
||||
|
||||
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? meatSparkle : meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
|
||||
// Despawn immediately afterwards.
|
||||
NPC.checkDead();
|
||||
NPC.active = false;
|
||||
}
|
||||
|
||||
GlowingVisualScale = Utils.Remap(Timer, 0f, 210f, 1f, 0f, true);
|
||||
AdditionalBrightness = Utils.Remap(Timer, 0f, 45f, 1f, 0f, true);
|
||||
NPC.scale *= 0.96f;
|
||||
NPC.velocity *= 0.9f;
|
||||
NPC.ShowNameOnHover = false;
|
||||
}
|
||||
|
||||
public void MainBehavior_OfferingFailed()
|
||||
{
|
||||
if (Timer >= 75f)
|
||||
{
|
||||
CustomPulse meatLightRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 2f, 75);
|
||||
GeneralParticleHandler.SpawnParticle(meatLightRing, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
BloomParticle meatBloom = new(NPC.Center, Vector2.Zero, Color.White, 0f, 2f, 125);
|
||||
for (int i = 0; i < 3; i++)
|
||||
GeneralParticleHandler.SpawnParticle(meatBloom, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
QuickSparkleParticle meatSparkle = new(NPC.Center, Main.rand.NextVector2Circular(15f, 15f), Color.White, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
|
||||
SquishyLightParticle meatLight = new(NPC.Center, Main.rand.NextVector2Circular(5f, 5f), Main.rand.NextFloat(0.6f, 0.8f), Color.White, Main.rand.Next(45, 60));
|
||||
|
||||
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? meatSparkle : meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center);
|
||||
SoundEngine.PlaySound(IdleSound, NPC.Center);
|
||||
|
||||
NPC.checkDead();
|
||||
NPC.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Timer <= 45f)
|
||||
{
|
||||
DivineSwineTintStrength = MathHelper.Lerp(0f, 1f, CalamityUtils.PolyInOutEasing(Timer / 45f, 2));
|
||||
GlowingVisualScale = MathHelper.Lerp(1f, 0f, CalamityUtils.PolyInOutEasing(Timer / 45f, 2));
|
||||
}
|
||||
|
||||
int lightAmt = Main.rand.Next(2, 3);
|
||||
for (int i = 0; i < lightAmt; i++)
|
||||
{
|
||||
float lightScale = Main.rand.NextFloat(0.15f, 0.3f);
|
||||
SquishyLightParticle meatLight = new(NPC.Center, Main.rand.NextVector2Circular(2f, 2f), lightScale, Color.White, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(meatLight, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
|
||||
NPC.velocity *= 0.9f;
|
||||
NPC.ShowNameOnHover = false;
|
||||
}
|
||||
|
||||
public void TransformIntoPiggy()
|
||||
{
|
||||
AIState = (int)BehaviorState.PiggyTransformation;
|
||||
LocalAIState = 0f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
public bool TryTransformingIntoPiggy()
|
||||
{
|
||||
if (AIState == (int)BehaviorState.PiggyTransformation)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AvoidTileCollision(float maxSpeed, ref bool leavingWorldTop, ref bool leavingWorldBottom, ref bool leavingWorldLeft, ref bool leavingWorldRight, float turnAwayStrength = 0.125f)
|
||||
{
|
||||
float distanceToCollisionLeft = CalamityUtils.DistanceToTileCollisionHit(NPC.Center, NPC.velocity.RotatedBy(MathHelper.PiOver2), 32, ShouldAvoidTile) ?? 10000f;
|
||||
float distanceToCollisionRight = CalamityUtils.DistanceToTileCollisionHit(NPC.Center, NPC.velocity.RotatedBy(-MathHelper.PiOver2), 32, ShouldAvoidTile) ?? 10000f;
|
||||
int directionToMove = (distanceToCollisionLeft > distanceToCollisionRight).ToDirectionInt();
|
||||
|
||||
Vector2 idealVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2 * directionToMove) * (maxSpeed - NPC.velocity.Length());
|
||||
if (leavingWorldTop)
|
||||
idealVelocity = Vector2.UnitY * 2f;
|
||||
if (leavingWorldBottom)
|
||||
idealVelocity = Vector2.UnitY * -2f;
|
||||
if (leavingWorldLeft)
|
||||
idealVelocity = Vector2.UnitX * 2f;
|
||||
if (leavingWorldRight)
|
||||
idealVelocity = Vector2.UnitX * -2f;
|
||||
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, idealVelocity, turnAwayStrength);
|
||||
}
|
||||
|
||||
public void AmbientParticles()
|
||||
{
|
||||
if (AIState != (int)BehaviorState.IdleAndFly)
|
||||
return;
|
||||
|
||||
// Feathers, both falling and non falling ones.
|
||||
if (Main.rand.NextBool(70))
|
||||
{
|
||||
int featherAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < featherAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height);
|
||||
Vector2 velocity = Vector2.UnitY * Main.rand.NextFloat(0.25f, 0.75f);
|
||||
Color featherColor = Color.Lerp(Color.Lerp(new Color(27, 103, 155), new Color(83, 184, 255), Main.rand.NextFloat()), new Color(221, 253, 255), Main.rand.NextFloat(0.4f));
|
||||
float scale = Main.rand.NextFloat(0.8f, 1f);
|
||||
FeatherParticle feather = new(spawnPosition, velocity, featherColor, scale, Main.rand.Next(360, 480), null, 0.8f, true, false, true);
|
||||
|
||||
GeneralDrawLayer featherLayer = Utils.SelectRandom(Main.rand, GeneralDrawLayer.BeforeNPCs, GeneralDrawLayer.AfterNPCs);
|
||||
GeneralParticleHandler.SpawnParticle(feather, manualDrawLayerOverride: featherLayer);
|
||||
}
|
||||
}
|
||||
|
||||
// Small sparkles.
|
||||
if (Main.rand.NextBool(45))
|
||||
{
|
||||
int sparkleAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < sparkleAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(80f, 160f);
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
|
||||
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, Main.rand.NextFloat(0.2f, 0.3f), Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(sparkle, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimateSprite()
|
||||
{
|
||||
if (Timer % 5 == 0f)
|
||||
{
|
||||
FrameY++;
|
||||
if (FrameY >= Main.npcFrameCount[Type] - 1)
|
||||
FrameY = 0;
|
||||
|
||||
if (FrameY == 5)
|
||||
NPC.velocity.Y -= (NPC.velocity.X != 0f) ? 2.2f : 0.46f;
|
||||
}
|
||||
}
|
||||
|
||||
public void SoundEffects()
|
||||
{
|
||||
if (NPC.soundDelay == 0 && Main.rand.NextBool(200) && AIState == (int)BehaviorState.IdleAndFly)
|
||||
{
|
||||
SoundEngine.PlaySound(IdleSound, NPC.Center);
|
||||
SquashVector = Utils.SelectRandom(Main.rand, new Vector2(1.4f, 0.7f), new Vector2(0.7f, 1.4f));
|
||||
AdditionalBrightness = Main.rand.NextFloat(0.3f, 0.4f);
|
||||
NPC.soundDelay = Main.rand.Next(60, 120);
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (!SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out _))
|
||||
SwineSpeakSoundSlot = SoundEngine.PlaySound(SwineSpeakLoopingSound, NPC.Center, SoundCallbackMethod);
|
||||
|
||||
// Fade the music depending on the distance between the player and Divine Swine.
|
||||
float musicVolumeInterpolant = Utils.Remap(NPC.Distance(Main.LocalPlayer.Center), 600f, 100f, 1f, 0.2f, true);
|
||||
Main.musicFade[Main.curMusic] = musicVolumeInterpolant;
|
||||
}
|
||||
|
||||
private bool SoundCallbackMethod(ActiveSound soundInstance)
|
||||
{
|
||||
soundInstance.Position = NPC.Center;
|
||||
|
||||
float idealPitch = 0f;
|
||||
bool raisePitchDuringBehavior = AIState == (int)BehaviorState.OfferingAccepted || AIState == (int)BehaviorState.PiggyTransformation;
|
||||
if (raisePitchDuringBehavior)
|
||||
idealPitch = 0.4f;
|
||||
|
||||
float volumeInterpolant = Utils.Remap(NPC.Distance(Main.LocalPlayer.Center), 600f, 100f, 0.1f, 0.7f, true) * GlowingVisualScale;
|
||||
soundInstance.Volume = volumeInterpolant;
|
||||
soundInstance.Pitch = MathHelper.Lerp(soundInstance.Pitch, idealPitch, 0.075f);
|
||||
return NPC.active;
|
||||
}
|
||||
|
||||
public void AcceptOffering(bool accepted)
|
||||
{
|
||||
SoundStyle offeringSound = accepted ? CoinPassSound : CoinFailSound;
|
||||
SoundEngine.PlaySound(offeringSound, NPC.Center);
|
||||
if (accepted)
|
||||
SoundEngine.PlaySound(SoundID.Coins, NPC.Center);
|
||||
|
||||
AIState = accepted ? (int)BehaviorState.OfferingAccepted : (int)BehaviorState.OfferingFailed;
|
||||
Timer = 0f;
|
||||
LocalAIState = 0f;
|
||||
NPC.netUpdate = true;
|
||||
NetMessage.SendData(MessageID.WorldData);
|
||||
}
|
||||
|
||||
private bool ShouldAvoidTile(Tile tile) => WorldGen.SolidTile(tile) || (tile.HasUnactuatedTile && Main.tileSolidTop[tile.TileType]) || tile.LiquidAmount >= 255;
|
||||
|
||||
public override float SpawnChance(NPCSpawnInfo spawnInfo)
|
||||
{
|
||||
if (spawnInfo.Sky && NPC.CountNPCS(Type) < 1)
|
||||
return 0.001f;
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private static void DivineSwineRightClickInteraction(On_Main.orig_HoverOverNPCs orig, Main self, Rectangle mouseRectangle)
|
||||
{
|
||||
orig(self, mouseRectangle);
|
||||
|
||||
Player player = Main.LocalPlayer;
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
if (npc.type != ModContent.NPCType<DivineSwine>())
|
||||
continue;
|
||||
|
||||
if ((!npc.ShowNameOnHover || !(npc.active & (npc.shimmerTransparency == 0f || npc.CanApplyHunterPotionEffects()))))
|
||||
continue;
|
||||
|
||||
Main.instance.LoadNPC(npc.whoAmI);
|
||||
npc.position += npc.netOffset;
|
||||
|
||||
Rectangle npcRectangle = new((int)(npc.Bottom.X - npc.frame.Width * 0.5f), (int)(npc.Bottom.Y - npc.frame.Height), npc.frame.Width, npc.frame.Height);
|
||||
NPCLoader.ModifyHoverBoundingBox(npc, ref npcRectangle);
|
||||
|
||||
bool hoveringOverHitbox = mouseRectangle.Intersects(npcRectangle);
|
||||
bool canBeInteractedWith = hoveringOverHitbox || (Main.SmartInteractShowingGenuine && Main.SmartInteractNPC == npc.whoAmI);
|
||||
if (canBeInteractedWith && npc.ai[1] != 1)
|
||||
{
|
||||
player.cursorItemIconEnabled = true;
|
||||
player.cursorItemIconID = ItemID.PlatinumCoin;
|
||||
player.cursorItemIconText = "";
|
||||
player.noThrow = 2;
|
||||
|
||||
PlayerInput.SetZoom_MouseInWorld();
|
||||
if (Main.mouseRight && Main.npcChatRelease)
|
||||
{
|
||||
Main.npcChatRelease = false;
|
||||
if (PlayerInput.UsingGamepad)
|
||||
player.releaseInventory = false;
|
||||
|
||||
if (player.talkNPC != npc.whoAmI && !player.tileInteractionHappened)
|
||||
{
|
||||
bool offeringState = TryOfferingPlatinumToSwine();
|
||||
npc.ModNPC<DivineSwine>().AcceptOffering(offeringState);
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
DivineSwineOfferingPacket.Send(npc.ModNPC<DivineSwine>(), offeringState);
|
||||
}
|
||||
}
|
||||
npc.position -= npc.netOffset;
|
||||
}
|
||||
|
||||
// Change the mouse display to just show the name and not the text.
|
||||
if (hoveringOverHitbox && !player.mouseInterface)
|
||||
{
|
||||
self.MouseTextHackZoom(npc.GivenOrTypeName);
|
||||
Main.mouseText = true;
|
||||
npc.position -= npc.netOffset;
|
||||
}
|
||||
npc.position -= npc.netOffset;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryOfferingPlatinumToSwine()
|
||||
{
|
||||
Player player = Main.LocalPlayer;
|
||||
bool inPiggyBank = false;
|
||||
|
||||
int inventoryIndexSlot = player.FindItem(ItemID.PlatinumCoin);
|
||||
int piggyBankIndexSlot = player.FindItem(ItemID.PlatinumCoin, player.bank.item);
|
||||
if (piggyBankIndexSlot != -1)
|
||||
inPiggyBank = true;
|
||||
|
||||
if (inventoryIndexSlot == -1 && piggyBankIndexSlot == -1)
|
||||
return false;
|
||||
|
||||
Item foundItem = inPiggyBank ? player.bank.item[piggyBankIndexSlot] : player.inventory[inventoryIndexSlot];
|
||||
if (--foundItem.stack <= 0)
|
||||
foundItem.TurnToAir();
|
||||
|
||||
Recipe.FindRecipes();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void AdjustLifeformAnalyzerTextColor(On_Main.orig_DrawInfoAccs_AdjustInfoTextColorsForNPC orig, Main self, NPC npc, ref Color infoTextColor, ref Color infoTextShadowColor)
|
||||
{
|
||||
orig(self, npc, ref infoTextColor, ref infoTextShadowColor);
|
||||
if (npc.type == ModContent.NPCType<DivineSwine>())
|
||||
{
|
||||
infoTextColor = Color.Lerp(DivineBlue, DivineYellow, MathF.Sin((float)Main.timeForVisualEffects / 45f) * 0.5f + 0.5f);
|
||||
infoTextShadowColor = infoTextColor * 0.1f;
|
||||
infoTextColor.A = Main.mouseTextColor;
|
||||
infoTextShadowColor.A = Main.mouseTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
{
|
||||
if (NPC.IsABestiaryIconDummy)
|
||||
{
|
||||
NPC.frameCounter += 1;
|
||||
if (NPC.frameCounter >= 5)
|
||||
{
|
||||
if (NPC.frame.Y / frameHeight >= Main.npcFrameCount[Type] - 1)
|
||||
NPC.frame.Y = 0;
|
||||
else
|
||||
NPC.frame.Y += frameHeight;
|
||||
|
||||
NPC.frameCounter = 0;
|
||||
}
|
||||
|
||||
Timer++;
|
||||
if (Timer >= 3600)
|
||||
Timer = 0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NPC.frame.Y = frameHeight * FrameY;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
if (NPC.IsABestiaryIconDummy)
|
||||
{
|
||||
Draw_BestiaryPortrait(spriteBatch);
|
||||
return false;
|
||||
}
|
||||
|
||||
spriteBatch.End(out var snapshot);
|
||||
|
||||
Texture2D baseTexture = TextureAssets.Npc[Type].Value;
|
||||
Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY;
|
||||
SpriteEffects spriteEffects = NPC.spriteDirection < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
|
||||
// Draw the cool glowing sigil behind the Divine Swine.
|
||||
Draw_DivineSigiliGlowyBullshit(spriteBatch, drawPosition);
|
||||
|
||||
// Subtractive backing images.
|
||||
spriteBatch.SetBlendState(CalamityUtils.SubtractiveBlending);
|
||||
|
||||
int backShadowCount = 3;
|
||||
for (int i = 0; i < backShadowCount; i++)
|
||||
{
|
||||
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.08f) + NPC.whoAmI;
|
||||
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount + rotation) * 6f;
|
||||
spriteBatch.Draw(baseTexture, backglowDrawPosition, NPC.frame, NPC.GetAlpha(Color.White) * 0.9f, NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale * GlowingVisualScale, spriteEffects, 0f);
|
||||
}
|
||||
|
||||
int backShadowCount2 = 6;
|
||||
for (int i = 0; i < backShadowCount2; i++)
|
||||
{
|
||||
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.06f) + NPC.whoAmI;
|
||||
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount2 + rotation) * 12f;
|
||||
spriteBatch.Draw(baseTexture, backglowDrawPosition, NPC.frame, NPC.GetAlpha(Color.White) * 0.7f, NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale * GlowingVisualScale, spriteEffects, 0f);
|
||||
}
|
||||
|
||||
// Actual Divine Swine.
|
||||
Effect tintShader = CalamityShaders.BasicTintShader.Value;
|
||||
tintShader.Parameters["uColor"].SetValue(Color.White.ToVector3());
|
||||
tintShader.Parameters["uOpacity"].SetValue(DivineSwineTintStrength);
|
||||
|
||||
spriteBatch.EnterShaderRegion(effect: tintShader);
|
||||
spriteBatch.Draw(baseTexture, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, SquashVector * NPC.scale, spriteEffects, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
// Offering accept visual of the reward item being conjured.
|
||||
Draw_OfferingAcceptedVisual(spriteBatch, drawPosition);
|
||||
|
||||
spriteBatch.Begin(snapshot);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Draw_DivineSigiliGlowyBullshit(SpriteBatch spriteBatch, Vector2 drawPosition)
|
||||
{
|
||||
using var glowingBullshitLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth, Main.screenHeight, RenderTargetDescriptor.Default);
|
||||
using var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
|
||||
|
||||
// Buncha yellow-colored bloom stuff to look like a glowing sun.
|
||||
using (spriteBatch.Scope())
|
||||
{
|
||||
using (glowingBullshitLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
|
||||
float bloomFlareScale = MathHelper.Lerp(0.4f, 0.7f, MathF.Sin((float)Main.timeForVisualEffects / 60f) * 0.5f + 0.5f) * GlowingVisualScale;
|
||||
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, NPC.GetAlpha(DivineYellow with { A = 0 }) * (0.8f + AdditionalBrightness), MathHelper.PiOver4, BloomFlare.Size() * 0.5f, bloomFlareScale, 0, 0f);
|
||||
|
||||
spriteBatch.Draw(ShineFlare.Value, drawPosition, null, NPC.GetAlpha(DivineYellow with { A = 0 }) * (1f + AdditionalBrightness), 0f, MagicStarCircle.Size() * 0.5f, bloomFlareScale, 0, 0f);
|
||||
spriteBatch.Draw(MagicStarCircle.Value, drawPosition, null, NPC.GetAlpha(DivineYellow with { A = 0 }) * (0.8f + AdditionalBrightness), 0f, MagicStarCircle.Size() * 0.5f, 0.5f * GlowingVisualScale, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
Effect chromaAbberShader = CalamityShaders.ChromaticAbberationShader.Value;
|
||||
chromaAbberShader.Parameters["abberationStrength"].SetValue(10f);
|
||||
chromaAbberShader.Parameters["impactPosition"].SetValue(drawPosition);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, chromaAbberShader, Matrix.Identity);
|
||||
|
||||
float starRingScale = MathHelper.Lerp(0.7f, 1f, MathF.Sin((float)Main.timeForVisualEffects / 180f) * 0.5f + 0.5f) * GlowingVisualScale;
|
||||
spriteBatch.Draw(FadedStarRing.Value, drawPosition, null, NPC.GetAlpha(DivineBlue with { A = 0 }) * (0.7f + AdditionalBrightness), (float)(Main.timeForVisualEffects / 720f) + NPC.whoAmI, FadedStarRing.Size() * 0.5f, starRingScale, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
float distortionStrength = 0.034f;
|
||||
using (spriteBatch.Scope())
|
||||
{
|
||||
using (pixelationLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Effect distortionShader = CalamityShaders.BasicTextureDistortionShader.Value;
|
||||
distortionShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
|
||||
distortionShader.Parameters["noiseScale"].SetValue(1.3f);
|
||||
distortionShader.Parameters["distortionStrength"].SetValue(distortionStrength);
|
||||
distortionShader.Parameters["timeOffset"].SetValue(new Vector2(-0.02f, 0.01f));
|
||||
|
||||
Main.graphics.GraphicsDevice.Textures[1] = DistortionTexture.Value;
|
||||
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, distortionShader, PixelationManager.PixelationMatrix);
|
||||
spriteBatch.Draw(glowingBullshitLease.Target, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
Vector2 targetDrawPosition = Main.ScreenSize.ToVector2() * 0.5f * distortionStrength;
|
||||
spriteBatch.Draw(pixelationLease.Target, targetDrawPosition, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
|
||||
}
|
||||
|
||||
public void Draw_OfferingAcceptedVisual(SpriteBatch spriteBatch, Vector2 drawPosition)
|
||||
{
|
||||
if (AIState != (int)BehaviorState.OfferingAccepted)
|
||||
return;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
float bloomRotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.03f) + NPC.whoAmI;
|
||||
float bloomMultiplier = CalamityUtils.PolyOutEasing(Utils.Remap(Timer, 0f, 30f, 0f, 1f, true), 2);
|
||||
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, NPC.GetAlpha(Color.White with { A = 0 }) * bloomMultiplier, bloomRotation, BloomFlare.Size() * 0.5f, 0.2f * bloomMultiplier, SpriteEffects.None, 0f);
|
||||
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, NPC.GetAlpha(Color.White with { A = 0 }) * 0.8f * bloomMultiplier, -bloomRotation * 0.5f, BloomFlare.Size() * 0.5f, 0.3f * bloomMultiplier, SpriteEffects.FlipVertically, 0f);
|
||||
|
||||
spriteBatch.SetBlendState(CalamityUtils.SubtractiveBlending);
|
||||
|
||||
int backShadowCount = 6;
|
||||
float backShadowInterpolant = Utils.GetLerpValue(0f, 150f, Timer, true);
|
||||
float backShadowDistance = MathHelper.Lerp(36f, 4f, backShadowInterpolant);
|
||||
for (int i = 0; i < backShadowCount; i++)
|
||||
{
|
||||
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.08f) + NPC.whoAmI;
|
||||
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount + rotation) * backShadowDistance;
|
||||
spriteBatch.Draw(DivineMeatTexture.Value, backglowDrawPosition, DivineMeatTexture.Value.Frame(1, 3), NPC.GetAlpha(Color.White) * backShadowInterpolant, NPC.rotation, DivineMeatTexture.Value.Frame(1, 3).Size() * 0.5f, 1f, 0, 0f);
|
||||
}
|
||||
|
||||
spriteBatch.SetBlendState(BlendState.AlphaBlend);
|
||||
|
||||
float shineInterpolant = Utils.GetLerpValue(150f, 210f, Timer, true);
|
||||
float shineScale = CalamityUtils.SineOutEasing(0.8f * shineInterpolant, 0);
|
||||
spriteBatch.Draw(BloomCircle.Value, drawPosition, null, NPC.GetAlpha(Color.White with { A = 0 }), NPC.rotation, BloomCircle.Size() * 0.5f, shineScale, 0, 0f);
|
||||
spriteBatch.Draw(ShineFlare.Value, drawPosition, null, NPC.GetAlpha(Color.White with { A = 0 }), NPC.rotation, ShineFlare.Size() * 0.5f, shineScale - 0.4f, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void Draw_BestiaryPortrait(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D baseTexture = TextureAssets.Npc[Type].Value;
|
||||
float floatHeight = MathHelper.Lerp(-8f, 8f, MathF.Sin((float)Timer / 150f) * 0.5f + 0.5f);
|
||||
Vector2 drawPosition = NPC.Center + Vector2.UnitY * floatHeight;
|
||||
Matrix pixelationMatrix = Matrix.CreateScale(0.5f, 0.5f, 1f);
|
||||
|
||||
RasterizerState previousRasterizerState = spriteBatch.GraphicsDevice.RasterizerState;
|
||||
Rectangle previousScissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
using (spriteBatch.Scope())
|
||||
{
|
||||
var device = Main.graphics.GraphicsDevice;
|
||||
using var glowingBullshitLease = RenderTargetPool.Shared.Rent(device, Main.screenWidth, Main.screenHeight, RenderTargetDescriptor.Default);
|
||||
using var pixelationLease = RenderTargetPool.Shared.Rent(device, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
|
||||
using (glowingBullshitLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
|
||||
float bloomFlareScale = MathHelper.Lerp(0.15f, 0.3f, MathF.Sin((float)Main.timeForVisualEffects / 60f) * 0.5f + 0.5f);
|
||||
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, NPC.GetAlpha(DivineYellow) with { A = 0 } * 0.4f, MathHelper.PiOver4, BloomFlare.Size() * 0.5f, bloomFlareScale, 0, 0f);
|
||||
|
||||
spriteBatch.Draw(ShineFlare.Value, drawPosition, null, NPC.GetAlpha(DivineYellow) with { A = 0 } * 0.7f, 0f, MagicStarCircle.Size() * 0.5f, bloomFlareScale, 0, 0f);
|
||||
spriteBatch.Draw(MagicStarCircle.Value, drawPosition, null, NPC.GetAlpha(DivineYellow) with { A = 0 } * 0.5f, 0f, MagicStarCircle.Size() * 0.5f, 0.25f, 0, 0f);
|
||||
|
||||
Effect chromaAbberShader = CalamityShaders.ChromaticAbberationShader.Value;
|
||||
chromaAbberShader.Parameters["abberationStrength"].SetValue(10f);
|
||||
chromaAbberShader.Parameters["impactPosition"].SetValue(drawPosition);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, chromaAbberShader, Matrix.Identity);
|
||||
|
||||
float starRingScale = MathHelper.Lerp(0.2f, 0.4f, MathF.Sin((float)Main.timeForVisualEffects / 180f) * 0.5f + 0.5f);
|
||||
spriteBatch.Draw(FadedStarRing.Value, drawPosition, null, NPC.GetAlpha(DivineBlue) with { A = 0 } * 0.8f, (float)(Main.timeForVisualEffects / 720f) + NPC.whoAmI, FadedStarRing.Size() * 0.5f, starRingScale, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
using (pixelationLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
float distortionStrength = 0.0212f;
|
||||
Effect distortionShader = CalamityShaders.BasicTextureDistortionShader.Value;
|
||||
distortionShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
|
||||
distortionShader.Parameters["noiseScale"].SetValue(2.3f);
|
||||
distortionShader.Parameters["distortionStrength"].SetValue(distortionStrength);
|
||||
distortionShader.Parameters["timeOffset"].SetValue(new Vector2(-0.02f, 0.01f));
|
||||
|
||||
Main.graphics.GraphicsDevice.Textures[1] = DistortionTexture.Value;
|
||||
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, distortionShader, pixelationMatrix);
|
||||
|
||||
Vector2 targetDrawPosition = Main.ScreenSize.ToVector2() * 0.5f * distortionStrength;
|
||||
spriteBatch.Draw(glowingBullshitLease.Target, targetDrawPosition, Color.White with { A = 0 });
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
spriteBatch.GraphicsDevice.RasterizerState = previousRasterizerState;
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = previousScissorRectangle;
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, previousRasterizerState, null, Main.UIScaleMatrix);
|
||||
|
||||
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, CalamityUtils.SubtractiveBlending, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix);
|
||||
|
||||
int backShadowCount = 3;
|
||||
for (int i = 0; i < backShadowCount; i++)
|
||||
{
|
||||
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.08f) + NPC.whoAmI;
|
||||
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount + rotation) * 6f;
|
||||
spriteBatch.Draw(baseTexture, backglowDrawPosition, NPC.frame, NPC.GetAlpha(Color.White) * 0.9f, NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, 0, 0f);
|
||||
}
|
||||
|
||||
int backShadowCount2 = 6;
|
||||
for (int i = 0; i < backShadowCount2; i++)
|
||||
{
|
||||
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.06f) + NPC.whoAmI;
|
||||
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount2 + rotation) * 12f;
|
||||
spriteBatch.Draw(baseTexture, backglowDrawPosition, NPC.frame, NPC.GetAlpha(Color.White) * 0.7f, NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, 0, 0f);
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix);
|
||||
spriteBatch.Draw(baseTexture, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,901 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Graphics.Metaballs;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Enemy;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.NormalNPCs.HorribleHog
|
||||
{
|
||||
public partial class HorribleHog
|
||||
{
|
||||
#region Static Behavior Properties
|
||||
public static int Damage_HogCharge => 10;
|
||||
public static int Damage_ShockwaveProjectile => 10;
|
||||
public static int Damage_ShockwaveRubbleProjectile => 12;
|
||||
public static int Damage_VomitChunkProjectile => 12;
|
||||
public static int Damage_VomitBombProjectile => 18;
|
||||
public static int Damage_VomitEyeProjectile => 14;
|
||||
|
||||
public static int ChaseTime => 180;
|
||||
public static float ChasePlayer_MaxSpeed => 5f;
|
||||
public static float ChasePlayer_MaxAcceleration => 0.3f;
|
||||
|
||||
public static int HogCharge_PreChargeTime => 75;
|
||||
public static int HogCharge_ChargingTime => 240;
|
||||
public static int HogCharge_ChargeCooldownTime => CalamityWorld.revenge ? -20 : Main.expertMode ? -30 : -45;
|
||||
public static int HogCharge_PreDashTime => 45;
|
||||
public static int HogCharge_DashTime => 20;
|
||||
public static int HogCharge_MaxCharges => CalamityWorld.revenge ? 4 : Main.expertMode ? 3 : 2;
|
||||
public static float HogCharge_MaxSpeed => CalamityWorld.revenge ? 18f : Main.expertMode ? 15f : 12f;
|
||||
public static float HogCharge_MaxAcceleration => CalamityWorld.revenge ? 0.425f : Main.expertMode ? 0.4f : 0.375f;
|
||||
public static float HogCharge_MaxSlowdownDistance => CalamityWorld.revenge ? 64f : Main.expertMode ? 96f : 128f;
|
||||
|
||||
public static int JumpAndDash_PreJumpTime => 75;
|
||||
public static int JumpAndDash_JumpPreDashTime => 45;
|
||||
public static int JumpAndDash_DashTime => 20;
|
||||
public static int JumpAndDash_CooldownTime => 60;
|
||||
public static int JumpAndDash_PreVomitTime => 60;
|
||||
public static int JumpAndDash_PreGroundPoundTime => 45;
|
||||
public static int JumpAndDash_MaxVomitChunks => CalamityWorld.revenge ? 5 : Main.expertMode ? 4 : 3;
|
||||
public static int JumpAndDash_VomitTimeInterval => CalamityWorld.revenge ? 10 : 15;
|
||||
public static int JumpAndDash_MaxBounces => Main.expertMode ? 3 : 2;
|
||||
public static float JumpAndDash_MaxJumpHeight => 14f;
|
||||
public static float JumpAndDash_MaxDashSpeed => 20f;
|
||||
public static float JumpAndDash_MaxBounceSpeed => CalamityWorld.revenge ? 16f : Main.expertMode ? 14f : 12f;
|
||||
|
||||
public static int HorribleHoller_RoarTime => 75;
|
||||
public static int HorribleHoller_PostRoarCooldownTime => 30;
|
||||
public static int HorribleHoller_MaxZombies => 3;
|
||||
|
||||
public static int VomitBarrage_PreJumpTime => 75;
|
||||
public static int VomitBarrage_VomitTime => 25;
|
||||
public static int VomitBarrage_PostVomitCooldown => 100;
|
||||
public static int VomitBarrage_MaxVomitChunks => CalamityWorld.revenge ? 10 : Main.expertMode ? 8 : 6;
|
||||
public static int VomitBarrage_MinVomitBombs => CalamityWorld.death ? 3 : CalamityWorld.revenge ? 2 : 0;
|
||||
public static int VomitBarrage_MaxVomitBombs => CalamityWorld.death ? 6 : CalamityWorld.revenge ? 5 : Main.expertMode ? 3 : 4;
|
||||
public static float VomitBarrage_MaxSpeed => 8f;
|
||||
public static float VomitBarrage_MaxAcceleration => 0.45f;
|
||||
#endregion
|
||||
|
||||
public void MainBehavior_ChasePlayer(Player target)
|
||||
{
|
||||
// Whenever the player is able to be hit, don't modify velocity mid-air.
|
||||
// Otherwise, move as any grounded NPC would in order to get back towards the player.
|
||||
bool canHitPlayer = NPC.velocity.Y == 0f && Collision.CanHit(NPC, target);
|
||||
if (canHitPlayer || !Collision.CanHit(NPC, target))
|
||||
{
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
GroundedMovement(target.Center, ChasePlayer_MaxSpeed, ChasePlayer_MaxAcceleration);
|
||||
}
|
||||
|
||||
bool jumpUpToPlayer = Main.expertMode && NPC.Center.Y - target.Center.Y >= 64f;
|
||||
bool closeToPlayer = MathHelper.Distance(NPC.Center.X, target.Center.X) < 112f;
|
||||
if (NPC.velocity.Y == 0f && jumpUpToPlayer && closeToPlayer)
|
||||
{
|
||||
NPC.velocity.Y -= 8f;
|
||||
SoundEngine.PlaySound(JumpSound, NPC.Center);
|
||||
}
|
||||
|
||||
bool closeEnoughToAttack = MathHelper.Distance(NPC.Center.X, target.Center.X) <= 64f;
|
||||
if (Timer >= ChaseTime || (closeEnoughToAttack && Timer >= 120f && NPC.velocity.Y == 0f))
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.JumpAndDash];
|
||||
if (NPC.Center.Y - target.Center.Y < 128)
|
||||
possibleAttacks.Add(BehaviorState.HogCharge);
|
||||
SwitchBehavior(BehaviorState.ChasePlayer, null, [.. possibleAttacks]);
|
||||
}
|
||||
|
||||
float idealRotation = (NPC.velocity.Y != 0f) ? NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi) : 0f;
|
||||
NPC.rotation = idealRotation;
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, ChasePlayer_MaxSpeed, 9, 3, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
}
|
||||
|
||||
public void MainBehavior_HogCharge(Player target)
|
||||
{
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer <= HogCharge_PreChargeTime)
|
||||
{
|
||||
float backupSpeed = MathHelper.Lerp(0.08f, 0.16f, Timer / HogCharge_PreChargeTime);
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
if (MathF.Abs(NPC.velocity.X) > 0.4f)
|
||||
NPC.velocity.X *= 0.9f;
|
||||
else
|
||||
NPC.velocity.X -= backupSpeed * NPC.direction;
|
||||
}
|
||||
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, 7, true, dynamicChanges: true);
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
}
|
||||
|
||||
if (Timer >= HogCharge_PreChargeTime)
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 1f;
|
||||
SoundEngine.PlaySound(SoundID.Zombie38, NPC.Center);
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.rotation = 0f;
|
||||
if (Timer % 15f == 0f && NPC.velocity.Y == 0f)
|
||||
SoundEngine.PlaySound(SoundID.Run with { Pitch = -0.8f, Identifier = "Horrible Hog Run" }, NPC.Center);
|
||||
}
|
||||
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
bool finishedWithCharges = Timer >= HogCharge_ChargingTime || MiscAttackCounter >= HogCharge_MaxCharges;
|
||||
if (Timer <= 0f)
|
||||
{
|
||||
// Kill the hitbox when slowing down.
|
||||
KillChargeHitboxProjectile();
|
||||
|
||||
if (NPC.velocity.Y == 0f)
|
||||
NPC.velocity.X *= 0.93f;
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
NPC.rotation = 0f;
|
||||
|
||||
Vector2 dustPosition = new(NPC.Bottom.X + Main.rand.NextFloat(-NPC.width * 0.5f, NPC.width * 0.5f), NPC.Bottom.Y);
|
||||
Dust.NewDustPerfect(dustPosition, DustID.Cloud, new Vector2(NPC.velocity.X * 0.4f, Main.rand.NextFloat(-0.38f, 0.38f)), 120, Color.LightGray, Main.rand.NextFloat(1f, 1.2f));
|
||||
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
if (Timer == -10 && !finishedWithCharges)
|
||||
DoEyeGlintEffect(0.4f);
|
||||
|
||||
FrameY = 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Spawn an artificial hitbox that can knockback and hit both hostile and friendly enemies alongside the player.
|
||||
if (!CalamityUtils.AnyProjectiles(ModContent.ProjectileType<HorribleHogChargeHitbox>()) && Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
float knockback = 20f;
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType<HorribleHogChargeHitbox>(), Damage_HogCharge, knockback, ai0: NPC.whoAmI);
|
||||
}
|
||||
|
||||
float maxSpeed = MathHelper.Lerp(HogCharge_MaxSpeed, HogCharge_MaxSpeed + 3.5f, MiscAttackCounter / HogCharge_MaxCharges);
|
||||
float maxAcceleration = MathHelper.Lerp(HogCharge_MaxAcceleration, HogCharge_MaxAcceleration + 0.35f, MiscAttackCounter / HogCharge_MaxCharges);
|
||||
if (MathF.Abs(NPC.velocity.X) < maxSpeed)
|
||||
NPC.velocity.X += maxAcceleration * NPC.direction;
|
||||
|
||||
// Turn around if the player jumps over to the other side of it.
|
||||
bool turnLeft = NPC.direction == 1 && (NPC.Center.X - target.Center.X) > HogCharge_MaxSlowdownDistance;
|
||||
bool turnRight = NPC.direction == -1 && (NPC.Center.X - target.Center.X) < -HogCharge_MaxSlowdownDistance;
|
||||
bool hitAWall = NPC.collideX && MathF.Abs(NPC.velocity.X) >= maxSpeed * 0.8f;
|
||||
if (((turnLeft || turnRight) && Timer > 30f) || finishedWithCharges || hitAWall)
|
||||
{
|
||||
if (hitAWall)
|
||||
{
|
||||
NPC.velocity.X = NPC.oldVelocity.X * -0.64f;
|
||||
NPC.velocity.Y -= 5f;
|
||||
}
|
||||
|
||||
Timer = HogCharge_ChargeCooldownTime;
|
||||
MiscAttackCounter++;
|
||||
if (finishedWithCharges && PhaseTwo)
|
||||
AltAttackVariant = Main.rand.Next(2);
|
||||
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
Vector2 dustPosition = new(NPC.Bottom.X + Main.rand.NextFloat(-NPC.width * 0.5f, NPC.width * 0.5f), NPC.Bottom.Y);
|
||||
Dust.NewDustPerfect(dustPosition, DustID.Cloud, new Vector2(NPC.velocity.X * 0.2f, Main.rand.NextFloat(-0.3f, 0.3f)), 120, Color.LightGray, Main.rand.NextFloat(1f, 1.2f));
|
||||
if (Timer % 7 == 0f && NPC.velocity.Y == 0f)
|
||||
SoundEngine.PlaySound(SoundID.Run with { Pitch = -0.4f, Identifier = "Horrible Hog Run" }, NPC.Center);
|
||||
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 1f, 0.15f);
|
||||
|
||||
if (MiscAttackCounter >= HogCharge_MaxCharges + 1)
|
||||
{
|
||||
KillChargeHitboxProjectile();
|
||||
if (PhaseTwo && AltAttackVariant == 1f)
|
||||
{
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.HorribleHoller, BehaviorState.JumpAndDash, BehaviorState.VomitBarrage];
|
||||
SwitchBehavior(BehaviorState.HogCharge, null, [.. possibleAttacks]);
|
||||
}
|
||||
}
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, maxSpeed, 6, 2, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
|
||||
NPC.damage = 0;
|
||||
NPC.rotation = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Alt attack in phase two.
|
||||
// Same jump and dash but with a smaller shockwave.
|
||||
if (LocalAIState == 2f)
|
||||
AltBehavior_HogCharge_JumpAndDash(target);
|
||||
|
||||
// Rebounding, land and switch attacks.
|
||||
if (LocalAIState == 3f)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f && Timer > 2f)
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.HorribleHoller, BehaviorState.JumpAndDash, BehaviorState.VomitBarrage];
|
||||
SwitchBehavior(BehaviorState.HogCharge, null, [.. possibleAttacks]);
|
||||
}
|
||||
|
||||
NPC.rotation = NPC.rotation.AngleLerp(0f, 0.075f);
|
||||
SpriteRotation = SpriteRotation.AngleLerp(0f, 0.075f);
|
||||
}
|
||||
}
|
||||
|
||||
public void AltBehavior_HogCharge_JumpAndDash(Player target)
|
||||
{
|
||||
if (Timer == 0f)
|
||||
{
|
||||
NPC.velocity.Y = -JumpAndDash_MaxJumpHeight * 1.2f;
|
||||
NPC.velocity.X += JumpAndDash_MaxDashSpeed * 0.4f * NPC.direction;
|
||||
DoJumpEffects();
|
||||
UseBalledSprite = true;
|
||||
}
|
||||
|
||||
if (Timer <= HogCharge_PreDashTime)
|
||||
{
|
||||
NPC.velocity.Y *= 0.98f;
|
||||
NPC.velocity.X *= 0.96f;
|
||||
|
||||
SetSquashVectors(new Vector2(1.06f, 0.94f));
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SpriteRotation -= (MathHelper.TwoPi / 20f) * NPC.direction;
|
||||
|
||||
if (Timer <= HogCharge_PreDashTime - 10)
|
||||
{
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
LastPlayerPosition = target.Center;
|
||||
if (Timer == HogCharge_PreDashTime - 10)
|
||||
DoEyeGlintEffect(0.6f);
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer == HogCharge_PreDashTime)
|
||||
{
|
||||
NPC.noGravity = true;
|
||||
NPC.velocity = NPC.SafeDirectionTo(LastPlayerPosition) * JumpAndDash_MaxDashSpeed;
|
||||
|
||||
UseBalledSprite = false;
|
||||
FrameY = JumpFrame;
|
||||
SetSquashVectors(new Vector2(1.12f, 0.96f));
|
||||
SpriteRotation = 0f;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SoundEngine.PlaySound(SoundID.Zombie38, NPC.Center);
|
||||
}
|
||||
|
||||
if (Timer >= HogCharge_PreDashTime && Timer <= HogCharge_PreDashTime + HogCharge_DashTime)
|
||||
{
|
||||
if (NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height))
|
||||
{
|
||||
// Spawn shockwave on tile impact.
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
SpawnShockwave(2, 6, (i > 0).ToDirectionInt(), 1f, 2f);
|
||||
}
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 6f);
|
||||
Collision.HitTiles(NPC.position, NPC.velocity, NPC.width, NPC.height);
|
||||
SoundEngine.PlaySound(GroundImpactSound, NPC.Center);
|
||||
|
||||
UseBalledSprite = true;
|
||||
NPC.velocity.X = NPC.DirectionFrom(target.Center).SafeNormalize(Vector2.UnitX).X * 3f;
|
||||
NPC.velocity.Y = -10f;
|
||||
LocalAIState = 3f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.noGravity = true;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
FrameY = JumpFrame;
|
||||
}
|
||||
|
||||
if (Timer >= HogCharge_PreDashTime + HogCharge_DashTime)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
UseBalledSprite = false;
|
||||
FrameY = IdleFrame;
|
||||
SetSquashVectors();
|
||||
LocalAIState = 3f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.GravityMultiplier *= 3f;
|
||||
NPC.velocity.X *= 0.95f;
|
||||
SpriteRotation = 0f;
|
||||
UseBalledSprite = true;
|
||||
}
|
||||
|
||||
SetSquashVectors(VelocityBasedSquashNStretch);
|
||||
}
|
||||
|
||||
public void MainBehavior_JumpAndDash(Player target)
|
||||
{
|
||||
// Stop, jump and dash towards the target.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer <= JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime)
|
||||
{
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
if (Timer < JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime - 15)
|
||||
LastPlayerPosition = target.Center;
|
||||
}
|
||||
|
||||
if (Timer <= JumpAndDash_PreJumpTime)
|
||||
{
|
||||
GroundedMovement(target.Center, ChasePlayer_MaxSpeed, ChasePlayer_MaxAcceleration, slowdownDistance: 160f);
|
||||
float targetAngle = (NPC.velocity.Y != 0f) ? NPC.velocity.X * 0.175f * (NPC.velocity.Y < 0).ToDirectionInt() : 0f;
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.075f);
|
||||
|
||||
int preJumpVisualsTime = JumpAndDash_PreJumpTime - 30;
|
||||
if (Timer >= preJumpVisualsTime)
|
||||
{
|
||||
NPC.velocity.X *= 0.96f;
|
||||
float interpolant = Utils.GetLerpValue(preJumpVisualsTime, VomitBarrage_PreJumpTime, Timer, true);
|
||||
HorizontalShakeStrength = MathHelper.Lerp(0f, 6f, interpolant);
|
||||
SetSquashVectors(new Vector2(1.24f, 0.84f));
|
||||
FrameY = BalledUpFrame;
|
||||
}
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, ChasePlayer_MaxSpeed, 8, 2, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
}
|
||||
|
||||
if (Timer == JumpAndDash_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.Y = -JumpAndDash_MaxJumpHeight;
|
||||
NPC.velocity.X += JumpAndDash_MaxDashSpeed * 0.2f * NPC.direction;
|
||||
|
||||
DoJumpEffects();
|
||||
UseBalledSprite = true;
|
||||
SetSquashVectors(new Vector2(0.84f, 1.14f));
|
||||
HorizontalShakeStrength = 0f;
|
||||
}
|
||||
|
||||
if (Timer >= JumpAndDash_PreJumpTime && Timer <= JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.Y *= 0.98f;
|
||||
NPC.velocity.X *= 0.96f;
|
||||
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SpriteRotation -= (MathHelper.TwoPi / 20f) * NPC.direction;
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 1f, 0.15f);
|
||||
if (Timer == JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime - 10)
|
||||
DoEyeGlintEffect(0.4f);
|
||||
}
|
||||
|
||||
if (Timer == JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime)
|
||||
{
|
||||
NPC.noGravity = true;
|
||||
NPC.velocity = NPC.SafeDirectionTo(LastPlayerPosition) * JumpAndDash_MaxDashSpeed;
|
||||
|
||||
UseBalledSprite = false;
|
||||
SpriteRotation = 0f;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SoundEngine.PlaySound(SoundID.Zombie38, NPC.Center);
|
||||
}
|
||||
|
||||
if (Timer >= JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime && Timer <= JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime + JumpAndDash_DashTime)
|
||||
{
|
||||
if (NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height))
|
||||
{
|
||||
// Spawn shockwave on tile impact.
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int shockwaveAmt = PhaseTwo ? 14 : 8;
|
||||
SpawnShockwave(2, shockwaveAmt, (i > 0).ToDirectionInt(), 1f, 3f);
|
||||
}
|
||||
}
|
||||
|
||||
NPC.velocity.X = NPC.DirectionFrom(target.Center).SafeNormalize(Vector2.UnitX).X * 5f;
|
||||
NPC.velocity.Y = PhaseTwo ? -16f : -12f;
|
||||
LocalAIState = 1f;
|
||||
Timer = 0f;
|
||||
AltAttackVariant = Main.rand.Next(2);
|
||||
|
||||
UseBalledSprite = true;
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 6f);
|
||||
Collision.HitTiles(NPC.position, NPC.velocity, NPC.width, NPC.height);
|
||||
SoundEngine.PlaySound(GroundImpactSound, NPC.Center);
|
||||
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.noGravity = true;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
FrameY = JumpFrame;
|
||||
}
|
||||
|
||||
if (Timer >= JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime + JumpAndDash_DashTime)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
UseBalledSprite = false;
|
||||
FrameY = IdleFrame;
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.GravityMultiplier *= 3f;
|
||||
NPC.velocity.X *= 0.95f;
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
}
|
||||
|
||||
if (Timer > JumpAndDash_PreJumpTime)
|
||||
SetSquashVectors(VelocityBasedSquashNStretch);
|
||||
}
|
||||
|
||||
// Rebounding after ground collision.
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
// Randomly perform two smaller attacks right after the main dash in Phase two.
|
||||
if (PhaseTwo)
|
||||
{
|
||||
// Alt attck #1:
|
||||
// Shoot vomit chunks at the player.
|
||||
// Shoot more in higher difficulties.
|
||||
//
|
||||
// Alt attack #2:
|
||||
// Bounce on the ground near the player predictively.
|
||||
// In Death Mode and above, perform a large ground pound after the last bounce.
|
||||
|
||||
if (AltAttackVariant == 0f)
|
||||
AltBehavior_JumpAndDash_VomitChunks(target);
|
||||
else if (AltAttackVariant == 1f)
|
||||
AltBehavior_JumpAndDash_GroundPound(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NPC.collideY && Timer > 2f)
|
||||
{
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
SetSquashVectors();
|
||||
SpriteRotation -= (MathHelper.TwoPi / 20f) * NPC.direction;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
}
|
||||
}
|
||||
|
||||
// Landed back on the ground.
|
||||
if (LocalAIState == 2f)
|
||||
{
|
||||
NPC.velocity.X *= 0.94f;
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
UseBalledSprite = false;
|
||||
NPC.rotation = 0f;
|
||||
SpriteRotation = 0f;
|
||||
}
|
||||
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
NPC.rotation = NPC.rotation.AngleLerp(0f, 0.075f);
|
||||
SpriteRotation = SpriteRotation.AngleLerp(0f, 0.075f);
|
||||
SetSquashVectors();
|
||||
FrameY = IdleFrame;
|
||||
|
||||
if (Timer >= JumpAndDash_CooldownTime && NPC.velocity.Y == 0f)
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.VomitBarrage, BehaviorState.HorribleHoller];
|
||||
if (NPC.Center.Y - target.Center.Y < 128)
|
||||
possibleAttacks.Add(BehaviorState.HogCharge);
|
||||
|
||||
SwitchBehavior(BehaviorState.JumpAndDash, null, [.. possibleAttacks]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AltBehavior_JumpAndDash_VomitChunks(Player target)
|
||||
{
|
||||
if (Timer <= JumpAndDash_PreVomitTime)
|
||||
{
|
||||
NPC.velocity *= 0.98f;
|
||||
NPC.GravityMultiplier *= 0.84f;
|
||||
if (Timer == JumpAndDash_PreVomitTime - 10)
|
||||
DoEyeGlintEffect(0.6f);
|
||||
}
|
||||
|
||||
if (Timer >= JumpAndDash_PreVomitTime)
|
||||
{
|
||||
if (Timer % JumpAndDash_VomitTimeInterval == 0f && MiscAttackCounter < JumpAndDash_MaxVomitChunks)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int maxVomitPerShot = 2;
|
||||
for (int i = 0; i < maxVomitPerShot; i++)
|
||||
{
|
||||
Vector2 chunkVelocity = NPC.SafeDirectionTo(target.Center).RotatedBy(MathHelper.ToRadians(MathHelper.Lerp(-22f, 22f, i / (maxVomitPerShot - 1)))) * 14f;
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, chunkVelocity, ModContent.ProjectileType<HorribleHogVomitChunk>(), Damage_VomitChunkProjectile, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 knockbackVelocity = NPC.DirectionFrom(target.Center).SafeNormalize(-Vector2.UnitY);
|
||||
NPC.velocity = knockbackVelocity * new Vector2(3f, 5f);
|
||||
|
||||
FrameY = VomitFrame;
|
||||
SoundEngine.PlaySound(SoundID.DD2_OgreSpit, NPC.Center);
|
||||
MiscAttackCounter++;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (MiscAttackCounter >= JumpAndDash_MaxVomitChunks && NPC.velocity.Y == 0f)
|
||||
{
|
||||
FrameY = JumpFrame;
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
FrameY = JumpFrame;
|
||||
}
|
||||
|
||||
SetSquashVectors();
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
NPC.rotation = NPC.rotation.AngleLerp(NPC.AngleTo(target.Center) + (NPC.direction > 0 ? 0f : -MathHelper.Pi), 0.15f);
|
||||
SpriteRotation = 0f;
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
}
|
||||
|
||||
public void AltBehavior_JumpAndDash_GroundPound(Player target)
|
||||
{
|
||||
// Using plus 1 here cause the first bounce is coming off of the rebound.
|
||||
if (MiscAttackCounter <= JumpAndDash_MaxBounces)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
if (MiscAttackCounter == JumpAndDash_MaxBounces)
|
||||
{
|
||||
if (!CalamityWorld.death)
|
||||
{
|
||||
LocalAIState = 2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to bounce in front of the player for the ground pound.
|
||||
Vector2 bounceVelocity = (target.Center.X > NPC.Center.X) ? new Vector2(18f, -20f) : new Vector2(-18f, -20f);
|
||||
NPC.velocity = bounceVelocity;
|
||||
}
|
||||
|
||||
Timer = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float speedByDistance = Utils.Remap(MathHelper.Distance(target.Center.X, NPC.Center.X), 60f, 600f, 4f, 10f, true);
|
||||
float xVelocity = speedByDistance * (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
NPC.velocity = new Vector2(xVelocity, -11.25f);
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient && MiscAttackCounter > 0f)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
SpawnShockwave(2, 4, (i > 0).ToDirectionInt(), 1f, 2f);
|
||||
|
||||
for (int i = 0; i < MiscAttackCounter; i++)
|
||||
{
|
||||
Vector2 rubbleVelocityRight = new Vector2(2f + i * 3f, -8f - i * 1.25f);
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Bottom, rubbleVelocityRight, ModContent.ProjectileType<HorribleHogRubble>(), Damage_ShockwaveProjectile, 1f);
|
||||
Vector2 rubbleVelocityLeft = new Vector2(-2f - i * 3f, -8f - i * 1.25f);
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Bottom, rubbleVelocityLeft, ModContent.ProjectileType<HorribleHogRubble>(), Damage_ShockwaveProjectile, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 4f);
|
||||
SoundEngine.PlaySound(HitSound with { Pitch = -0.4f }, NPC.Center);
|
||||
MiscAttackCounter++;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (NPC.velocity.Y > 1f && NPC.velocity.Y < 24f && MiscAttackCounter > 0f)
|
||||
{
|
||||
NPC.velocity.Y *= 1.12f;
|
||||
NPC.velocity.X *= 0.96f;
|
||||
NPC.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ground pound attack in Death Mode.
|
||||
if (CalamityWorld.death && MiscAttackCounter >= JumpAndDash_MaxBounces + 1)
|
||||
{
|
||||
if (Timer < JumpAndDash_PreGroundPoundTime)
|
||||
{
|
||||
NPC.velocity *= 0.96f;
|
||||
NPC.GravityMultiplier *= 0.4f;
|
||||
if (Timer == JumpAndDash_PreGroundPoundTime - 10)
|
||||
DoEyeGlintEffect(0.6f);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.noGravity = true;
|
||||
}
|
||||
|
||||
if (Timer == JumpAndDash_PreGroundPoundTime)
|
||||
{
|
||||
NPC.velocity.Y = 30f;
|
||||
NPC.velocity.X *= 0f;
|
||||
}
|
||||
|
||||
if (Timer > JumpAndDash_PreGroundPoundTime && NPC.velocity.Y == 0f)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
SpawnShockwave(2, 20, (target.Center.X > NPC.Center.X).ToDirectionInt(), 1f, 8f);
|
||||
|
||||
NPC.velocity.X = NPC.DirectionFrom(target.Center).SafeNormalize(Vector2.UnitX).X * 4f;
|
||||
NPC.velocity.Y = -12f;
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 8f);
|
||||
Collision.HitTiles(NPC.position, NPC.velocity, NPC.width, NPC.height);
|
||||
SoundEngine.PlaySound(GroundImpactSound, NPC.Center);
|
||||
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
NPC.damage = 0;
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SpriteRotation -= (MathHelper.TwoPi / 20f) * NPC.direction;
|
||||
SetSquashVectors(VelocityBasedSquashNStretch);
|
||||
UseBalledSprite = true;
|
||||
}
|
||||
|
||||
public void MainBehavior_HorribleHoller(Player target)
|
||||
{
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
if (NPC.velocity.Y == 0f)
|
||||
NPC.velocity.X *= 0.9f;
|
||||
|
||||
if (Timer <= HorribleHoller_RoarTime)
|
||||
{
|
||||
if (Timer == HorribleHoller_RoarTime - 30)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Roar, NPC.Center);
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 6f);
|
||||
NPC.velocity.Y -= 6f;
|
||||
}
|
||||
|
||||
// Spawn the Zombie Spawner projectiles on top of tiles.
|
||||
if (Timer == HorribleHoller_RoarTime)
|
||||
{
|
||||
for (int i = 0; i < HorribleHoller_MaxZombies; i++)
|
||||
{
|
||||
int maxTileRange = 12;
|
||||
Vector2 zombieSpawnPosition = NPC.Center + new Vector2(Main.rand.Next(-maxTileRange * 16, (maxTileRange + 1) * 16), 0f);
|
||||
Vector2 actualSpawnPosition = FindSuitableGround(zombieSpawnPosition.ToTileCoordinates()).ToWorldCoordinates() + Vector2.UnitY * 16f;
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int maxTime = 150 + Main.rand.Next(31);
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), actualSpawnPosition, Vector2.Zero, ModContent.ProjectileType<HorribleHogZombieSpawner>(), 0, 0f, Main.myPlayer, 0f, maxTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer >= HorribleHoller_RoarTime - 30)
|
||||
Animate(MinFrame_Roar, MaxFrame_Roar, HorribleHoller_RoarTime / (MaxFrame_Roar + 1), true, MaxFrame_Roar - 1);
|
||||
}
|
||||
|
||||
if (Timer >= HorribleHoller_RoarTime)
|
||||
Animate(MinFrame_RoarFinish, MaxFrame_RoarFinish, 4, false);
|
||||
|
||||
float targetAngle = (NPC.velocity.Y != 0f) ? NPC.velocity.X * 0.125f * (NPC.velocity.Y < 0).ToDirectionInt() : 0f;
|
||||
if (Timer >= HorribleHoller_RoarTime - 30 && Timer <= HorribleHoller_RoarTime)
|
||||
targetAngle = (NPC.velocity.Y != 0f) ? (NPC.direction < 0 ? MathHelper.ToRadians(50f) : MathHelper.ToRadians(-50f)) : 0f;
|
||||
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.125f);
|
||||
|
||||
if (Timer >= HorribleHoller_RoarTime + HorribleHoller_PostRoarCooldownTime)
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.ChasePlayer, BehaviorState.VomitBarrage];
|
||||
SwitchBehavior(BehaviorState.HorribleHoller, null, [.. possibleAttacks]);
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_VomitBarrage(Player target)
|
||||
{
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer == 1f)
|
||||
{
|
||||
SoundEngine.PlaySound(VomitChargeUpSound, NPC.Center);
|
||||
if (PhaseTwo && CalamityWorld.revenge)
|
||||
{
|
||||
AltAttackVariant = Main.rand.Next(2);
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Move away from the player.
|
||||
if (Timer <= VomitBarrage_PreJumpTime)
|
||||
{
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
GroundedMovement(target.Center, VomitBarrage_MaxSpeed, ChasePlayer_MaxAcceleration, slowdownDistance: 200f);
|
||||
|
||||
float targetAngle = (NPC.velocity.Y != 0f) ? NPC.velocity.X * 0.135f * (NPC.velocity.Y < 0).ToDirectionInt() : 0f;
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.125f);
|
||||
|
||||
int preJumpVisualsTime = VomitBarrage_PreJumpTime - 30;
|
||||
if (Timer >= preJumpVisualsTime)
|
||||
{
|
||||
NPC.velocity.X *= 0.96f;
|
||||
float interpolant = Utils.GetLerpValue(preJumpVisualsTime, VomitBarrage_PreJumpTime, Timer, true);
|
||||
HorizontalShakeStrength = MathHelper.Lerp(0f, 6f, interpolant);
|
||||
SetSquashVectors(new Vector2(1.24f, 0.84f));
|
||||
}
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, VomitBarrage_MaxSpeed, 9, 3, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
}
|
||||
|
||||
// Jump and shoot a bunch of vomit projectiles shortly afterwards.
|
||||
if (Timer == VomitBarrage_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.Y = -JumpAndDash_MaxJumpHeight;
|
||||
NPC.velocity.X = -12f * NPC.direction;
|
||||
|
||||
HorizontalShakeStrength = 0f;
|
||||
DoJumpEffects(6, 9);
|
||||
SetSquashVectors(squashVector: new Vector2(0.84f, 1.14f));
|
||||
}
|
||||
|
||||
if (Timer >= VomitBarrage_PreJumpTime && Timer <= VomitBarrage_PreJumpTime + VomitBarrage_VomitTime)
|
||||
{
|
||||
NPC.velocity.Y *= 0.98f;
|
||||
NPC.velocity.X *= 0.96f;
|
||||
|
||||
float targetAngle = NPC.direction < 0 ? MathHelper.ToRadians(50f) : MathHelper.ToRadians(-50f);
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.075f);
|
||||
}
|
||||
|
||||
if (Timer == JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime)
|
||||
{
|
||||
bool spawnEyeballs = PhaseTwo && CalamityWorld.revenge && AltAttackVariant == 1f;
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
for (int i = 0; i < VomitBarrage_MaxVomitChunks; i++)
|
||||
{
|
||||
int projectileType = ModContent.ProjectileType<HorribleHogVomitChunk>();
|
||||
int damage = Damage_VomitChunkProjectile;
|
||||
|
||||
// Randomly replace chunks with bombs in Expert and above.
|
||||
bool vomitBombFloorNotReached = MiscAttackCounter < VomitBarrage_MinVomitBombs;
|
||||
bool vomitBombCeilingNotReached = Main.rand.NextBool(4) && MiscAttackCounter >= VomitBarrage_MinVomitBombs && MiscAttackCounter < VomitBarrage_MaxVomitBombs;
|
||||
if (Main.expertMode && (vomitBombFloorNotReached || vomitBombCeilingNotReached))
|
||||
{
|
||||
projectileType = ModContent.ProjectileType<HorribleHogVomitBomb>();
|
||||
damage = Damage_VomitBombProjectile;
|
||||
MiscAttackCounter++;
|
||||
}
|
||||
|
||||
// Replace chunks with homing Demon Eyes in Rev+ during phase two when the alt attack is picked.
|
||||
if (spawnEyeballs)
|
||||
{
|
||||
projectileType = ModContent.ProjectileType<HorribleHogVomitEye>();
|
||||
damage = Damage_VomitEyeProjectile;
|
||||
}
|
||||
|
||||
Vector2 vomitVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(NPC.Center, target.Center + new Vector2(Main.rand.NextFloat(-16f, 16f), 0f), 0.125f, Main.rand.NextFloat(5f, 8f));
|
||||
vomitVelocity.X *= Main.rand.NextFloat(0.25f, 2.25f);
|
||||
int vomit = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, vomitVelocity, projectileType, damage, 0f);
|
||||
if (spawnEyeballs)
|
||||
Main.projectile[vomit].ai[0] = Main.rand.Next(45, 75);
|
||||
if (projectileType == ModContent.ProjectileType<HorribleHogVomitBomb>())
|
||||
Main.projectile[vomit].ai[1] = NPC.whoAmI;
|
||||
}
|
||||
}
|
||||
|
||||
int vomitAmt = Main.rand.Next(12, 19);
|
||||
for (int i = 0; i < vomitAmt; i++)
|
||||
{
|
||||
Vector2 velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(NPC.Center, target.Center + new Vector2(Main.rand.NextFloat(-16f, 16f), 0f), 0.125f, Main.rand.NextFloat(5f, 8f));
|
||||
velocity.X *= Main.rand.NextFloat(1f, 2f);
|
||||
int dustType = Utils.SelectRandom(Main.rand, DustID.ToxicBubble, DustID.GreenBlood, DustID.Blood);
|
||||
|
||||
Dust.NewDust(NPC.Center, 1, 1, dustType, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1.8f, 2.4f));
|
||||
}
|
||||
|
||||
FrameY = VomitFrame;
|
||||
SoundEngine.PlaySound(VomitSound with { Volume = 1.3f }, NPC.Center);
|
||||
NPC.velocity.X = 6f * -NPC.direction;
|
||||
NPC.velocity.Y += 2f;
|
||||
}
|
||||
|
||||
if (Timer > JumpAndDash_JumpPreDashTime + JumpAndDash_PreJumpTime && NPC.velocity.Y == 0f)
|
||||
{
|
||||
FrameY = IdleFrame;
|
||||
LocalAIState = 1f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
if (Timer >= VomitBarrage_PostVomitCooldown)
|
||||
{
|
||||
List<BehaviorState> possibleAttacks = [BehaviorState.HorribleHoller, BehaviorState.JumpAndDash];
|
||||
if (NPC.Center.Y - target.Center.Y < 128)
|
||||
possibleAttacks.Add(BehaviorState.HogCharge);
|
||||
SwitchBehavior(BehaviorState.VomitBarrage, null, [.. possibleAttacks]);
|
||||
}
|
||||
|
||||
// Do a small hiccup/burp after the attack.
|
||||
int burpTime = VomitBarrage_PostVomitCooldown / 2;
|
||||
if (Timer == burpTime)
|
||||
{
|
||||
SoundEngine.PlaySound(HiccupSound with { Volume = 1.25f }, NPC.Center);
|
||||
SetSquashVectors(squashVector: new Vector2(0.84f, 1.14f));
|
||||
NPC.velocity.Y = -4.25f;
|
||||
|
||||
int burpDustAmt = Main.rand.Next(6, 10);
|
||||
for (int i = 0; i < burpDustAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + new Vector2(8f * NPC.direction, -8f);
|
||||
Vector2 velocity = Vector2.UnitX.RotatedByRandom(MathHelper.ToRadians(20f) + NPC.rotation) * Main.rand.NextFloat(3f, 5f) * NPC.direction;
|
||||
Dust.NewDust(spawnPosition, 1, 1, DustID.FartInAJar, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
}
|
||||
|
||||
if (NPC.velocity.Y == 0f)
|
||||
NPC.velocity.X *= 0.9f;
|
||||
|
||||
float targetAngle = (NPC.velocity.Y != 0f) ? NPC.velocity.X * 0.135f * (NPC.velocity.Y < 0).ToDirectionInt() : 0f;
|
||||
if (Timer >= burpTime && Timer <= VomitBarrage_PostVomitCooldown)
|
||||
targetAngle = (NPC.velocity.Y != 0f) ? (NPC.direction < 0 ? MathHelper.ToRadians(30f) : MathHelper.ToRadians(-30f)) : 0f;
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.125f);
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, VomitBarrage_MaxSpeed, 9, 3, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnShockwave(int spawnImterval, int maxShockwaves, int direction, float minHeightMultiplier, float maxHeightMultiplier)
|
||||
{
|
||||
int spawnerIndex = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Bottom, Vector2.Zero, ModContent.ProjectileType<HorribleHogShockwaveSpawner>(), Damage_ShockwaveProjectile, 0f);
|
||||
Main.projectile[spawnerIndex].ModProjectile<HorribleHogShockwaveSpawner>().OwnerIndex = NPC.whoAmI;
|
||||
Main.projectile[spawnerIndex].ai[0] = spawnImterval;
|
||||
Main.projectile[spawnerIndex].ai[1] = maxShockwaves;
|
||||
Main.projectile[spawnerIndex].ai[2] = direction;
|
||||
Main.projectile[spawnerIndex].localAI[0] = minHeightMultiplier;
|
||||
Main.projectile[spawnerIndex].localAI[1] = maxHeightMultiplier;
|
||||
Main.projectile[spawnerIndex].netUpdate = true;
|
||||
}
|
||||
|
||||
private void KillChargeHitboxProjectile()
|
||||
{
|
||||
if (CalamityUtils.AnyProjectiles(ModContent.ProjectileType<HorribleHogChargeHitbox>()))
|
||||
{
|
||||
int hitboxIndex = CalamityUtils.FindFirstProjectile(ModContent.ProjectileType<HorribleHogChargeHitbox>());
|
||||
if (Main.projectile.IndexInRange(hitboxIndex) && Main.projectile[hitboxIndex].ai[0] == NPC.whoAmI)
|
||||
{
|
||||
Main.projectile[hitboxIndex].Kill();
|
||||
Main.projectile[hitboxIndex].netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,550 @@
|
||||
using System;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.NormalNPCs.HorribleHog
|
||||
{
|
||||
public partial class HorribleHog
|
||||
{
|
||||
#region Static Behavior Properties
|
||||
public static float EngageDistance => 300f;
|
||||
public static float Idle_MaxSpeed => 2f;
|
||||
public static float Idle_MaxAcceleration => 0.125f;
|
||||
|
||||
public static int DigTowardsTarget_PreJumpTime => 30;
|
||||
public static int DigTowardsTarget_FindSuitablePositionTime => 120;
|
||||
public static int DigTowardsTraget_MaxDiggingTime => 180;
|
||||
#endregion
|
||||
|
||||
public void MainBehavior_PiggyTransformation()
|
||||
{
|
||||
NPC.ShowNameOnHover = false;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.damage = 0;
|
||||
NPC.velocity.X *= 0.9f;
|
||||
NPC.rotation *= 0.9f;
|
||||
SpriteRotation *= 0.9f;
|
||||
|
||||
float volumeMultiplier = Utils.GetLerpValue(0f, 45f, Timer, true) * Utils.GetLerpValue(240f, 190f, Timer, true);
|
||||
DevilsTongueVolumeMultiplier = volumeMultiplier;
|
||||
|
||||
float tintStrength = Utils.GetLerpValue(0f, 45f, Timer, true);
|
||||
TintStrength = tintStrength;
|
||||
TintColorTarget = Color.White;
|
||||
|
||||
float shakeStrength = Utils.Remap(Timer, 0f, 180f, 0f, 5f, true);
|
||||
HorizontalShakeStrength = shakeStrength;
|
||||
|
||||
float distanceFromHog = Main.LocalPlayer.Distance(NPC.Center);
|
||||
if (distanceFromHog < 400f)
|
||||
{
|
||||
float screenshakeStrength = Utils.Remap(distanceFromHog, 400f, 100f, 0f, 3f, true) * Utils.GetLerpValue(0f, 180f, Timer, true);
|
||||
Main.LocalPlayer.SetScreenshake(screenshakeStrength);
|
||||
}
|
||||
|
||||
if (Timer >= 45f)
|
||||
{
|
||||
float smokeOpacity = 1.2f * Utils.GetLerpValue(45f, 75f, Timer, true);
|
||||
int smokeAmt = Main.rand.Next(2, 5);
|
||||
for (int i = 0; i < smokeAmt; i++)
|
||||
{
|
||||
Color color = Color.Lerp(new(30, 30, 30), Color.Crimson, Main.rand.NextBool(3) ? Main.rand.NextFloat(0.2f, 0.8f) : Main.rand.Next(2));
|
||||
int lifetime = Main.rand.Next(30, 45);
|
||||
float scale = Main.rand.NextFloat(1.4f, 1.6f);
|
||||
|
||||
HeavySmokeParticle circlingSmoke = new(NPC.Center, Main.rand.NextVector2Circular(16f, 16f), color, lifetime, scale, smokeOpacity, 0.01f, affectedByLight: true);
|
||||
GeneralParticleHandler.SpawnParticle(circlingSmoke, true, Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
|
||||
float particleStrengthInterpolant = Utils.GetLerpValue(0f, 180f, Timer, true);
|
||||
int lightSpawnRate = (int)MathHelper.Lerp(8, 1, particleStrengthInterpolant);
|
||||
if (Main.rand.NextBool(lightSpawnRate))
|
||||
{
|
||||
int lightAmt = (int)MathHelper.Lerp(1, 6, particleStrengthInterpolant);
|
||||
for (int i = 0; i < Main.rand.Next(1, lightAmt + 1); i++)
|
||||
{
|
||||
float lightSpeed = MathHelper.Lerp(2f, 4f, particleStrengthInterpolant) * tintStrength;
|
||||
float lightScale = MathHelper.Lerp(0.5f, 0.8f, particleStrengthInterpolant) * Main.rand.NextFloat(0.5f, 1f) * tintStrength;
|
||||
|
||||
SquishyLightParticle transformLight = new(NPC.Center, Main.rand.NextVector2Circular(lightSpeed, lightSpeed), lightScale, Color.White, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(transformLight, true, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer % 30 == 0f)
|
||||
{
|
||||
float glowRingScale = Utils.Remap(Timer, 0f, 240f, 0.6f, 1.8f, true);
|
||||
Color glowRingColor = Color.Lerp(Color.Crimson, Color.White, Utils.GetLerpValue(0f, 240f, Timer, true));
|
||||
CustomPulse transformRing = new(NPC.Center, Vector2.Zero, glowRingColor, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, glowRingScale, 45);
|
||||
GeneralParticleHandler.SpawnParticle(transformRing, false);
|
||||
}
|
||||
|
||||
if (Timer >= 240f)
|
||||
{
|
||||
BloomParticle bloom = new(NPC.Center, Vector2.Zero, Color.White, 0f, 2.4f, 125);
|
||||
for (int i = 0; i < 3; i++)
|
||||
GeneralParticleHandler.SpawnParticle(bloom, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
CustomPulse glowRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 3f, 75);
|
||||
GeneralParticleHandler.SpawnParticle(glowRing, false, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
QuickSparkleParticle sparkle = new(NPC.Center, Main.rand.NextVector2Circular(16f, 16f), Color.White, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
|
||||
SquishyLightParticle light = new(NPC.Center, Main.rand.NextVector2Circular(8f, 8f), Main.rand.NextFloat(0.6f, 0.8f), Color.White, Main.rand.Next(45, 60));
|
||||
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? sparkle : light, true, Enums.GeneralDrawLayer.AfterNPCs);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item29 with { Pitch = 0.25f, Volume = 0.25f }, NPC.Center);
|
||||
if (SoundEngine.TryGetActiveSound(DevilsTongueSlot, out var activeSound))
|
||||
activeSound.Stop();
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NPC.Transform(ModContent.NPCType<Piggy>());
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
Animate(IdleFrame, IdleFrame, 0, false, dynamicChanges: true);
|
||||
}
|
||||
|
||||
public void MainBehavior_EngageAnimation(Player target)
|
||||
{
|
||||
if (Timer >= 45f)
|
||||
{
|
||||
if (Timer == 45f)
|
||||
{
|
||||
FrameY = 0;
|
||||
NPC.frameCounter = 0;
|
||||
SoundEngine.PlaySound(SoundID.ForceRoarPitched, NPC.Center);
|
||||
}
|
||||
|
||||
if (Timer % 10f == 0f)
|
||||
{
|
||||
PulseRing hogRoar = new(NPC.Center, Vector2.Zero, Color.Red, 0f, 1.2f, 20);
|
||||
GeneralParticleHandler.SpawnParticle(hogRoar, true);
|
||||
}
|
||||
|
||||
NPC.frameCounter++;
|
||||
if (NPC.frameCounter >= 5 && FrameY < MaxFrame_RoarFinish)
|
||||
{
|
||||
FrameY++;
|
||||
NPC.frameCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer >= 120f)
|
||||
SwitchBehavior(specificAttack: BehaviorState.ChasePlayer);
|
||||
|
||||
NPC.velocity.X *= 0.9f;
|
||||
NPC.spriteDirection = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
}
|
||||
|
||||
public void MainBehavior_LaughAtDeadPlayer()
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
// LMFAOOOOOOOOOOOOOOOOOOOOOOOO
|
||||
if (!SoundEngine.TryGetActiveSound(DeathLaughSoundSlot, out var _))
|
||||
{
|
||||
DeathLaughSoundSlot = SoundEngine.PlaySound(CackleSound, NPC.Center, (activeSound) =>
|
||||
{
|
||||
activeSound.Position = NPC.Center;
|
||||
return AIState == (int)BehaviorState.LaughAtDeadPlayer;
|
||||
});
|
||||
}
|
||||
|
||||
NPC.direction *= -1;
|
||||
NPC.velocity.Y -= 4f;
|
||||
}
|
||||
|
||||
SearchForTargetEveryFrame = true;
|
||||
NPC.defense = 60;
|
||||
NPC.damage = 0;
|
||||
NPC.velocity.X *= 0.92f;
|
||||
|
||||
float targetAngle = NPC.direction < 0 ? MathHelper.ToRadians(50f) : MathHelper.ToRadians(-50f);
|
||||
NPC.rotation = (NPC.velocity.Y != 0f) ? NPC.rotation.AngleLerp(targetAngle, 0.075f) : 0f;
|
||||
|
||||
Animate(MinFrame_Laughing, MaxFrame_Laughing);
|
||||
|
||||
if (Timer >= 130f)
|
||||
{
|
||||
BehaviorState nextAttack = NPC.HasValidTarget ? BehaviorState.ChasePlayer : BehaviorState.Idle;
|
||||
SwitchBehavior(specificAttack: nextAttack);
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_DespawnAnimation()
|
||||
{
|
||||
NPC.damage = 0;
|
||||
|
||||
// Wait until Hog hits the ground before running the actual animation.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f && Timer > 3f)
|
||||
{
|
||||
LocalAIState = 1f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.GravityMultiplier *= 2f;
|
||||
}
|
||||
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
// Jump into the ground and dig away.
|
||||
if (Timer < DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.X *= 0.8f;
|
||||
HorizontalShakeStrength = Utils.Remap(Timer, 0, DigTowardsTarget_PreJumpTime - 5, 0f, 6f, true);
|
||||
SetSquashVectors(new Vector2(1.24f, 0.84f));
|
||||
}
|
||||
|
||||
if (Timer == DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.Y -= 6f;
|
||||
NPC.velocity.X += 4f * NPC.direction;
|
||||
HorizontalShakeStrength = 0f;
|
||||
SetSquashVectors();
|
||||
}
|
||||
|
||||
if (Timer > DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
int dustAmt = Main.rand.Next(10, 15);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 dustPosition = NPC.Bottom + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, -2f));
|
||||
Dust.NewDust(dustPosition, 1, 1, DustID.Dirt, dustVelocity.X, dustVelocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(9, 13);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Bottom + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 velocity = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-2f, -1f));
|
||||
Color color = Color.Lerp(Color.SandyBrown, Color.SaddleBrown, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle dustCloud = new(spawnPosition, velocity, color, color, Main.rand.NextFloat(1.2f, 1.4f), 1f, Main.rand.Next(45, 55), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true);
|
||||
}
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 5f);
|
||||
SoundEngine.PlaySound(SoundID.Item70, NPC.Center);
|
||||
|
||||
NPC.active = false;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float idealRotation = (NPC.velocity.Y != 0f) ? NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi) : 0f;
|
||||
NPC.rotation = idealRotation;
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, VomitBarrage_MaxSpeed, 120, 8, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
}
|
||||
|
||||
public void MainBehavior_DeathAnimation()
|
||||
{
|
||||
SetSquashVectors(VelocityBasedSquashNStretch);
|
||||
NPC.rotation = NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi);
|
||||
SpriteRotation -= (MathHelper.TwoPi / 15f) * NPC.direction;
|
||||
TintColor = Color.Red;
|
||||
|
||||
if (Timer > 2 && (NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height)))
|
||||
{
|
||||
if (MiscAttackCounter >= 3)
|
||||
{
|
||||
// Create smoke and throw up a big green "5000" on death just like the pigs in Angry Birds
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
int goreType = Main.rand.Next(GoreID.Smoke1, GoreID.Smoke3 + 1);
|
||||
Gore.NewGorePerfect(NPC.position, Main.rand.NextVector2Circular(2f, 2f), goreType);
|
||||
}
|
||||
|
||||
CombatText.NewText(NPC.Hitbox, Color.LawnGreen, 5000);
|
||||
SoundEngine.PlaySound(NPC.DeathSound, NPC.Center);
|
||||
Collision.HitTiles(NPC.position, NPC.velocity, NPC.width, NPC.height);
|
||||
|
||||
NPC.life = 0;
|
||||
NPC.checkDead();
|
||||
NPC.HitEffect();
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundEngine.PlaySound(NPC.HitSound, NPC.Center);
|
||||
TintStrength = 0.75f;
|
||||
|
||||
MiscAttackCounter++;
|
||||
NPC.velocity.X = NPC.oldVelocity.X * 0.6f;
|
||||
NPC.velocity.Y = -10f;
|
||||
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(NPC.Center, 4f);
|
||||
}
|
||||
|
||||
UseBalledSprite = true;
|
||||
NPC.damage = 0;
|
||||
NPC.GravityMultiplier *= 1.28f;
|
||||
NPC.dontTakeDamage = true;
|
||||
}
|
||||
|
||||
public void MainBehavior_Idle(Player target)
|
||||
{
|
||||
bool targetIsVisible = target.Distance(NPC.Center) <= EngageDistance && Collision.CanHit(NPC, target);
|
||||
bool wasHitByNearestTarget = NPC.HasValidTarget && NPC.justHit;
|
||||
if (targetIsVisible || wasHitByNearestTarget)
|
||||
{
|
||||
SwitchBehavior(specificAttack: BehaviorState.EngageAnimation);
|
||||
DoEyeGlintEffect(0.4f);
|
||||
}
|
||||
|
||||
// Standing still, occasionally switch directions.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer > 0f && Timer % 45f == 0f && Main.rand.NextBool(12))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 1f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (NPC.velocity.Y == 0f)
|
||||
NPC.velocity.X *= 0.8f;
|
||||
|
||||
if (Timer % 45f == 0f && Main.rand.NextBool(4))
|
||||
NPC.direction *= -1;
|
||||
}
|
||||
|
||||
// Walking around aimlessly.
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
if (Timer > 0f && Timer % 45f == 0f && Main.rand.NextBool(6))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (MathF.Abs(NPC.velocity.X) < Idle_MaxSpeed)
|
||||
NPC.velocity.X += Idle_MaxAcceleration * NPC.direction;
|
||||
|
||||
bool shouldJump = NPC.collideX || IsNPCApproachingHole();
|
||||
if (NPC.velocity.Y == 0f && shouldJump)
|
||||
NPC.velocity.Y -= 6f;
|
||||
}
|
||||
|
||||
// Animation.
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, 5, true, dynamicChanges: true);
|
||||
NPC.rotation = 0f;
|
||||
|
||||
// Idle sounds.
|
||||
if (NPC.soundDelay == 0f && Main.rand.NextBool(250))
|
||||
{
|
||||
SetSquashVectors(squashVector: new Vector2(1.24f, 0.84f));
|
||||
SoundEngine.PlaySound(IdleSound, NPC.Center);
|
||||
NPC.soundDelay = Main.rand.Next(30, 45);
|
||||
}
|
||||
|
||||
// Spawn ambient mist around itself while it idles.
|
||||
Rectangle tileWorkSpace = GetTileWorkSpaceForMist();
|
||||
int tileWorkSpaceWithWidth = tileWorkSpace.X + tileWorkSpace.Width;
|
||||
int tileWorkSpaceWithHeight = tileWorkSpace.Y + tileWorkSpace.Height;
|
||||
for (int x = tileWorkSpace.X; x < tileWorkSpaceWithWidth; x++)
|
||||
{
|
||||
for (int y = tileWorkSpace.Y; y < tileWorkSpaceWithHeight; y++)
|
||||
{
|
||||
TrySpawningMist(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
// Tint slightly black.
|
||||
TintColor = Color.Black;
|
||||
TintStrength = 0.6f;
|
||||
|
||||
NPC.chaseable = false;
|
||||
SearchForTargetEveryFrame = true;
|
||||
HorizontalShakeStrength = 0f;
|
||||
}
|
||||
|
||||
public void MainBehavior_DigTowardsTarget(Player target)
|
||||
{
|
||||
// Initial animation.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer < DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.X *= 0.8f;
|
||||
HorizontalShakeStrength = Utils.Remap(Timer, 0, DigTowardsTarget_PreJumpTime - 5, 0f, 6f, true);
|
||||
SetSquashVectors(new Vector2(1.24f, 0.84f));
|
||||
}
|
||||
|
||||
if (Timer == DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
NPC.velocity.Y -= 6f;
|
||||
HorizontalShakeStrength = 0f;
|
||||
SetSquashVectors(squashVector: new Vector2(0.84f, 1.24f));
|
||||
SoundEngine.PlaySound(JumpSound, NPC.Center);
|
||||
}
|
||||
|
||||
if (Timer > DigTowardsTarget_PreJumpTime)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
int dustAmt = Main.rand.Next(10, 15);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 dustPosition = NPC.Bottom + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, -2f));
|
||||
Dust.NewDust(dustPosition, 1, 1, DustID.Dirt, dustVelocity.X, dustVelocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(9, 13);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Bottom + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 velocity = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-2f, -1f));
|
||||
Color color = Color.Lerp(Color.SandyBrown, Color.SaddleBrown, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle dustCloud = new(spawnPosition, velocity, color, color, Main.rand.NextFloat(1.2f, 1.4f), 1f, Main.rand.Next(45, 55), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true);
|
||||
}
|
||||
|
||||
NPC.rotation = 0f;
|
||||
SoundEngine.PlaySound(SoundID.Item70, NPC.Center);
|
||||
LocalAIState = 1f;
|
||||
Timer = 0f;
|
||||
SetSquashVectors();
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
NPC.rotation = MathHelper.Lerp(NPC.rotation, -MathHelper.PiOver2, 0.175f);
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a position around the player to emerge.
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.Opacity = 0f;
|
||||
|
||||
// Find closest spot around player.
|
||||
if (Timer <= DigTowardsTarget_FindSuitablePositionTime)
|
||||
{
|
||||
DiggingEmergeSpot = FindSuitableGround(target.Bottom.ToTileCoordinates()).ToWorldCoordinates();
|
||||
}
|
||||
else
|
||||
{
|
||||
float distanceInterpolant = Utils.GetLerpValue(800f, 200f, target.Distance(DiggingEmergeSpot), true);
|
||||
float screenshake = Utils.Remap(Timer, DigTowardsTarget_FindSuitablePositionTime, DigTowardsTraget_MaxDiggingTime, 1f, 4f, true) * distanceInterpolant;
|
||||
target.SetScreenshake(screenshake);
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
int dustAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 dustPosition = DiggingEmergeSpot + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-5f, -3f));
|
||||
Dust.NewDust(dustPosition, 1, 1, DustID.Dirt, dustVelocity.X, dustVelocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
}
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = DiggingEmergeSpot + Main.rand.NextVector2Circular(NPC.width, 0f);
|
||||
Vector2 velocity = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-5f, -3f));
|
||||
Color color = Color.Lerp(Color.SandyBrown, Color.SaddleBrown, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle dustCloud = new(spawnPosition, velocity, color, color, Main.rand.NextFloat(0.6f, 0.8f), 1f, Main.rand.Next(25, 45), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true, Enums.GeneralDrawLayer.BeforeSolidTiles);
|
||||
}
|
||||
|
||||
// Play digging sounds.
|
||||
if (Timer <= DigTowardsTarget_FindSuitablePositionTime)
|
||||
{
|
||||
if (!SoundEngine.TryGetActiveSound(DiggingSoundSlot, out _))
|
||||
{
|
||||
DiggingSoundSlot = SoundEngine.PlaySound(DiggingSlowSound, NPC.Center, (activeSound) =>
|
||||
{
|
||||
activeSound.Position = DiggingEmergeSpot;
|
||||
return AIState == (int)BehaviorState.DigTowardsTarget && Timer <= 120;
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SoundEngine.TryGetActiveSound(DiggingSoundSlot, out _))
|
||||
{
|
||||
DiggingSoundSlot = SoundEngine.PlaySound(DiggingFastSound, NPC.Center, (activeSound) =>
|
||||
{
|
||||
activeSound.Position = DiggingEmergeSpot;
|
||||
activeSound.Volume = 1.5f;
|
||||
return AIState == (int)BehaviorState.DigTowardsTarget && Timer >= 120 && Timer <= 180;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Jump out.
|
||||
if (Timer >= DigTowardsTraget_MaxDiggingTime)
|
||||
{
|
||||
CalamityUtils.AddScreenshakeAt(DiggingEmergeSpot, 4f);
|
||||
SoundEngine.PlaySound(SoundID.Item70, DiggingEmergeSpot);
|
||||
|
||||
NPC.Center = DiggingEmergeSpot;
|
||||
NPC.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(NPC.Center, target.Center, NPC.gravity, 7f) * new Vector2(1f, 1.45f);
|
||||
DoJumpEffects();
|
||||
|
||||
LocalAIState = 2f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
AfterimageTrailOpacity = MathHelper.Lerp(AfterimageTrailOpacity, 0f, 0.15f);
|
||||
NPC.rotation = NPC.rotation.AngleLerp(0f, 0.075f);
|
||||
SpriteRotation = SpriteRotation.AngleLerp(0f, 0.075f);
|
||||
}
|
||||
|
||||
// Land after jumping and go back to attacking.
|
||||
if (LocalAIState == 2f)
|
||||
{
|
||||
NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 1f, 0.085f);
|
||||
if (NPC.velocity.Y == 0f && Timer > 2f)
|
||||
{
|
||||
DoEyeGlintEffect(0.4f);
|
||||
SwitchBehavior(specificAttack: BehaviorState.ChasePlayer);
|
||||
}
|
||||
|
||||
float idealRotation = (NPC.velocity.Y != 0f) ? NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi) : 0f;
|
||||
NPC.rotation = idealRotation;
|
||||
NPC.direction = (target.Center.X > NPC.Center.X).ToDirectionInt();
|
||||
}
|
||||
|
||||
int frameSpeed = (int)Utils.Remap(MathF.Abs(NPC.velocity.X), 0f, VomitBarrage_MaxSpeed, 120, 8, true);
|
||||
Animate(MinFrame_Walking, MaxFrame_Walking, frameSpeed, true, dynamicChanges: true);
|
||||
|
||||
DigTimer = 0f;
|
||||
SearchForTargetEveryFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 816 B |
@@ -1,56 +1,123 @@
|
||||
using System;
|
||||
using System.Security.Policy;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Items.Critters;
|
||||
using CalamityMod.Items.Placeables.Banners;
|
||||
using CalamityMod.NPCs.NormalNPCs.HorribleHog;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.Utilities;
|
||||
|
||||
namespace CalamityMod.NPCs.NormalNPCs
|
||||
{
|
||||
public class Piggy : ModNPC
|
||||
{
|
||||
public enum BehaviorState
|
||||
{
|
||||
DivineSwineTransformation = -2,
|
||||
HorribleHogTransformation = -1,
|
||||
IdleAndWalk,
|
||||
Running,
|
||||
}
|
||||
|
||||
private static Asset<Texture2D> SpotlightTexture;
|
||||
private static Asset<Texture2D> BloomCircle;
|
||||
private static Asset<Texture2D> BloomFlare;
|
||||
private static Asset<Texture2D> ShineFlare;
|
||||
|
||||
private static SoundStyle IdleSound_Grunt = new("CalamityMod/Sounds/Custom/Piggy/PiggyIdle_Grunt", 3);
|
||||
private static SoundStyle IdleSound_SnortYip = new("CalamityMod/Sounds/Custom/Piggy/PiggyIdle_SnortYip", 3);
|
||||
private static SoundStyle IdleSound_Yip = new("CalamityMod/Sounds/Custom/Piggy/PiggyIdle_Yip", 2);
|
||||
private static SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/PiggyDeath", 2);
|
||||
|
||||
private static SoundStyle DivineSwine_CoinFailSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineCoinFail", 3);
|
||||
private static SoundStyle DivineSwine_SwineSpeakLoopingSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineNearbyLoop")
|
||||
{
|
||||
IsLooped = true,
|
||||
PauseBehavior = PauseBehavior.PauseWithGame,
|
||||
MaxInstances = 0,
|
||||
};
|
||||
|
||||
private static SoundStyle HorribleHog_CackleSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogCackle");
|
||||
private static SoundStyle HorribleHog_IdleSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogIdle", 2)
|
||||
{
|
||||
PitchVariance = 0.25f,
|
||||
};
|
||||
private static SoundStyle HorribleHog_DevilsTongueLoopingSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogNearbyLoop")
|
||||
{
|
||||
IsLooped = true,
|
||||
PauseBehavior = PauseBehavior.PauseWithGame,
|
||||
MaxInstances = 0
|
||||
};
|
||||
|
||||
public Vector2 SquashVector;
|
||||
|
||||
public SlotId NearbySoundSlot;
|
||||
|
||||
public static float MaxAcceleration_Walking => 0.035f;
|
||||
public static float MaxAcceleration_Running => 0.085f;
|
||||
public static float MaxSpeed_Walking => 1.2f;
|
||||
public static float MaxSpeed_Running => 3.6f;
|
||||
|
||||
public ref float Timer => ref NPC.ai[0];
|
||||
|
||||
public ref float AIState => ref NPC.ai[1];
|
||||
|
||||
public ref float LocalAIState => ref NPC.ai[2];
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
SpotlightTexture = ModContent.Request<Texture2D>("Terraria/Images/Extra_60");
|
||||
BloomCircle = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
|
||||
BloomFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BloomFlare");
|
||||
ShineFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/ShineFlare");
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.npcFrameCount[Type] = 5;
|
||||
Main.npcFrameCount[Type] = 8;
|
||||
Main.npcCatchable[Type] = true;
|
||||
NPCID.Sets.CountsAsCritter[Type] = true;
|
||||
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
|
||||
{
|
||||
SpriteDirection = 1
|
||||
};
|
||||
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
|
||||
NPCID.Sets.CantTakeLunchMoney[Type] = true;
|
||||
NPCID.Sets.NormalGoldCritterBestiaryPriority.Add(Type);
|
||||
NPCID.Sets.TakesDamageFromHostilesWithoutBeingFriendly[Type] = true;
|
||||
NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 1, Type);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.chaseable = false;
|
||||
NPC.damage = 0;
|
||||
NPC.width = 26;
|
||||
NPC.height = 26;
|
||||
NPC.lifeMax = 2000;
|
||||
NPC.aiStyle = NPCAIStyleID.Passive;
|
||||
AIType = NPCID.Squirrel;
|
||||
NPC.knockBackResist = 0.99f;
|
||||
NPC.width = 42;
|
||||
NPC.height = 28;
|
||||
NPC.lifeMax = 300;
|
||||
NPC.aiStyle = -1;
|
||||
NPC.knockBackResist = 1.15f;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.DeathSound = DeathSound;
|
||||
NPC.catchItem = (short)ModContent.ItemType<PiggyItem>();
|
||||
Banner = NPC.type;
|
||||
BannerItem = ModContent.ItemType<PiggyBanner>();
|
||||
NPC.catchItem = (short)ModContent.ItemType<PiggyItem>();
|
||||
NPC.chaseable = false;
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Force bestiary unlock
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0)
|
||||
{
|
||||
Main.BestiaryTracker.Kills.RegisterKill(NPC);
|
||||
}
|
||||
SquashVector = Vector2.One;
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
@@ -63,13 +130,380 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
});
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Force bestiary cause this doesn't count as Vanilla's definition of a critter for the Bestiary.
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0)
|
||||
Main.BestiaryTracker.Kills.SetKillCountDirectly(NPC.GetBestiaryCreditId(), 100);
|
||||
|
||||
if (NPC.direction == 0)
|
||||
NPC.direction = Utils.SelectRandom(Main.rand, -1, 1);
|
||||
|
||||
switch ((BehaviorState)AIState)
|
||||
{
|
||||
case BehaviorState.DivineSwineTransformation:
|
||||
MainBehavior_DivineSwineTransformation();
|
||||
break;
|
||||
|
||||
case BehaviorState.HorribleHogTransformation:
|
||||
MainBehavior_HorribleHogTransformation();
|
||||
break;
|
||||
|
||||
case BehaviorState.IdleAndWalk:
|
||||
MainBehavior_IdleAndWalk();
|
||||
break;
|
||||
|
||||
case BehaviorState.Running:
|
||||
MainBehavior_Running();
|
||||
break;
|
||||
}
|
||||
|
||||
NPC.StepUpBlocks();
|
||||
|
||||
SquashVector = Vector2.Lerp(SquashVector, Vector2.One, 0.125f);
|
||||
Timer++;
|
||||
}
|
||||
|
||||
public void MainBehavior_DivineSwineTransformation()
|
||||
{
|
||||
NPC.velocity.X *= 0.9f;
|
||||
NPC.rotation = 0f;
|
||||
if (!SoundEngine.TryGetActiveSound(NearbySoundSlot, out _))
|
||||
NearbySoundSlot = SoundEngine.PlaySound(DivineSwine_SwineSpeakLoopingSound, NPC.Center, NearbySoundCallbackMethod);
|
||||
|
||||
float lightSpawnDistance = MathHelper.Lerp(52f, 84f, Timer / 180f);
|
||||
int lightAmt = Main.rand.Next(1, 2);
|
||||
for (int i = 0; i < lightAmt; i++)
|
||||
{
|
||||
Vector2 lightSpawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.7f, 1f);
|
||||
Vector2 lightVelocity = (NPC.Center - lightSpawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(3f, 4f);
|
||||
float lightScale = Utils.Remap(Timer, 0f, 180f, 0.3f, 0.9f, true);
|
||||
|
||||
SquishyLightParticle meatLight = new(lightSpawnPosition, lightVelocity, lightScale, Color.White, Main.rand.Next(30, 45));
|
||||
GeneralParticleHandler.SpawnParticle(meatLight, true);
|
||||
}
|
||||
|
||||
int sparkleSpawnRate = (int)Utils.Remap(Timer, 0f, 180f, 45, 5, true);
|
||||
if (Main.rand.NextBool(sparkleSpawnRate))
|
||||
{
|
||||
int sparkleAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < sparkleAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.8f, 1.2f);
|
||||
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
|
||||
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
|
||||
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
|
||||
float sparkleScale = Utils.Remap(Timer, 0f, 180f, 0.2f, 0.8f, true);
|
||||
|
||||
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, sparkleScale * Main.rand.NextFloat(0.5f, 1f), Main.rand.Next(20, 30));
|
||||
GeneralParticleHandler.SpawnParticle(sparkle, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Timer >= 30f && Main.rand.NextBool(10))
|
||||
{
|
||||
Vector2 spawnPosition = NPC.Center + new Vector2(Main.rand.NextFloat(-16f, 16f), Main.rand.NextFloat(-144f, -134f));
|
||||
Vector2 velocity = Vector2.UnitY * Main.rand.NextFloat(0.25f, 0.75f);
|
||||
Color featherColor = Color.Lerp(Color.Lerp(new Color(27, 103, 155), new Color(83, 184, 255), Main.rand.NextFloat()), new Color(221, 253, 255), Main.rand.NextFloat(0.4f));
|
||||
float scale = Main.rand.NextFloat(0.8f, 1f);
|
||||
|
||||
FeatherParticle feather = new(spawnPosition, velocity, featherColor, scale, Main.rand.Next(75, 90), null, 0.9f, false, false, true);
|
||||
GeneralParticleHandler.SpawnParticle(feather, manualDrawLayerOverride: Enums.GeneralDrawLayer.BeforeNPCs);
|
||||
}
|
||||
|
||||
if (Timer >= 180f && Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
CustomPulse lightRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 2f, 75);
|
||||
GeneralParticleHandler.SpawnParticle(lightRing);
|
||||
|
||||
BloomParticle bloom = new(NPC.Center, Vector2.Zero, Color.White, 0f, 2f, 125);
|
||||
for (int i = 0; i < 3; i++)
|
||||
GeneralParticleHandler.SpawnParticle(bloom);
|
||||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
QuickSparkleParticle sparkle = new(NPC.Center, Main.rand.NextVector2Circular(15f, 15f), Color.White, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
|
||||
SquishyLightParticle light = new(NPC.Center, Main.rand.NextVector2Circular(5f, 5f), Main.rand.NextFloat(0.6f, 0.8f), Color.White, Main.rand.Next(45, 60));
|
||||
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? sparkle : light, true);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(DivineSwine_CoinFailSound, NPC.Center);
|
||||
if (SoundEngine.TryGetActiveSound(NearbySoundSlot, out var activeSound))
|
||||
activeSound.Stop();
|
||||
|
||||
NPC.Transform(ModContent.NPCType<DivineSwine>());
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_HorribleHogTransformation()
|
||||
{
|
||||
NPC.velocity.X *= 0.9f;
|
||||
NPC.rotation = 0f;
|
||||
if (!SoundEngine.TryGetActiveSound(NearbySoundSlot, out _))
|
||||
NearbySoundSlot = SoundEngine.PlaySound(HorribleHog_DevilsTongueLoopingSound, NPC.Center, NearbySoundCallbackMethod);
|
||||
|
||||
float smokeOpacity = Utils.GetLerpValue(0f, 45f, Timer, true);
|
||||
int circlingSmokeAmount = Main.rand.Next(2, 5);
|
||||
for (int i = 0; i < circlingSmokeAmount; i++)
|
||||
{
|
||||
Vector2 spawnDistanceVariance = Main.rand.NextVector2Circular(50f, 50f);
|
||||
Vector2 spawnPosition = NPC.Center + spawnDistanceVariance;
|
||||
Vector2 velocity = spawnDistanceVariance.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(2f, 5f);
|
||||
Color color = Color.Lerp(new(30, 30, 30), Color.Crimson, Main.rand.Next(2));
|
||||
int lifetime = Main.rand.Next(30, 45);
|
||||
float scale = Main.rand.NextFloat(1f, 1.2f);
|
||||
|
||||
HeavySmokeParticle circlingSmoke = new(spawnPosition, velocity, color, lifetime, scale, smokeOpacity, 0.01f, affectedByLight: true);
|
||||
GeneralParticleHandler.SpawnParticle(circlingSmoke, true);
|
||||
}
|
||||
|
||||
if (Timer >= 180f)
|
||||
{
|
||||
SoundEngine.PlaySound(HorribleHog_CackleSound, NPC.Center);
|
||||
if (SoundEngine.TryGetActiveSound(NearbySoundSlot, out var activeSound))
|
||||
activeSound.Stop();
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NPC.Transform(ModContent.NPCType<HorribleHog.HorribleHog>());
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MainBehavior_IdleAndWalk()
|
||||
{
|
||||
// Idling.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (Timer > 0f)
|
||||
{
|
||||
if (Timer % 60f == 0f && Main.rand.NextBool(6))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 1f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (Timer % 60f == 0f && Main.rand.NextBool(12))
|
||||
{
|
||||
AIState = (int)BehaviorState.Running;
|
||||
Timer = 0f;
|
||||
LocalAIState = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop moving and occasionally switch directions.
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
NPC.velocity.X *= 0.8f;
|
||||
if (Timer % 15f == 0f && Main.rand.NextBool(12))
|
||||
NPC.direction *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Walking.
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
if (Timer > 120f && Timer % 60f == 0f && Main.rand.NextBool(5))
|
||||
{
|
||||
Timer = 0f;
|
||||
LocalAIState = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (MathF.Abs(NPC.velocity.X) < MaxSpeed_Walking)
|
||||
NPC.velocity.X += MaxAcceleration_Walking * NPC.direction;
|
||||
|
||||
if (NPC.collideX && NPC.velocity.Y == 0f)
|
||||
NPC.velocity.Y -= 6f;
|
||||
}
|
||||
|
||||
// Sound effects.
|
||||
if (NPC.soundDelay == 0 && Main.rand.NextBool(200))
|
||||
{
|
||||
// Small chance to do a cute lil hop as well.
|
||||
if (Main.rand.NextBool(5))
|
||||
{
|
||||
NPC.velocity.Y -= Main.rand.NextFloat(2f, 4f);
|
||||
SquashVector = new Vector2(0.7f, 1.3f);
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
var chosenSoundStyle = Utils.SelectRandom(Main.rand, IdleSound_Grunt, IdleSound_SnortYip, IdleSound_Yip);
|
||||
SoundEngine.PlaySound(chosenSoundStyle, NPC.Center);
|
||||
NPC.soundDelay = Main.rand.Next(60, 120);
|
||||
}
|
||||
|
||||
NPC.spriteDirection = NPC.direction;
|
||||
float targetAngle = (NPC.velocity.Y != 0f) ? NPC.velocity.X * 0.085f * (NPC.velocity.Y < 0).ToDirectionInt() : 0f;
|
||||
NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.075f);
|
||||
}
|
||||
|
||||
public void MainBehavior_Running()
|
||||
{
|
||||
// Run in a random direction until collision with a wall is made.
|
||||
if (LocalAIState == 0f)
|
||||
{
|
||||
if (MathF.Abs(NPC.velocity.X) < MaxSpeed_Running)
|
||||
NPC.velocity.X += MaxAcceleration_Running * NPC.direction;
|
||||
NPC.spriteDirection = NPC.direction;
|
||||
|
||||
// Spawn particles when running at max speed.
|
||||
if (NPC.velocity.Y == 0f && MathF.Abs(NPC.velocity.X) >= MaxSpeed_Running)
|
||||
{
|
||||
int dustType = NPC.type == ModContent.NPCType<PiggyGold>() ? DustID.Enchanted_Gold : DustID.Cloud;
|
||||
Vector2 dustPosition = new(NPC.Bottom.X + Main.rand.NextFloat(-NPC.width * 0.5f, NPC.width * 0.5f), NPC.Bottom.Y);
|
||||
Dust.NewDustPerfect(dustPosition, dustType, new Vector2(NPC.velocity.X * 0.2f, Main.rand.NextFloat(-0.3f, 0.3f)), 0, default, Main.rand.NextFloat(1f, 1.2f));
|
||||
if (Timer % 7 == 0f)
|
||||
SoundEngine.PlaySound(SoundID.Run with { Pitch = 0.3f, Volume = 0.7f, Identifier = "Piggy Run" }, NPC.Center);
|
||||
}
|
||||
|
||||
if (HoleBelow() && NPC.velocity.Y == 0f)
|
||||
NPC.velocity.Y -= 6f;
|
||||
|
||||
if (NPC.collideX)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Dig with { Volume = 0.7f }, NPC.Center);
|
||||
SoundEngine.PlaySound(IdleSound_Grunt with { Volume = 1.2f }, NPC.Center);
|
||||
SquashVector = new Vector2(0.6f, 1f);
|
||||
|
||||
NPC.velocity.X = NPC.oldVelocity.X * -0.86f;
|
||||
NPC.velocity.Y -= 3f;
|
||||
Timer = 0f;
|
||||
LocalAIState = 1f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
// Stop running and go back to idling if 5 seconds has passed without collision.
|
||||
else if (Timer >= 300f)
|
||||
{
|
||||
AIState = (int)BehaviorState.IdleAndWalk;
|
||||
LocalAIState = Main.rand.Next(1);
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
float idealRotation = (NPC.velocity.Y != 0f) ? NPC.velocity.ToRotation() + (NPC.direction > 0 ? 0f : -MathHelper.Pi) : 0f;
|
||||
NPC.rotation = idealRotation;
|
||||
}
|
||||
|
||||
if (LocalAIState == 1f)
|
||||
{
|
||||
if (NPC.velocity.Y == 0f)
|
||||
{
|
||||
NPC.velocity.X *= 0.9f;
|
||||
if (MathF.Abs(NPC.velocity.X) >= 0.08f && MathF.Abs(NPC.velocity.X) < 0.09f)
|
||||
{
|
||||
NPC.velocity.Y = -4f;
|
||||
var soundStyle = Utils.SelectRandom(Main.rand, IdleSound_SnortYip, IdleSound_Yip);
|
||||
SoundEngine.PlaySound(soundStyle.WithPitchOffset(0.35f), NPC.Center);
|
||||
}
|
||||
}
|
||||
|
||||
if (MathF.Abs(NPC.velocity.X) > 0.09f)
|
||||
NPC.rotation += NPC.velocity.X * 0.075f;
|
||||
else
|
||||
NPC.rotation = NPC.rotation.AngleLerp(0f, 0.125f);
|
||||
|
||||
if (Timer >= 120f)
|
||||
{
|
||||
AIState = (int)BehaviorState.IdleAndWalk;
|
||||
LocalAIState = Main.rand.Next(1);
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformIntoVariant(int type)
|
||||
{
|
||||
if (type == ModContent.NPCType<DivineSwine>())
|
||||
AIState = (int)BehaviorState.DivineSwineTransformation;
|
||||
else if (type == ModContent.NPCType<HorribleHog.HorribleHog>())
|
||||
AIState = (int)BehaviorState.HorribleHogTransformation;
|
||||
else
|
||||
AIState = (int)BehaviorState.IdleAndWalk;
|
||||
|
||||
LocalAIState = 0f;
|
||||
Timer = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
public bool TryTransformingIntoVariant()
|
||||
{
|
||||
if (AIState == (int)BehaviorState.DivineSwineTransformation || AIState == (int)BehaviorState.HorribleHogTransformation)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HoleBelow()
|
||||
{
|
||||
int npcWidthInTiles = NPC.width / 16;
|
||||
int tileX = (int)(NPC.Center.X / 16f) - npcWidthInTiles;
|
||||
if (NPC.velocity.X > 0)
|
||||
tileX += npcWidthInTiles;
|
||||
|
||||
int tileY = (int)((NPC.position.Y + NPC.height) / 16f);
|
||||
for (int y = tileY; y < tileY + 2; y++)
|
||||
{
|
||||
for (int x = tileX; x < tileX + npcWidthInTiles; x++)
|
||||
{
|
||||
if (Main.tile[x, y].HasTile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool NearbySoundCallbackMethod(ActiveSound soundInstance)
|
||||
{
|
||||
float interpolant = Utils.GetLerpValue(0f, 75f, Timer, true) * Utils.GetLerpValue(180f, 130f, Timer, true);
|
||||
soundInstance.Position = NPC.Center;
|
||||
soundInstance.Volume = interpolant;
|
||||
return NPC.active;
|
||||
}
|
||||
|
||||
public override float SpawnChance(NPCSpawnInfo spawnInfo)
|
||||
{
|
||||
if (spawnInfo.Player.Calamity().ZoneSulphur || spawnInfo.Player.Calamity().ZoneSunkenSea)
|
||||
float goldMultiplier = NPC.type == ModContent.NPCType<PiggyGold>() ? 0.15f : 1f;
|
||||
bool inAtTown = spawnInfo.Player.townNPCs > 2f && (Main.remixWorld ? spawnInfo.Player.ZoneNormalCaverns : spawnInfo.Player.ZoneForest);
|
||||
if (inAtTown)
|
||||
return SpawnCondition.TownCritter.Chance * 0.15f * goldMultiplier;
|
||||
else if (spawnInfo.Player.ZonePurity)
|
||||
return (Main.remixWorld ? SpawnCondition.Cavern.Chance * 0.005f : SpawnCondition.OverworldDayGrassCritter.Chance * 0.005f) * goldMultiplier;
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Bacon);
|
||||
|
||||
public override void HitEffect(NPC.HitInfo hit)
|
||||
{
|
||||
int dustType = Type == ModContent.NPCType<PiggyGold>() ? DustID.GoldCritter : DustID.Blood;
|
||||
for (int k = 0; k < 5; k++)
|
||||
{
|
||||
return 0f;
|
||||
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, hit.HitDirection, -1f, 0, default, 1f);
|
||||
}
|
||||
return SpawnCondition.TownCritter.Chance * 0.005f;
|
||||
|
||||
if (NPC.life <= 0)
|
||||
{
|
||||
for (int k = 0; k < 15; k++)
|
||||
{
|
||||
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, hit.HitDirection, -1f, 0, default, 1f);
|
||||
}
|
||||
|
||||
if (!Main.dedServ && Type != ModContent.NPCType<PiggyGold>())
|
||||
{
|
||||
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Piggy").Type, 1f);
|
||||
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Piggy2").Type, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
NPC.direction = hit.HitDirection;
|
||||
}
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
@@ -78,15 +512,6 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
{
|
||||
if (!NPC.IsABestiaryIconDummy)
|
||||
{
|
||||
if (NPC.direction == 1)
|
||||
{
|
||||
NPC.spriteDirection = -1;
|
||||
}
|
||||
if (NPC.direction == -1)
|
||||
{
|
||||
NPC.spriteDirection = 1;
|
||||
}
|
||||
|
||||
if (NPC.velocity.X == 0f)
|
||||
{
|
||||
NPC.frame.Y = 0;
|
||||
@@ -94,13 +519,15 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NPC.frameCounter += NPC.IsABestiaryIconDummy ? 0.6f : Math.Abs(NPC.velocity.X) * 0.25f;
|
||||
NPC.frameCounter += 1.0;
|
||||
if (NPC.frameCounter > 12.0)
|
||||
if (NPC.frameCounter > 7.0)
|
||||
{
|
||||
NPC.frame.Y = NPC.frame.Y + frameHeight;
|
||||
NPC.frameCounter = 0.0;
|
||||
}
|
||||
|
||||
if (NPC.frame.Y / frameHeight >= Main.npcFrameCount[Type] - 1)
|
||||
{
|
||||
NPC.frame.Y = frameHeight;
|
||||
@@ -113,21 +540,61 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Bacon);
|
||||
|
||||
public override void HitEffect(NPC.HitInfo hit)
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
for (int k = 0; k < 5; k++)
|
||||
if (NPC.IsABestiaryIconDummy)
|
||||
return true;
|
||||
|
||||
Texture2D baseTexture = TextureAssets.Npc[Type].Value;
|
||||
Vector2 scale = SquashVector * NPC.scale;
|
||||
SpriteEffects spriteEffects = NPC.spriteDirection < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
spriteBatch.Draw(baseTexture, NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, scale, spriteEffects, 0f);
|
||||
|
||||
spriteBatch.End(out var snapshot);
|
||||
|
||||
// Draw the transformation visuals when needed.
|
||||
if (AIState == (int)BehaviorState.DivineSwineTransformation)
|
||||
Draw_DivineSwineTransformationVisuals(spriteBatch, screenPos);
|
||||
|
||||
spriteBatch.Begin(snapshot);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Draw_DivineSwineTransformationVisuals(SpriteBatch spriteBatch, Vector2 screenPos)
|
||||
{
|
||||
Vector2 baseDrawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY;
|
||||
float interpolant = CalamityUtils.SineOutEasing(Utils.GetLerpValue(0f, 120f, Timer, true), 1);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
// Spotlight from heaven.
|
||||
float spotlightOpacity = CalamityUtils.SineInOutEasing(Utils.GetLerpValue(0f, 30f, Timer, true) * Utils.GetLerpValue(180f, 150f, Timer, true), 1);
|
||||
Vector2 spotlightDrawPosition = baseDrawPosition + Vector2.UnitY * -16f;
|
||||
Vector2 spotlightScale = new Vector2(1.3f * interpolant, 1.6f);
|
||||
Vector2 spotlightOrigin = new Vector2(SpotlightTexture.Width() * 0.5f, SpotlightTexture.Height());
|
||||
spriteBatch.Draw(SpotlightTexture.Value, spotlightDrawPosition, null, Color.White with { A = 0 } * spotlightOpacity, 0f, spotlightOrigin, spotlightScale, SpriteEffects.FlipVertically, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
|
||||
using (pixelationLease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f);
|
||||
}
|
||||
if (NPC.life <= 0)
|
||||
{
|
||||
for (int k = 0; k < 15; k++)
|
||||
{
|
||||
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f);
|
||||
}
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, PixelationManager.PixelationMatrix);
|
||||
|
||||
// Typical bloom effects.
|
||||
float flareRotation = (float)(Main.timeForVisualEffects / 150f) + NPC.whoAmI;
|
||||
spriteBatch.Draw(BloomFlare.Value, baseDrawPosition, null, Color.White with { A = 0 } * interpolant * 0.5f, flareRotation, BloomFlare.Size() * 0.5f, 0.2f * interpolant, 0, 0f);
|
||||
spriteBatch.Draw(BloomFlare.Value, baseDrawPosition, null, Color.White with { A = 0 } * interpolant, flareRotation * -0.6f, BloomFlare.Size() * 0.5f, 0.15f * interpolant, 0, 0f);
|
||||
|
||||
spriteBatch.Draw(BloomCircle.Value, baseDrawPosition, null, Color.White with { A = 0 } * interpolant, 0f, BloomCircle.Size() * 0.5f, 0.2f * interpolant, 0, 0f);
|
||||
spriteBatch.Draw(ShineFlare.Value, baseDrawPosition, null, Color.White with { A = 0 } * interpolant, 0f, ShineFlare.Size() * 0.5f, 0.1f * interpolant, 0, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.Items.Critters;
|
||||
using CalamityMod.Items.Placeables.Banners;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.NormalNPCs
|
||||
{
|
||||
public class PiggyGold : Piggy
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
NPCID.Sets.GoldCrittersCollection.Add(Type);
|
||||
NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 2, Type);
|
||||
base.SetStaticDefaults();
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
base.SetDefaults();
|
||||
NPC.catchItem = (short)ModContent.ItemType<PiggyGoldItem>();
|
||||
Banner = 0;
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
{
|
||||
// All gold critters have the same Bestiary entry.
|
||||
var flavorText = database.FindEntryByNPCID(NPCID.GoldBunny).Info.Where(info => info is FlavorTextBestiaryInfoElement).FirstOrDefault();
|
||||
bestiaryEntry.AddTags(
|
||||
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.DayTime,
|
||||
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface,
|
||||
flavorText);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
base.AI();
|
||||
NPC.ProduceGoldCritterDust();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -834,22 +834,16 @@ namespace CalamityMod.NPCs.Providence
|
||||
if (NPC.Center.X < player.Center.X)
|
||||
{
|
||||
flightPath = 1;
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flightPath = -1;
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Increase speed over time if flying in same direction for too long
|
||||
if (revenge)
|
||||
calamityGlobalNPC.newAI[0] += 1f;
|
||||
|
||||
// Distance needed from target to change direction
|
||||
float changeDirectionThreshold = 800f;
|
||||
|
||||
@@ -881,7 +875,6 @@ namespace CalamityMod.NPCs.Providence
|
||||
|
||||
// Velocity and acceleration
|
||||
float speedIncreaseTimer = fullPowerAI ? 75f : death ? 120f : 150f;
|
||||
bool increaseSpeed = calamityGlobalNPC.newAI[0] > speedIncreaseTimer;
|
||||
float accelerationBoost = death ? 0.3f * (1f - lifeRatio) : 0.2f * (1f - lifeRatio);
|
||||
float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
|
||||
float acceleration = (expertMode ? 1.1f : 1.05f) + accelerationBoost;
|
||||
@@ -893,14 +886,8 @@ namespace CalamityMod.NPCs.Providence
|
||||
}
|
||||
if (laserPhaseSlow)
|
||||
{
|
||||
acceleration *= getFuckedAI ? 0.6f : 0.4f;
|
||||
velocity *= getFuckedAI ? 0.6f : 0.4f;
|
||||
}
|
||||
else if (increaseSpeed)
|
||||
{
|
||||
velocity += (calamityGlobalNPC.newAI[0] - speedIncreaseTimer) * 0.04f;
|
||||
if (velocity > 30f)
|
||||
velocity = 30f;
|
||||
acceleration *= getFuckedAI ? 0.6f : 0.2f;
|
||||
velocity *= getFuckedAI ? 0.6f : 0.2f;
|
||||
}
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
var item = Main.player[projectile.owner].HeldItem;
|
||||
if (item.pick > 0 && projectile.CountsAsClass<MeleeDamageClass>())
|
||||
if (item.pick > 0 && !projectile.CountsAsClass<SummonDamageClass>())
|
||||
{
|
||||
modifiers.FlatBonusDamage += -10000;
|
||||
modifiers.FinalDamage.Flat += item.pick-1;
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
var item = Main.player[projectile.owner].HeldItem;
|
||||
if (item.pick > 0 && projectile.CountsAsClass<MeleeDamageClass>())
|
||||
if (item.pick > 0 && !projectile.CountsAsClass<SummonDamageClass>())
|
||||
{
|
||||
modifiers.FlatBonusDamage += -10000;
|
||||
modifiers.FinalDamage.Flat += item.pick - 1;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace CalamityMod.NPCs.TownNPCs
|
||||
AIType = NPCID.TownBunny;
|
||||
NPC.damage = 0;
|
||||
NPC.defense = 0;
|
||||
NPC.lifeMax = 50;
|
||||
NPC.lifeMax = 250;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.knockBackResist = 0.5f;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.IO;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.Packets
|
||||
{
|
||||
internal class DivineSwineOfferingPacket : CalamityPacket
|
||||
{
|
||||
public static DivineSwineOfferingPacket Instance { get; private set; }
|
||||
|
||||
public static void Send(DivineSwine divineSwine, bool? offeringState = null, int toClient = -1, int ignoreClient = -1)
|
||||
{
|
||||
if (divineSwine is null || !offeringState.HasValue)
|
||||
return;
|
||||
|
||||
var packet = Instance.CreateBasePacket();
|
||||
packet.WriteWhoAmI(divineSwine);
|
||||
packet.Write(offeringState.Value);
|
||||
packet.Send(toClient, ignoreClient);
|
||||
}
|
||||
|
||||
public override void HandlePacket(BinaryReader packet, int sender)
|
||||
{
|
||||
var divineSwine = packet.ReadModNPC<DivineSwine>();
|
||||
var offeringState = packet.ReadBoolean();
|
||||
|
||||
if (divineSwine is null)
|
||||
return;
|
||||
|
||||
if (Main.dedServ)
|
||||
divineSwine.AcceptOffering(offeringState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using CalamityMod.Items.Tools;
|
||||
using MonoMod.Core.Platforms;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Packets
|
||||
{
|
||||
internal class DisgustingMeatPlayerSyncPacket : CalamityPacket
|
||||
{
|
||||
public static DisgustingMeatPlayerSyncPacket Instance { get; private set; }
|
||||
|
||||
public static void Send(DisgustingMeatPlayer playerToSync, int toClient = -1, int ignoreClient = -1)
|
||||
{
|
||||
if (playerToSync is null)
|
||||
return;
|
||||
|
||||
var packet = Instance.CreateBasePacket();
|
||||
packet.WriteWhoAmI(playerToSync);
|
||||
packet.Write(playerToSync.DoingVomitAnimation);
|
||||
packet.Write(playerToSync.EjectMiscUpgrades);
|
||||
packet.Write(playerToSync.VomitTime);
|
||||
packet.Write((int)playerToSync.Player.eyeHelper.CurrentEyeFrame);
|
||||
packet.Send(toClient, ignoreClient);
|
||||
}
|
||||
|
||||
public override void HandlePacket(BinaryReader packet, int sender)
|
||||
{
|
||||
var player = packet.ReadPlayer();
|
||||
var doingVomitAnimation = packet.ReadBoolean();
|
||||
var ejectMiscUpgrades = packet.ReadBoolean();
|
||||
var vomitTime = packet.ReadInt32();
|
||||
var currentEyeFrame = packet.ReadInt32();
|
||||
|
||||
if (player is null)
|
||||
return;
|
||||
|
||||
var modPlayer = player.GetModPlayer<DisgustingMeatPlayer>();
|
||||
modPlayer.DoingVomitAnimation = doingVomitAnimation;
|
||||
modPlayer.EjectMiscUpgrades = ejectMiscUpgrades;
|
||||
modPlayer.VomitTime = vomitTime;
|
||||
player.eyeHelper.CurrentEyeFrame = (PlayerEyeHelper.EyeFrame)currentEyeFrame;
|
||||
|
||||
if (Main.dedServ)
|
||||
Send(modPlayer, ignoreClient: sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Packets.Worlds
|
||||
{
|
||||
internal class DisableNPCUpgradesSyncPacket : CalamityPacket
|
||||
{
|
||||
public static DisableNPCUpgradesSyncPacket Instance { get; private set; }
|
||||
|
||||
public static void Send(int upgradeType = -1, int toClient = -1, int ignoreClient = -1)
|
||||
{
|
||||
if (upgradeType < 0 || upgradeType > 2)
|
||||
return;
|
||||
|
||||
var packet = Instance.CreateBasePacket();
|
||||
packet.Write(upgradeType);
|
||||
packet.Send(toClient, ignoreClient);
|
||||
}
|
||||
|
||||
public override void HandlePacket(BinaryReader packet, int sender)
|
||||
{
|
||||
var upgradeType = packet.ReadInt32();
|
||||
|
||||
if (upgradeType == 0)
|
||||
NPC.peddlersSatchelWasUsed = false;
|
||||
else if (upgradeType == 1)
|
||||
NPC.combatBookWasUsed = false;
|
||||
else if (upgradeType == 2)
|
||||
NPC.combatBookVolumeTwoWasUsed = false;
|
||||
|
||||
// Apply change to everyone
|
||||
if (Main.netMode == NetmodeID.Server)
|
||||
{
|
||||
NetMessage.SendData(MessageID.WorldData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class FeatherParticle : Particle
|
||||
{
|
||||
public float RotationSpeed;
|
||||
|
||||
public float Opacity;
|
||||
|
||||
public float SwayAngleStrength;
|
||||
|
||||
public bool AffectedByWind;
|
||||
|
||||
public bool NoGravity;
|
||||
|
||||
public bool ShouldCollideWithTiles;
|
||||
|
||||
public bool DieWithTileCollision;
|
||||
|
||||
private int DeathTimer;
|
||||
|
||||
public static float WaveAngle => MathHelper.ToRadians(25f);
|
||||
|
||||
public float WaveFrameState { get; private set; }
|
||||
|
||||
public int SwayInterval { get; private set; }
|
||||
|
||||
public bool CurrentlyCollidingWithTiles { get; private set; }
|
||||
|
||||
public FeatherParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, float? rotationSpeed = null, float swayAngleStrength = 1f, bool affectedByWind = false, bool noGravity = false, bool shouldCollideWithTiles = false, bool dieWithTileCollision = false)
|
||||
{
|
||||
Position = position;
|
||||
Velocity = velocity;
|
||||
Color = color;
|
||||
Scale = scale;
|
||||
Lifetime = lifetime;
|
||||
RotationSpeed = rotationSpeed ?? Main.rand.NextFloat(120f, 150f) * Main.rand.NextBool().ToDirectionInt();
|
||||
SwayAngleStrength = swayAngleStrength;
|
||||
AffectedByWind = affectedByWind;
|
||||
NoGravity = noGravity;
|
||||
ShouldCollideWithTiles = shouldCollideWithTiles;
|
||||
DieWithTileCollision = dieWithTileCollision;
|
||||
|
||||
Variant = Main.rand.Next(3);
|
||||
Opacity = 0f;
|
||||
SwayInterval = Main.rand.Next(75, 150);
|
||||
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
}
|
||||
|
||||
public override string Texture => "CalamityMod/Particles/FeatherParticle";
|
||||
|
||||
public override bool SetLifetime => false;
|
||||
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public override int FrameVariants => 3;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!CurrentlyCollidingWithTiles)
|
||||
Rotation += (MathHelper.Pi / RotationSpeed) + (Velocity.X * 0.01f);
|
||||
|
||||
// Original math from AstralGodRay.cs.
|
||||
int waveSign = (WaveFrameState > 0f).ToDirectionInt();
|
||||
if (Math.Abs(WaveFrameState) < 1f)
|
||||
{
|
||||
int dirToUse = WaveFrameState == 0 ? (Main.rand.NextBool() ? -1 : 1) : waveSign;
|
||||
waveSign = -dirToUse;
|
||||
WaveFrameState = dirToUse * SwayInterval * 0.5f;
|
||||
}
|
||||
|
||||
// Switch directions whenever necessary.
|
||||
else if (Math.Abs(WaveFrameState) > SwayInterval)
|
||||
WaveFrameState = -waveSign;
|
||||
else
|
||||
WaveFrameState += waveSign;
|
||||
|
||||
// Rotate velocity towards the wave angle to appear as if its swaying side to side.
|
||||
float swayAngle = WaveAngle / (SwayInterval * 0.5f);
|
||||
Velocity = Velocity.RotatedBy(waveSign * swayAngle * SwayAngleStrength);
|
||||
|
||||
Velocity.X *= 0.98f;
|
||||
if (Velocity.Y < 0.6f && !NoGravity)
|
||||
Velocity.Y += 0.005f;
|
||||
else
|
||||
Velocity.Y *= 0.98f;
|
||||
|
||||
// Move with wind speed.
|
||||
if (AffectedByWind)
|
||||
Velocity.X += Main.windSpeedCurrent / 3f;
|
||||
|
||||
// Tile collision.
|
||||
if (ShouldCollideWithTiles)
|
||||
{
|
||||
CurrentlyCollidingWithTiles = false;
|
||||
|
||||
Vector2 hitboxDimensions = new(12f, 12f);
|
||||
if (Collision.SolidCollision(Position, (int)hitboxDimensions.X, (int)hitboxDimensions.Y))
|
||||
{
|
||||
Velocity = Collision.TileCollision(Position, Velocity, (int)hitboxDimensions.X, (int)hitboxDimensions.Y);
|
||||
CurrentlyCollidingWithTiles = true;
|
||||
}
|
||||
|
||||
if (Collision.WetCollision(Position, (int)hitboxDimensions.X, (int)hitboxDimensions.Y))
|
||||
{
|
||||
Velocity.Y *= 0.8f;
|
||||
CurrentlyCollidingWithTiles = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (DieWithTileCollision && ShouldCollideWithTiles)
|
||||
{
|
||||
if (CurrentlyCollidingWithTiles)
|
||||
{
|
||||
Opacity = MathHelper.Lerp(1f, 0f, (float)(DeathTimer / 45));
|
||||
if (DeathTimer >= 45)
|
||||
{
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
DeathTimer++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Opacity = MathHelper.Clamp(Opacity + 0.075f, 0f, 1f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int fadeInTime = 45 - (int)(Lifetime * 0.2f);
|
||||
if (fadeInTime < 20)
|
||||
fadeInTime = 20;
|
||||
int fadeOutTime = (int)(Lifetime * 0.8f);
|
||||
Opacity = Utils.GetLerpValue(0, fadeInTime, Time, true) * Utils.GetLerpValue(Lifetime, fadeOutTime, Time);
|
||||
|
||||
if (Time >= Lifetime)
|
||||
{
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D texture = GeneralParticleHandler.GetTexture(Type);
|
||||
Color lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint()));
|
||||
Rectangle frame = texture.Frame(1, FrameVariants, 0, Variant);
|
||||
spriteBatch.Draw(texture, Position - Main.screenPosition, frame, lightColor * Opacity, Rotation, frame.Size() * 0.5f, Scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 329 B |
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using CalamityMod.Systems.Graphic.TempParticleSystem;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class FlyParticle : Particle
|
||||
{
|
||||
public float Opacity;
|
||||
|
||||
private bool WasSpawnedWithAnchor;
|
||||
|
||||
public Entity AnchorEntity { get; private set; }
|
||||
|
||||
public Vector2 StoredPosition { get; private set; }
|
||||
|
||||
public float HeightToNeverGoBelow { get; private set; }
|
||||
|
||||
public FlyParticle(Vector2 position, float scale, int lifetime, Entity anchorEntity = null)
|
||||
{
|
||||
Position = position;
|
||||
Scale = scale;
|
||||
Lifetime = lifetime;
|
||||
AnchorEntity = anchorEntity;
|
||||
|
||||
if (anchorEntity == null)
|
||||
{
|
||||
StoredPosition = position;
|
||||
HeightToNeverGoBelow = position.Y + 8f;
|
||||
WasSpawnedWithAnchor = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WasSpawnedWithAnchor = true;
|
||||
}
|
||||
|
||||
Variant = Main.rand.Next(2);
|
||||
Color = Color.White;
|
||||
AffectedByLight = true;
|
||||
}
|
||||
|
||||
public override string Texture => "Terraria/Images/Extra_262";
|
||||
|
||||
public override bool SetLifetime => true;
|
||||
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public override int FrameVariants => 2;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (WasSpawnedWithAnchor)
|
||||
{
|
||||
StoredPosition = AnchorEntity.Top;
|
||||
HeightToNeverGoBelow = AnchorEntity.Top.Y + 8f;
|
||||
if (!AnchorEntity.active || AnchorEntity == null)
|
||||
{
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Velocity += new Vector2(MathF.Sign(StoredPosition.X - Position.X) * 0.02f, MathF.Sign(StoredPosition.Y - Position.Y) * 0.02f);
|
||||
if (Time % 30 == 0 && Main.rand.NextBool(2))
|
||||
{
|
||||
Velocity = Main.rand.NextVector2Circular(1f, 1f);
|
||||
if (Main.rand.NextBool(2))
|
||||
Velocity /= 2;
|
||||
}
|
||||
|
||||
if (Position.Y > HeightToNeverGoBelow)
|
||||
{
|
||||
Position.Y = HeightToNeverGoBelow;
|
||||
if (Velocity.Y > 0f)
|
||||
Velocity *= -1f;
|
||||
}
|
||||
|
||||
Variant = Time % 6 / 3;
|
||||
int fadeInTime = (int)(Lifetime * 0.13f);
|
||||
int fadeOutTime = (int)(Lifetime * 0.93f);
|
||||
Opacity = Utils.GetLerpValue(0f, fadeInTime, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - fadeOutTime, Time, true);
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Color lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint()));
|
||||
Rectangle frame = GeneralParticleHandler.GetTexture(Type).Frame(1, FrameVariants, 0, Variant);
|
||||
SpriteEffects effects = (Velocity.X > 0f) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Main.spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, frame, lightColor * Opacity, Rotation, frame.Size() * 0.5f, Scale, effects, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class GraveyardMistParticle : Particle
|
||||
{
|
||||
public float StretchFactor;
|
||||
|
||||
public float BaseOpacity;
|
||||
|
||||
public int Direction;
|
||||
|
||||
public float Opacity { get; private set; }
|
||||
|
||||
public int TextureIndex { get; private set; }
|
||||
|
||||
public GraveyardMistParticle(Vector2 spawnPosition, Vector2 velocity, Color color, float scale, float baseOpacity, int lifetime, int textureIndex)
|
||||
{
|
||||
Position = spawnPosition;
|
||||
Velocity = velocity;
|
||||
Color = color;
|
||||
Scale = scale;
|
||||
BaseOpacity = baseOpacity;
|
||||
Lifetime = lifetime;
|
||||
TextureIndex = textureIndex;
|
||||
StretchFactor = Main.rand.NextFloat(1f, 2f);
|
||||
}
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override bool SetLifetime => true;
|
||||
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
float halfLifetime = Lifetime / 2;
|
||||
Opacity = BaseOpacity * MathHelper.Lerp(0f, 1f, MathF.Sin(MathHelper.TwoPi * (Time / halfLifetime)));
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D mistTexture = Main.Assets.Request<Texture2D>("Images/Gore_" + TextureIndex).Value;
|
||||
SpriteEffects spriteEffects = (Velocity.X > 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Vector2 scale = new Vector2(StretchFactor, 1f) * Scale;
|
||||
spriteBatch.Draw(mistTexture, Position - Main.screenPosition, mistTexture.Frame(), Color * Opacity * 0.375f, Rotation, mistTexture.Frame().Size() * 0.5f, scale, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class QuickSparkleParticle : Particle
|
||||
{
|
||||
public float StoredScale;
|
||||
|
||||
public float LightStrength;
|
||||
|
||||
public bool EmitLight;
|
||||
|
||||
public Vector2 StretchFactor;
|
||||
|
||||
public QuickSparkleParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, Vector2? stretchFactor = null,bool emitLight = false, float lightStrength = 1.45f)
|
||||
{
|
||||
Position = position;
|
||||
Velocity = velocity;
|
||||
Color = color;
|
||||
StoredScale = scale;
|
||||
Lifetime = lifetime;
|
||||
StretchFactor = stretchFactor ?? new(0.75f, 1.75f);
|
||||
EmitLight = emitLight;
|
||||
LightStrength = lightStrength;
|
||||
}
|
||||
|
||||
public override bool SetLifetime => true;
|
||||
|
||||
public override bool UseAdditiveBlend => true;
|
||||
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public override string Texture => "CalamityMod/ExtraTextures/ShineFlare";
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Velocity *= 0.92f;
|
||||
Scale = MathHelper.Lerp(0f, StoredScale, MathF.Sin(LifetimeCompletion * MathHelper.Pi));
|
||||
if (EmitLight)
|
||||
Lighting.AddLight(Position, Color.ToVector3() * Scale * LightStrength);
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, null, Color.White, Rotation, GeneralParticleHandler.GetTexture(Type).Size() * 0.5f, Scale * StretchFactor * 0.1f, 0, 0f);
|
||||
spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, null, Color, Rotation, GeneralParticleHandler.GetTexture(Type).Size() * 0.5f, Scale * StretchFactor * 0.2f, 0, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,9 @@ namespace CalamityMod.Particles
|
||||
private Color ColorStart;
|
||||
private Color ColorFade;
|
||||
private float Spin;
|
||||
private bool FadeIn;
|
||||
|
||||
public TimedSmokeParticle(Vector2 position, Vector2 velocity, Color colorStart, Color colorFade, float scale, float opacity, int timeleft, float rotationSpeed = 0f)
|
||||
public TimedSmokeParticle(Vector2 position, Vector2 velocity, Color colorStart, Color colorFade, float scale, float opacity, int timeleft, float rotationSpeed = 0f, bool fadeIn = false)
|
||||
{
|
||||
Position = position;
|
||||
Velocity = velocity;
|
||||
@@ -27,6 +28,7 @@ namespace CalamityMod.Particles
|
||||
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
Spin = rotationSpeed;
|
||||
Lifetime = timeleft;
|
||||
FadeIn = fadeIn;
|
||||
|
||||
Variant = Main.rand.Next(3);
|
||||
}
|
||||
@@ -48,6 +50,9 @@ namespace CalamityMod.Particles
|
||||
Velocity -= Vector2.UnitY * 0.08f;
|
||||
|
||||
float opacityMult = 1 - (float)Math.Pow(LifetimeCompletion, 2);
|
||||
if (FadeIn)
|
||||
opacityMult = 1f * MathF.Sin(LifetimeCompletion * MathHelper.Pi);
|
||||
|
||||
Color = Color.Lerp(ColorStart, ColorFade, opacityMult) * (Opacity * opacityMult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using CalamityMod.NPCs.NormalNPCs.HorribleHog;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogChargeHitbox : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public ref float HogIndex => ref Projectile.ai[0];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 40;
|
||||
Projectile.height = 28;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.hostile = true;
|
||||
Projectile.hide = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 15;
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override bool? CanHitNPC(NPC target) => target.whoAmI != (int)HogIndex;
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.FinalDamage *= 5f;
|
||||
|
||||
public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) => modifiers.Knockback *= 0f;
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
||||
{
|
||||
target.velocity.X += 8f * info.HitDirection;
|
||||
target.velocity.Y -= 3f;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (!Main.npc.IndexInRange((int)HogIndex) || !Main.npc[(int)HogIndex].active || Main.npc[(int)HogIndex].type != ModContent.NPCType<HorribleHog>())
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile.Center = Main.npc[(int)HogIndex].Center;
|
||||
Projectile.velocity = Main.npc[(int)HogIndex].velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogRubble : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public int FrameX;
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "Terraria/Images/Projectile_" + ProjectileID.DeerclopsRangedProjectile;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projFrames[Type] = 4;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 8;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 24;
|
||||
Projectile.height = 24;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.scale = 0f;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Projectile.spriteDirection = Main.rand.NextBool().ToDirectionInt();
|
||||
FrameX = Main.rand.Next(3);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.25f);
|
||||
Projectile.ExpandHitboxBy(Projectile.scale);
|
||||
|
||||
Projectile.rotation += Projectile.velocity.X * 0.035f;
|
||||
if (Projectile.velocity.Y < 8f)
|
||||
Projectile.velocity.Y += 0.165f;
|
||||
|
||||
if (Projectile.timeLeft <= 250)
|
||||
Projectile.velocity.X *= 0.92f;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
int dustCloudAmt = Main.rand.Next(3, 6);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(8f, 8f);
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(3f, 3f);
|
||||
Color color = Color.Lerp(Color.SaddleBrown, Color.SandyBrown, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
SmallSmokeParticle dustCloud = new(spawnPosition, velocity, color, color, Main.rand.NextFloat(1.6f, 1.8f), Main.rand.Next(75, 100), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true);
|
||||
}
|
||||
|
||||
int dustAmt = Main.rand.Next(6, 9);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(8f, 8f);
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(3f, 3f);
|
||||
Dust.NewDust(spawnPosition, 0, 0, DustID.Dirt, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(0.8f, 1.2f));
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
Rectangle frame = texture.Frame(3, Main.projFrames[Type], FrameX, Projectile.frame);
|
||||
Vector2 origin = frame.Size() * 0.5f;
|
||||
SpriteEffects spriteEffects = Projectile.spriteDirection < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Main.spriteBatch.Draw(texture, drawPos, frame, Projectile.GetAlpha(lightColor) * 0.3f * interpolant, Projectile.rotation, origin, Projectile.scale * interpolant, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Potions.Alcohol;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogShockwave : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public ref float Timer => ref Projectile.ai[0];
|
||||
|
||||
public ref float HeightMultiplier => ref Projectile.ai[1];
|
||||
|
||||
public ref float HogIndex => ref Projectile.ai[2];
|
||||
|
||||
public float CurrentHeight => 32f * MathHelper.Lerp(1f, HeightMultiplier, Timer / 9f);
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 32;
|
||||
Projectile.height = 32;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.alpha = 255;
|
||||
Projectile.hostile = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 15;
|
||||
}
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
float _ = 0f;
|
||||
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center - Vector2.UnitY * CurrentHeight * Projectile.scale, Projectile.width * Projectile.scale, ref _);
|
||||
}
|
||||
|
||||
public override bool? CanHitNPC(NPC target) => target.whoAmI != (int)HogIndex;
|
||||
|
||||
// Player knockback is constant and applies whenever any damage is dealt, regardless of if a projectile spawned deals zero knockback or not.
|
||||
// Therefore, the knockback stat modifier here needs to be multiplied by zero in order for any custom knockback effect to take place.
|
||||
// This isn't the same for NPCs, so they don't need it so long as the projectile is spawned with zero knockback.
|
||||
public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) => modifiers.Knockback *= 0f;
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.FinalDamage *= 5f;
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.velocity.Y -= MathHelper.Clamp(8f + (CurrentHeight * 0.1f), 8f, 16f);
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.velocity.Y -= MathHelper.Clamp(8f + (CurrentHeight * 0.1f) * target.knockBackResist, 8f, 16f);
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Timer >= 9f)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Timer == 1f)
|
||||
SoundEngine.PlaySound(SoundID.Item70, Projectile.Center);
|
||||
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
|
||||
Point topLeft = Projectile.TopLeft.ToTileCoordinates();
|
||||
Point bottomRight = Projectile.BottomRight.ToTileCoordinates();
|
||||
int halfWidth = Projectile.width / 2;
|
||||
int dustSpawnInterval = (int)Projectile.ai[0] / 3;
|
||||
|
||||
Timer++;
|
||||
if (Timer % 3 != 0f)
|
||||
return;
|
||||
|
||||
float heightMulti = MathHelper.Lerp(1f, HeightMultiplier, Timer / 9f);
|
||||
int dustCloudAmt = Main.rand.Next(4, 7);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 dustCloudPosition = Projectile.Bottom + Main.rand.NextVector2Circular(24f, 0f);
|
||||
Vector2 dustVelocity = Vector2.UnitY * -1.3f * heightMulti * i * Main.rand.NextFloat(0.8f, 1.2f);
|
||||
Color dustCloudColor = Color.Lerp(Color.SandyBrown, Color.SandyBrown, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
TimedSmokeParticle dustCloud = new(dustCloudPosition, dustVelocity, dustCloudColor, dustCloudColor, Main.rand.NextFloat(0.7f, 0.8f), Main.rand.NextFloat(0.72f, 0.84f), Main.rand.Next(30, 45), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true, Enums.GeneralDrawLayer.BeforeSolidTiles);
|
||||
}
|
||||
|
||||
for (int i = topLeft.X; i <= bottomRight.X; i++)
|
||||
{
|
||||
for (int j = topLeft.Y; j <= bottomRight.Y; j++)
|
||||
{
|
||||
if (Vector2.Distance(Projectile.Center, new Vector2(i * 16f, j * 16f)) > halfWidth)
|
||||
continue;
|
||||
|
||||
Tile tile = Framing.GetTileSafely(i, j);
|
||||
if (!tile.HasTile || !Main.tileSolid[tile.TileType] || Main.tileSolidTop[tile.TileType] || Main.tileFrameImportant[tile.TileType])
|
||||
continue;
|
||||
|
||||
Tile tileAbove = Framing.GetTileSafely(i, j - 1);
|
||||
if (tileAbove.HasTile && Main.tileSolid[tileAbove.TileType] && !Main.tileSolidTop[tileAbove.TileType])
|
||||
continue;
|
||||
|
||||
int dustCountFromTile = WorldGen.KillTile_GetTileDustAmount(fail: true, tile, i, j);
|
||||
for (int k = 0; k < dustCountFromTile; k++)
|
||||
{
|
||||
Dust dust = Main.dust[WorldGen.KillTile_MakeTileDust(i, j, tile)];
|
||||
dust.velocity.Y -= 3f + dustSpawnInterval * 1.5f * HeightMultiplier;
|
||||
dust.velocity.Y *= Main.rand.NextFloat();
|
||||
dust.velocity.Y *= 0.75f;
|
||||
dust.scale += dustSpawnInterval * 0.03f;
|
||||
}
|
||||
|
||||
if (dustSpawnInterval >= 2)
|
||||
{
|
||||
for (int m = 0; m < dustCountFromTile - 1; m++)
|
||||
{
|
||||
Dust dust = Main.dust[WorldGen.KillTile_MakeTileDust(i, j, tile)];
|
||||
dust.velocity.Y -= 1f + dustSpawnInterval * HeightMultiplier;
|
||||
dust.velocity.Y *= Main.rand.NextFloat();
|
||||
dust.velocity.Y *= 0.75f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogShockwaveSpawner : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public int OwnerIndex;
|
||||
|
||||
public int ShockwaveCounter;
|
||||
|
||||
public int Timer;
|
||||
|
||||
public ref float SpawnInterval => ref Projectile.ai[0];
|
||||
|
||||
public ref float MaxShockwaves => ref Projectile.ai[1];
|
||||
|
||||
public ref float Direction => ref Projectile.ai[2];
|
||||
|
||||
public ref float MinHeightMultiplier => ref Projectile.localAI[0];
|
||||
|
||||
public ref float MaxHeightMultiplier => ref Projectile.localAI[1];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 4;
|
||||
Projectile.height = 4;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.hide = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(OwnerIndex);
|
||||
writer.Write(ShockwaveCounter);
|
||||
writer.Write(Timer);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
OwnerIndex = reader.ReadInt32();
|
||||
ShockwaveCounter = reader.ReadInt32();
|
||||
Timer = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override bool? CanHitNPC(NPC target) => false;
|
||||
|
||||
public override bool CanHitPlayer(Player target) => false;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (ShockwaveCounter >= MaxShockwaves)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
Direction = MathHelper.Clamp(Direction, -1, 1);
|
||||
if (Direction == 0)
|
||||
{
|
||||
Direction = Main.rand.NextBool().ToDirectionInt();
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
if (Timer % SpawnInterval == 0f)
|
||||
{
|
||||
Vector2 shockwaveSpawnPosition = new();
|
||||
|
||||
int spawnAttempts = 20;
|
||||
int shockwaveSpawnDistance = 32 * (int)ShockwaveCounter * (int)Direction;
|
||||
Point bottomInTileCoords = (Projectile.Bottom + Vector2.UnitX * shockwaveSpawnDistance).ToTileCoordinates();
|
||||
for (int i = 0; i < spawnAttempts; i++)
|
||||
{
|
||||
int posX = bottomInTileCoords.X;
|
||||
int posY = bottomInTileCoords.Y - i;
|
||||
Tile tileAbove = CalamityUtils.ParanoidTileRetrieval(posX, posY - 1);
|
||||
if (WorldGen.ActiveAndWalkableTile(posX, posY) && !tileAbove.HasTile)
|
||||
{
|
||||
shockwaveSpawnPosition = new Point(posX, posY).ToWorldCoordinates();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spawnAttempts; i++)
|
||||
{
|
||||
int posX = bottomInTileCoords.X;
|
||||
int posY = bottomInTileCoords.Y + i;
|
||||
if (WorldGen.ActiveAndWalkableTile(posX, posY))
|
||||
{
|
||||
shockwaveSpawnPosition = new Point(posX, posY).ToWorldCoordinates();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
float shockwaveHeight = MathHelper.Lerp(MinHeightMultiplier, MaxHeightMultiplier, ShockwaveCounter / MaxShockwaves);
|
||||
Projectile.NewProjectile(Projectile.GetItemSource_FromThis(), shockwaveSpawnPosition, Vector2.Zero, ModContent.ProjectileType<HorribleHogShockwave>(), Projectile.damage, Projectile.knockBack, ai1: shockwaveHeight, ai2: OwnerIndex);
|
||||
}
|
||||
|
||||
ShockwaveCounter++;
|
||||
}
|
||||
|
||||
Timer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogVomitBomb : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public bool HasExplodedYet
|
||||
{
|
||||
get => Projectile.ai[0] == 1f;
|
||||
set => Projectile.ai[0] = value.ToInt();
|
||||
}
|
||||
|
||||
public ref float HogIndex => ref Projectile.ai[1];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "Terraria/Images/Projectile_" + ProjectileID.Bomb;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 12;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 22;
|
||||
Projectile.height = 22;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.scale = 0f;
|
||||
Projectile.hostile = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 15;
|
||||
}
|
||||
|
||||
public override bool? CanHitNPC(NPC target) => target.whoAmI != (int)HogIndex;
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.FinalDamage *= 5f;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (!HasExplodedYet && Projectile.timeLeft <= 1)
|
||||
{
|
||||
Explode();
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.25f);
|
||||
Projectile.ExpandHitboxBy(Projectile.scale);
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
|
||||
Projectile.rotation += Projectile.velocity.X * 0.035f;
|
||||
if (Projectile.velocity.Y < 8f)
|
||||
Projectile.velocity.Y += 0.125f;
|
||||
|
||||
Vector2 dustPosition = Projectile.Center + new Vector2(4f, -14f).RotatedBy(Projectile.rotation);
|
||||
Dust.NewDustPerfect(dustPosition, DustID.Torch, Vector2.UnitY * -2f, Scale: 0.8f);
|
||||
|
||||
int vomitAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < vomitAmt; i++)
|
||||
{
|
||||
Vector2 velocity = Projectile.oldVelocity * Main.rand.NextFloat(-0.8f, -0.6f);
|
||||
int dustType = Utils.SelectRandom(Main.rand, DustID.ToxicBubble, DustID.GreenBlood, DustID.Blood);
|
||||
int dust = Dust.NewDust(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width, Projectile.height), 1, 1, dustType, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1f, 1.4f));
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
Vector2 velocity = Projectile.oldVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(-1.8f, -0.6f) * Projectile.direction;
|
||||
Color color = Color.Lerp(Color.DarkOliveGreen, Color.Green, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle vomit = new(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width, Projectile.height), velocity, color, color, Main.rand.NextFloat(0.4f, 0.6f), Main.rand.NextFloat(0.8f, 1f), Main.rand.Next(25, 35), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(vomit, false, Enums.GeneralDrawLayer.BeforeProjectiles);
|
||||
}
|
||||
}
|
||||
|
||||
private void Explode()
|
||||
{
|
||||
Projectile.knockBack = 8f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.hostile = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 6;
|
||||
Projectile.velocity *= 0f;
|
||||
Projectile.ExpandHitboxBy(80, 80);
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(12, 17);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center;
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(8f, 8f);
|
||||
Color color = Color.Lerp(Color.OrangeRed, Color.Orange, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle explosionCloud = new(spawnPosition, velocity, new Color(10, 10, 10), color, Main.rand.NextFloat(1.2f, 1.4f), 1f, Main.rand.Next(20, 30), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(explosionCloud, true);
|
||||
}
|
||||
|
||||
int sparkAmt = Main.rand.Next(7, 13);
|
||||
for (int i = 0; i < sparkAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center;
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(8f, 8f);
|
||||
Color color = Color.Lerp(Color.Yellow, Color.Orange, Main.rand.NextFloat());
|
||||
|
||||
SparkParticle explosionSpark = new(spawnPosition, velocity, false, Main.rand.Next(20, 30), Main.rand.NextFloat(1f, 1.2f), color);
|
||||
GeneralParticleHandler.SpawnParticle(explosionSpark, true);
|
||||
}
|
||||
|
||||
int dustAmt = Main.rand.Next(6, 9);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(8f, 8f);
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(8f, 8f);
|
||||
Dust.NewDust(spawnPosition, 0, 0, DustID.Torch, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1.2f, 1.6f));
|
||||
}
|
||||
|
||||
CalamityUtils.AddScreenshakeAt(Projectile.Center, 3f);
|
||||
SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode, Projectile.Center);
|
||||
Projectile.ai[0] = 1f;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override bool PreKill(int timeLeft)
|
||||
{
|
||||
if (!HasExplodedYet)
|
||||
{
|
||||
Explode();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Explode();
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
|
||||
{
|
||||
int targetIndex = Player.FindClosest(Projectile.Center, 1, 1);
|
||||
Player target = Main.player[targetIndex];
|
||||
if (Projectile.Center.Y > target.Center.Y - 48f)
|
||||
fallThrough = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
Vector2 origin = texture.Size() * 0.5f;
|
||||
SpriteEffects spriteEffects = Projectile.spriteDirection < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
float timeLeftInterpolant = Utils.Remap(Projectile.timeLeft, 75, 0, 1f, 0f, true);
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
float trailLengthInterpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Color afterimageColor = Projectile.GetAlpha(Color.Orange) * 0.5f * trailLengthInterpolant * (1f - timeLeftInterpolant);
|
||||
|
||||
Main.spriteBatch.Draw(texture, afterimageDrawPosition, null, afterimageColor, Projectile.rotation, origin, Projectile.scale * trailLengthInterpolant, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
using (Main.spriteBatch.Scope())
|
||||
{
|
||||
Effect tintShader = CalamityShaders.BasicTintShader.Value;
|
||||
tintShader.Parameters["uColor"].SetValue(Color.White.ToVector3());
|
||||
tintShader.Parameters["uOpacity"].SetValue(1f - timeLeftInterpolant);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, tintShader, Main.GameViewMatrix.TransformationMatrix);
|
||||
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, spriteEffects, 0f);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogVomitChunk : ModProjectile, ILocalizedModType
|
||||
{
|
||||
private static Asset<Texture2D>[] VomitChunkTextures;
|
||||
|
||||
private string[] VomitChunkTexturePaths = new string[]
|
||||
{
|
||||
"Terraria/Images/Gore_3",
|
||||
"Terraria/Images/Gore_154",
|
||||
"Terraria/Images/Gore_241",
|
||||
"Terraria/Images/Gore_243",
|
||||
"Terraria/Images/Gore_246",
|
||||
"Terraria/Images/Gore_262",
|
||||
"Terraria/Images/Gore_722",
|
||||
"Terraria/Images/Gore_1214"
|
||||
};
|
||||
|
||||
public ref float TextureVariant => ref Projectile.ai[0];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
VomitChunkTextures = new Asset<Texture2D>[VomitChunkTexturePaths.Length];
|
||||
for (int i = 0; i < VomitChunkTexturePaths.Length; i++)
|
||||
VomitChunkTextures[i] = ModContent.Request<Texture2D>(VomitChunkTexturePaths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 8;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 16;
|
||||
Projectile.height = 16;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.scale = 0f;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
TextureVariant = Main.rand.Next(VomitChunkTexturePaths.Length);
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.25f);
|
||||
Projectile.ExpandHitboxBy(Projectile.scale);
|
||||
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
Projectile.rotation += Projectile.velocity.X * 0.035f;
|
||||
if (Projectile.velocity.Y < 8f)
|
||||
Projectile.velocity.Y += 0.125f;
|
||||
|
||||
int vomitAmt = Main.rand.Next(1, 3);
|
||||
for (int i = 0; i < vomitAmt; i++)
|
||||
{
|
||||
Vector2 velocity = Projectile.oldVelocity * Main.rand.NextFloat(-0.8f, -0.6f);
|
||||
int dustType = Utils.SelectRandom(Main.rand, DustID.ToxicBubble, DustID.GreenBlood, DustID.Blood);
|
||||
int dust = Dust.NewDust(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width, Projectile.height), 1, 1, dustType, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1f, 1.4f));
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
Vector2 velocity = Projectile.oldVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(-1.8f, -0.6f) * Projectile.direction;
|
||||
Color color = Color.Lerp(Color.DarkOliveGreen, Color.Green, Main.rand.NextFloat());
|
||||
float rotationSpeed = Main.rand.NextFloat(0.01f, 0.03f) * Main.rand.NextBool().ToDirectionInt();
|
||||
|
||||
TimedSmokeParticle vomit = new(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width, Projectile.height), velocity, color, color, Main.rand.NextFloat(0.4f, 0.6f), Main.rand.NextFloat(0.8f, 1f), Main.rand.Next(25, 35), rotationSpeed);
|
||||
GeneralParticleHandler.SpawnParticle(vomit, false, Enums.GeneralDrawLayer.BeforeProjectiles);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
|
||||
{
|
||||
int targetIndex = Player.FindClosest(Projectile.Center, 1, 1);
|
||||
Player target = Main.player[targetIndex];
|
||||
if (Projectile.Center.Y > target.Center.Y - 48f)
|
||||
fallThrough = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
int dustAmt = Main.rand.Next(15, 21);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(8f, 8f);
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(3f, 3f);
|
||||
int dustType = Utils.SelectRandom(Main.rand, DustID.ToxicBubble, DustID.GreenBlood, DustID.Blood);
|
||||
Dust.NewDust(spawnPosition, 0, 0, dustType, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1.2f, 1.8f));
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath21, Projectile.Center);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = VomitChunkTextures[(int)TextureVariant].Value;
|
||||
Vector2 origin = texture.Size() * 0.5f;
|
||||
SpriteEffects spriteEffects = Projectile.spriteDirection < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Color color = Color.GreenYellow * interpolant;
|
||||
|
||||
Main.spriteBatch.Draw(texture, drawPos, null, Projectile.GetAlpha(color) * 0.6f, Projectile.rotation, origin, Projectile.scale * interpolant * 1.25f, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using CalamityMod.Graphics.Metaballs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogVomitEye : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public static int PlayerSearchArea => 128;
|
||||
|
||||
public ref float LockOnTime => ref Projectile.ai[0];
|
||||
|
||||
public ref float Timer => ref Projectile.ai[1];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "Terraria/Images/NPC_" + NPCID.DemonEye;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projFrames[Type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 6;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 16;
|
||||
Projectile.height = 16;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 480;
|
||||
Projectile.scale = 0f;
|
||||
Projectile.hostile = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target) => Projectile.scale > 0.15f;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.scale = MathHelper.Lerp(Projectile.scale, 0.75f, 0.125f);
|
||||
Projectile.ExpandHitboxBy(Projectile.scale);
|
||||
|
||||
int targetIndex = Player.FindClosest(Projectile.Center, 1, 1);
|
||||
if (Main.player[targetIndex].dead || !Main.player.IndexInRange(targetIndex))
|
||||
{
|
||||
Projectile.velocity *= 1.12f;
|
||||
Projectile.tileCollide = true;
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.velocity.ToRotation() + MathHelper.Pi, 0.15f);
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Main.player[targetIndex];
|
||||
if (Timer >= LockOnTime)
|
||||
{
|
||||
if (Timer <= LockOnTime + 45)
|
||||
{
|
||||
Projectile.velocity *= 0.94f;
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.AngleTo(target.Center) + MathHelper.Pi, 0.15f);
|
||||
}
|
||||
else
|
||||
{
|
||||
float turnResistance = 30f;
|
||||
Vector2 directionToPoint = target.Center - Projectile.Center;
|
||||
directionToPoint *= 30f / directionToPoint.Length();
|
||||
Vector2 idealVelocity = (Projectile.velocity * turnResistance + directionToPoint) / (turnResistance + 1f);
|
||||
Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.35f);
|
||||
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.velocity.ToRotation() + MathHelper.Pi, 0.15f);
|
||||
Projectile.tileCollide = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.Pi;
|
||||
}
|
||||
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter >= 4)
|
||||
{
|
||||
Projectile.frame++;
|
||||
Projectile.frame %= 2;
|
||||
Projectile.frameCounter = 0;
|
||||
}
|
||||
|
||||
Timer++;
|
||||
}
|
||||
|
||||
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
|
||||
{
|
||||
int targetIndex = Player.FindClosest(Projectile.Center, 1, 1);
|
||||
Player target = Main.player[targetIndex];
|
||||
if (Projectile.Center.Y > target.Center.Y - 48f)
|
||||
fallThrough = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.Center);
|
||||
int bloodAmt = Main.rand.Next(14, 19);
|
||||
for (int i = 0; i < bloodAmt; i++)
|
||||
{
|
||||
Vector2 velocity = Main.rand.NextVector2Circular(8f, 8f);
|
||||
Dust.NewDust(Projectile.Center, 1, 1, DustID.Blood, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1.2f, 1.4f));
|
||||
}
|
||||
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
Gore.NewGore(Projectile.Center, Projectile.oldVelocity * -0.8f, 1, 0.75f);
|
||||
Gore.NewGore(Projectile.Center, Projectile.oldVelocity * -0.8f, 2, 0.75f);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Vector2 origin = frame.Size() * 0.5f;
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
float trailLengthInterpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Color afterimgeColor = Color.Red * trailLengthInterpolant;
|
||||
|
||||
Main.spriteBatch.Draw(texture, afterimageDrawPosition, frame, Projectile.GetAlpha(afterimgeColor) * 0.6f, Projectile.oldRot[i], origin, Projectile.scale * trailLengthInterpolant * 1.25f, 0, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, 0, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class HorribleHogZombieSpawner : ModProjectile, ILocalizedModType
|
||||
{
|
||||
private static Asset<Texture2D> ZombieArmTexture;
|
||||
private static Asset<Texture2D> BackglowTexture;
|
||||
|
||||
private static SoundStyle ZombieEmergeSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogZombieEmerge");
|
||||
|
||||
public List<int> Zombies = new()
|
||||
{
|
||||
NPCID.Zombie,
|
||||
NPCID.FemaleZombie,
|
||||
NPCID.BaldZombie,
|
||||
NPCID.PincushionZombie,
|
||||
NPCID.SlimedZombie,
|
||||
NPCID.SwampZombie,
|
||||
NPCID.TwiggyZombie,
|
||||
NPCID.TorchZombie,
|
||||
NPCID.BloodZombie,
|
||||
NPCID.MaggotZombie,
|
||||
ModContent.NPCType<BucketZombie>(),
|
||||
};
|
||||
|
||||
public static CalamityUtils.CurveSegment Rise => new(CalamityUtils.EasingType.ExpOut, 0f, 0f, 1.08f);
|
||||
|
||||
public static CalamityUtils.CurveSegment Fallback => new(CalamityUtils.EasingType.SineOut, 0.08f, Rise.EndingHeight, -0.08f);
|
||||
|
||||
public static CalamityUtils.CurveSegment Linger => new(CalamityUtils.EasingType.Linear, 0.20f, Fallback.EndingHeight, 0f);
|
||||
|
||||
public static CalamityUtils.CurveSegment BounceUp => new(CalamityUtils.EasingType.PolyInOut, 0.82f, Linger.EndingHeight, 0.14f, 4);
|
||||
|
||||
public static CalamityUtils.CurveSegment Descend => new(CalamityUtils.EasingType.PolyOut, 0.92f, BounceUp.EndingHeight, -1.48f, 3);
|
||||
|
||||
public float ZombieArmRiseAnimation => CalamityUtils.PiecewiseAnimation(Timer / MaxTime, Rise, Fallback, Linger, BounceUp, Descend);
|
||||
|
||||
public ref float Timer => ref Projectile.ai[0];
|
||||
|
||||
public ref float MaxTime => ref Projectile.ai[1];
|
||||
|
||||
public new string LocalizationCategory => "Projectiles.Enemy";
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
ZombieArmTexture = ModContent.Request<Texture2D>("Terraria/Images/Item_" + ItemID.ZombieArm);
|
||||
BackglowTexture = ModContent.Request<Texture2D>("Terraria/Images/Extra_60");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 4;
|
||||
Projectile.height = 4;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.hostile = true;
|
||||
Projectile.hide = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Projectile.spriteDirection = Main.rand.NextBool().ToDirectionInt();
|
||||
Projectile.rotation = MathHelper.ToRadians(Main.rand.NextFloat(-8f, 8f));
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Timer >= MaxTime)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
int dustAmt = Main.rand.Next(1, 2);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 dustPosition = Projectile.Bottom + Main.rand.NextVector2Circular(12f, 0f);
|
||||
Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-3f, -2f));
|
||||
int dustType = Main.rand.Next(2);
|
||||
Dust.NewDustPerfect(dustPosition, dustType, dustVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(1, 2);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 dustCloudPosition = Projectile.Bottom + Main.rand.NextVector2Circular(12f, 0f);
|
||||
float dustCloudScale = Main.rand.NextFloat(0.2f, 0.3f);
|
||||
Color dustCloudColor = Color.Lerp(Color.SandyBrown, Color.SaddleBrown, Main.rand.NextFloat());
|
||||
TimedSmokeParticle dustCloud = new(dustCloudPosition, Vector2.Zero, dustCloudColor, dustCloudColor, dustCloudScale, 1f, Main.rand.Next(15, 30));
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true);
|
||||
}
|
||||
|
||||
Timer++;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
// Raincoat Zombies get added when its raining.
|
||||
if (Main.raining)
|
||||
Zombies.Add(NPCID.ZombieRaincoat);
|
||||
|
||||
// Multiple Bucket Zombies and Blood Zombies get added in Revengeance and Death Mode to increase the chances of them spawning.
|
||||
if (CalamityWorld.revenge)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
Zombies.Add(NPCID.BloodZombie);
|
||||
}
|
||||
|
||||
if (CalamityWorld.death)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Zombies.Add(ModContent.NPCType<BucketZombie>());
|
||||
Zombies.Add(NPCID.BloodZombie);
|
||||
}
|
||||
}
|
||||
|
||||
int zombieType = Utils.SelectRandom(Main.rand, [.. Zombies]);
|
||||
int zombie = NPC.NewNPC(Projectile.GetItemSource_FromThis(), (int)Projectile.Center.X, (int)Projectile.Center.Y, zombieType);
|
||||
Main.npc[zombie].velocity = Vector2.UnitY * -4f;
|
||||
}
|
||||
|
||||
int dustAmt = Main.rand.Next(12, 19);
|
||||
for (int i = 0; i < dustAmt; i++)
|
||||
{
|
||||
Vector2 dustPosition = Projectile.Bottom + Main.rand.NextVector2Circular(12f, 0f);
|
||||
Vector2 dustVelocity = Vector2.UnitY * Main.rand.NextFloat(-6f, -4f);
|
||||
int dustType = Main.rand.Next(2);
|
||||
Dust.NewDust(dustPosition, 0, 0, dustType, dustVelocity.X, dustVelocity.Y);
|
||||
}
|
||||
|
||||
int dustCloudAmt = Main.rand.Next(9, 13);
|
||||
for (int i = 0; i < dustCloudAmt; i++)
|
||||
{
|
||||
Vector2 dustCloudPosition = Projectile.Bottom + Main.rand.NextVector2Circular(12f, 0f);
|
||||
Vector2 dustCloudVelocity = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-6f, -4f));
|
||||
float dustCloudScale = Main.rand.NextFloat(1.2f, 1.6f);
|
||||
Color dustCloudColor = Color.Lerp(Color.SandyBrown, Color.SaddleBrown, Main.rand.NextFloat());
|
||||
SmallSmokeParticle dustCloud = new(dustCloudPosition, dustCloudVelocity, dustCloudColor, dustCloudColor, dustCloudScale, Main.rand.Next(120, 150));
|
||||
GeneralParticleHandler.SpawnParticle(dustCloud, true);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(ZombieEmergeSound, Projectile.Center);
|
||||
}
|
||||
|
||||
public override void DrawBehind(int index, List<int> behindNPCsAndTiles, List<int> behindNPCs, List<int> behindProjectiles, List<int> overPlayers, List<int> overWiresUI)
|
||||
{
|
||||
behindNPCsAndTiles.Add(index);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
float scaleX = MathHelper.Lerp(0f, 1f, ZombieArmRiseAnimation);
|
||||
Vector2 backglowScale = new(scaleX, 1f);
|
||||
for (int i = 0; i < 2; i++)
|
||||
Main.spriteBatch.Draw(BackglowTexture.Value, drawPosition, null, Color.Red with { A = 0 } * ZombieArmRiseAnimation, 0f, BackglowTexture.Size() * 0.5f, backglowScale, 0, 0f);
|
||||
|
||||
float armScale = MathHelper.Lerp(0.2f, 1f, ZombieArmRiseAnimation);
|
||||
float armRotation = Projectile.rotation - MathHelper.PiOver4 + MathHelper.ToRadians(Main.rand.NextFloat(-2f, 2f));
|
||||
|
||||
float height = MathHelper.Lerp(68f, 12f, ZombieArmRiseAnimation);
|
||||
Vector2 armDrawPostion = drawPosition + Vector2.UnitY * height;
|
||||
|
||||
Main.spriteBatch.Draw(ZombieArmTexture.Value, armDrawPostion, null, lightColor, armRotation, ZombieArmTexture.Size() * new Vector2(0f, 1f), armScale, 0, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using CalamityMod.Buffs.Pets;
|
||||
using CalamityMod.CalPlayer;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
public class Beldum : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Pets";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projPet[Type] = true;
|
||||
Main.projFrames[Type] = 4;
|
||||
ProjectileID.Sets.CharacterPreviewAnimations[Type] = ProjectileID.Sets.SimpleLoop(0, 0, 1)
|
||||
.WithOffset(-8f, -20f).WithSpriteDirection(-1).WhenNotSelected(0, 0);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.netImportant = true;
|
||||
Projectile.width = 32;
|
||||
Projectile.height = 32;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft *= 5;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[Projectile.owner];
|
||||
Vector2 beldumcenter = Projectile.Center;
|
||||
Vector2 vectorbeldum = player.Center - beldumcenter;
|
||||
float playerdistance = vectorbeldum.Length();
|
||||
if (!player.active)
|
||||
{
|
||||
Projectile.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//Delete the projectile if the player doesnt have the buff or is very far away (dunno if this needs to be deleted)
|
||||
if (!player.HasBuff(ModContent.BuffType<BeldumBuff>()) || playerdistance >= 4000f)
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (player.dead)
|
||||
{
|
||||
modPlayer.beldum = false;
|
||||
}
|
||||
if (modPlayer.beldum)
|
||||
{
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
if (player.InInteractionRange((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, TileReachCheckSettings.Simple))
|
||||
{
|
||||
if (Projectile.Hitbox.Contains(player.ClampedMouseWorld().ToPoint()))
|
||||
{
|
||||
if (player.controlUseItem && player.velocity == Vector2.Zero)
|
||||
{
|
||||
Projectile.ai[1] = Projectile.ai[1] == 1 ? 0 : 1;
|
||||
}
|
||||
else if (player.controlUseTile)
|
||||
{
|
||||
Projectile.ai[1] = Projectile.ai[1] == 2 ? 0 : 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normal behaviour
|
||||
if (Projectile.ai[1] == 0)
|
||||
{
|
||||
Projectile.FloatingPetAI(false, 0);
|
||||
}
|
||||
// Being pet
|
||||
else if (Projectile.ai[1] == 1)
|
||||
{
|
||||
if (player.velocity != Vector2.Zero || player.HasIFrames())
|
||||
{
|
||||
Projectile.ai[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.Center = player.Center + new Vector2(40 * player.direction, 0);
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
PlayerPetting();
|
||||
}
|
||||
}
|
||||
// Shoulder
|
||||
else
|
||||
{
|
||||
Projectile.Center = player.Center + new Vector2(0, -20 * player.gravDir) + Vector2.UnitY * player.gfxOffY;
|
||||
}
|
||||
|
||||
if (Projectile.ai[1] != 2)
|
||||
{
|
||||
Projectile.ai[0]++;
|
||||
if (Projectile.ai[1] == 0)
|
||||
{
|
||||
Projectile.spriteDirection = -Projectile.velocity.X.DirectionalSign();
|
||||
Projectile.rotation = MathF.Sin(Projectile.ai[0] * 0.05f) * MathHelper.ToRadians(20);
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.spriteDirection = -Projectile.DirectionTo(player.Center).X.DirectionalSign();
|
||||
Projectile.rotation = MathF.Sin(Projectile.ai[0] * 0.05f) * MathHelper.ToRadians(5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.ai[0] = 0;
|
||||
Projectile.rotation = 0;
|
||||
Projectile.spriteDirection = -player.direction;
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(600) && Projectile.ai[2] == 0)
|
||||
{
|
||||
Projectile.ai[2] = 1;
|
||||
}
|
||||
|
||||
if (Projectile.ai[2] == 1)
|
||||
{
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter > 3)
|
||||
{
|
||||
Projectile.frameCounter = 0;
|
||||
Projectile.frame++;
|
||||
}
|
||||
|
||||
if (Projectile.frame > 3)
|
||||
{
|
||||
Projectile.frame = 0;
|
||||
Projectile.ai[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerPetting()
|
||||
{
|
||||
Player player = Main.player[Projectile.owner];
|
||||
int targetDirection = (Projectile.Center.X > player.Center.X) ? 1 : (-1);
|
||||
player.StopVanityActions();
|
||||
player.ChangeDir(targetDirection);
|
||||
player.gravDir = 1f;
|
||||
int completion = player.miscCounter % 14 / 7;
|
||||
Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.ThreeQuarters;
|
||||
if (completion == 1)
|
||||
{
|
||||
stretch = Player.CompositeArmStretchAmount.Full;
|
||||
}
|
||||
player.SetCompositeArmBack(enabled: true, stretch, player.DirectionTo(Projectile.Center).ToRotation() - MathHelper.PiOver2);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D tex = TextureAssets.Projectile[Type].Value;
|
||||
SpriteEffects fx = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
if (Main.player[Projectile.owner].gravDir == -1)
|
||||
fx |= SpriteEffects.FlipVertically;
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + Vector2.UnitY * MathF.Cos(Projectile.ai[0] * 0.05f) * (Projectile.ai[1] == 0 ? 10 : 2), tex.Frame(1, 4, 0, Projectile.frame), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(tex.Width / 2, tex.Height / Main.projFrames[Type] / 2), Projectile.scale, fx);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 746 B |
@@ -0,0 +1,52 @@
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.NPCs.NormalNPCs.HorribleHog;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles
|
||||
{
|
||||
public class PowderTransformationsProjectile : GlobalProjectile
|
||||
{
|
||||
public override bool AppliesToEntity(Projectile entity, bool lateInstantiation)
|
||||
{
|
||||
return entity.type == ProjectileID.VilePowder || entity.type == ProjectileID.ViciousPowder || entity.type == ProjectileID.PurificationPowder;
|
||||
}
|
||||
|
||||
public override void AI(Projectile projectile)
|
||||
{
|
||||
// Transform certain NPCs into different variants when contact is made with Vile/Vicious Powder or Purification Powder.
|
||||
// Currently only used for Piggy, Divine Swine and Horrible Hog.
|
||||
|
||||
bool isPurePowder = projectile.type == ProjectileID.PurificationPowder;
|
||||
bool isEvilPowder = projectile.type == ProjectileID.VilePowder || projectile.type == ProjectileID.ViciousPowder;
|
||||
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
bool targetIsPiggy = npc.type == ModContent.NPCType<Piggy>() || npc.type == ModContent.NPCType<PiggyGold>();
|
||||
bool targetIsDivineSwine = npc.type == ModContent.NPCType<DivineSwine>();
|
||||
bool targetIsHorribleHog = npc.type == ModContent.NPCType<HorribleHog>();
|
||||
|
||||
if (!targetIsPiggy && !targetIsDivineSwine && !targetIsHorribleHog)
|
||||
continue;
|
||||
|
||||
if (projectile.Hitbox.Intersects(npc.Hitbox))
|
||||
{
|
||||
if (targetIsPiggy && npc.ModNPC<Piggy>().TryTransformingIntoVariant())
|
||||
{
|
||||
if (isEvilPowder)
|
||||
npc.ModNPC<Piggy>().TransformIntoVariant(ModContent.NPCType<HorribleHog>());
|
||||
else if (isPurePowder)
|
||||
npc.ModNPC<Piggy>().TransformIntoVariant(ModContent.NPCType<DivineSwine>());
|
||||
}
|
||||
|
||||
if (targetIsDivineSwine && isEvilPowder && npc.ModNPC<DivineSwine>().TryTransformingIntoPiggy())
|
||||
npc.ModNPC<DivineSwine>().TransformIntoPiggy();
|
||||
|
||||
if (targetIsHorribleHog && isPurePowder && npc.ModNPC<HorribleHog>().TryTransformingIntoPiggy())
|
||||
npc.ModNPC<HorribleHog>().TransformIntoPiggy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.coldDamage = true;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 10;
|
||||
|
||||