diff --git a/Buffs/Pets/FlakPetBuff.cs b/Buffs/Pets/FlakPetBuff.cs new file mode 100644 index 0000000000..e77750ff92 --- /dev/null +++ b/Buffs/Pets/FlakPetBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class FlakPetBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Flak Hermit"); + Description.SetDefault("Little acid buggy"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().flakPet = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } + } +} diff --git a/Buffs/Pets/FlakPetBuff.png b/Buffs/Pets/FlakPetBuff.png new file mode 100644 index 0000000000..bc94958e66 Binary files /dev/null and b/Buffs/Pets/FlakPetBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 3626899b7d..7021207576 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -211,6 +211,7 @@ namespace CalamityMod.CalPlayer public bool trashMan = false; public int trashManChest = -1; public bool astrophage = false; + public bool flakPet = false; public bool babyGhostBell = false; public bool radiator = false; public bool scalPet = false; @@ -1082,6 +1083,7 @@ namespace CalamityMod.CalPlayer kendra = false; trashMan = false; astrophage = false; + flakPet = false; babyGhostBell = false; radiator = false; scalPet = false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 5a4e494ec0..81add82dc7 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3065,7 +3065,7 @@ namespace CalamityMod.CalPlayer // Tarragon Summon set bonus life aura if (modPlayer.tarraSummon) { - const int FramesPerHit = 60; + const int FramesPerHit = 80; // Constantly increment the timer every frame. modPlayer.tarraLifeAuraTimer = (modPlayer.tarraLifeAuraTimer + 1) % FramesPerHit; @@ -3073,8 +3073,8 @@ namespace CalamityMod.CalPlayer // If the timer rolls over, it's time to deal damage. Only run this code for the client which is wearing the armor. if (modPlayer.tarraLifeAuraTimer == 0 && player.whoAmI == Main.myPlayer) { - const int BaseDamage = 200; - int damage = (int)(BaseDamage * (player.allDamage + player.minionDamage - 1f)); + const int BaseDamage = 150; + int damage = (int)(BaseDamage * player.MinionDamage()); float range = 300f; for (int i = 0; i < Main.maxNPCs; ++i) diff --git a/Items/Critters/BabyFlakHermit.cs b/Items/Critters/BabyFlakHermit.cs new file mode 100644 index 0000000000..a7a586fbca --- /dev/null +++ b/Items/Critters/BabyFlakHermit.cs @@ -0,0 +1,32 @@ +using CalamityMod.NPCs.AcidRain; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class BabyFlakHermit : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Flak Crab"); + } + + public override void SetDefaults() + { + item.useStyle = 1; + item.autoReuse = true; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.maxStack = 999; + item.consumable = true; + item.noUseGraphic = true; + item.value = Item.buyPrice(0, 0, 30, 0); + //item.CloneDefaults(2004); //Lightning Bug item + item.width = 26; + item.height = 24; + item.makeNPC = (short)ModContent.NPCType(); + item.rare = 6; + } + } +} diff --git a/Items/Critters/BabyFlakHermit.png b/Items/Critters/BabyFlakHermit.png new file mode 100644 index 0000000000..2bd8fd3641 Binary files /dev/null and b/Items/Critters/BabyFlakHermit.png differ diff --git a/Items/Pets/GeyserShell.cs b/Items/Pets/GeyserShell.cs new file mode 100644 index 0000000000..7bdded2aec --- /dev/null +++ b/Items/Pets/GeyserShell.cs @@ -0,0 +1,40 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class GeyserShell : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Geyser Shell"); + Tooltip.SetDefault("Summons a little flak hermit"); + } + public override void SetDefaults() + { + item.damage = 0; + item.useStyle = 1; + item.useAnimation = 20; + item.useTime = 20; + item.noMelee = true; + item.width = 30; + item.height = 30; + item.value = Item.sellPrice(0, 1, 50, 0); + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); + item.rare = 6; + item.UseSound = SoundID.Item2; + } + + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 15, true); + } + } + } +} diff --git a/Items/Pets/GeyserShell.png b/Items/Pets/GeyserShell.png new file mode 100644 index 0000000000..ed760aff16 Binary files /dev/null and b/Items/Pets/GeyserShell.png differ diff --git a/NPCs/AcidRain/FlakBaby.cs b/NPCs/AcidRain/FlakBaby.cs index 84e372723d..2ceb1bf88d 100644 --- a/NPCs/AcidRain/FlakBaby.cs +++ b/NPCs/AcidRain/FlakBaby.cs @@ -1,5 +1,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Critters; +using CalamityMod.Items.Pets; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -15,6 +17,7 @@ namespace CalamityMod.NPCs.AcidRain { DisplayName.SetDefault("Baby Flak Crab"); Main.npcFrameCount[npc.type] = 6; + Main.npcCatchable[npc.type] = true; } public override void SetDefaults() @@ -40,7 +43,7 @@ namespace CalamityMod.NPCs.AcidRain banner = npc.type; bannerItem = ModContent.ItemType(); npc.dontTakeDamageFromHostiles = true; - //npc.catchItem = (short)ModContent.ItemType(); + npc.catchItem = (short)ModContent.ItemType(); } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { @@ -49,6 +52,27 @@ namespace CalamityMod.NPCs.AcidRain } public override void AI() { + if (npc.localAI[0] == 0f) + { + if (Main.rand.NextBool(20)) + npc.catchItem = (short)ModContent.ItemType(); + npc.localAI[0] = 1f; + npc.velocity.Y = -3f; + npc.netUpdate = true; + } + if (Main.rand.NextBool(8) && npc.catchItem == (short)ModContent.ItemType()) + { + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, (int)CalamityDusts.SulfurousSeaAcid, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 200, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.1f; + Main.dust[dust].velocity.Y += 0.25f; + Main.dust[dust].noLight = true; + if (Main.rand.NextBool(2)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } Player closest = Main.player[Player.FindClosest(npc.Top, 0, 0)]; if (Math.Abs(closest.Center.X - npc.Center.X) > 600f) { @@ -105,7 +129,7 @@ namespace CalamityMod.NPCs.AcidRain } return 0.15f; } - /* + public override void OnCatchNPC(Player player, Item item) { try @@ -115,7 +139,8 @@ namespace CalamityMod.NPCs.AcidRain { return; } - }*/ + } + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/Projectiles/Pets/FlakPet.cs b/Projectiles/Pets/FlakPet.cs new file mode 100644 index 0000000000..1b3e7ce35c --- /dev/null +++ b/Projectiles/Pets/FlakPet.cs @@ -0,0 +1,295 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Pets +{ + public class FlakPet : ModProjectile + { + private int playerStill = 0; + private bool fly = false; + private int idleTimer = 0; + private bool hiding = false; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Flak Hermit"); + Main.projFrames[projectile.type] = 7; + Main.projPet[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.tileCollide = true; + } + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + Player player = Main.player[projectile.owner]; + Vector2 center2 = projectile.Center; + Vector2 vector48 = player.Center - center2; + float playerDistance = vector48.Length(); + fallThrough = playerDistance > 200f; + return true; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (!player.active) + { + projectile.active = false; + return; + } + CalamityPlayer modPlayer = player.Calamity(); + if (player.dead) + { + modPlayer.flakPet = false; + } + if (modPlayer.flakPet) + { + projectile.timeLeft = 2; + } + Vector2 vector46 = projectile.position; + if (!fly) + { + projectile.rotation = 0; + Vector2 center2 = projectile.Center; + Vector2 vector48 = player.Center - center2; + float playerDistance = vector48.Length(); + if (projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && projectile.position.X == projectile.oldPosition.X))) + { + projectile.velocity.Y = -5f; + } + projectile.velocity.Y += 0.20f; + if (projectile.velocity.Y > 7f) + { + projectile.velocity.Y = 7f; + } + if (playerDistance > 600f) + { + fly = true; + projectile.velocity.X = 0f; + projectile.velocity.Y = 0f; + } + if (playerDistance > 100f) + { + if (player.position.X - projectile.position.X > 0f) + { + projectile.velocity.X += 0.10f; + if (projectile.velocity.X > 7f) + { + projectile.velocity.X = 7f; + } + } + else + { + projectile.velocity.X -= 0.10f; + if (projectile.velocity.X < -7f) + { + projectile.velocity.X = -7f; + } + } + } + if (playerDistance < 100f) + { + if (projectile.velocity.X != 0f) + { + if (projectile.velocity.X > 0.5f) + { + projectile.velocity.X -= 0.15f; + } + else if (projectile.velocity.X < -0.5f) + { + projectile.velocity.X += 0.15f; + } + else if (projectile.velocity.X < 0.5f && projectile.velocity.X > -0.5f) + { + projectile.velocity.X = 0f; + } + } + } + if (projectile.position.X == projectile.oldPosition.X && projectile.position.Y == projectile.oldPosition.Y && projectile.velocity.X == 0) + { + if (!hiding) + { + idleTimer++; + projectile.frame = 2; + } + if (idleTimer > 300) + { + hiding = true; + if (projectile.frame > 0) + { + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame--; + projectile.frameCounter = 0; + } + if (projectile.frame < 0) + { + projectile.frame = 0; + } + } + } + } + else if (projectile.velocity.Y > 0.3f && projectile.position.Y != projectile.oldPosition.Y) + { + idleTimer = 0; + hiding = false; + projectile.frame = 2; + projectile.frameCounter = 0; + } + else + { + idleTimer = 0; + hiding = false; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + { + projectile.frame = 2; + } + } + } + else if (fly) + { + float num16 = 0.3f; + projectile.tileCollide = false; + Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float horiPos = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector3.X; + float vertiPos = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector3.Y; + vertiPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)(60 * -(float)player.direction); + vertiPos -= 60f; + float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); + float num21 = 18f; + float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); + if (playerDistance > 1200f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDistance < 100f) + { + num16 = 0.1f; + if (player.velocity.Y == 0f) + { + ++playerStill; + } + else + { + playerStill = 0; + } + if (playerStill > 60 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + fly = false; + projectile.tileCollide = true; + } + } + if (playerDistance < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.90f; + } + num16 = 0.01f; + } + else + { + if (playerDistance < 100f) + { + num16 = 0.1f; + } + if (playerDistance > 300f) + { + num16 = 1f; + } + playerDistance = num21 / playerDistance; + horiPos *= playerDistance; + vertiPos *= playerDistance; + } + if (projectile.velocity.X <= horiPos) + { + projectile.velocity.X = projectile.velocity.X + num16; + if (num16 > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X = projectile.velocity.X + num16; + } + } + if (projectile.velocity.X > horiPos) + { + projectile.velocity.X = projectile.velocity.X - num16; + if (num16 > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X = projectile.velocity.X - num16; + } + } + if (projectile.velocity.Y <= vertiPos) + { + projectile.velocity.Y = projectile.velocity.Y + num16; + if (num16 > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + } + } + if (projectile.velocity.Y > vertiPos) + { + projectile.velocity.Y = projectile.velocity.Y - num16; + if (num16 > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + } + } + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; + projectile.frame = 6; + hiding = false; + idleTimer = 0; + } + if (projectile.velocity.X > 0.25f) + { + projectile.spriteDirection = -1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.spriteDirection = 1; + } + } + + private bool HoleBelow() //pretty much the same as the one used in mantis + { + int tileWidth = 4; + int tileX = (int)(projectile.Center.X / 16f) - tileWidth; + if (projectile.velocity.X > 0) + { + tileX += tileWidth; + } + int tileY = (int)((projectile.position.Y + projectile.height) / 16f); + for (int y = tileY; y < tileY + 2; y++) + { + for (int x = tileX; x < tileX + tileWidth; x++) + { + if (Main.tile[x, y].active()) + { + return false; + } + } + } + return true; + } + } +} diff --git a/Projectiles/Pets/FlakPet.png b/Projectiles/Pets/FlakPet.png new file mode 100644 index 0000000000..351c9b5a93 Binary files /dev/null and b/Projectiles/Pets/FlakPet.png differ diff --git a/Projectiles/Summon/ElementalAxeMinion.cs b/Projectiles/Summon/ElementalAxeMinion.cs index 00d3c6afe2..27891c0d9a 100644 --- a/Projectiles/Summon/ElementalAxeMinion.cs +++ b/Projectiles/Summon/ElementalAxeMinion.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.extraUpdates = 1; projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 4; + projectile.idStaticNPCHitCooldown = 6; } public override void AI() @@ -44,15 +44,15 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = (player.allDamage + player.minionDamage - 1f); + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] += 1f; } - if ((player.allDamage + player.minionDamage - 1f) != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * - (player.allDamage + player.minionDamage - 1f)); + player.MinionDamage()); projectile.damage = damage2; } bool flag64 = projectile.type == ModContent.ProjectileType();