diff --git a/Gores/CladCrab/CladCrab.png b/Gores/CladCrab/CladCrab.png new file mode 100644 index 0000000000..1671a2d983 Binary files /dev/null and b/Gores/CladCrab/CladCrab.png differ diff --git a/Gores/CladCrab/CladCrab2.png b/Gores/CladCrab/CladCrab2.png new file mode 100644 index 0000000000..dbf0208c30 Binary files /dev/null and b/Gores/CladCrab/CladCrab2.png differ diff --git a/Gores/CladCrab/CladCrab3.png b/Gores/CladCrab/CladCrab3.png new file mode 100644 index 0000000000..463bed6400 Binary files /dev/null and b/Gores/CladCrab/CladCrab3.png differ diff --git a/Gores/CladCrab/CladCrab4.png b/Gores/CladCrab/CladCrab4.png new file mode 100644 index 0000000000..968ab44748 Binary files /dev/null and b/Gores/CladCrab/CladCrab4.png differ diff --git a/Items/Placeables/Banners/CladCrabBanner.cs b/Items/Placeables/Banners/CladCrabBanner.cs new file mode 100644 index 0000000000..337bd4dbe9 --- /dev/null +++ b/Items/Placeables/Banners/CladCrabBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class CladCrabBanner : BaseBanner + { + public override int BannerTileStyle => 54; + } +} diff --git a/Items/Placeables/Banners/CladCrabBanner.png b/Items/Placeables/Banners/CladCrabBanner.png new file mode 100644 index 0000000000..5f33251b97 Binary files /dev/null and b/Items/Placeables/Banners/CladCrabBanner.png differ diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index baf6053ade..21097320aa 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -150,6 +150,7 @@ AuroraSpirit.DisplayName: Aurora Spirit BloodlettingServant.DisplayName: Bloodletting Servant BloomSlime.DisplayName: Bloom Slime Bohldohr.DisplayName: Bohldohr +CladCrab.DisplayName: Clad Crab Cnidrion.DisplayName: Cnidrion CrawlerAmber.DisplayName: Amber Crawler CrawlerAmethyst.DisplayName: Amethyst Crawler diff --git a/NPCs/NormalNPCs/CladCrab.cs b/NPCs/NormalNPCs/CladCrab.cs new file mode 100644 index 0000000000..6fd8be4319 --- /dev/null +++ b/NPCs/NormalNPCs/CladCrab.cs @@ -0,0 +1,292 @@ +using System; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +namespace CalamityMod.NPCs.NormalNPCs +{ + public class CladCrab : ModNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[NPC.type] = 7; + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + { + SpriteDirection = 1 + }; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + } + + public override void SetDefaults() + { + NPC.chaseable = false; + NPC.damage = 12; + NPC.defense = 7; + NPC.width = 56; + NPC.height = 54; + NPC.lifeMax = 100; + NPC.aiStyle = -1; + NPC.knockBackResist = 0.4f; + NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.HitSound = SoundID.NPCHit41 with { Pitch = 0.6f }; + NPC.DeathSound = SoundID.NPCDeath36 with { Pitch = -0.4f }; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToSickness = true; + + // Scale stats in Expert and Master + CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); + CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); + } + + public override void AI() + { + NPC.TargetClosest(false); + float movementSpeed = 1; + + // Enrage if target is close enough + if (NPC.HasPlayerTarget) + { + Player target = Main.player[NPC.target]; + // Enrage if the player is close enough, not too far above, and in its line of sight + if (target.Distance(NPC.Center) < 320 && target.Bottom.Y > NPC.Top.Y - 40 && Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1)) + { + // Enter attack mode + if (NPC.ai[0] != 2) + { + NPC.ai[1] = 60; + NPC.ai[0] = 2; + } + // Set calm down timer to 0 as long as these conditions are met + NPC.ai[2] = 0; + } + else + { + // Calm down + NPC.ai[2]++; + // After 5 seconds of no valid target, go back to passive behaviour + if (NPC.ai[2] > 300) + { + NPC.ai[0] = Main.rand.Next(0, 2); + NPC.ai[1] = Main.rand.Next(120, 301); + NPC.ai[2] = 0; + NPC.ai[3] = 0; + } + } + } + + if (NPC.direction == 0) + { + NPC.direction = Main.rand.NextBool() ? -1 : 1; + } + + // If not enraged and the phase timer is at 0, change phase + if (NPC.ai[1] <= 0 && NPC.ai[0] != 2) + { + NPC.ai[0] = NPC.ai[0] == 0 ? 1 : 0; + NPC.ai[1] = Main.rand.Next(120, 301); // Set the phase timer + NPC.direction = Main.rand.NextBool() ? -1 : 1; // Flip direction randomly + } + + // Passive walking + if (NPC.ai[0] == 0) + { + // If it bumps into something, turn around + if (NPC.ai[3] <= 0 && NPC.velocity.X == 0) + { + NPC.direction *= -1; + NPC.ai[3] = 30; + } + // Move + if (!NPC.justHit) + NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); + // Don't get stuck on 1 block obstacles + StepUp(); + } + // Stand still + else if (NPC.ai[0] == 1) + { + // Slow to a stop if not falling/being moved up + if (NPC.velocity.Y == 0) + NPC.velocity.X *= 0; + // Start running if hit + // This behavior is mostly only here for if it gets hurt but you aren't within its aggro range + if (NPC.justHit) + { + NPC.ai[0] = 0; + NPC.ai[1] = Main.rand.Next(120, 301); + } + } + // Enrage + else + { + Player target = Main.player[NPC.target]; + // If it bumps into something, turn around + if (NPC.ai[3] <= 0 && NPC.velocity.X == 0) + { + NPC.direction *= -1; + NPC.ai[3] = 30; + } + // If it's too far from the player, turn around + else if ((NPC.ai[3] <= 0 && target.Distance(NPC.Center) > 160) || NPC.ai[3] < -180) + { + int dir = Math.Sign(Main.player[NPC.target].Center.X - NPC.Center.X); + NPC.direction = dir; + NPC.ai[3] = 120; + } + // Move + if (!NPC.justHit) + NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); + StepUp(); + } + + // Phase timer + if (NPC.ai[1] > 0) + { + NPC.ai[1]--; + } + // Change direction cooldown + NPC.ai[3]--; + + NPC.spriteDirection = -NPC.direction; + } + + public void StepUp() + { + Vector2 position = NPC.position; + position.X += NPC.velocity.X; + int x = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1)) * NPC.direction) / 16f); + int y = (int)((position.Y + (float)NPC.height - 1f) / 16f); + if ((float)(x * 16) < position.X + (float)NPC.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - NPC.direction, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - NPC.direction, y - 3].TileType])) + { + float npcBottom = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + npcBottom += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + npcBottom -= 8f; + } + if (npcBottom < position.Y + (float)NPC.height) + { + float percentageTileRisen = position.Y + (float)NPC.height - npcBottom; + if (percentageTileRisen <= 16.1f) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - npcBottom; + NPC.position.Y = npcBottom - (float)NPC.height; + if (percentageTileRisen < 9f) + { + NPC.stepSpeed = 1f; + } + else + { + NPC.stepSpeed = 2f; + } + } + } + } + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.DayTime, + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.CladCrab") + }); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneSulphur || spawnInfo.Player.Calamity().ZoneSunkenSea) + { + return 0f; + } + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * 0.05f; + } + + public override void FindFrame(int frameHeight) + { + if (NPC.velocity.Y == 0f) + { + 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 = frameHeight * 1; + NPC.frameCounter = 0.0; + return; + } + } + NPC.frameCounter += NPC.IsABestiaryIconDummy ? 0.6f : Math.Abs(NPC.velocity.X) * 0.5f; + NPC.frameCounter += 1.0; + if (NPC.frameCounter > 12.0) + { + NPC.frame.Y = NPC.frame.Y + frameHeight; + NPC.frameCounter = 0.0; + } + if (NPC.frame.Y / frameHeight >= Main.npcFrameCount[NPC.type] - 1) + { + NPC.frame.Y = frameHeight; + } + } + else + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * (Main.npcFrameCount[NPC.type] - 1); + } + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemID.StoneBlock, 1, 10, 20); + npcLoot.Add(ItemID.Daybloom, 1, 1, 4); + npcLoot.Add(ItemID.Blinkroot, 1, 1, 3); + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 2; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Stone, hit.HitDirection, -1f, 0, default, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 7; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Stone, hit.HitDirection, -1f, 0, default, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, hit.HitDirection, -1f, 0, default, 1f); + } + if (Main.netMode != NetmodeID.Server) + { + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("CladCrab").Type); + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("CladCrab2").Type); + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("CladCrab3").Type); + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("CladCrab4").Type); + } + } + } + } +} diff --git a/NPCs/NormalNPCs/CladCrab.png b/NPCs/NormalNPCs/CladCrab.png new file mode 100644 index 0000000000..53d950960b Binary files /dev/null and b/NPCs/NormalNPCs/CladCrab.png differ diff --git a/NPCs/NormalNPCs/Shroomble.cs b/NPCs/NormalNPCs/Shroomble.cs index 5de897f1ab..45548a73dc 100644 --- a/NPCs/NormalNPCs/Shroomble.cs +++ b/NPCs/NormalNPCs/Shroomble.cs @@ -25,7 +25,6 @@ namespace CalamityMod.NPCs.NormalNPCs }; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.CantTakeLunchMoney[Type] = true; - NPCID.Sets.NormalGoldCritterBestiaryPriority.Add(Type); } public override void SetDefaults() @@ -38,7 +37,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.aiStyle = NPCAIStyleID.Passive; AIType = NPCID.Squirrel; NPC.knockBackResist = 0.5f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(0, 0, 0, 20); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; diff --git a/Tiles/MonsterBanner.cs b/Tiles/MonsterBanner.cs index 134f81524f..fea7ff6959 100644 --- a/Tiles/MonsterBanner.cs +++ b/Tiles/MonsterBanner.cs @@ -231,9 +231,9 @@ namespace CalamityMod.Tiles case 53: npc = NPCType(); break; - /*case 54: - npc = NPCType(); - Formerly Calamity Eye - break*/ + case 54: + npc = NPCType(); + break; case 55: npc = NPCType(); break;