diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs new file mode 100644 index 0000000000..9b48e1101c --- /dev/null +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -0,0 +1,95 @@ +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class ParasiticSceptor : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Parasitic Sceptor"); + Tooltip.SetDefault("Fires a spread of water leeches that latch onto enemies, dealing a stacking damage over time"); + Item.staff[item.type] = true; + } + + public override void SetDefaults() + { + item.damage = 12; + item.knockBack = 3f; + item.mana = 10; + item.useTime = item.useAnimation = 25; + item.autoReuse = true; + item.magic = true; + item.shootSpeed = 10f; + item.shoot = ModContent.ProjectileType(); + + item.width = item.height = 52; + item.UseSound = SoundID.Item46; + item.noMelee = true; + item.useStyle = 5; + item.rare = 2; + item.value = CalamityGlobalItem.Rarity2BuyPrice; + } + + public override Vector2? HoldoutOrigin() => new Vector2(15, 15); + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + float speed = item.shootSpeed; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; + float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; + } + Vector2 vector = new Vector2(xDist, yDist); + float speedMult = vector.Length(); + if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) + { + xDist = player.direction; + yDist = 0f; + speedMult = speed; + } + else + { + speedMult = speed / speedMult; + } + xDist *= speedMult; + yDist *= speedMult; + int leechAmt = 2; + if (Main.rand.NextBool(3)) + { + leechAmt++; + } + if (Main.rand.NextBool(4)) + { + leechAmt++; + } + if (Main.rand.NextBool(5)) + { + leechAmt ++; + } + for (int i = 0; i < leechAmt; i++) + { + float xVec = xDist; + float yVec = yDist; + float spreadMult = 0.05f * i; + xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + Vector2 directionToShoot = new Vector2(xVec, yVec); + speedMult = directionToShoot.Length(); + speedMult = speed / speedMult; + xVec *= speedMult; + yVec *= speedMult; + directionToShoot = new Vector2(xVec, yVec); + Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } + } +} diff --git a/Items/Weapons/Magic/ParasiticSceptor.png b/Items/Weapons/Magic/ParasiticSceptor.png new file mode 100644 index 0000000000..9aca524358 Binary files /dev/null and b/Items/Weapons/Magic/ParasiticSceptor.png differ diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index d9447e9b28..db02795914 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -1,5 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -174,5 +175,11 @@ namespace CalamityMod.NPCs.AcidRain { target.AddBuff(ModContent.BuffType(), 120); } + + public override void NPCLoot() + { + float dropChance = CalamityWorld.downedAquaticScourge ? 0.01f : 0.05f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); + } } } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index bae811d798..355ecb328f 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -585,6 +585,28 @@ namespace CalamityMod.NPCs } } + if (irradiated > 0) + { + int projectileCount = 0; + for (int j = 0; j < Main.maxProjectiles; j++) + { + if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() && + Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + { + projectileCount++; + } + } + + if (projectileCount > 0) + { + ApplyDPSDebuff(irradiated, projectileCount * 20, projectileCount * 4, ref npc.lifeRegen, ref damage); + } + else + { + ApplyDPSDebuff(irradiated, 20, 4, ref npc.lifeRegen, ref damage); + } + } + // Exo Freeze, Glacial State and Temporal Sadness don't work on bosses or other specific enemies. if (!npc.boss && !CalamityMod.movementImpairImmuneList.Contains(npc.type)) { @@ -623,7 +645,6 @@ namespace CalamityMod.NPCs } ApplyDPSDebuff(vaporfied, 30, 6, ref npc.lifeRegen, ref damage); - ApplyDPSDebuff(irradiated, 20, 4, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(bFlames, 40, 8, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(hFlames, 50, 10, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(pFlames, 100, 20, ref npc.lifeRegen, ref damage); @@ -2523,12 +2544,16 @@ namespace CalamityMod.NPCs break; case NPCID.Dryad: - switch (Main.rand.Next(22)) // 21 Dryad names + switch (Main.rand.Next(23)) // 21 Dryad names { case 0: npc.GivenName = "Rythmi"; break; + case 1: + npc.GivenName = "Izuna"; + break; + default: break; } diff --git a/Projectiles/Boss/MushBomb.cs b/Projectiles/Boss/MushBomb.cs index d7da2db6a3..d14f549908 100644 --- a/Projectiles/Boss/MushBomb.cs +++ b/Projectiles/Boss/MushBomb.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; int drawStart = height * projectile.frame; Vector2 origin = projectile.Size / 2; SpriteEffects spriteEffects = SpriteEffects.None; @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Boss public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; int drawStart = height * projectile.frame; Vector2 origin = projectile.Size / 2; SpriteEffects spriteEffects = SpriteEffects.None; diff --git a/Projectiles/Boss/MushBombFall.cs b/Projectiles/Boss/MushBombFall.cs index 863d528f99..fc8492233b 100644 --- a/Projectiles/Boss/MushBombFall.cs +++ b/Projectiles/Boss/MushBombFall.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; int drawStart = height * projectile.frame; Vector2 origin = projectile.Size / 2; SpriteEffects spriteEffects = SpriteEffects.None; @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Boss public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; int drawStart = height * projectile.frame; Vector2 origin = projectile.Size / 2; SpriteEffects spriteEffects = SpriteEffects.None; diff --git a/Projectiles/Magic/WaterLeechProj.cs b/Projectiles/Magic/WaterLeechProj.cs new file mode 100644 index 0000000000..c092e1101d --- /dev/null +++ b/Projectiles/Magic/WaterLeechProj.cs @@ -0,0 +1,109 @@ +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class WaterLeechProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Leech"); + Main.projFrames[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 18; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 540; + projectile.magic = true; + } + + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + if (projectile.ai[0] == 0f) + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.Pi; + } + //Sticky Behaviour + CalamityUtils.StickyProjAI(projectile, 5); + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + CalamityUtils.ModifyHitNPCSticky(projectile, 4, false); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); + projectile.Kill(); + return false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Magic/WaterLeechProjGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 1, 0.5f, 0f); + for (int i = 0; i < 5; i++) + { + int dust = Dust.NewDust(projectile.Center, 1, 1, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } +} diff --git a/Projectiles/Magic/WaterLeechProj.png b/Projectiles/Magic/WaterLeechProj.png new file mode 100644 index 0000000000..17bc7c88b0 Binary files /dev/null and b/Projectiles/Magic/WaterLeechProj.png differ diff --git a/Projectiles/Magic/WaterLeechProjGlow.png b/Projectiles/Magic/WaterLeechProjGlow.png new file mode 100644 index 0000000000..48aaa585d2 Binary files /dev/null and b/Projectiles/Magic/WaterLeechProjGlow.png differ