diff --git a/Items/Armor/TarragonVisage.cs b/Items/Armor/TarragonVisage.cs index c893615581..2fd839489e 100644 --- a/Items/Armor/TarragonVisage.cs +++ b/Items/Armor/TarragonVisage.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Armor "Increased heart pickup range\n" + "Enemies have a chance to drop extra hearts on death\n" + "Ranged critical strikes will cause an explosion of leaves\n" + - "Ranged projectiles have a chance to split into life energy on death"; + "Ranged projectiles have a chance to split into life energy on death by hitting an enemy"; } public override void UpdateEquip(Player player) diff --git a/Items/Critters/BabyGhostBellItem.cs b/Items/Critters/BabyGhostBellItem.cs new file mode 100644 index 0000000000..e1a4250d1d --- /dev/null +++ b/Items/Critters/BabyGhostBellItem.cs @@ -0,0 +1,32 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class BabyGhostBellItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Ghost Bell"); + } + + 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 = 2; + } + } +} diff --git a/Items/Critters/BabyGhostBellItem.png b/Items/Critters/BabyGhostBellItem.png new file mode 100644 index 0000000000..7e7e84c4f1 Binary files /dev/null and b/Items/Critters/BabyGhostBellItem.png differ diff --git a/Items/Critters/PiggyItem.cs b/Items/Critters/PiggyItem.cs new file mode 100644 index 0000000000..c07b0306d3 --- /dev/null +++ b/Items/Critters/PiggyItem.cs @@ -0,0 +1,33 @@ +using CalamityMod.NPCs.NormalNPCs; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class PiggyItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Piggy"); + } + + 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, 50, 0, 0); + //item.CloneDefaults(2004); //Lightning Bug item + item.width = 26; + item.height = 24; + item.makeNPC = (short)ModContent.NPCType(); + item.rare = 1; + item.Calamity().postMoonLordRarity = 21; + } + } +} diff --git a/Items/Critters/PiggyItem.png b/Items/Critters/PiggyItem.png new file mode 100644 index 0000000000..bb7b57d0bb Binary files /dev/null and b/Items/Critters/PiggyItem.png differ diff --git a/Items/Critters/SeaMinnowItem.cs b/Items/Critters/SeaMinnowItem.cs new file mode 100644 index 0000000000..11565c06cb --- /dev/null +++ b/Items/Critters/SeaMinnowItem.cs @@ -0,0 +1,33 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SeaMinnowItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sea Minnow"); + } + + 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.bait = 20; + item.makeNPC = (short)ModContent.NPCType(); + item.rare = 2; + } + } +} diff --git a/Items/Critters/SeaMinnowItem.png b/Items/Critters/SeaMinnowItem.png new file mode 100644 index 0000000000..b016fc2245 Binary files /dev/null and b/Items/Critters/SeaMinnowItem.png differ diff --git a/Items/Fishing/AstralCatches/TwinklerItem.cs b/Items/Critters/TwinklerItem.cs similarity index 94% rename from Items/Fishing/AstralCatches/TwinklerItem.cs rename to Items/Critters/TwinklerItem.cs index f7eeb72a99..db7cc03a0b 100644 --- a/Items/Fishing/AstralCatches/TwinklerItem.cs +++ b/Items/Critters/TwinklerItem.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Items.Fishing.AstralCatches +namespace CalamityMod.Items.Critters { public class TwinklerItem : ModItem { diff --git a/Items/Fishing/AstralCatches/TwinklerItem.png b/Items/Critters/TwinklerItem.png similarity index 100% rename from Items/Fishing/AstralCatches/TwinklerItem.png rename to Items/Critters/TwinklerItem.png diff --git a/Items/Fishing/AstralCatches/AstralCrate.cs b/Items/Fishing/AstralCatches/AstralCrate.cs index 5186279a4e..352c2a6725 100644 --- a/Items/Fishing/AstralCatches/AstralCrate.cs +++ b/Items/Fishing/AstralCatches/AstralCrate.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Materials; +using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Potions; diff --git a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs index 1fa9781e91..027f00b0db 100644 --- a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Materials; +using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Potions; @@ -69,6 +70,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches //Bait DropHelper.DropItemChance(player, ItemID.MasterBait, 10, 1, 2); DropHelper.DropItemChance(player, ItemID.JourneymanBait, 5, 1, 3); + DropHelper.DropItemChance(player, ModContent.ItemType(), 5, 1, 3); DropHelper.DropItemChance(player, ItemID.ApprenticeBait, 3, 2, 3); //Potions diff --git a/Items/Weapons/Melee/DivineHatchet.cs b/Items/Weapons/Melee/DivineHatchet.cs new file mode 100644 index 0000000000..4a7046c6f1 --- /dev/null +++ b/Items/Weapons/Melee/DivineHatchet.cs @@ -0,0 +1,50 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class DivineHatchet : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Scorcher"); + Tooltip.SetDefault("May your enemies burn in hell for the sins they have committed\n" + + "Throws a holy boomerang that seeks out up to three enemies before returning to the player"); + } + + public override void SetDefaults() + { + item.width = 60; + item.damage = 500; + item.noMelee = true; + item.noUseGraphic = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useStyle = 1; + item.useTime = 15; + item.knockBack = 8.5f; + item.UseSound = SoundID.Item1; + item.melee = true; + item.height = 62; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = 8; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; + item.Calamity().postMoonLordRarity = 13; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.PossessedHatchet); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 9); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Melee/DivineHatchet.png b/Items/Weapons/Melee/DivineHatchet.png new file mode 100644 index 0000000000..991e07cd78 Binary files /dev/null and b/Items/Weapons/Melee/DivineHatchet.png differ diff --git a/Items/Weapons/Melee/StreamGouge.cs b/Items/Weapons/Melee/StreamGouge.cs index 174d3f1ba6..a2231026d5 100644 --- a/Items/Weapons/Melee/StreamGouge.cs +++ b/Items/Weapons/Melee/StreamGouge.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Stream Gouge"); - Tooltip.SetDefault("Fires an essence flame beam\n" + + Tooltip.SetDefault("Fires an essence spear clone\n" + "Ignores immunity frames"); } diff --git a/Items/Weapons/Ranged/AcesHigh.cs b/Items/Weapons/Ranged/AcesHigh.cs index b899938b09..dc79f6efb2 100644 --- a/Items/Weapons/Ranged/AcesHigh.cs +++ b/Items/Weapons/Ranged/AcesHigh.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 999; + item.damage = 1599; item.ranged = true; item.width = 48; item.height = 30; diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index d13ff5538d..7fc6ff178f 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.value = Item.buyPrice(1, 80, 0, 0); item.rare = 10; - item.damage = 549; + item.damage = 469; item.useAnimation = 21; item.useTime = 3; item.crit = 16; diff --git a/Items/Weapons/Rogue/ThrowingBrick.cs b/Items/Weapons/Rogue/ThrowingBrick.cs index 9aa919a78f..324990a72b 100644 --- a/Items/Weapons/Rogue/ThrowingBrick.cs +++ b/Items/Weapons/Rogue/ThrowingBrick.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.useTime = 20; item.useAnimation = 20; item.useStyle = 1; - item.knockBack = 10; + item.knockBack = 5f; item.crit = 20; item.value = Item.buyPrice(0, 0, 0, 50); item.rare = 0; diff --git a/Items/Weapons/Summon/WulfrumController.cs b/Items/Weapons/Summon/WulfrumController.cs index 04101457b6..fc887c6bad 100644 --- a/Items/Weapons/Summon/WulfrumController.cs +++ b/Items/Weapons/Summon/WulfrumController.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon position = Main.MouseWorld; speedX = 0; speedY = 0; - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); } return false; } diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index d6c52c78eb..464ddc8cfa 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -1,5 +1,5 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Fishing.AstralCatches; +using CalamityMod.Items.Critters; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 13bafc2a53..17220b7cde 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Critters; using System; using Terraria; using Terraria.ID; @@ -11,6 +12,7 @@ namespace CalamityMod.NPCs.NormalNPCs { DisplayName.SetDefault("Piggy"); Main.npcFrameCount[npc.type] = 5; + Main.npcCatchable[npc.type] = true; } public override void SetDefaults() @@ -29,6 +31,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); + npc.catchItem = (short)ModContent.ItemType(); } public override float SpawnChance(NPCSpawnInfo spawnInfo) @@ -79,7 +82,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Bacon); + DropHelper.DropItem(npc, ItemID.Bacon, 1, 1); } public override void HitEffect(int hitDirection, double damage) @@ -96,5 +99,15 @@ namespace CalamityMod.NPCs.NormalNPCs } } } + + public override void OnCatchNPC(Player player, Item item) + { + try + { + } catch + { + return; + } + } } } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index bbf5754a75..00e4fb80b3 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -1076,11 +1076,12 @@ namespace CalamityMod.NPCs.Providence DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedProvidence); DropHelper.DropResidentEvilAmmo(npc, CalamityWorld.downedProvidence, 5, 2, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), biomeType != 2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), biomeType == 2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedProvidence); + //Accessories clientside only in Expert + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, biomeType != 2 && Main.expertMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, biomeType == 2 && Main.expertMode); + // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { @@ -1098,6 +1099,8 @@ namespace CalamityMod.NPCs.Providence // Equipment DropHelper.DropItemChance(npc, ModContent.ItemType(), 40); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), biomeType != 2); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), biomeType == 2); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/SunkenSea/GhostBellSmall.cs b/NPCs/SunkenSea/GhostBellSmall.cs index 75b989c9bd..bdd6b1b5c0 100644 --- a/NPCs/SunkenSea/GhostBellSmall.cs +++ b/NPCs/SunkenSea/GhostBellSmall.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Critters; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.IO; @@ -16,6 +17,7 @@ namespace CalamityMod.NPCs.SunkenSea { DisplayName.SetDefault("Baby Ghost Bell"); Main.npcFrameCount[npc.type] = 4; + Main.npcCatchable[npc.type] = true; } public override void SetDefaults() @@ -36,6 +38,7 @@ namespace CalamityMod.NPCs.SunkenSea npc.DeathSound = SoundID.NPCDeath28; banner = npc.type; bannerItem = ModContent.ItemType(); + npc.catchItem = (short)ModContent.ItemType(); } public override void SendExtraAI(BinaryWriter writer) @@ -54,7 +57,8 @@ namespace CalamityMod.NPCs.SunkenSea { if (npc.localAI[0] == 0f) { - npc.catchItem = (Main.rand.NextBool(20)) ? (short)ModContent.ItemType() : ItemID.None; + if (Main.rand.NextBool(20)) + npc.catchItem = (short)ModContent.ItemType(); npc.localAI[0] = 1f; npc.velocity.Y = -3f; npc.netUpdate = true; diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index 8d75c70f0d..1c9b39c44f 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Critters; using System; using Terraria; using Terraria.ID; @@ -11,6 +12,7 @@ namespace CalamityMod.NPCs.SunkenSea { DisplayName.SetDefault("Sea Minnow"); Main.npcFrameCount[npc.type] = 4; + Main.npcCatchable[npc.type] = true; } public override void SetDefaults() @@ -29,6 +31,7 @@ namespace CalamityMod.NPCs.SunkenSea banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; + npc.catchItem = (short)ModContent.ItemType(); } public override void AI() @@ -212,5 +215,15 @@ namespace CalamityMod.NPCs.SunkenSea Dust.NewDust(npc.position, npc.width, npc.height, 68, hitDirection, -1f, 0, default, 1f); } } + + public override void OnCatchNPC(Player player, Item item) + { + try + { + } catch + { + return; + } + } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 15a2665d76..e9732c1ac7 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1630,6 +1630,30 @@ namespace CalamityMod.Projectiles Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 2.0), 0f, projectile.owner, 0f, ai1); } } + + if (projectile.ranged) + { + if (Main.player[projectile.owner].Calamity().tarraRanged && Main.rand.Next(0, 100) >= 88 && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] <= 20 && (projectile.timeLeft <= 2 || projectile.penetrate <= 1)) + { + int num251 = Main.rand.Next(2, 4); + for (int num252 = 0; num252 < num251; num252++) + { + Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (value15.X == 0f && value15.Y == 0f) + { + value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + } + value15.Normalize(); + value15 *= (float)Main.rand.Next(70, 101) * 0.1f; + int newDamage = (int)((double)projectile.damage * 0.33); + if (newDamage > 65) + { + newDamage = 65; + } + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); + } + } + } } } #endregion @@ -1798,30 +1822,6 @@ namespace CalamityMod.Projectiles } } - if (projectile.ranged) - { - if (Main.player[projectile.owner].Calamity().tarraRanged && Main.rand.Next(0, 100) >= 88) - { - int num251 = Main.rand.Next(2, 4); - for (int num252 = 0; num252 < num251; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int newDamage = (int)((double)projectile.damage * 0.33); - if (newDamage > 65) - { - newDamage = 65; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); - } - } - } - if (rogue) { if (Main.player[projectile.owner].Calamity().etherealExtorter && Main.rand.Next(0, 100) >= 95) diff --git a/Projectiles/Melee/DivineHatchetBoomerang.cs b/Projectiles/Melee/DivineHatchetBoomerang.cs new file mode 100644 index 0000000000..ab78c0d863 --- /dev/null +++ b/Projectiles/Melee/DivineHatchetBoomerang.cs @@ -0,0 +1,220 @@ +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class DivineHatchetBoomerang : ModProjectile + { + private bool hasHitEnemy = false; + private static int Lifetime = 300; + private static int ReboundTime = 100; + private int targetNPC = -1; + private List previousNPCs = new List() { -1 }; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scorching Seeker"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 60; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = 3; + projectile.timeLeft = Lifetime; + projectile.melee = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + //holy dust + if (Main.rand.NextBool(8)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + + // Boomerang rotation + projectile.rotation += 0.4f * (float)projectile.direction; + + // Boomerang sound + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + + // Returns after some number of frames in the air + if (projectile.timeLeft < Lifetime - ReboundTime) + projectile.ai[0] = 1f; + + if (projectile.ai[0] != 0f) + { + float returnSpeed = 26f; + float acceleration = 1.4f; + + Player owner = Main.player[projectile.owner]; + + // Delete the projectile if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + if (dist > 3000f) + projectile.Kill(); + + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; + + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } + + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + + //home in on nearby NPCs if not returning to player + if (projectile.penetrate != -1) + { + if (!hasHitEnemy) + { + float range = 999f; + for (int a = 0; a < Main.npc.Length; a++) + { + if (Main.npc[a].CanBeChasedBy(projectile, false)) + { + float var2 = Main.npc[a].position.X + (Main.npc[a].width / 2); + float var3 = Main.npc[a].position.Y + (Main.npc[a].height / 2); + float distance2npc = Math.Abs(projectile.position.X + (projectile.width / 2) - var2) + Math.Abs(projectile.position.Y + (projectile.height / 2) - var3); + if (distance2npc < range) + { + Vector2 newVelocity = Main.npc[a].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } + } + else + { + if (targetNPC >= 0) + { + Vector2 newVelocity = Main.npc[targetNPC].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + //inflict Holy Flames for 6 seconds + target.AddBuff(ModContent.BuffType(), 360); + + if (projectile.penetrate != -1) + { + //find a nearby NPC to track + float minDist = 999f; + int index = 0; + for (int i = 0; i < Main.npc.Length; i++) + { + bool hasHitNPC = false; + for (int j = 0; j < previousNPCs.Count; j++) + { + if (previousNPCs[j] == i) + { + hasHitNPC = true; + } + } + + NPC npc = Main.npc[i]; + if (npc == target) + { + previousNPCs.Add(i); + } + if (!npc.friendly && !npc.townNPC && npc.active && !npc.dontTakeDamage && npc.chaseable && npc != target && !hasHitNPC && npc.type != NPCID.TargetDummy) + { + float dist = (projectile.Center - npc.Center).Length(); + if (dist < minDist) + { + minDist = dist; + index = i; + } + } + } + + Vector2 velocityNew; + if (minDist < 999f) + { + hasHitEnemy = true; + targetNPC = index; + velocityNew = Main.npc[index].Center - projectile.Center; + velocityNew.Normalize(); + velocityNew *= 15f; + projectile.velocity = velocityNew; + } + else + { + projectile.penetrate = -1; + projectile.ai[0] = 1f; + targetNPC = -1; + } + } + + // After its last hit, starts returning instead of vanishing. Can pierce infinitely on the way back. + if (projectile.penetrate == 1) + { + projectile.penetrate = -1; + projectile.ai[0] = 1f; + targetNPC = -1; + } + } + } +} diff --git a/Projectiles/Melee/DivineHatchetBoomerang.png b/Projectiles/Melee/DivineHatchetBoomerang.png new file mode 100644 index 0000000000..991e07cd78 Binary files /dev/null and b/Projectiles/Melee/DivineHatchetBoomerang.png differ diff --git a/Projectiles/Summon/WulfrumDroid.cs b/Projectiles/Summon/WulfrumDroid.cs index e794f3e4fd..aa3a78fd03 100644 --- a/Projectiles/Summon/WulfrumDroid.cs +++ b/Projectiles/Summon/WulfrumDroid.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Summon } if (!flag) { - for (int index2 = 0; index2 < 200; ++index2) + for (int index2 = 0; index2 < Main.npc.Length; ++index2) { NPC npc = Main.npc[index2]; if (npc.CanBeChasedBy((object) this, false)) diff --git a/Projectiles/Typeless/TarraEnergy.cs b/Projectiles/Typeless/TarraEnergy.cs index 3aa7c8b5eb..ce127d9b2c 100644 --- a/Projectiles/Typeless/TarraEnergy.cs +++ b/Projectiles/Typeless/TarraEnergy.cs @@ -43,16 +43,18 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreAI() { - for (int num136 = 0; num136 < 3; num136++) + for (int num136 = 0; num136 < 2; num136++) { float x2 = projectile.position.X - projectile.velocity.X / 10f * (float)num136; float y2 = projectile.position.Y - projectile.velocity.Y / 10f * (float)num136; + Vector2 dspeed = projectile.velocity * Main.rand.NextFloat(0.7f, 0.4f); int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); Main.dust[num137].alpha = projectile.alpha; Main.dust[num137].position.X = x2; Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity *= 0f; + Main.dust[num137].velocity = dspeed; Main.dust[num137].noGravity = true; + Main.dust[num137].noLight = true; } float num138 = (float)Math.Sqrt((double)(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y)); float num139 = projectile.localAI[0];