Added Jellyghoul

This commit is contained in:
GinYuH committed 2024-08-21 18:31:21 -07:00
1 parent b52ca5ced6
commit 7e92adc68f
5 files changed
+366 -3

No files matched your search

@@ -272,6 +272,7 @@ GiantClam.DisplayName: Giant Clam
Clamitas: Clamitas
SupremeClamitas: Supreme Clamitas
HauntedChum.DisplayName: Haunted Chum
Jellyghoul.DisplayName: Jellyghoul
KelpieSeadragon.DisplayName: Kelpie Seadragon
LostShoal.DisplayName: Lost Shoal
PearlpodBlack.DisplayName: Pearlpod
@@ -280,6 +281,8 @@ PearlpodPink.DisplayName: Pearlpod
PearlpodWhite.DisplayName: Pearlpod
PolypPanasea.DisplayName: Polyp Panasea
PrismBack.DisplayName: Prism-Back
Probesnout.DisplayName: Probesnout
ProbesnoutGold.DisplayName: Probesnout Gold
SandProwler.DisplayName: Sand Prowler
SandProwlerNested.DisplayName: Sand Prowler
SeaFloaty.DisplayName: Sea Floaty
@@ -639,6 +642,3 @@ WITCH: {
Princess_LovesNPC: "{NPCName} is always lonely, it's why I want to hang out with her, no one should be left alone like that!"
}
}
Probesnout.DisplayName: Probesnout
ProbesnoutGold.DisplayName: Probesnout Gold
@@ -20,6 +20,7 @@ HorsWaterBlast.DisplayName: Water
IceClasperEnemyProjectile.DisplayName: Ice Shard
InkBombHostile.DisplayName: Ink Bomb
InkPoisonCloud.DisplayName: Ink Cloud
JellyghoulBolt.DisplayName: Jellyghoul Bolt
LightningCloud.DisplayName: Cloud
MantisRing.DisplayName: Mantis Ring
MaulerAcidBubble.DisplayName: Acid Bubble
+251
View File
@@ -0,0 +1,251 @@
using CalamityMod.BiomeManagers;
using CalamityMod.Projectiles.Enemy;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SunkenSea
{
public class Jellyghoul : ModNPC
{
public static Color lesserRed = new Color(255, 100, 100);
public static Color startColor = new Color(131, 115, 122);
public static Color endColor = new Color(101, 116, 113);
// Cycle between two gray colors by default
public Color DefaultColor => Color.Lerp(startColor, endColor, NPC.localAI[1] * 0.25f + MathF.Sin(Main.GlobalTimeWrappedHourly));
// Turn red when enraged, otherwise just continue using DefaultColor
public Color FinalColor => NPC.ai[2] > 0 ? Color.Lerp(DefaultColor, lesserRed, NPC.ai[2]) : DefaultColor;
public static SoundStyle JellyGhoulScream = SoundID.NPCDeath51 with { Pitch = -1, Volume = 0.2f, MaxInstances = 0 };
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 1;
}
public override void SetDefaults()
{
NPC.npcSlots = 1f;
NPC.noGravity = true;
NPC.aiStyle = -1;
AIType = -1;
NPC.damage = 0;
NPC.width = 28;
NPC.height = 36;
NPC.defense = 0;
NPC.lifeMax = 1;
NPC.knockBackResist = 0f;
NPC.alpha = 100;
NPC.HitSound = null; // instantly dies
NPC.DeathSound = SoundID.NPCDeath3;
NPC.chaseable = false;
NPC.noTileCollide = true;
// Banner = NPC.type;
//BannerItem = ModContent.ItemType<JellyghoulBanner>();
SpawnModBiomes = new int[1] { ModContent.GetInstance<SunkenSeaBiome>().Type };
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Jellyghoul")
});
}
public override void AI()
{
// LocalAI controls variance between jellies. Randomize it on spawn to desync them
if (NPC.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[0] = 1f;
NPC.localAI[1] = Main.rand.NextFloat(0, 4f);
NPC.netUpdate = true;
}
Lighting.AddLight(NPC.Center, FinalColor.R * 0.002f, FinalColor.G * 0.002f, FinalColor.B * 0.002f);
NPC.ai[0]++;
// Play a scream randomly with a 5 second cooldown
// Chance decreases with amount of jellies active for sanity
if (NPC.ai[0] > 300 && Main.rand.NextBool(300 * NPC.CountNPCS(Type)) && NPC.ai[1] == 0)
{
SoundEngine.PlaySound(JellyGhoulScream, NPC.Center);
NPC.ai[1] = 1;
}
// While screaming, shake the screen
if (NPC.ai[1] > 0)
{
NPC.ai[1]++;
float screenShakePower = 2 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower;
// After 2 seconds, stop shaking and set the scream on cooldown
if (NPC.ai[1] > 120)
{
NPC.ai[0] = 0;
NPC.ai[1] = 0;
}
}
// Controls enrage coloring
if (NPC.ai[2] > 0)
{
NPC.ai[2] += 0.01f;
if (NPC.ai[2] > 1f)
{
NPC.ai[2] = 1f;
}
}
if (NPC.ai[2] >= 1)
{
NPC.TargetClosest(false);
NPC.ai[3]++;
if (NPC.ai[3] >= 120 + (NPC.localAI[1] * 10))
{
int damage = Main.masterMode ? 4 : Main.expertMode ? 6 : 8;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound with { Pitch = 1f });
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, NPC.SafeDirectionTo(Main.player[NPC.target].Center) * 16, ModContent.ProjectileType<JellyghoulBolt>(), damage, 0f, Main.myPlayer);
}
NPC.ai[3] = 0;
}
}
}
public override void FindFrame(int frameHeight)
{
NPC.frameCounter += 0.15f;
NPC.frameCounter %= Main.npcFrameCount[NPC.type];
int frame = (int)NPC.frameCounter;
NPC.frame.Y = frame * frameHeight;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.Player.Calamity().ZoneSunkenSeaShores && !spawnInfo.Player.Calamity().clamity)
{
return 0.05f;
}
return 0f;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 2; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SpectreStaff, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SpectreStaff, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f);
}
}
}
public override void OnKill()
{
bool soundPlayed = false;
// Cause nearby ghouls to become angry on death
foreach (NPC n in Main.ActiveNPCs)
{
if (n.life < 0)
continue;
if (n.type != Type)
continue;
if (n.Distance(NPC.Center) > 1000)
continue;
// If the jelly isn't enraged yet, enrage it
if (n.ai[2] == 0)
{
n.ai[2] = 0.01f;
// Play a sound if at least one jelly successfully enraged
if (!soundPlayed)
{
SoundEngine.PlaySound(SoundID.Zombie83 with { Pitch = -0.5f, Volume = 1.6f }, NPC.Center);
soundPlayed = true;
}
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
float afterimageRotationSpeed = 1;
float afterimageDistance = 2;
float rotationMultiplier = 0.15f;
// Make the jelly visually move in circles
Vector2 afterimageOffset = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * afterimageRotationSpeed) + NPC.localAI[1], (float)Math.Sin(Main.GlobalTimeWrappedHourly * afterimageRotationSpeed) + NPC.localAI[1]) * afterimageDistance;
// Spooky glowey aura effect
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Texture2D bloom = ModContent.Request<Texture2D>("CalamityMod/Particles/SmallBloom").Value;
spriteBatch.Draw(bloom, NPC.Center - Main.screenPosition + afterimageOffset, null, FinalColor * 0.45f, 0f, bloom.Size() / 2f, 0.6f, SpriteEffects.None, 0);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2));
// Rotate back and forth like a bell
float rotation = NPC.rotation + MathF.Sin(Main.GlobalTimeWrappedHourly + NPC.localAI[1]) * rotationMultiplier;
Vector2 npcOffset = NPC.Center - screenPos;
npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY);
// Draws transparent clones around itself to look woozy
int cloneAmt = 4;
for (int i = 0; i < cloneAmt; i++)
{
spriteBatch.Draw(texture, npcOffset + afterimageOffset + Vector2.One.RotatedBy((i + 1) * (MathHelper.TwoPi / cloneAmt) + Main.GlobalTimeWrappedHourly + NPC.localAI[1]) * cloneAmt * MathF.Sin(Main.GlobalTimeWrappedHourly + NPC.localAI[1]), NPC.frame, FinalColor * NPC.Opacity * 0.2f, rotation, origin, NPC.scale, spriteEffects, 0f);
}
spriteBatch.Draw(texture, npcOffset + afterimageOffset, NPC.frame, FinalColor * NPC.Opacity, rotation, origin, NPC.scale, spriteEffects, 0f);
if (!NPC.HasValidTarget)
return false;
// Telegraph
float shotGate = 30 + (NPC.localAI[1] * 10);
float shotCompletion = (NPC.ai[3] - 90) / shotGate;
Effect effect = Terraria.Graphics.Effects.Filters.Scene["CalamityMod:SpreadTelegraph"].GetShader().Shader;
effect.Parameters["centerOpacity"].SetValue(MathHelper.Lerp(0, 0.7f + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.05f, shotCompletion));
effect.Parameters["mainOpacity"].SetValue(MathHelper.Lerp(0, 1f + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.05f, shotCompletion));
effect.Parameters["halfSpreadAngle"].SetValue(MathHelper.Lerp(0, MathHelper.PiOver4 * 0.33f, shotCompletion));
effect.Parameters["edgeColor"].SetValue(Color.DarkRed.ToVector3());
effect.Parameters["centerColor"].SetValue(Color.Red.ToVector3());
effect.Parameters["edgeBlendLength"].SetValue(0.07f);
effect.Parameters["edgeBlendStrength"].SetValue(4f);
Main.spriteBatch.EnterShaderRegion(BlendState.Additive, effect);
Texture2D invis = ModContent.Request<Texture2D>("CalamityMod/Projectiles/InvisibleProj").Value;
Main.EntitySpriteDraw(invis, npcOffset + afterimageOffset, null, Color.White, NPC.DirectionTo(Main.player[NPC.target].Center).ToRotation(), new Vector2(invis.Width / 2f, invis.Height / 2f), 500f, 0, 0);
Main.spriteBatch.ExitShaderRegion();
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

