diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson index a3201816ea..4d18b3fabb 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson @@ -16,6 +16,7 @@ LuminousCorvina: Lumenyl grows on the fins of these exotic corvina, making these MirageJelly: Using the light refracted from lumenyl crystals and water warmed by the scorching heat of scoria, these jellyfish can create afterimages of themselves to confuse predators, or catch prey of their own. MorayEel: When a fish bites your heel and it looks like an eel, that's a moray. When it swims in the reef and has two sets of teeth, that's a moray. When you're slapped in the face with a slimy embrace, that's a moray. Oarfish: Oarfish are known for laying thousands or even millions of eggs in astonishingly quick gestation cycles. These eggs are the most abundant source of food in the Abyss, being part of the reason even the smallest and least threatening creatures can live in the otherwise near inhospitable depths of the sea. +SlabCrab: Potential holder of the crab secret...? No, that can't be. ReaperShark: Apex predators of the void, these sharks take advantage of both their stealthiness and might to hunt anything and everything that comes near. Using their arms for purposes from hurling colossal squids into the Abyss' walls to crushing the heavily armored heads of eidolon wyrms, few can match their raw strength. ToxicMinnow: These abnormally large minnows have evolved to use nutrients from plants they consume to create toxins inside their body, which is then released after they die. They have next to no predators due to this, and contribute nearly nothing to their environment. Viperfish: Omnivorous fish that dwell in the middle sections of the Abyss, viperfish rest firmly near the bottom of the food chain. Their wide mouth normally reserved for filter feeding can double as a means to scare off predators by mimicking the much more threatening gulper eels. diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index 06acb0756d..7629952a49 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -18,6 +18,7 @@ MirageJelly.DisplayName: Mirage Jelly MorayEel.DisplayName: Moray Eel OarfishHead.DisplayName: Oarfish ReaperShark.DisplayName: Reaper Shark +SlabCrab.DisplayName: Slab Crab ToxicMinnow.DisplayName: Toxic Minnow Viperfish.DisplayName: Viperfish AcidEel.DisplayName: Acid Eel diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 9ac54fa763..381c9b0968 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -13,6 +13,7 @@ using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; +using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.NPCs.Abyss { @@ -280,7 +281,11 @@ namespace CalamityMod.NPCs.Abyss NPC.netUpdate = true; } - public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) => target.AddBuff(BuffID.Poisoned, 60 * (this.shouldTarget ? 10 : 5)); //10 sec for explosion, 5 sec for non explosion + public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) + { + target.AddBuff(BuffID.Poisoned, 60 * (this.shouldTarget ? 4 : 2)); //10 sec for explosion, 5 sec for non explosion + target.AddBuff(ModContent.BuffType(), 60 * (this.shouldTarget ? 4 : 2)); //10 sec for explosion, 5 sec for non explosion + } public override bool CheckDead() { diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index d0b2b2bc6d..864380f5a1 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -288,7 +288,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180, true); + target.AddBuff(ModContent.BuffType(), 180, true); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 2f17785853..227c06701a 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -354,7 +354,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 90); } } } diff --git a/NPCs/Abyss/SlabCrab.cs b/NPCs/Abyss/SlabCrab.cs new file mode 100644 index 0000000000..7aa44e2483 --- /dev/null +++ b/NPCs/Abyss/SlabCrab.cs @@ -0,0 +1,331 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.Abyss +{ + public class SlabCrab : ModNPC + { + enum AIState + { + Hiding = 0, + IdleAnim = 1, + Enraged = 2, + Active = 3 + } + + public Player Target => Main.player[NPC.target]; + public ref float CurrentPhase => ref NPC.ai[0]; + public ref float AITimer => ref NPC.ai[1]; + public ref float HopTimer => ref NPC.ai[2]; + public ref float CalmDownTimer => ref NPC.ai[3]; + public override void SetStaticDefaults() + { + Main.npcFrameCount[NPC.type] = 23; + } + + public override void SetDefaults() + { + NPC.width = 44; + NPC.height = 30; + + NPC.damage = 20; + NPC.lifeMax = 300; + + NPC.aiStyle = AIType = -1; + + NPC.knockBackResist = 0f; + NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.lavaImmune = true; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.chaseable = false; + NPC.knockBackResist = 0f; + NPC.defense = 999998; + NPC.HitSound = SoundID.NPCHit33; + NPC.DeathSound = SoundID.NPCDeath36; + //Banner = NPC.type; + //BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + NPC.GravityIgnoresLiquid = true; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.SlabCrab") + }); + } + + public override void AI() + { + NPC.direction = Math.Sign(NPC.velocity.X); + NPC.spriteDirection = -NPC.direction; + NPC.localAI[0]++; + if (NPC.localAI[0] < 90) + return; + // Enables expert scaling, if damage is 0 in set defaults expert scaling will not happen. + NPC.damage = 0; + switch (CurrentPhase) + { + case (int)AIState.Hiding: + NPC.ShowNameOnHover = false; + NPC.chaseable = false; + NPC.defense = 999998; + NPC.velocity.X = 0; + AITimer++; + // if the block below it is mined, instantly start running + //if (NPC.velocity.Y > 0) + { + //ChangePhase((int)AIState.Active); + } + // randomly start looking around after a bit + if (AITimer > 300 && Main.rand.NextBool(420)) + { + ChangePhase((int)AIState.IdleAnim); + } + break; + case (int)AIState.IdleAnim: + NPC.ShowNameOnHover = true; + NPC.chaseable = false; + NPC.defense = 999998; + AITimer++; + NPC.velocity.X = 0; + // if the block below it is mined, instantly start running + if (NPC.velocity.Y > 0) + { + ChangePhase((int)AIState.Active); + } + NPC.TargetClosest(); + // if a player gets too close while it's looking, pop out + if (Target.Distance(NPC.Center) < 480 && Collision.CanHitLine(NPC.Center, 1, 1, Target.Center, 1, 1)) + { + ChangePhase((int)AIState.Enraged); + } + // if the animation finishes, go back to stone mode + if (AITimer > 90) + { + ChangePhase((int)AIState.Hiding); + } + break; + case (int)AIState.Enraged: + NPC.ShowNameOnHover = true; + AITimer++; + NPC.defense = 10; + NPC.knockBackResist = 0f; + NPC.chaseable = false; + // give the animation time to play out then start attacking + if (AITimer > 24) + { + ChangePhase((int)AIState.Active); + } + break; + case (int)AIState.Active: + NPC.ShowNameOnHover = true; + NPC.TargetClosest(); + NPC.defense = 10; + NPC.knockBackResist = 1f; + NPC.damage = 20; + NPC.chaseable = true; + bool outofRange = ((Target.Center.Distance(NPC.Center) > 600) || (Target.Center.Distance(NPC.Center) > 320 && !Collision.CanHitLine(NPC.Center, 1, 1, Target.Center, 1, 1))); + if (outofRange) + { + CalmDownTimer++; + } + else if (CalmDownTimer > 0) + { + CalmDownTimer--; + } + if (NPC.velocity.Y == 0f) + { + AITimer++; + NPC.knockBackResist = 0.6f; + NPC.TargetClosest(true); + NPC.velocity.X *= 0.85f; + + float hopRate = MathHelper.Lerp(25f, 10f, 1f - NPC.life / (float)NPC.lifeMax); + float lungeForwardSpeed = 6f; + float jumpSpeed = 7f; + if (Collision.CanHit(NPC.Center, 1, 1, Target.Center, 1, 1)) + lungeForwardSpeed *= 1.2f; + + if (Main.netMode != NetmodeID.MultiplayerClient && AITimer > hopRate) + { + HopTimer++; + + // Make a bigger leap every 3 hops. + if (HopTimer % 3f == 2f) + lungeForwardSpeed *= 1.5f; + + AITimer = 0f; + NPC.velocity.Y -= jumpSpeed; + NPC.velocity.X = lungeForwardSpeed * NPC.direction; + NPC.netUpdate = true; + } + } + else + { + NPC.knockBackResist = 0.2f; + NPC.velocity.X *= 0.995f; + } + // go back to hiding if on the ground, has been angri for over 5 seconds, and is far enough from the player (distance reduced if no line of sight) + if (CalmDownTimer > 300 && outofRange && NPC.velocity.Y == 0 && Main.rand.NextBool(180)) + { + ChangePhase(0); + } + break; + } + if (NPC.velocity.Y > 0) + { + NPC.velocity.Y *= 1.1f; + } + } + + public void ChangePhase(float ai0, float ai1 = -1, float ai2 = -1, float ai3 = -1) + { + CurrentPhase = ai0; + AITimer = ai1 == -1 ? 0 : ai1; + HopTimer = ai2 == -1 ? 0 : ai2; + CalmDownTimer = ai3 == -1 ? 0 : ai3; + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + // Don't draw the bar if in stealth mode. + if (CurrentPhase < (int)AIState.Enraged) + return false; + return null; + } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneAbyssLayer1 && spawnInfo.Water) + { + return SpawnCondition.OceanMonster.Chance; + } + return 0f; + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 5, 10, 30); + } + + public override void FindFrame(int frameHeight) + { + // walkie + if (NPC.IsABestiaryIconDummy || CurrentPhase == (int)AIState.Active) + { + if (NPC.velocity.Y == 0) + { + if (NPC.frameCounter++ % 6 == 0) + { + NPC.frame.Y += frameHeight; + } + } + if (NPC.frame.Y > frameHeight * 22 || NPC.frame.Y < frameHeight * 19) + { + NPC.frame.Y = frameHeight * 19; + } + return; + } + switch (CurrentPhase) + { + case (int)AIState.Hiding: + NPC.frame.Y = 0; + break; + case (int)AIState.IdleAnim: + if (NPC.frameCounter++ % 6 == 0) + { + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y > frameHeight * 14) + { + NPC.frame.Y = frameHeight * 0; + } + break; + case (int)AIState.Enraged: + if (NPC.frame.Y < frameHeight * 18) + { + NPC.frameCounter++; + } + if (NPC.frame.Y > frameHeight * 18 || NPC.frame.Y < frameHeight * 15) + { + NPC.frame.Y = frameHeight * 15; + } + if (NPC.frameCounter == 6) + { + NPC.frame.Y += frameHeight; + NPC.frameCounter = 0; + } + break; + default: + if (NPC.frameCounter++ % 6 == 0) + { + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y > frameHeight * 22 || NPC.frame.Y < frameHeight * 19) + { + NPC.frame.Y = frameHeight * 19; + } + break; + } + } + + public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (CurrentPhase < (int)AIState.Enraged) + { + ChangePhase((int)AIState.Enraged); + } + } + + public override bool? CanBeHitByItem(Player player, Item item) => CurrentPhase > (int)AIState.IdleAnim || (item.pick > 0 && new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 20, 20).Intersects(NPC.getRect())); // can only be hit by pickaxes while hidden + + public override bool? CanBeHitByProjectile(Projectile projectile) => CurrentPhase > (int)AIState.IdleAnim; + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Water, 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.Water, hit.HitDirection, -1f, 0, default, 1f); + } + } + } + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage > 0) + target.AddBuff(ModContent.BuffType(), 90); + } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (!NPC.IsABestiaryIconDummy) + { + Texture2D tex = ModContent.Request("CalamityMod/NPCs/Abyss/SlabCrabGlow").Value; + + var effects = NPC.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(tex, NPC.Center - Main.screenPosition + new Vector2(0, NPC.gfxOffY + 4), + NPC.frame, Color.White * 0.5f, NPC.rotation, NPC.frame.Size() / 2f, NPC.scale, effects, 0); + } + } + } +} diff --git a/NPCs/Abyss/SlabCrab.png b/NPCs/Abyss/SlabCrab.png new file mode 100644 index 0000000000..d1e3465c13 Binary files /dev/null and b/NPCs/Abyss/SlabCrab.png differ diff --git a/NPCs/Abyss/SlabCrabGlow.png b/NPCs/Abyss/SlabCrabGlow.png new file mode 100644 index 0000000000..0af1cd2b82 Binary files /dev/null and b/NPCs/Abyss/SlabCrabGlow.png differ diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index 43e88471c6..7a9c5393d2 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120, true); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index d57e7c20de..1c928b725a 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -343,6 +343,7 @@ namespace CalamityMod { ModContent.NPCType(), abyss }, { ModContent.NPCType(), abyss }, { ModContent.NPCType(), abyss }, + { ModContent.NPCType(), abyss }, { ModContent.NPCType(), abyss }, { ModContent.NPCType(), abyss }, { ModContent.NPCType(), abyss },