+111
View File
@@ -0,0 +1,111 @@
using System.Collections.Generic;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class JellyghoulBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Enemy";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public float Progress => 1 - Projectile.timeLeft / (float)300;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.TrailCacheLength[Type] = 10;
Main.projFrames[Projectile.type] = 20;
}
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.penetrate = -1;
Projectile.hostile = true;
Projectile.timeLeft = 300;
Projectile.tileCollide = true;
Projectile.ignoreWater = true;
Projectile.alpha = 255;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 1f * Projectile.Opacity, 0.1f * Projectile.Opacity, 0.1f);
Projectile.frameCounter++;
Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Projectile.type];
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
Projectile.ai[0]++;
if (Projectile.ai[0] % 5 == 0)
{
Color pulseColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.Red : Color.DarkRed) : (Main.rand.NextBool() ? Color.OrangeRed : Color.IndianRed);
Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), Projectile.velocity.ToRotation(), 0.1f, 0.2f + 0.2f * (1 - Progress), 10);
GeneralParticleHandler.SpawnParticle(pulse);
}
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.CrimsonTorch, Scale: 1.5f);
dust.noGravity = true;
dust.velocity = Vector2.Zero;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
}
public override void OnKill(int timeLeft)
{
for (int i = 0; i < 3; i++)
{
int idx = Dust.NewDust(Projectile.position, 8, 8, (int)CalamityDusts.Brimstone, 0, 0, 0, default, 0.75f);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 3f;
idx = Dust.NewDust(Projectile.position, 8, 8, (int)CalamityDusts.Brimstone, 0, 0, 0, default, 0.75f);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 3f;
}
}
public override bool PreDraw(ref Color lightColor)
{
GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise"));
GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189");
GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Color.Red);
GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Color.OrangeRed);
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30);
Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
int projFrame = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value.Height / Main.projFrames[Projectile.type];
int y6 = projFrame * Projectile.frame;
/*Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
Texture2D ring = ModContent.Request<Texture2D>("CalamityMod/Particles/HollowCircleHardEdge").Value;
for (int j = 0; j < 2; j++)
{
for (int i = 2; i < 7; i += 2)
{
Main.spriteBatch.Draw(ring, Projectile.oldPos[i] + Projectile.Size / 2 - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), null, Color.Red * Projectile.Opacity, Projectile.velocity.ToRotation(), ring.Size() / 2, new Vector2(0.5f, 1) * 0.2f * MathHelper.Lerp(1f, 0.5f, (i - 2) / 3f), SpriteEffects.None, 0);
}
}
Main.spriteBatch.ExitShaderRegion();*/
return false;
}
public float SlashWidthFunction(float _) => 16 * Utils.GetLerpValue(0f, 0.1f, _, true);
public Color SlashColorFunction(float _) => Color.IndianRed * Projectile.Opacity;
}
}